Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot3d.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: plot3d.C,v 1.7 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 <cstdlib>
34 #include <cmath>
35 #include <cassert>
36 #include "commpi.h"
37 
38 COM_EXTERN_MODULE( Rocface);
39 
40 using namespace std;
41 
42 class Point_3 {
43  typedef double Type;
44 public:
45  Point_3() {}
46  Point_3( Type a, Type b, Type c) : _x(a), _y(b), _z(c) {}
47  Type &operator[](const int i) { return (&_x)[i]; }
48  const Type &operator[](const int i) const { return (&_x)[i]; }
49 
50 protected:
51  Type _x, _y, _z;
52 };
53 
54 // Read in a nstructed mesh
55 void read_plot3d( istream &is, vector<vector<Point_3> > &coors,
56  vector< pair<int,int> > &dims) {
57  int ngrid;
58  is >> ngrid;
59 
60  dims.resize(ngrid);
61  for ( int i=0; i<ngrid; ++i) {
62  int t;
63  is >> dims[i].first >> dims[i].second >> t;
64  }
65 
66  coors.resize( ngrid);
67  for ( int i=0; i<ngrid; ++i) {
68  coors[i].resize( dims[i].first*dims[i].second);
69 
70  for ( int l=0; l<3; ++l) {
71  for ( int j=0, nj=coors[i].size(); j<nj; ++j)
72  is >> coors[i][j][l];
73  }
74  }
75 }
76 
77 int main(int argc, char *argv[]) {
78  MPI_Init( &argc, &argv);
79  COM_init( &argc, &argv);
80 
81  if ( argc < 3) {
82  std::cout << "Usage: " << argv[0]
83  << " file1 file2 [<out_path>] "
84  << " [<scale_1>] [<scale_2>]" << std::endl;
85  exit(-1);
86  }
87 
88  COM_set_verbose( 1);
90 
91  const string wnames[2] = {string(argv[1], string( argv[1]).find(".")),
92  string(argv[2], string( argv[2]).find("."))};
93 
94  vector< vector<Point_3> > coors[2];
95 
96  COM_LOAD_MODULE_STATIC_DYNAMIC( Rocface, "RFC");
97 
98  for ( int k=0; k<2; ++k) {
99  COM_new_window( wnames[k].c_str());
100 
101  ifstream fi( argv[k+1]);
102  vector<pair< int, int> > dims;
103  read_plot3d( fi, coors[k], dims);
104 
105  for ( int i=0, ni=dims.size(); i<ni; ++i) {
106  COM_set_array( (wnames[k]+".:st2:").c_str(), i+1, &dims[i].first);
107  COM_set_array( (wnames[k]+".nc").c_str(), i+1, &coors[k][i][0]);
108  }
109 
110  COM_window_init_done( wnames[k].c_str());
111  }
112 
113  MPI_Comm comm = MPI_COMM_WORLD;
114 
115  int RFC_overlay = COM_get_function_handle( "RFC.overlay");
116  int RFC_write = COM_get_function_handle( "RFC.write_overlay");
117 
118  int tri1_mesh = COM_get_attribute_handle( (wnames[0]+".mesh").c_str());
119  int tri2_mesh = COM_get_attribute_handle( (wnames[1]+".mesh").c_str());
120 
121  COM_call_function( RFC_overlay, &tri1_mesh, &tri2_mesh, &comm, "./");
122  COM_call_function( RFC_write, &tri1_mesh, &tri2_mesh);
123 
124  COM_print_profile( "", "");
125 
126  COM_finalize();
127  MPI_Finalize();
128 }
129 
130 
131 
132 
133 
134 
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
Point_3()
Definition: plot3d.C:45
j indices k indices k
Definition: Indexing.h:6
This file contains the prototypes for Roccom API.
Point_3(Type a, Type b, Type c)
Definition: plot3d.C:46
void COM_set_verbose(int i)
Definition: roccom_c++.h:543
int COM_get_attribute_handle(const char *waname)
Definition: roccom_c++.h:412
void COM_finalize()
Definition: roccom_c++.h:59
void read_plot3d(istream &is, vector< vector< Point_3 > > &coors, vector< pair< int, int > > &dims)
Definition: plot3d.C:55
void COM_print_profile(const char *fname, const char *header)
Definition: roccom_c++.h:557
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
Type & operator[](const int i)
Definition: plot3d.C:47
int main(int argc, char *argv[])
Definition: blastest.C:94
double Type
Definition: plot3d.C:43
Type _z
Definition: plot3d.C:51
j indices j
Definition: Indexing.h:6
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
SURF::Point_3< Real > Point_3
Definition: rfc_basic.h:41
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void int * nj
Definition: read.cpp:74
const Type & operator[](const int i) const
Definition: plot3d.C:48
#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