Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
genstar.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 #include <iostream>
24 #include <iomanip>
25 #include <vector>
26 #include <string>
27 #include <fstream>
28 #include <sstream>
29 #include <map>
30 #include <list>
31 #include <cassert>
32 #include <cstdlib>
33 
34 using namespace std;
35 
36 #include "GEM.H"
37 //#include "Partition.H"
38 #include "FluRegion.H"
39 
40 //#ifdef _TRAIL_MPI_
41 #include "mpi.h"
42 //#ifdef _ROCSTAR_X_
43 #include "roccom.h"
45 //#endif
46 //#endif
47 
48 int
49 main(int argc,char *argv[])
50 {
51  if(argc < 4){
52  cerr << "genstar <source_prefix> <target_prefix> <npartitions>" << endl;
53  return(1);
54  }
55  int nproc = 1;
56  int rank = 0;
57  //#ifdef _TRAIL_MPI_
58  MPI_Init(&argc,&argv);
59  MPI_Comm_size(MPI_COMM_WORLD,&nproc);
60  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
61  //#ifdef _ROCSTAR_X_
62  COM_init(&argc,&argv);
63  //#endif
64  //#endif
65  bool verbose = true;
66  string source_prefix(argv[1]);
67  string targ_prefix(argv[2]);
68  unsigned int npart;
69  string snpart(argv[3]);
70  istringstream Istr(snpart);
71  Istr >> npart;
72  unsigned int N;
73  int R;
74  unsigned int first;
75 
76  if(npart < (unsigned int)nproc){
77  N = 1;
78  first = rank;
79  }
80  else{
81  N = npart/nproc;
82  R = npart - (nproc*N);
83  if(rank < R){
84  first = rank * N + rank;
85  N++;
86  }
87  else
88  first = rank * N + R;
89  }
90  if(!rank)
91  cout << rank << ": Processing " << npart << " partitions." << endl;
92  if(verbose)
93  cout << rank << ": Local partitions: (" << N << "," << first
94  << ")" << endl;
95  int part_index = first;
96  unsigned int n = 0;
97  while(n < N){
98  if(!rank && verbose)
99  cout << "Processing " << part_index++ << "." << endl;
100  FluRegion fluregion;
101  fluregion.debug();
102  bool unsteady = true;
103  double t = 0.0;
104  unsigned int niter = 0;
105  fluregion.ReadRegionASCII(source_prefix,part_index,niter,t,unsteady);
106  fluregion.WriteFluNative(targ_prefix);
107  fluregion.WriteFluGridASCII(targ_prefix,t,unsteady);
108  fluregion.WriteFluSolnASCII(targ_prefix,niter,t,unsteady);
109  fluregion.CreateRegionMapFile(targ_prefix,npart,npart);
110  //#ifdef _ROCSTAR_X_
111  fluregion.InitRoccomWindows("flu",fluregion._borders,fluregion._patches);
112  fluregion.RegisterFluSurfaceMesh();
113  fluregion.RegisterVolumeSoln(true);
114  fluregion.RegisterSurfaceSoln(false);
115  fluregion.InitDone();
116  string::size_type y = targ_prefix.find_last_of("/");
117  string targ_dir = targ_prefix.substr(0,y);
118  fluregion.WriteRocstar(targ_dir);
119  fluregion.DestroyWindows();
120  //#endif
121 
122  n++;
123  }
124  //#ifdef _TRAIL_MPI_
125  MPI_Finalize();
126  //#endif
127 
128  //#ifdef _ROCSTAR_X_
129  COM_finalize();
130  //#endif
131  return(0);
132 }
133 
134 
135 
136 
137 
138 
139 
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
bool InitRoccomWindows(const std::string &wname)
Definition: GEM.C:685
bool WriteFluSolnASCII(const std::string &p="", unsigned int=0, double=0.0, bool=true)
Definition: FluRegion.C:1298
bool CreateRegionMapFile(const string &p="", unsigned int=0, unsigned int=0)
Definition: FluRegion.C:328
void int int REAL REAL * y
Definition: read.cpp:74
bool ReadRegionASCII(const string &p="", unsigned int=0, unsigned int=0, double=0.0, bool=true)
Definition: FluRegion.C:1577
vector< FluBorder > _borders
Definition: FluRegion.H:133
This file contains the prototypes for Roccom API.
bool WriteRocstar(const std::string &, double t=0.0)
Definition: GEM.C:601
void COM_finalize()
Definition: roccom_c++.h:59
bool DestroyWindows()
Definition: GEM.C:584
bool RegisterVolumeSoln(bool)
Definition: FluRegion.C:1689
Definition: Rocout.h:81
const NT & n
bool WriteFluNative(const string &p="")
Definition: FluRegion.C:114
vector< FluPatch > _patches
Definition: FluRegion.H:132
bool debug(bool s=true)
Definition: GEM.C:1266
int main(int argc, char *argv[])
Definition: blastest.C:94
bool RegisterSurfaceSoln(bool)
Definition: FluRegion.C:1742
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
static int rank
Definition: advectest.C:66
bool WriteFluGridASCII(const string &pre="", double=0.0, bool=true)
Definition: FluRegion.C:1085
bool RegisterFluSurfaceMesh()
Definition: FluRegion.C:1783
#define COM_EXTERN_MODULE(moduleName)
Definition: roccom_basic.h:116