Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ex5.C
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: ex5.C,v 1.21 2008/12/06 08:43:29 mtcampbe Exp $
24 
25 #include "roccom.h"
26 #include <cstdio>
27 #include <iostream>
28 #include <fstream>
29 #include <vector>
30 #include <algorithm>
31 #include <cstring>
32 #include <string>
33 #include <cassert>
34 #include "commpi.h"
35 
36 COM_EXTERN_MODULE( Rocface);
38 
39 using namespace std;
40 
41 extern int read_obj( std::istream &is, vector<double> &coors,
42  vector<int> &elems);
43 
44 int main(int argc, char *argv[]) {
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 }
142 
143 
144 
145 
146 
147 
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
This file contains the prototypes for Roccom API.
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
Definition: Rocout.h:81
blockLoc i
Definition: read.cpp:79
Contains declarations of MPI subroutines used in Roccom.
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
int main(int argc, char *argv[])
Definition: blastest.C:94
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
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116