Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ex5.C File Reference
#include "roccom.h"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cassert>
#include "commpi.h"
Include dependency graph for ex5.C:

Go to the source code of this file.

Functions

 COM_EXTERN_MODULE (Rocface)
 
 COM_EXTERN_MODULE (Rocout)
 
int read_obj (std::istream &is, vector< double > &coors, vector< int > &elems)
 
int main (int argc, char *argv[])
 

Function Documentation

COM_EXTERN_MODULE ( Rocface  )
COM_EXTERN_MODULE ( Rocout  )
int main ( int  argc,
char *  argv[] 
)

Definition at line 44 of file ex5.C.

References COM_call_function(), COM_delete_window(), COM_finalize(), COM_get_attribute_handle(), COM_get_function_handle(), COM_init(), COM_LOAD_MODULE_STATIC_DYNAMIC, COM_new_window(), COM_print_profile(), COM_set_array(), COM_set_profiling(), COM_set_size(), COM_set_verbose(), COM_window_init_done(), i, MPI_COMM_WORLD, and read_obj().

44  {
45  COM_init( &argc, &argv);
46 
47  if ( argc < 7) {
48  std::cout << "Usage: " << argv[0]
49  << " <t1_prefix> <t1_num_blocks> <t1_suffix> <t2_prefix>"
50  << " <t2_num_blocks> <t2_suffix>" << std::endl;
51  exit(-1);
52  }
53 
54  COM_set_verbose( 1);
56 
57  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocface, "RFC");
58 
59  MPI_Comm comm = MPI_COMM_WORLD;
60  const int comm_rank=0;
61  const int comm_size=1;
62 
63  const char *t1_prefix = argv[1];
64  const int t1_num_blocks=atoi(argv[2]);
65  const char *t1_suffix = argv[3];
66  assert( t1_num_blocks <= 5);
67 
68  std::vector<double> t1_mesh_coors[5];
69  std::vector<int> t1_mesh_elems[5];
70 
71  for ( int i=0; i<t1_num_blocks; ++i) if ( i%comm_size==comm_rank) {
72  char fname[100];
73  std::sprintf( fname, "%s%d%s", t1_prefix, i+1, t1_suffix);
74  std::ifstream is( fname);
75  assert( is != NULL);
76  read_obj( is, t1_mesh_coors[i], t1_mesh_elems[i]);
77  }
78 
79  COM_new_window("tri1");
80  for ( int i=0; i<t1_num_blocks; ++i) if ( i%comm_size==comm_rank) {
81  COM_set_size( "tri1.nc", i+1, t1_mesh_coors[i].size()/3);
82  COM_set_array( "tri1.nc", i+1, &t1_mesh_coors[i][0]);
83  COM_set_size( "tri1.:t3:", i+1, t1_mesh_elems[i].size()/3);
84  COM_set_array( "tri1.:t3:", i+1, &t1_mesh_elems[i][0]);
85  }
86  COM_window_init_done( "tri1");
87 
88  const char *t2_prefix = argv[4];
89  const int t2_num_blocks=atoi(argv[5]);
90  const char *t2_suffix = argv[6];
91  assert( t2_num_blocks <= 5);
92 
93  std::vector<double> t2_mesh_coors[5];
94  std::vector<int> t2_mesh_elems[5];
95 
96  for ( int i=0; i<t2_num_blocks; ++i) if ( i%comm_size==comm_rank) {
97  char fname[100];
98  std::sprintf( fname, "%s%d%s", t2_prefix, i+1, t2_suffix);
99  std::ifstream is( fname);
100  assert( is != NULL);
101  read_obj( is, t2_mesh_coors[i], t2_mesh_elems[i]);
102  }
103  COM_new_window("tri2");
104  for ( int i=0; i<t2_num_blocks; ++i) if ( i%comm_size==comm_rank) {
105  COM_set_size( "tri2.nc", i+1, t2_mesh_coors[i].size()/3);
106  COM_set_array( "tri2.nc", i+1, &t2_mesh_coors[i][0]);
107  COM_set_size( "tri2.:t3:", i+1, t2_mesh_elems[i].size()/3);
108  COM_set_array( "tri2.:t3:", i+1, &t2_mesh_elems[i][0]);
109  }
110  COM_window_init_done( "tri2");
111 
112  int tri1_mesh = COM_get_attribute_handle( "tri1.mesh");
113  int tri2_mesh = COM_get_attribute_handle( "tri2.mesh");
114  int RFC_clear = COM_get_function_handle( "RFC.clear_overlay");
115  int RFC_write = COM_get_function_handle( "RFC.write_overlay");
116 
117  if ( comm_size==1) {
118  int RFC_overlay = COM_get_function_handle( "RFC.overlay");
119 
120  COM_call_function( RFC_overlay, &tri1_mesh, &tri2_mesh, &comm);
121  COM_call_function( RFC_write, &tri1_mesh, &tri2_mesh, "tri1", "tri2", "HDF" );
122  COM_call_function( RFC_clear, "tri1", "tri2");
123  }
124 
125  int RFC_read = COM_get_function_handle( "RFC.read_overlay");
126  COM_call_function( RFC_read, &tri1_mesh, &tri2_mesh, &comm,
127  "tri1", "tri2", "HDF");
128 
129  char prefix1[100], prefix2[100];
130  std::sprintf(prefix1, "tri1_%d", comm_rank);
131  std::sprintf(prefix2, "tri2_%d", comm_rank);
132 
133  COM_call_function( RFC_clear, "tri1", "tri2");
134 
135  COM_delete_window( "tri1");
136  COM_delete_window( "tri2");
137 
138  COM_print_profile( "", "");
139 
140  COM_finalize();
141 }
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
void COM_delete_window(const char *wname)
Definition: roccom_c++.h:94
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_set_verbose(int i)
Definition: roccom_c++.h:543
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
int read_obj(std::istream &is, vector< double > &coors, vector< int > &elems)
Definition: meshio.C:39
void COM_finalize()
Definition: roccom_c++.h:59
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
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_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
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 COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
Definition: roccom_c++.h:156
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
#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:

int read_obj ( std::istream &  is,
vector< double > &  coors,
vector< int > &  elems 
)

Definition at line 39 of file meshio.C.

References i, j, MAXLEN, p0, and p1.

40  {
41  const int MAXLEN=255;
42  char buf[MAXLEN];
43  int face_type = 3;
44 
45  is.getline( buf, MAXLEN);
46  if ( strncmp( buf, "#OBJ", 4)==0 && !is.eof()) {
47  face_type = buf[4] - '0';
48  assert( face_type == 3 || face_type == 4 || face_type == 6);
49  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
50  }
51  int np=0, nf=0;
52  if ( strcmp( buf, "off")==0 || strcmp( buf, "OFF")==0 )
53  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
54  sscanf( buf, "%d %d", &np, &nf);
55 
56  // Allocate space for points and faces.
57  coors.reserve( np*3); elems.reserve( nf*face_type);
58 
59  // Read in the coordinates
60  for ( int i=0; i<np; ++i) {
61  do { is.getline( buf, MAXLEN); } while ( buf[0]=='#' && !is.eof());
62  double p0, p1, p2;
63  sscanf( buf, "%lf %lf %lf", &p0, &p1, &p2);
64  coors.push_back( p0); coors.push_back( p1); coors.push_back( p2);
65  }
66 
67  // Read in faces
68  vector<int> f( face_type);
69  while( is.peek() == '#' && !is.eof()) is.getline( buf, MAXLEN);
70  for ( int i=0; i<nf; ++i) {
71  for ( int j=0; j<face_type; ++j) {
72  is >> f[j]; assert( f[j] >= 1 && f[j] <= np);
73  elems.push_back( f[j]);
74  }
75  }
76 
77  return face_type;
78 }
NT p1
#define MAXLEN
Definition: Coupling.h:41
NT p0
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6