Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
proptest.C File Reference
#include "roccom.h"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <sstream>
#include "roccom_assertion.h"
#include "../Rocblas/include/Rocblas.h"
#include "../Rocsurf/include/Rocsurf.h"
#include "../Rocsurf/test/IM_Reader.h"
Include dependency graph for proptest.C:

Go to the source code of this file.

Classes

struct  Control_parameter
 

Functions

 COM_EXTERN_MODULE (Rocblas)
 
 COM_EXTERN_MODULE (Rocmap)
 
 COM_EXTERN_MODULE (Rocprop)
 
 COM_EXTERN_MODULE (Rocsurf)
 
 COM_EXTERN_MODULE (Rocout)
 
void load_modules ()
 
void print_usage (int argc, char *argv[])
 
void read_control_file (const char *fname, Control_parameter &cp)
 
void init_parameters (const Control_parameter &cntr_param)
 
std::string read_in_mesh (const char *fname)
 
void rescale_object (std::string &wname, double alpha, const SURF::Vector_3< double > &origin)
 
void init_constraints_acmflu (const string &wname)
 
void init_constraints_acmfrac (const string &wname)
 
template<class T >
square (T t)
 
void init_constraints_starslice (const string &wname, const Control_parameter &cntr_param)
 
void init_constraints_staraft (const string &wname, const Control_parameter &cntr_param)
 
void init_constraints_myacm (const string &wname, const Control_parameter &cntr_param)
 
void init_constraints_labscale (const string &wname, const Control_parameter &cntr_param)
 
void init_constraints (const string &wname, const Control_parameter &cntr_param)
 
void init_attributes (const string &wname, const Control_parameter &cntr_param)
 
void output_solution (const string &wname, const char *timelevel, const string &format)
 
double compute_area (const string &wname)
 
double compute_volume (const string &wname)
 
int main (int argc, char *argv[])
 

Variables

static int rank = 0
 

Function Documentation

COM_EXTERN_MODULE ( Rocblas  )
COM_EXTERN_MODULE ( Rocmap  )
COM_EXTERN_MODULE ( Rocprop  )
COM_EXTERN_MODULE ( Rocsurf  )
COM_EXTERN_MODULE ( Rocout  )
double compute_area ( const string &  wname)

Definition at line 841 of file proptest.C.

References COM_call_function(), COM_get_attribute_handle(), COM_get_function_handle(), and MPI_COMM_WORLD.

841  {
842  static int SURF_area = 0, BLAS_mul, BLAS_sum_scalar, area_hdl, flag_hdl;
843 
844  if ( SURF_area==0) {
845  SURF_area = COM_get_function_handle( "SURF.compute_element_areas");
846  BLAS_mul = COM_get_function_handle( "BLAS.mul");
847  BLAS_sum_scalar = COM_get_function_handle( "BLAS.sum_scalar_MPI");
848 
849  area_hdl = COM_get_attribute_handle( (wname+".faceareas").c_str());
850  flag_hdl = COM_get_attribute_handle( (wname+".flag_spd").c_str());
851  }
852 
853  COM_call_function( SURF_area, &area_hdl);
854  COM_call_function( BLAS_mul, &area_hdl, &flag_hdl, &area_hdl);
855 
856  double sum;
857  MPI_Comm comm=MPI_COMM_WORLD;
858  COM_call_function( BLAS_sum_scalar, &area_hdl, &sum, &comm);
859  return sum;
860 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

double compute_volume ( const string &  wname)

Definition at line 862 of file proptest.C.

References COM_call_function(), COM_get_attribute_handle(), and COM_get_function_handle().

862  {
863  static int SURF_vol = 0, mesh_hdl;
864 
865  if ( SURF_vol==0) {
866  SURF_vol = COM_get_function_handle( "SURF.compute_signed_volumes");
867 
868  mesh_hdl = COM_get_attribute_handle( (wname+".mesh").c_str());
869  }
870 
871  double vol;
872  COM_call_function( SURF_vol, &mesh_hdl, &vol);
873 
874  return vol;
875 }
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void init_attributes ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 722 of file proptest.C.

References COM_call_function(), COM_DOUBLE, COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_INT, COM_new_attribute(), COM_resize_array(), COM_set_size(), COM_window_init_done(), i, Control_parameter::speed, and Control_parameter::sploc.

723  {
724  COM_new_attribute((wname+".flag").c_str(), 'p', COM_DOUBLE, 1, "");
725  COM_set_size( (wname+".flag").c_str(), 0, 1);
726 
727  COM_new_attribute((wname+".flag_spd").c_str(), 'e', COM_DOUBLE, 1, "");
728 
729  COM_new_attribute((wname+".disps_total").c_str(), 'n', COM_DOUBLE, 3, "");
730  // COM_new_attribute((wname+".lambdas").c_str(), 'n', COM_DOUBLE, 3, "");
731  // COM_new_attribute((wname+".eigvecs").c_str(), 'n', COM_DOUBLE, 9, "");
732  COM_new_attribute((wname+".cnstr_types_nodal").c_str(), 'n', COM_INT, 1, "");
733  COM_new_attribute((wname+".cnstr_types_facial").c_str(), 'e', COM_INT, 1, "");
734  COM_new_attribute((wname+".cnstr_types_panel").c_str(), 'p', COM_INT, 1, "");
735  COM_set_size((wname+".cnstr_types_panel").c_str(), 0, 1);
736 
737 #if 1
738  COM_new_attribute((wname+".cnstr_bound").c_str(), 'p', COM_DOUBLE, 15, "");
739  COM_set_size( (wname+".cnstr_bound").c_str(), 0, 1);
740 #endif
741 
742  COM_new_attribute((wname+".spds").c_str(), cntr_param.sploc,
743  COM_DOUBLE, 1, "m/s");
744  COM_new_attribute((wname+".disps").c_str(), 'n', COM_DOUBLE, 3, "m");
745 
746  COM_new_attribute((wname+".faceareas").c_str(), 'e', COM_DOUBLE, 1, "");
747  COM_new_attribute((wname+".facenormals").c_str(), 'e', COM_DOUBLE, 3, "");
748  COM_new_attribute((wname+".facecenters").c_str(), 'e', COM_DOUBLE, 3, "");
749 
750  // Attribute for storing the number of eigenvalues for each node.
751  COM_new_attribute((wname+".tangranks").c_str(), 'n', COM_INT, 1, "");
752 
753  // Ridges of each pane.
754  COM_new_attribute((wname+".ridges").c_str(), 'p', COM_INT, 2, "");
755  COM_set_size((wname+".ridges").c_str(), 0, 0);
756 
757  COM_resize_array( (wname+".atts").c_str());
758  COM_window_init_done( wname.c_str());
759 
760  // Set speed for different panes.
761  int *pane_ids, npanes;
762  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
763 
764  for ( int i=0; i<npanes; ++i) {
765  double *flag;
766  COM_get_array( (wname+".flag").c_str(), pane_ids[i], &flag);
767  // Set constraints for nonburning panes and speeds for burning panes.
768  if ( wname.substr(0,5) == "acmfl" ) {
769  if ( COM_get_attribute_handle((wname+".bcflag").c_str())>0) {
770  int *bcflag;
771  COM_get_array( (wname+".bcflag").c_str(), pane_ids[i], &bcflag);
772 
773  *flag = ( *bcflag == 1) ? cntr_param.speed : 0.;
774  }
775  else
776  *flag = (pane_ids[i]<=2)?cntr_param.speed:0.;
777  }
778  else if ( wname.substr(0,4) == "star")
779  *flag = (i%2)?0.:cntr_param.speed;
780  else if ( COM_get_attribute_handle((wname+".bcflag").c_str())>0) {
781  int *bcflag;
782  COM_get_array( (wname+".bcflag").c_str(), pane_ids[i], &bcflag);
783 
784  *flag = ( *bcflag == 1) ? cntr_param.speed : 0.;
785  }
786  else
787  *flag = cntr_param.speed;
788 
789  std::cout << "Setting speed for pane " << pane_ids[i]
790  << " to " << *flag << std::endl;
791  }
792 
793  COM_free_buffer( &pane_ids);
794 
795  int spds = COM_get_attribute_handle( (wname+".spds").c_str());
796  int spd_pane = COM_get_attribute_handle( (wname+".flag").c_str());
797 
798  int BLAS_copy = COM_get_function_handle( "BLAS.copy");
799  COM_call_function( BLAS_copy, &spd_pane, &spds);
800 
801  int BLAS_div_scalar = COM_get_function_handle( "BLAS.div_scalar");
802  COM_call_function( BLAS_div_scalar, &spd_pane, &cntr_param.speed, &spd_pane);
803 
804  int spd_elms = COM_get_attribute_handle( (wname+".flag_spd").c_str());
805  COM_call_function( BLAS_copy, &spd_pane, &spd_elms);
806 }
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
Definition: roccom_c++.h:118
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
Definition: roccom_c++.h:200
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void init_constraints ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 700 of file proptest.C.

References COM_call_function(), COM_get_attribute_handle(), COM_get_function_handle(), init_constraints_acmflu(), init_constraints_labscale(), init_constraints_myacm(), init_constraints_staraft(), and init_constraints_starslice().

Referenced by main().

701  {
702 
703  if ( wname.substr(0,5) == "acmfl")
704  init_constraints_acmflu( wname);
705  else if ( wname.substr(0,9) == "starslice")
706  init_constraints_starslice( wname, cntr_param);
707  else if ( wname.substr(0,7) == "staraft")
708  init_constraints_staraft( wname, cntr_param);
709  else if ( wname.substr(0,8) == "labscale")
710  init_constraints_labscale( wname, cntr_param);
711  else if ( wname.substr(0,3) == "acm")
712  init_constraints_myacm( wname, cntr_param);
713  else {
714  int cnstr_handle = COM_get_attribute_handle((wname+".cnstr_type").c_str());
715  if ( cnstr_handle>=0) {
716  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
717  COM_call_function( PROP_set_cnstr, &cnstr_handle);
718  }
719  }
720 }
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void init_constraints_staraft(const string &wname, const Control_parameter &cntr_param)
Definition: proptest.C:462
void init_constraints_acmflu(const string &wname)
Definition: proptest.C:334
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void init_constraints_myacm(const string &wname, const Control_parameter &cntr_param)
Definition: proptest.C:579
void init_constraints_labscale(const string &wname, const Control_parameter &cntr_param)
Definition: proptest.C:652
void init_constraints_starslice(const string &wname, const Control_parameter &cntr_param)
Definition: proptest.C:404
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_constraints_acmflu ( const string &  wname)

Definition at line 334 of file proptest.C.

References COM_call_function(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), i, j, and x.

Referenced by init_constraints(), and main().

334  {
335 
336  int SURF_centers = COM_get_function_handle( "SURF.interpolate_to_centers");
337  int nc_handle = COM_get_attribute_handle( (wname+".nc").c_str());
338  int centers_handle = COM_get_attribute_handle( (wname+".facecenters").c_str());
339  COM_call_function( SURF_centers, &nc_handle, &centers_handle);
340 
341  // Set speed for different panes.
342  int *pane_ids, npanes;
343  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
344 
345  for ( int i=0; i<npanes; ++i) {
346  bool not_interacting;
347  if ( COM_get_attribute_handle((wname+".bcflag").c_str())>0) {
348  int *bcflag;
349  COM_get_array( (wname+".bcflag").c_str(), pane_ids[i], &bcflag);
350 
351  not_interacting = (*bcflag == 2);
352  }
353  else
354  not_interacting = (pane_ids[i] == 3);
355 
356  if ( !not_interacting) continue;
357 
358  int pid = pane_ids[i], nelems, ngelems;
359  COM_get_size( (wname+".cnstr_types_facial").c_str(), pid, &nelems, &ngelems);
360  int *cnstr_types;
361  COM_get_array( (wname+".cnstr_types_facial").c_str(), pid, (void**)&cnstr_types);
362  double *spds;
363  COM_get_array( (wname+".spds").c_str(), pid, (void**)&spds);
364 
365  MAP::Vector_3<double> *centers;
366  COM_get_array( (wname+".facecenters").c_str(), pid, (void**)&centers);
367 
368  // Loop through all faces
369  for ( int j=0; j<nelems-ngelems; ++j) {
370  spds[j] = 0; // Set speed to zero.
371 
372  if ( centers[j].x() <= 1.e-10 || centers[j].x() > 0.047624)
373  cnstr_types[j] = 2; // Fix the nodes at two ends.
374  else
375  cnstr_types[j] = 'x'; // Allow nodes to move only along x dir.
376  }
377  }
378 
379  COM_free_buffer( &pane_ids);
380 
381  int cnstr_handle = COM_get_attribute_handle((wname+".cnstr_types_facial").c_str());
382  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
383  COM_call_function( PROP_set_cnstr, &cnstr_handle);
384 }
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_constraints_acmfrac ( const string &  wname)

Definition at line 388 of file proptest.C.

References COM_call_function(), COM_get_array(), COM_get_attribute_handle(), and COM_get_function_handle().

Referenced by main().

388  {
389  // Set constraint for pane 2 so that nodes can move only along x-direction
390  int *cnstr_types;
391  COM_get_array( (wname+".cnstr_types_panel").c_str(), 2, (void**)&cnstr_types);
392  *cnstr_types = 'x';
393 
394  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
395  int cnstr_handle = COM_get_attribute_handle( (wname+".cnstr_types_panel").c_str());
396 
397  COM_call_function( PROP_set_cnstr, &cnstr_handle);
398 }
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_constraints_labscale ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 652 of file proptest.C.

References NTS::abs(), COM_call_function(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), i, and j.

Referenced by init_constraints().

653  {
654  int BLAS_copy_scalar = COM_get_function_handle( "BLAS.copy_scalar");
655  int cnstr_handle = COM_get_attribute_handle( (wname+".cnstr_types_facial").c_str());
656  int zero = 0;
657  COM_call_function( BLAS_copy_scalar, &zero, &cnstr_handle);
658 
659  int SURF_normals = COM_get_function_handle( "SURF.compute_element_normals");
660  int nrms_handle = COM_get_attribute_handle( (wname+".facenormals").c_str());
661  COM_call_function( SURF_normals, &nrms_handle);
662 
663  int SURF_centers = COM_get_function_handle( "SURF.interpolate_to_centers");
664  int nc_handle = COM_get_attribute_handle( (wname+".nc").c_str());
665  int centers_handle = COM_get_attribute_handle( (wname+".facecenters").c_str());
666  COM_call_function( SURF_centers, &nc_handle, &centers_handle);
667 
668  // Set speed for different panes.
669  int *pane_ids, npanes;
670  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
671 
672  for ( int i=0; i<npanes; ++i) {
673  int pid = pane_ids[i];
674  MAP::Vector_3<double> *nrms, *centers;
675  COM_get_array( (wname+".facenormals").c_str(), pid, (void**)&nrms);
676  COM_get_array( (wname+".facecenters").c_str(), pid, (void**)&centers);
677 
678  // Set for pane 2 separately
679  int *cnstr_types;
680  COM_get_array( (wname+".cnstr_types_facial").c_str(),
681  pid, (void**)&cnstr_types);
682 
683  int nelems, ngelems;
684  COM_get_size( (wname+".facenormals").c_str(), pid, &nelems, &ngelems);
685 
686  double eps = 1.e-2;
687  // Loop through all faces
688  for ( int j=0; j<nelems-ngelems; ++j) {
689  if ( std::abs(std::abs(nrms[j][0])-1)<eps && centers[j][0] < 0.153)
690  cnstr_types[j] = 't'; // Move within yz plane.
691  }
692  }
693  COM_free_buffer( &pane_ids);
694 
695  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
696  COM_call_function( PROP_set_cnstr, &cnstr_handle);
697 }
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
NT abs(const NT &x)
Definition: number_utils.h:130
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_constraints_myacm ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 579 of file proptest.C.

References NTS::abs(), COM_call_function(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), i, j, Control_parameter::speed, square(), and Control_parameter::start.

Referenced by init_constraints().

580  {
581  int cnstr_handle = COM_get_attribute_handle( (wname+".cnstr_types_facial").c_str());
582 
583  int SURF_normals = COM_get_function_handle( "SURF.compute_element_normals");
584  int nrms_handle = COM_get_attribute_handle( (wname+".facenormals").c_str());
585  COM_call_function( SURF_normals, &nrms_handle);
586 
587  int SURF_centers = COM_get_function_handle( "SURF.interpolate_to_centers");
588  int nc_handle = COM_get_attribute_handle( (wname+".nc").c_str());
589  int centers_handle = COM_get_attribute_handle( (wname+".facecenters").c_str());
590  COM_call_function( SURF_centers, &nc_handle, &centers_handle);
591 
592  // Set speed for different panes.
593  int *pane_ids, npanes;
594  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
595 
596  double zero = 0;
597  int spd_elms = COM_get_attribute_handle( (wname+".flag_spd").c_str());
598  int BLAS_copy_scalar = COM_get_function_handle( "BLAS.copy_scalar");
599  COM_call_function( BLAS_copy_scalar, &zero, &spd_elms);
600 
601  for ( int i=0; i<npanes; ++i) {
602  int pid = pane_ids[i];
603  MAP::Vector_3<double> *nrms, *centers;
604  COM_get_array( (wname+".facenormals").c_str(), pid, (void**)&nrms);
605  COM_get_array( (wname+".facecenters").c_str(), pid, (void**)&centers);
606 
607  int *cnstr_types;
608  COM_get_array( (wname+".cnstr_types_facial").c_str(),
609  pid, (void**)&cnstr_types);
610  double *spds;
611  COM_get_array( (wname+".spds").c_str(), pid, (void**)&spds);
612  double *flags;
613  COM_get_array( (wname+".flag_spd").c_str(), pid, (void**)&flags);
614 
615  int nelems, ngelems;
616  COM_get_size( (wname+".facenormals").c_str(), pid, &nelems, &ngelems);
617 
618  double eps = 5.e-2;
619  if ( cntr_param.start == 0) {
620  // Loop through all faces
621  for ( int j=0; j<nelems-ngelems; ++j) {
622  if ( std::abs(nrms[j][2])<eps &&
623  square(centers[j][0])+square(centers[j][1]) >= square(0.0065)) {
624  cnstr_types[j] = 'z';
625  flags[j] = spds[j]= 0;
626  }
627  else {
628  cnstr_types[j] = 0;
629  flags[j] = 1.; spds[j]= cntr_param.speed;
630  }
631  }
632  }
633  else {
634  for ( int j=0; j<nelems-ngelems; ++j) {
635  if ( cnstr_types[j] == 0) {
636  flags[j] = 1.; spds[j]= cntr_param.speed;
637  }
638  else {
639  flags[j] = spds[j]= 0;
640  }
641  }
642  }
643  }
644  COM_free_buffer( &pane_ids);
645 
646  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
647  COM_call_function( PROP_set_cnstr, &cnstr_handle);
648 }
double square(double x)
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
NT abs(const NT &x)
Definition: number_utils.h:130
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_constraints_staraft ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 462 of file proptest.C.

References NTS::abs(), COM_call_function(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), COM_resize_array(), COM_set_size(), i, j, Control_parameter::speed, and Control_parameter::start.

Referenced by init_constraints().

463  {
464 
465  int *pane_ids, npanes;
466  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
467  int cnstr_handle = COM_get_attribute_handle( (wname+".cnstr_types_facial").c_str());
468 
469  // Set constraints and speeds
470  if ( cntr_param.start == 0) {
471  int cnstr_handle_pn = COM_get_attribute_handle((wname+".cnstr_type").c_str());
472  if ( cnstr_handle_pn>0) {
473  std::cout << "Obtaining constraints from input file" << std::endl;
474  int BLAS_copy = COM_get_function_handle( "BLAS.copy");
475 
476  COM_call_function( BLAS_copy, &cnstr_handle_pn, &cnstr_handle);
477 
478  int BLAS_copy_scalar = COM_get_function_handle( "BLAS.copy_scalar");
479  double zero = 0;
480  int spd_elms = COM_get_attribute_handle( (wname+".flag_spd").c_str());
481  COM_call_function( BLAS_copy_scalar, &zero, &spd_elms);
482  }
483  else {
484  std::cout << "Did not find constraints from input file. "
485  << "Setting constraints from geometry." << std::endl;
486 
487  // Compute constraints from geometry
488  int BLAS_copy_scalar = COM_get_function_handle( "BLAS.copy_scalar");
489  int zero = 0;
490  COM_call_function( BLAS_copy_scalar, &zero, &cnstr_handle);
491 
492  int SURF_normals = COM_get_function_handle( "SURF.compute_element_normals");
493  int nrms_handle = COM_get_attribute_handle( (wname+".facenormals").c_str());
494  COM_call_function( SURF_normals, &nrms_handle);
495 
496  int SURF_centers = COM_get_function_handle( "SURF.interpolate_to_centers");
497  int nc_handle = COM_get_attribute_handle( (wname+".nc").c_str());
498  int centers_handle = COM_get_attribute_handle( (wname+".facecenters").c_str());
499  COM_call_function( SURF_centers, &nc_handle, &centers_handle);
500 
501  for ( int i=0; i<npanes; ++i) {
502  int pid = pane_ids[i];
503  MAP::Vector_3<double> *nrms, *centers;
504  COM_get_array( (wname+".facenormals").c_str(), pid, (void**)&nrms);
505  COM_get_array( (wname+".facecenters").c_str(), pid, (void**)&centers);
506 
507  int *cnstr_types, nelems, ngelems;
508  COM_get_array( (wname+".cnstr_types_facial").c_str(),
509  pid, (void**)&cnstr_types);
510  COM_get_size( (wname+".facenormals").c_str(), pid, &nelems, &ngelems);
511 
512  double eps = 1.e-6;
513  // Loop through all faces
514  for ( int j=0; j<nelems-ngelems; ++j) {
515  if ( centers[j][0] < eps || centers[j][0]+eps > 1.76314)
516  cnstr_types[j] = 2;
517  else if ( centers[j][0] - 0.004826 < eps)
518  cnstr_types[j] = -'x';
519  else if ( centers[j][0] >= 1.6962 && std::abs(nrms[j][0])<0.1)
520  cnstr_types[j] = 'x';
521  }
522  }
523  }
524  }
525 
526  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
527  COM_call_function( PROP_set_cnstr, &cnstr_handle);
528 
529  // Set speeds based on constraints
530  for ( int i=0; i<npanes; ++i) {
531  int pid = pane_ids[i];
532 
533 #if 1
534  double *bnd;
535  // Set bounds
536  COM_set_size( (wname+".cnstr_bound").c_str(), pid, 1);
537  COM_resize_array( (wname+".cnstr_bound").c_str(), pid, (void**)&bnd);
538 
539  bnd[0] = -'x'; bnd[1] = 0; bnd[2] = 0.0635;
540  bnd[3] = bnd[4] = bnd[5] = 0; // Center
541  bnd[6] = 0; bnd[7] = bnd[8] = -0.07; // Lower bound of bounding box
542  bnd[9] = 1.7; bnd[10] = bnd[11] = 0.07; // Upper bound of bounding box
543 #endif
544 
545  // Set speeds
546  int *cnstr_types, nelems, ngelems;
547  double *spds;
548 
549  COM_get_array( (wname+".cnstr_types_facial").c_str(),
550  pid, (void**)&cnstr_types);
551  COM_get_size( (wname+".facenormals").c_str(), pid, &nelems, &ngelems);
552  COM_get_array( (wname+".spds").c_str(), pid, (void**)&spds);
553 
554  double *flags;
555  COM_get_array( (wname+".flag_spd").c_str(), pid, (void**)&flags);
556 
557  // Loop through all faces
558  for ( int j=0; j<nelems-ngelems; ++j) {
559  if ( cnstr_types[j]) {
560  flags[j] = spds[j] = 0;
561  }
562  else {
563  spds[j] = cntr_param.speed;
564  flags[j] = 1.;
565  }
566  }
567  }
568 
569 #if 1
570  int PROP_set_bounds = COM_get_function_handle( "PROP.set_bounds");
571  int bnd_handle = COM_get_attribute_handle( (wname+".cnstr_bound").c_str());
572  COM_call_function( PROP_set_bounds, &bnd_handle);
573 #endif
574 
575  COM_free_buffer( &pane_ids);
576 }
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
NT abs(const NT &x)
Definition: number_utils.h:130
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
Definition: roccom_c++.h:200
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_constraints_starslice ( const string &  wname,
const Control_parameter cntr_param 
)

Definition at line 404 of file proptest.C.

References NTS::abs(), COM_call_function(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), i, j, Control_parameter::speed, and square().

Referenced by init_constraints(), main(), and remesh().

405  {
406  int BLAS_copy_scalar = COM_get_function_handle( "BLAS.copy_scalar");
407  int cnstr_handle = COM_get_attribute_handle( (wname+".cnstr_types_facial").c_str());
408  int zero = 0;
409  COM_call_function( BLAS_copy_scalar, &zero, &cnstr_handle);
410 
411  int SURF_normals = COM_get_function_handle( "SURF.compute_element_normals");
412  int nrms_handle = COM_get_attribute_handle( (wname+".facenormals").c_str());
413  COM_call_function( SURF_normals, &nrms_handle);
414 
415  int SURF_centers = COM_get_function_handle( "SURF.interpolate_to_centers");
416  int nc_handle = COM_get_attribute_handle( (wname+".nc").c_str());
417  int centers_handle = COM_get_attribute_handle( (wname+".facecenters").c_str());
418  COM_call_function( SURF_centers, &nc_handle, &centers_handle);
419 
420  // Set speed for different panes.
421  int *pane_ids, npanes;
422  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
423 
424  for ( int i=0; i<npanes; ++i) {
425  int pid = pane_ids[i];
426  MAP::Vector_3<double> *nrms, *centers;
427  COM_get_array( (wname+".facenormals").c_str(), pid, (void**)&nrms);
428  COM_get_array( (wname+".facecenters").c_str(), pid, (void**)&centers);
429 
430  // Set for pane 2 separately
431  int *cnstr_types, nelems;
432  COM_get_array( (wname+".cnstr_types_facial").c_str(),
433  pid, (void**)&cnstr_types);
434  COM_get_size( (wname+".facenormals").c_str(), pid, &nelems);
435  double *spds;
436  COM_get_array( (wname+".spds").c_str(), pid, (void**)&spds);
437 
438  double eps = 1.e-5;
439  // Loop through all faces
440  for ( int j=0; j<nelems; ++j) {
441  if ( 1-std::abs(nrms[j][2])<eps &&
442  ( centers[j][2] < eps || (1-centers[j][2]) < eps)) {
443  cnstr_types[j] = 't'; // Move within xy plane.
444  spds[j] = 0;
445  }
446  else if ( std::abs(nrms[j][2]) < 0.5 &&
447  square(centers[j][0])+square(centers[j][1])>=3.999) {
448  cnstr_types[j] = 2;
449  spds[j] = 0;
450  }
451  else
452  spds[j] = cntr_param.speed;
453  }
454  }
455  COM_free_buffer( &pane_ids);
456 
457  int PROP_set_cnstr = COM_get_function_handle( "PROP.set_constraints");
458  COM_call_function( PROP_set_cnstr, &cnstr_handle);
459 }
double square(double x)
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
blockLoc i
Definition: read.cpp:79
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
Definition: roccom_c++.h:274
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
j indices j
Definition: Indexing.h:6
NT abs(const NT &x)
Definition: number_utils.h:130
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
Definition: roccom_c++.h:350
void COM_free_buffer(int **buf)
Definition: roccom_c++.h:397
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

Here is the caller graph for this function:

void init_parameters ( const Control_parameter cntr_param)

Definition at line 228 of file proptest.C.

References COM_call_function(), COM_get_function_handle(), Control_parameter::courant, Control_parameter::eigthres, Control_parameter::fangle, Control_parameter::feature_layer, Control_parameter::method, Control_parameter::normaldif, rank, Control_parameter::rediter, Control_parameter::sangle, Control_parameter::smoother, Control_parameter::verbose, Control_parameter::wavefrontal, and Control_parameter::weight.

228  {
229  int PROP_set_option = COM_get_function_handle( "PROP.set_option");
230 
231  if ( !cntr_param.method.empty()) {
232  COM_call_function( PROP_set_option, "method", cntr_param.method.c_str());
233 
234  if ( rank==0) std::cout << "Set propagation method to " << cntr_param.method << std::endl;
235  }
236 
237  if ( !cntr_param.wavefrontal.empty()) {
238  COM_call_function( PROP_set_option, "wavefrontal", cntr_param.wavefrontal.c_str());
239  if ( rank==0) std::cout << "Set wavefrontal to " << cntr_param.wavefrontal << std::endl;
240  }
241 
242  if ( !cntr_param.normaldif.empty()) {
243  COM_call_function( PROP_set_option, "normaldif", cntr_param.normaldif.c_str());
244  if ( rank==0) std::cout << "Set normaldif to " << cntr_param.normaldif << std::endl;
245  }
246 
247  if ( !cntr_param.eigthres.empty()) {
248  COM_call_function( PROP_set_option, "eigthres", cntr_param.eigthres.c_str());
249  if ( rank==0) std::cout << "Set eigthres to " << cntr_param.eigthres << std::endl;
250  }
251 
252  if ( !cntr_param.courant.empty()) {
253  COM_call_function( PROP_set_option, "courant", cntr_param.courant.c_str());
254  if ( rank==0) std::cout << "Set courant constant to " << cntr_param.courant << std::endl;
255  }
256 
257  if ( !cntr_param.fangle.empty()) {
258  COM_call_function( PROP_set_option, "fangle", cntr_param.fangle.c_str());
259  if ( rank==0) std::cout << "Set weak-feature angle to " << cntr_param.fangle << std::endl;
260  }
261  if ( !cntr_param.sangle.empty()) {
262  COM_call_function( PROP_set_option, "sangle", cntr_param.sangle.c_str());
263  if ( rank==0) std::cout << "Set strong-feature angle to " << cntr_param.sangle << std::endl;
264  }
265 
266  if ( !cntr_param.smoother.empty()) {
267  COM_call_function( PROP_set_option, "smoother", cntr_param.smoother.c_str());
268  if ( rank==0) std::cout << "Set smoother to " << cntr_param.smoother << std::endl;
269  }
270 
271  if ( !cntr_param.rediter.empty()) {
272  COM_call_function( PROP_set_option, "rediter", cntr_param.rediter.c_str());
273  if ( rank==0) std::cout << "Set rediter to " << cntr_param.rediter << std::endl;
274  }
275 
276  if ( !cntr_param.feature_layer.empty()) {
277  COM_call_function( PROP_set_option, "feature_layer",
278  cntr_param.feature_layer.c_str());
279  if ( rank==0)
280  std::cout << "Set feature_layer to " << cntr_param.feature_layer << std::endl;
281  }
282 
283  if ( !cntr_param.verbose.empty()) {
284  COM_call_function( PROP_set_option, "verbose", cntr_param.verbose.c_str());
285 
286  if ( rank==0) std::cout << "Set verbose level to " << cntr_param.verbose << std::endl;
287  }
288 
289  if ( !cntr_param.weight.empty()) {
290  COM_call_function( PROP_set_option, "weight", cntr_param.weight.c_str());
291  if ( rank==0) std::cout << "Set weight to " << cntr_param.weight << std::endl;
292  }
293 
294 }
string normaldif
Definition: advectest.C:84
static int rank
Definition: proptest.C:64
string wavefrontal
Definition: advectest.C:83
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
string feature_layer
Definition: proptest.C:90
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void load_modules ( )

Definition at line 56 of file proptest.C.

References COM_LOAD_MODULE_STATIC_DYNAMIC.

56  {
58  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocmap, "MAP");
60  COM_LOAD_MODULE_STATIC_DYNAMIC(Rocsurf, "SURF");
62 }
Definition: Rocout.h:81
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
int main ( int  argc,
char *  argv[] 
)

Definition at line 878 of file proptest.C.

References Control_parameter::adapt_iter, cimg_library::cimg::atof(), Control_parameter::collapse_ratio, COM_call_function(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_print_profile(), COM_set_profiling(), COM_set_profiling_barrier(), COMMPI_Comm_rank(), COMMPI_Initialized(), compute_area(), compute_volume(), Control_parameter::do_collapse, Control_parameter::do_flip, Control_parameter::do_redist, Control_parameter::do_split, Control_parameter::edge_len, Control_parameter::eigthres, Control_parameter::fangle, Control_parameter::feature_layer, Control_parameter::format, i, init_attributes(), init_constraints(), init_parameters(), Control_parameter::interval, j, k, load_modules(), max(), MPI_COMM_WORLD, output_solution(), Control_parameter::perturb, print_usage(), rank, read_control_file(), read_in_mesh(), Control_parameter::refine, Control_parameter::remesh_interval, Control_parameter::sangle, Control_parameter::smoother, Control_parameter::speed, Control_parameter::split_angle, Control_parameter::start, Control_parameter::steps, Control_parameter::subadapt, Control_parameter::timestep, and v.

878  {
879  COM_init( &argc, &argv);
880  load_modules();
881  print_usage( argc, argv);
882 
884 
885  // Read in mesh file.
886  string wname = read_in_mesh( argv[1]);
887 
888  // Read in control parameters
889  Control_parameter cntr_param;
890  read_control_file( argc>2?argv[2]:"control.txt", cntr_param);
891 
892  // Initialize the attributes and output the initial solution.
893  init_attributes( wname, cntr_param);
894 
895  // Attributes
896  int pmesh = COM_get_attribute_handle( (wname+".pmesh").c_str());
897  int nc = COM_get_attribute_handle( (wname+".nc").c_str());
898  int spds = COM_get_attribute_handle( (wname+".spds").c_str());
899  int disps = COM_get_attribute_handle( (wname+".disps").c_str());
900  int disps_total = COM_get_attribute_handle( (wname+".disps_total").c_str());
901 
902  // Funcitions
903  int PROP_init = COM_get_function_handle( "PROP.initialize");
904  int PROP_perturb = COM_get_function_handle( "PROP.perturb_mesh");
905  int PROP_propagate = COM_get_function_handle( "PROP.propagate");
906  int BLAS_add = COM_get_function_handle( "BLAS.add");
907 
908  if ( rank==0) cout << "Propagating interface..." << endl;
909  // Initialize control parameters
910  COM_call_function( PROP_init, &pmesh);
911  init_parameters( cntr_param);
912 
913  init_constraints( wname, cntr_param);
914 
915  if ( cntr_param.perturb > 0)
916  COM_call_function( PROP_perturb, &pmesh, &cntr_param.perturb);
917 
918  if ( cntr_param.start==0) {
919  double zero=0.;
920  // Run one step to detect features.
921  COM_call_function( PROP_propagate, &pmesh, &spds, &zero, &disps, &zero);
922  }
923  output_solution( wname, "00000", cntr_param.format);
924 
926  COM_set_profiling_barrier( PROP_propagate, MPI_COMM_WORLD);
927 
928  std::ofstream areas, vols;
929  if ( rank==0) {
930  areas.open((wname+"_areas.m").c_str());
931  vols.open((wname+"_vols.m").c_str());
932 
933  areas.precision(10); vols.precision(10); cout.precision(10);
934  }
935 
936  double a=compute_area( wname), v=compute_volume(wname);
937 
938  if ( rank==0) {
939  std::cout << "Burning area is " << a
940  << " and total volume is " << v << std::endl;
941  areas << wname << "_as = [0 " << a << ";..." << std::endl;
942  vols << wname << "_vs = [0 " << v << ";..." << std::endl;
943  }
944 
945  char fname[40];
946  std::sprintf(fname, "timedata_%03d.txt", rank);
947 
948 #ifdef MESH_ADAPT
949  AdaptCOMWindow acw( wname.c_str());
950  acw.set_option( "adapt_iter", 1); // cntr_param.adapt_iter);
951  acw.set_option( "redist_iter", 0); // cntr_param.do_redist);
952 
953  acw.set_option( "do_collapse", cntr_param.do_collapse);
954  acw.set_option( "do_flip", cntr_param.do_flip);
955  acw.set_option( "do_split", cntr_param.do_split);
956  acw.set_option( "refine", cntr_param.refine);
957  if ( cntr_param.edge_len>0)
958  acw.set_option( "edge_len", cntr_param.edge_len);
959 
960  if ( !cntr_param.fangle.empty())
961  acw.set_option( "fangle_weak",
962  std::atof(cntr_param.fangle.c_str())/180*M_PI);
963  if ( !cntr_param.sangle.empty())
964  acw.set_option( "fangle_strong",
965  std::atof(cntr_param.sangle.c_str())/180*M_PI);
966  if ( !cntr_param.eigthres.empty())
967  acw.set_option( "eig_thres", std::atof(cntr_param.eigthres.c_str()));
968  if ( cntr_param.collapse_ratio>0)
969  acw.set_option( "collapse_ratio", cntr_param.collapse_ratio);
970  if ( cntr_param.split_angle > 0)
971  acw.set_option( "split_angle", cntr_param.split_angle);
972 
973  acw.set_option( "anisotropic", cntr_param.smoother == "anisotropic");
974  if ( !cntr_param.feature_layer.empty())
975  acw.set_option( "feature_layer", std::atof(cntr_param.feature_layer.c_str()));
976 #endif
977 
978  double t=cntr_param.start*cntr_param.timestep;
979  for ( int i=1+cntr_param.start; i<=cntr_param.steps; ++i, t+=cntr_param.timestep) {
980  cntr_param.start = i; // Save current time step
981  if ( rank==0) cout << "Step " << i << endl;
982 
983  double local_t = 0, t_rem = cntr_param.timestep, t_elapsed = 0;
984  while ( t_rem > 0) {
985  // If speed is 0, then do smoothing only.
986  if ( cntr_param.speed==0) t_rem=0;
987 
988 #ifdef MESH_ADAPT
989  if ( i>1 && cntr_param.adapt_iter>0 &&
990  ( local_t!=0 && t_elapsed < cntr_param.subadapt*cntr_param.timestep ||
991  local_t==0 && (i-1)%cntr_param.remesh_interval==0)) {
992 
993  for (int j=0; j<cntr_param.adapt_iter; ++j) {
994  if ( !acw.adapt()) break;
995 
996  // Reset the constraints
997  init_constraints( wname, cntr_param);
998 
999  // If the window has changed, reinitialize Rocprop.
1000  COM_call_function( PROP_init, &pmesh);
1001 
1002  for ( int k=0; k<std::max(1,cntr_param.do_redist); ++k) {
1003  // Perform mesh smoothing
1004  double zero=0.;
1005  std::cout << "Perform anisotropic smoothing" << std::endl;
1006  COM_call_function( PROP_propagate, &pmesh, &spds,
1007  &zero, &disps, &t_elapsed);
1008  COM_call_function( BLAS_add, &nc, &disps, &nc);
1009  COM_call_function( BLAS_add, &disps_total, &disps, &disps_total);
1010  }
1011  }
1012  }
1013 #endif
1014 
1015  COM_call_function( PROP_propagate, &pmesh, &spds,
1016  &t_rem, &disps, &t_elapsed);
1017 
1018  COM_call_function( BLAS_add, &nc, &disps, &nc);
1019  COM_call_function( BLAS_add, &disps_total, &disps, &disps_total);
1020 
1021  local_t = cntr_param.timestep - (t_rem-t_elapsed);
1022  t_rem = cntr_param.timestep - local_t;
1023 
1024  if ( t_rem>0 && t_elapsed*1.e3<cntr_param.timestep) {
1025  std::cout << "Time step too small. Stopping..." << std::endl;
1026  exit(-1);
1027  }
1028  }
1029 
1030  a=compute_area( wname); v=compute_volume(wname);
1031  if ( rank==0) {
1032  std::cout << "Burning area is " << a
1033  << " and total volume is " << v << std::endl;
1034  double t = i*cntr_param.timestep;
1035  areas << '\t' << t << '\t' << a << ";..." << std::endl;
1036  vols << '\t' << t << '\t' << v << ";..." << std::endl;
1037  }
1038 
1039  if ( i%cntr_param.interval == 0) {
1040  char steps[10];
1041  if ( cntr_param.steps>=1.e6)
1042  std::sprintf( steps, "%07d", i);
1043  else if ( cntr_param.steps>=1.e5)
1044  std::sprintf( steps, "%06d", i);
1045  else
1046  std::sprintf( steps, "%05d", i);
1047 
1048  output_solution( wname, steps, cntr_param.format);
1049 
1050  COM_print_profile( fname, "Proptest");
1051  }
1052  }
1053 
1054  areas << "];" << std::endl;
1055  vols << "];" << std::endl;
1056 
1057  COM_finalize();
1058 }
int COMMPI_Comm_rank(MPI_Comm c)
Definition: commpi.h:162
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
j indices k indices k
Definition: Indexing.h:6
double compute_volume(const string &wname)
Definition: advectest.C:414
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void init_parameters(const Control_parameter &cntr_param)
Definition: advectest.C:217
float atof(const char *const str)
Read a float number from a C-string.
Definition: CImg.h:4905
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
std::string read_in_mesh(const char *fname)
Definition: advectest.C:283
double collapse_ratio
Definition: advectest.C:110
void COM_finalize()
Definition: roccom_c++.h:59
double compute_area(const string &wname)
Definition: advectest.C:395
static int rank
Definition: proptest.C:64
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
blockLoc i
Definition: read.cpp:79
void COM_set_profiling_barrier(int hdl, MPI_Comm comm)
Definition: roccom_c++.h:554
void print_usage(int argc, char *argv[])
Definition: advectest.C:68
void COM_set_profiling(int i)
Definition: roccom_c++.h:550
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void load_modules()
Definition: advectest.C:58
j indices j
Definition: Indexing.h:6
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
double split_angle
Definition: advectest.C:111
void init_constraints(const string &wname, const Control_parameter &cntr_param)
Definition: proptest.C:700
string feature_layer
Definition: proptest.C:90
int COMMPI_Initialized()
Definition: commpi.h:168
double output_solution(const string &wname, const char *timelevel, double ref=0.)
Definition: advectest.C:357
void init_attributes(const string &wname, const Control_parameter &cntr_param)
Definition: advectest.C:323
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428
void read_control_file(const char *fname, Control_parameter &cp)
Definition: advectest.C:115

Here is the call graph for this function:

void output_solution ( const string &  wname,
const char *  timelevel,
const string &  format 
)

Definition at line 808 of file proptest.C.

References COM_call_function(), COM_get_attribute_handle(), COM_get_function_handle(), and COMMPI_Initialized().

809  {
810  static int OUT_write = 0, hdl;
811 
812  if ( OUT_write==0) {
813  OUT_write = COM_get_function_handle( "OUT.write_attribute");
814  hdl = COM_get_attribute_handle( (wname+".all").c_str());
815 
816  int OUT_set = COM_get_function_handle( "OUT.set_option");
817 #if USE_CGNS
818  if ( format != "HDF" && format != "hdf")
819  COM_call_function( OUT_set, "format", "CGNS");
820  else
821 #endif
822  COM_call_function( OUT_set, "format", "HDF");
823  }
824 
825  std::string fname = wname+"_"+timelevel;
826 
827  if ( !COMMPI_Initialized()) {
828 #if USE_CGNS
829  if ( format != "HDF" && format != "hdf")
830  fname.append(".cgns");
831  else
832 #endif
833  fname.append(".hdf");
834  }
835  else fname.append("_");
836 
837  COM_call_function( OUT_write, (char*)fname.c_str(),
838  &hdl, (char*)wname.c_str(), timelevel);
839 }
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COMMPI_Initialized()
Definition: commpi.h:168
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void print_usage ( int  argc,
char *  argv[] 
)

Definition at line 66 of file proptest.C.

66  {
67  if ( argc <= 2) {
68  cout << "Usage: " << argv[0] << " <surffile> <controlfile>" << std::endl;
69 
70  exit(-1);
71  }
72 }
void read_control_file ( const char *  fname,
Control_parameter cp 
)

Definition at line 117 of file proptest.C.

References Control_parameter::adapt_iter, Control_parameter::collapse_ratio, COM_assertion_msg, Control_parameter::courant, Control_parameter::do_collapse, Control_parameter::do_flip, Control_parameter::do_redist, Control_parameter::do_split, Control_parameter::edge_len, Control_parameter::eigthres, Control_parameter::fangle, Control_parameter::feature_layer, Control_parameter::format, Control_parameter::interval, Control_parameter::method, Control_parameter::normaldif, Control_parameter::perturb, rank, Control_parameter::rediter, Control_parameter::refine, Control_parameter::remesh_interval, Control_parameter::sangle, Control_parameter::smoother, Control_parameter::speed, Control_parameter::split_angle, Control_parameter::sploc, Control_parameter::start, Control_parameter::steps, Control_parameter::subadapt, Control_parameter::timestep, Control_parameter::verbose, Control_parameter::wavefrontal, and Control_parameter::weight.

117  {
118  /* Sample control file:
119  * method: fo # method: fo and mp
120  * wavefrontal: 1 # wavefrontal expansion
121  * normaldif: 1 # normal diffusion
122  * eigthres: 1.e-4 # threshold for null space: 0..1 (1.e-4 default)
123  * courant: 0.5 # courant constant
124  * fangle: 25 # feature edge angle: between 0 and 180
125  * sangle: 65 # feature edge angle: between 0 and 180
126  * smoother: angle # type of mesh-smoothing algorithm
127  * rediter: 1 # Number of iterations for vertex redistribution
128  * speed: 0.1 # Speed
129  * sploc: e # location of speed: n or e
130  * timestep: 0.001 # time step
131  * steps: 100 # number of time steps
132  * interval: 10 # output intervals
133  * remesh_interval: 10 # remesh intervals
134  * weight: 3 # angle weighted
135  * verbose: 1 # verbose level
136  *
137  * adapt_iter: 2
138  * do_flip: 1
139  * do_split: 1
140  * do_redist: 1
141  * do_collapse: 1
142  * collapse_ratio: 0.1
143  * split_angle: 2.618 # (150 degrees)
144  */
145  ifstream is(fname); COM_assertion_msg( is, "File does not exist");
146 
147  while ( !is.eof()) {
148  char buf[255];
149  is.get( buf, 255, ':');
150  if ( buf[0] == '\0') { is.getline( buf, 255); continue; }
151 
152  istringstream istr(buf);
153  string keyword; istr >> keyword;
154  is.getline( buf, 255, ':');
155 
156  if ( keyword == "method")
157  is >> cp.method;
158  else if ( keyword == "wavefrontal")
159  is >> cp.wavefrontal;
160  else if ( keyword == "normaldif")
161  is >> cp.normaldif;
162  else if ( keyword == "eigthres")
163  is >> cp.eigthres;
164  else if ( keyword == "courant")
165  is >> cp.courant;
166  else if ( keyword == "fangle")
167  is >> cp.fangle;
168  else if ( keyword == "sangle")
169  is >> cp.sangle;
170  else if ( keyword == "smoother")
171  is >> cp.smoother;
172  else if ( keyword == "rediter")
173  is >> cp.rediter;
174  else if ( keyword == "perturb")
175  is >> cp.perturb;
176  else if ( keyword == "speed")
177  is >> cp.speed;
178  else if ( keyword == "sploc")
179  is >> cp.sploc;
180  else if ( keyword == "timestep")
181  is >> cp.timestep;
182  else if ( keyword == "steps")
183  is >> cp.steps;
184  else if ( keyword == "start")
185  is >> cp.start;
186  else if ( keyword == "interval")
187  is >> cp.interval;
188  else if ( keyword == "remesh_interval")
189  is >> cp.remesh_interval;
190  else if ( keyword == "weight")
191  is >> cp.weight;
192  else if ( keyword == "format")
193  is >> cp.format;
194  else if ( keyword == "verbose")
195  is >> cp.verbose;
196  else if ( keyword == "verbose")
197  is >> cp.verbose;
198  else if ( keyword == "subadapt")
199  is >> cp.subadapt;
200  else if ( keyword == "adapt_iter")
201  is >> cp.adapt_iter;
202  else if ( keyword == "do_redist")
203  is >> cp.do_redist;
204  else if ( keyword == "do_contract" || keyword == "do_collapse")
205  is >> cp.do_collapse;
206  else if ( keyword == "do_flip")
207  is >> cp.do_flip;
208  else if ( keyword == "do_split")
209  is >> cp.do_split;
210  else if ( keyword == "feature_layer")
211  is >> cp.feature_layer;
212  else if ( keyword == "refine")
213  is >> cp.refine;
214  else if ( keyword == "edge_len")
215  is >> cp.edge_len;
216  else if ( keyword == "collapse_ratio")
217  is >> cp.collapse_ratio;
218  else if ( keyword == "split_angle")
219  is >> cp.split_angle;
220  else
221  std::cerr << "Unknow keyword " << keyword << std::endl;
222  is.getline( buf, 255);
223  }
224 
225  if ( rank==0) std::cout << " speed is " << cp.speed << std::endl;
226 }
#define COM_assertion_msg(EX, msg)
double collapse_ratio
Definition: advectest.C:110
string normaldif
Definition: advectest.C:84
static int rank
Definition: proptest.C:64
string wavefrontal
Definition: advectest.C:83
double split_angle
Definition: advectest.C:111
string feature_layer
Definition: proptest.C:90
std::string read_in_mesh ( const char *  fname)

Definition at line 297 of file proptest.C.

References COM_assertion_msg, rank, and IM_Reader::read_winmesh().

297  {
298  if ( rank==0) cout << "Reading surface mesh file \"" << fname << '"' << endl;
299 
300  std::string fname_str(fname);
301 
302  std::string::size_type pos = fname_str.find_first_of( ".");
303  const string wname = fname_str.substr( 0, pos);
304 
305  if ( rank==0) cout << "Creating window \"" << wname << '"' << endl;
306 
307  IM_Reader im_reader;
308  int npanes = im_reader.read_winmesh( fname, wname, false);
309  COM_assertion_msg( npanes>=0, "Failed to read in mesh file. File empty?");
310 
311  return wname;
312 }
#define COM_assertion_msg(EX, msg)
static int rank
Definition: proptest.C:64
int read_winmesh(const char *fname, const std::string &wname, bool del=true)
Definition: IM_Reader.h:58

Here is the call graph for this function:

void rescale_object ( std::string &  wname,
double  alpha,
const SURF::Vector_3< double > &  origin 
)

Definition at line 314 of file proptest.C.

References Rocblas::add_scalar(), COM_get_roccom(), Rocblas::mul_scalar(), x, y, and z.

315  {
316  // Rescale and translate the object.
317  COM::Window *win=COM_get_roccom()->get_window_object(wname);
318  COM::Attribute *nc=win->attribute("nc");
319 
320  // Rescale the radius to 0.15
321  Rocblas::mul_scalar( nc, &alpha, nc);
322 
323  // Translate the origin to (0.5,0.75, 0.5);
324  COM::Attribute *x=win->attribute("1-nc");
325  COM::Attribute *y=win->attribute("2-nc");
326  COM::Attribute *z=win->attribute("3-nc");
327 
328  Rocblas::add_scalar( x, &origin[0], x);
329  Rocblas::add_scalar( y, &origin[1], y);
330  Rocblas::add_scalar( z, &origin[2], z);
331 }
void int int REAL REAL * y
Definition: read.cpp:74
static void mul_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for multiplication with y as a scalar pointer.
Definition: op3args.C:347
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
Definition: Roccom_base.h:537
static void add_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for addition with y as a scalar pointer.
Definition: op3args.C:299

Here is the call graph for this function:

T square ( t)

Definition at line 401 of file proptest.C.

401 { return t*t; }

Variable Documentation

int rank = 0
static

Definition at line 64 of file proptest.C.

Referenced by init_parameters(), main(), read_control_file(), and read_in_mesh().