Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Surfdiver.C File Reference
#include <iostream>
#include <cstring>
#include <cstdlib>
#include "roccom.h"
#include "basic_actions.h"
#include "FluidAgent.h"
#include "SolidAgent.h"
Include dependency graph for Surfdiver.C:

Go to the source code of this file.

Functions

void _load_rocface (FluidAgent *fagent, SolidAgent *sagent, const RocmanControl_parameters *param)
 
void read_file (const char *fname, const string &wname, double alpha)
 
void compute_overlay (FluidAgent *fagent, SolidAgent *sagent, double t)
 

Function Documentation

void _load_rocface ( FluidAgent fagent,
SolidAgent sagent,
const RocmanControl_parameters param 
)

Definition at line 43 of file transfer_actions.C.

References COM_call_function(), COM_get_attribute_handle_const(), COM_get_function_handle(), COM_get_window_handle(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_set_profiling_barrier(), compute_overlay(), Control_parameters::current_time, FluidAgent::fluidBufNG, Agent::get_comm_rank(), Agent::get_communicator(), Coupling::get_control_param(), Agent::get_coupling(), Agent::get_modinstance_name(), MAN_DEBUG, rank, RocmanControl_parameters::remeshed, RocmanControl_parameters::rfc_verb, and SolidAgent::solidBuf.

44 {
45  int rank = fagent->get_comm_rank();
46 
47  // INIT_ROCFACE of rocman.f90
48  if (COM_get_window_handle( "RFC") <=0 ) {
49  if(rank == 0)
50  MAN_DEBUG(3, ("Rocstar: load module RocFace.\n"));
51  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocface, "RFC");
52 
53  int RFC_setv = COM_get_function_handle( "RFC.set_verbose");
54  COM_call_function( RFC_setv, &param->rfc_verb);
55 
56 #if 0
57  // if remeshed
58  MAN_DEBUG(3, ("Rocstar: remeshed: %d.\n", param->remeshed));
59  if (param->remeshed) {
60  double t = fagent->get_coupling()->get_control_param()->current_time;
61  compute_overlay( fagent, sagent, t);
62  }
63 #endif
64 
65  // load overlay
66  MPI_Comm comm = fagent->get_communicator();
67 
68  int RFC_read = COM_get_function_handle( "RFC.read_overlay");
69  int fluid_mesh = COM_get_attribute_handle_const( fagent->fluidBufNG+".mesh");
70  int solid_mesh = COM_get_attribute_handle_const( sagent->solidBuf+".mesh");
71  std::string rfc_dir = "Rocman/"+fagent->get_modinstance_name()+sagent->get_modinstance_name()+"/";
72  //std::string rfc_dir = "Rocman/RocfloRocsolid/";
73  std::string fluid_dir = rfc_dir+"ifluid";
74  std::string solid_dir = rfc_dir+"isolid";
75 
76  if(rank == 0)
77  MAN_DEBUG(2, ("Rocstar: read RocFace overlay mesh from %s.\n", rfc_dir.c_str()));
78 
79  //COM_call_function( RFC_read, &fluid_mesh, &solid_mesh, &comm, fluid_dir.c_str(), solid_dir.c_str(), "HDF");
80  COM_call_function( RFC_read, &fluid_mesh, &solid_mesh, &comm, fluid_dir.c_str(), solid_dir.c_str(), "CGNS");
81 
82  int RFC_transfer = COM_get_function_handle("RFC.least_squares_transfer");
83  int RFC_interpolate = COM_get_function_handle("RFC.interpolate");
84  COM_set_profiling_barrier( RFC_transfer, comm);
85  COM_set_profiling_barrier( RFC_interpolate, comm);
86  }
87 }
std::string get_modinstance_name() const
Definition: Agent.h:222
Coupling * get_coupling()
Definition: Agent.h:213
std::string fluidBufNG
Definition: FluidAgent.h:78
std::string solidBuf
Definition: SolidAgent.h:68
void COM_set_profiling_barrier(int hdl, MPI_Comm comm)
Definition: roccom_c++.h:554
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
int COM_get_attribute_handle_const(const char *waname)
Definition: roccom_c++.h:420
int COM_get_window_handle(const char *wname)
Definition: roccom_c++.h:404
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
int get_comm_rank() const
Definition: Agent.h:224
double current_time
Definition: Coupling.h:54
void compute_overlay(FluidAgent *fagent, SolidAgent *sagent, double t)
Definition: Surfdiver.C:192
static int rank
Definition: advectest.C:66
MPI_Comm get_communicator() const
Definition: Agent.h:220
const Control_parameters * get_control_param()
Definition: Coupling.h:183
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
Definition: roccom_basic.h:111
int COM_get_function_handle(const char *wfname)
Definition: roccom_c++.h:428

Here is the call graph for this function:

void compute_overlay ( FluidAgent fagent,
SolidAgent sagent,
double  t 
)

Definition at line 192 of file Surfdiver.C.

References RocBlas::add, COM_call_function(), COM_get_attribute_handle(), COM_get_default_communicator(), COM_get_function_handle(), COM_set_default_communicator(), COM_set_profiling(), COM_window_init_done(), Agent::get_comm_rank(), Agent::get_communicator(), Agent::get_rocmod_name(), Agent::get_time_string(), MAN_DEBUG, read_file(), and SolidAgent::solidBuf.

Referenced by _load_rocface(), and SurfDiverAfterRemeshing::run().

192  {
193  MAN_DEBUG(1, ("[%d] Rocstar: compute_overlay with t:%e .\n", fagent->get_comm_rank(), t));
194 
195  MPI_Comm comm = fagent->get_communicator();
196 
197  MPI_Barrier(comm);
198 
199  // run sequentially
200  if (fagent->get_comm_rank() == 0) {
201 
202  MPI_Comm oldcomm = COM_get_default_communicator();
203  COM_set_default_communicator( MPI_COMM_NULL);
204  // need to turn off profiling as it may hang for npes > 1
206 
207  // read meshes
208 
209  std::string time_str;
210  fagent->get_time_string(t, time_str);
211  std::string fluid_file = fagent->get_rocmod_name()+"/Rocout/ifluid_"+time_str+".txt";
212  std::string solid_file = sagent->get_rocmod_name()+"/Rocout/isolid_"+time_str+".txt";
213 
214  std::string outdir = "Rocman/"+fagent->get_rocmod_name()+sagent->get_rocmod_name()+"/";
215  std::string fluid_wname = outdir+"ifluid";
216  std::string solid_wname = outdir+"isolid";
217 
218  // load two meshes
219  read_file( fluid_file.c_str(), fluid_wname.c_str(), 1.);
220  COM_window_init_done( fluid_wname);
221 
222  read_file( solid_file.c_str(), solid_wname.c_str(), 1.);
223  COM_window_init_done( solid_wname);
224 
225  int fluid_mesh1 = COM_get_attribute_handle( (fluid_wname+".mesh").c_str());
226  int solid_mesh1 = COM_get_attribute_handle( (solid_wname+".mesh").c_str());
227 
228  const char *format = "HDF";
229 
230  // call Rocblas to get deformed data HERE
231  int s_x_hdl = COM_get_attribute_handle( sagent->solidBuf + ".x");
232  int s_uhat_hdl = COM_get_attribute_handle( sagent->solidBuf + ".uhat");
233  int s_y_hdl = COM_get_attribute_handle( sagent->solidBuf + ".nc");
234 
235  // get deformed
236  COM_call_function( RocBlas::add, &s_x_hdl, &s_uhat_hdl, &s_y_hdl);
237 
238  int RFC_overlay = COM_get_function_handle( "RFC.overlay");
239  int RFC_write = COM_get_function_handle( "RFC.write_overlay");
240 
241  // mesh overlay
242  MAN_DEBUG(2,("Starting mesh overlay... "));
243  COM_call_function( RFC_overlay, &fluid_mesh1, &solid_mesh1);
244 
245  // output overlay mesh
246  COM_call_function( RFC_write, &fluid_mesh1, &solid_mesh1,
247  fluid_wname.c_str(), solid_wname.c_str(), format);
248 
251  } // end of PE 0
252 
253  MPI_Barrier(comm);
254 
255 }
void read_file(const char *fname, const string &wname, double alpha)
Definition: autosurfer.C:39
void COM_set_default_communicator(MPI_Comm comm)
Definition: roccom_c++.h:67
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void get_time_string(double t, std::string &s)
Definition: Agent.C:578
static int add
Definition: RocBlas.h:35
std::string get_rocmod_name() const
Definition: Agent.h:221
std::string solidBuf
Definition: SolidAgent.h:68
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
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
#define MAN_DEBUG(l, x)
Definition: rocman.h:98
int get_comm_rank() const
Definition: Agent.h:224
MPI_Comm get_communicator() const
Definition: Agent.h:220
MPI_Comm COM_get_default_communicator()
Definition: roccom_c++.h:69
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 read_file ( const char *  fname,
const string &  wname,
double  alpha 
)

Definition at line 38 of file Surfdiver.C.

References COM_call_function(), COM_clone_attribute(), COM_delete_attribute(), COM_delete_pane(), COM_delete_window(), COM_free_buffer(), COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_new_window(), i, man_verbose, and MPI_COMM_SELF.

39 {
40  char *lastdot=strrchr( const_cast<char *>(fname), '.');
41 
42  COM_new_window( wname.c_str(), MPI_COMM_SELF);
43 
44  // Read in HDF files or a Rocin control file
45  if(man_verbose > 2)
46  std::cout << "Reading file " << fname << " " << wname << std::endl;
47 
48  // Read in HDF format
49  //COM_UNLOAD_MODULE_STATIC_DYNAMIC( Rocin, "IN");
50  //COM_LOAD_MODULE_STATIC_DYNAMIC( Rocin, "IN");
51 
52  int IN_read;
53  // Read in HDF format using Rocin::read_window or ::read_by_control_file
54  if ( strcmp( lastdot, ".hdf")==0)
55  IN_read = COM_get_function_handle( "IN.read_window");
56  else
57  IN_read = COM_get_function_handle( "IN.read_by_control_file");
58 
59  // Pass MPI_COMM_NULL to Rocin so that the rank becomes a wildcard.
60  MPI_Comm comm_null = MPI_COMM_NULL;
61  std::string bufwin("bufwin");
62  COM_call_function( IN_read, fname, bufwin.c_str(), &comm_null);
63 
64  int IN_obtain = COM_get_function_handle( "IN.obtain_attribute");
65 
66  // Check whether bcflag exists. If so, retain only the panes with flag<=1.
67  int bcflag = COM_get_attribute_handle((bufwin+".bcflag").c_str());
68  if (bcflag > 0) {
69  // Read in bcflags.
70  COM_call_function( IN_obtain, &bcflag, &bcflag);
71 
72  // Obtain the IDs of the panes of the window
73  int npanes, *pane_ids;
74  COM_get_panes( bufwin.c_str(), &npanes, &pane_ids);
75 
76  // Loop through the panes to remove those with bcflag >1.
77  for ( int i=0; i<npanes; ++i) {
78  int *flag;
79  COM_get_array( (bufwin+".bcflag").c_str(), pane_ids[i], &flag);
80  if ( flag==NULL || *flag>1)
81  COM_delete_pane( bufwin.c_str(), pane_ids[i]);
82  }
83 
84  // remove buffers.
85  COM_free_buffer( &pane_ids);
86  }
87 
88  // Remove all attributes except for the mesh
89  COM_delete_attribute( (bufwin+".atts").c_str());
90 
91  // Read in the mesh.
92  int buf_mesh = COM_get_attribute_handle((bufwin+".mesh").c_str());
93  COM_call_function( IN_obtain, &buf_mesh, &buf_mesh);
94  //COM_UNLOAD_MODULE_STATIC_DYNAMIC( Rocin, "IN");
95 
96  if(man_verbose > 2)
97  std::cout << "Obtained window " << wname << " from file " << fname << std::endl;
98 
99  // Change the memory layout to contiguous.
100  COM_clone_attribute( (wname+".mesh").c_str(), (bufwin+".mesh").c_str(), 0);
101  COM_delete_window( bufwin.c_str());
102 }
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_SELF
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
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_delete_attribute(const char *wa_str)
Delete an existing attribute.
Definition: roccom_c++.h:128
int man_verbose
blockLoc i
Definition: read.cpp:79
void COM_clone_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Clone the subset of panes of another window of which the given pane attribute has value val...
Definition: roccom_c++.h:234
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
void COM_call_function(const int wf, int argc,...)
Definition: roccom_c.C:48
void COM_delete_pane(const char *str, int pid)
Definition: roccom_c++.h:110
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: