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

Go to the source code of this file.

Functions

int get_comm_rank (MPI_Comm comm)
 
int get_comm_size (MPI_Comm comm)
 
int main (int argc, char *argv[])
 

Function Documentation

int get_comm_rank ( MPI_Comm  comm)

Definition at line 32 of file pcommpartest.C.

References rank.

Referenced by main().

32  {
33  int rank;
34  int ierr = MPI_Comm_rank( comm, &rank); assert( ierr == 0);
35  return rank;
36 }
static int rank
Definition: advectest.C:66

Here is the caller graph for this function:

int get_comm_size ( MPI_Comm  comm)

Definition at line 37 of file pcommpartest.C.

Referenced by main().

37  {
38  int size;
39  int ierr = MPI_Comm_size( comm, &size); assert( ierr == 0);
40  return size;
41 }

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 43 of file pcommpartest.C.

References COM_assertion, COM_call_function(), COM_finalize(), COM_FLOAT, COM_get_array(), COM_get_attribute_handle(), COM_get_function_handle(), COM_get_panes(), COM_get_size(), COM_init(), COM_load_module(), COM_new_attribute(), COM_resize_array(), COM_window_init_done(), get_comm_rank(), get_comm_size(), j, k, and MPI_COMM_WORLD.

43  {
44  MPI_Init( &argc, &argv);
45 
46  MPI_Comm comm = MPI_COMM_WORLD;
47  int size_of_p = get_comm_size(comm);
48  int myrank = get_comm_rank(comm);
49  if(myrank == 0)
50  std::cout << "myrank = " << myrank <<" and size_of_p = " << size_of_p << std::endl;
51 
52  COM_init( &argc, &argv);
53  assert(size_of_p==2 && myrank <2);
54 
55  if(myrank == 0)
56  cout << "Reading mesh file \"" << argv[1] << '"' << endl;
57 
58  std::string wname("surf");
59  if(myrank == 0)
60  cout << "Creating window \"" << wname << '"' << endl;
61 
62  // Read in HDF format
63  if(myrank == 0)
64  cout << "Loading Rocin" << endl;
65  COM_load_module( "Rocin", "IN");
66 
67  std::string fname("surf000");
68  if(myrank==0)
69  fname += "0.hdf";
70  else
71  fname += "1.hdf";
72  if (myrank ==0)
73  cout << "Reading file " << fname << endl;
74  int IN_read = COM_get_function_handle( "IN.read_window");
75  COM_call_function( IN_read,
76  ("test/"+fname).c_str(),
77  wname.c_str(),
78  &comm);
79 
80  if (myrank ==0)
81  std::cout << "Obtaining the mesh " << endl;
82  int IN_obtain = COM_get_function_handle( "IN.obtain_attribute");
83  int mesh_hdl = COM_get_attribute_handle((wname+".mesh").c_str());
84  COM_call_function( IN_obtain, &mesh_hdl, &mesh_hdl);
85 
86  // Change the memory layout to contiguous.
87  if (myrank ==0)
88  std::cout << "Resizing the attribute arrays " << endl;
89  COM_resize_array( (wname+".all").c_str(), 0, NULL, 0);
90 
91  int npanes;
92  int* pane_ids;
93  COM_get_panes( wname.c_str(), &npanes, &pane_ids);
94  COM_assertion( npanes>=0);
95  if(myrank ==0)
96  std::cout << npanes << " panes found" << endl;
97 
98  if(myrank==0)
99  std::cout<< "Labeling nodes with pane ids" << endl;
100  COM_new_attribute("surf.pane_ids",'n', COM_FLOAT, 1, "empty");
101  COM_resize_array("surf.pane_ids");
102 
103  int nitems;
104  float *ptr;
105  for(int j = 0; j <npanes; ++j){
106  COM_get_size("surf.pane_ids", pane_ids[j], &nitems);
107  COM_get_array("surf.pane_ids", pane_ids[j], &ptr);
108  for(int k =0; k<nitems; ++k){
109  ptr[k] = pane_ids[j];
110  }
111  }
112  int pid_hdl = COM_get_attribute_handle("surf.pane_ids");
113 
114  if(myrank == 0)
115  cout << "Loading Rocmap" << endl;
116  COM_load_module( "Rocmap", "MAP");
117 
118  if(myrank == 0)
119  std::cout << "Performing an average-reduction on shared nodes." << endl;
120  int MAP_average_shared = COM_get_function_handle( "MAP.reduce_average_on_shared_nodes");
121  COM_call_function( MAP_average_shared, &pid_hdl);
122 
123  if(myrank == 0)
124  std::cout << "Updating ghost nodes." << endl;
125  int MAP_update_ghost = COM_get_function_handle( "MAP.update_ghosts");
126  COM_call_function( MAP_update_ghost, &pid_hdl);
127 
128  if(myrank == 0)
129  std::cout << "finishing up window initialization" << endl;
130  COM_window_init_done( wname.c_str());
131 
132  if(myrank == 0)
133  std::cout << "loading Rocout" << endl;
134  COM_load_module("Rocout", "OUT");
135 
136  const string pconn = wname+".pconn";
137 
138  // Output smoothed mesh
139  string newfile = "smoothed" + fname;
140  if(myrank == 0)
141  std::cout << "Outputting window into file " << newfile << endl;
142  int OUT_set = COM_get_function_handle( "OUT.set_option");
143  int OUT_write = COM_get_function_handle( "OUT.write_attribute");
144  COM_call_function( OUT_set, "mode", "w");
145  int all_hdl = COM_get_attribute_handle( (wname+".all").c_str());
146  COM_call_function( OUT_write, newfile.c_str(), &all_hdl,
147  (char*)wname.c_str(), "0000");
148 
149  COM_finalize();
150 }
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
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
int get_comm_rank(MPI_Comm comm)
Definition: pcommpartest.C:32
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_finalize()
Definition: roccom_c++.h:59
void COM_load_module(const char *libname, const char *winname)
Definition: roccom_c++.h:75
int get_comm_size(MPI_Comm comm)
Definition: pcommpartest.C:37
void COM_window_init_done(const char *w_str, int pane_changed=true)
Definition: roccom_c++.h:102
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_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
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_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: