Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
genflu.C File Reference
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <cassert>
#include <cstdlib>
#include "mpi.h"
#include "roccom.h"
#include "GEM.H"
#include "TRAIL_Flu.H"
#include "TRAIL_GeoPart.H"
Include dependency graph for genflu.C:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 50 of file genflu.C.

References GEM_Partition::_cell_ordering, GEM_Partition::_comm, GEM_Partition::_npart, GEM_Partition::_out, COM_finalize(), COM_init(), COM_set_verbose(), GEM_Partition::debug(), GEM_Partition::DestroyWindows(), GEM_Partition::InitRoccomWindows(), MPI_COMM_WORLD, n, rank, GEM_Partition::report(), TRAIL_FluInitSolver(), TRAIL_FluInitSurfSoln(), TRAIL_FluInitVolSoln(), TRAIL_FluPopulatePatches(), TRAIL_FluRegisterSurfMesh(), TRAIL_FluRegisterSurfSoln(), TRAIL_FluRegisterVolSoln(), TRAIL_FluWriteMAP(), TRAIL_FluWriteNative(), TRAIL_GeoPartReadASCII(), GEM_Partition::WindowInitDone(), and GEM_Partition::WriteRocstar().

51 {
52  bool debug = true;
53  bool map_wrote = false;
54  if(argc < 4){
55  cerr << "part2flu <source_prefix> <target_prefix> <npartitions>" << endl;
56  return(1);
57  }
58  int nproc = 1;
59  int rank = 0;
60  //#ifdef _TRAIL_MPI_
61  MPI_Init(&argc,&argv);
62  MPI_Comm_size(MPI_COMM_WORLD,&nproc);
63  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
64  //#ifdef _ROCSTAR_X_
65  COM_init(&argc,&argv);
66  //#endif
67  //#endif
68  std::ofstream DebugFile;
69  std::ostringstream DBFileName;
70  DBFileName << "gp2rstar_" << rank;
71  DebugFile.open(DBFileName.str().c_str());
72  bool verbose = true;
73  string source_prefix(argv[1]);
74  string targ_prefix(argv[2]);
75  unsigned int npart;
76  string snpart(argv[3]);
77  istringstream Istr(snpart);
78  Istr >> npart;
79  unsigned int N;
80  int R;
81  unsigned int first;
82 
83  if(npart < (unsigned int)nproc){
84  N = 1;
85  first = rank;
86  }
87  else{
88  N = npart/nproc;
89  R = npart - (nproc*N);
90  if(rank < R){
91  first = rank * N + rank;
92  N++;
93  }
94  else
95  first = rank * N + R;
96  }
97  if(debug)
98  DebugFile << "Processing " << npart << " partitions." << std::endl
99  << "Local partitions: (" << N << "," << first
100  << ")" << std::endl;
101  int part_index = first;
102  unsigned int n = 0;
103  // Now that we know which partitions we will process on this processor, the
104  // task at hand is to populate the GEM_ structures from Bill's output. That's
105  // all the following code does.
106  while(n < N){
107  if(!rank && verbose)
108  std::cout << "Processing " << part_index << "." << std::endl;
109  if(debug)
110  DebugFile << "Processing " << part_index << "." << std::endl;
111  std::ifstream Inf;
112  std::ostringstream FileName;
113  FileName << source_prefix << "." << part_index << ".asc";
114  Inf.open(FileName.str().c_str());
115  if(!Inf){
116  std::cerr << "Cannot open " << FileName.str() << ", aborting." << std::endl;
117  return(false);
118  }
119  GEM_Partition my_partition(part_index+1);
120  my_partition._cell_ordering[0] = 1;
121  my_partition._cell_ordering[1] = 4;
122  my_partition._cell_ordering[2] = 3;
123  my_partition._cell_ordering[3] = 2;
124  my_partition._npart = npart;
125  if(!TRAIL_FluInitSolver(my_partition,"Rocflu")){
126  std::cerr << rank << ": TRAIL_FluInitSolver() failed, aborting." << std::endl;
127  return(1);
128  }
129  if(debug){
130  my_partition.debug();
131  my_partition._out = &DebugFile;
132  }
133  //#ifdef _TRAIL_MPI_
134  my_partition._comm = MPI_COMM_WORLD;
135  //#endif
136  if(!TRAIL_GeoPartReadASCII(my_partition,Inf)){
137  cerr << rank << ": Cannot process " << FileName.str() << ", aborting." << endl;
138  return(1);
139  }
140  if(verbose && !rank)
141  cout << "Done reading Bill's partition, populating Rocflu data." << endl;
142  if(debug)
143  DebugFile << "Done reading Bill's partition, populating Rocflu data." << std::endl;
144 
145  // This function populates the Rocflu boundary patches. You'll need a
146  // *.cgi file for this (needed when translating a grid generator's BC id
147  // to Rocflu patch id's)
148  if(!TRAIL_FluPopulatePatches(my_partition))
149  std::cerr << rank << ": TRAIL_FluPopulatePatches failed, aborting." << std::endl;
150  if(debug)
151  DebugFile << "Patches done." << std::endl;
152 
153 
154  // When populating from scratch (like we do with Bill's meshes), we need
155  // to initialize actual solutions on the mesh. We don't need to do this
156  // after remeshing, or if data already exists.
157  TRAIL_FluInitVolSoln(my_partition);
158  if(debug)
159  DebugFile << "Volume solution done." << std::endl;
160  TRAIL_FluInitSurfSoln(my_partition);
161  if(debug){
162  DebugFile << "Surface solution done." << std::endl;
163  my_partition.report();
164  DebugFile << "Writing Rocflu native data." << std::endl;
165  }
166 
167  // Writes the Rocflu native text files that are required by both Rocflu
168  // standalone and Rocstar
169  if(!TRAIL_FluWriteNative(my_partition,"Rocflu/Modin")){
170  std::cerr << rank << ": TRAIL_FluWriteNative failed, aborting." << std::endl;
171  return(1);
172  }
173  // Write this file only once
174  if(!rank && !map_wrote){
175  TRAIL_FluWriteMAP(my_partition,npart,npart,"Rocflu/Modin");
176  map_wrote = true;
177  }
178  // FIXME! - Still need to populate remote border indices!
179 
180  // FIXME
181  // Writes the Grid and Soln files needed by standalone Rocflu
182  // fluregion.WriteFluGridASCII(targ_prefix,0.0);
183  // fluregion.WriteFluSolnASCII(targ_prefix,0,0.0,true);
184  // FIXME
185 
186  if(debug){
187  DebugFile << "Done writing native files." << std::endl
188  << "Writing Rocstar data." << std::endl;
189  }
190  //#ifdef _ROCSTAR_X_
191  if(debug)
192  COM_set_verbose(6);
193  // The next few calls set up, and populate a Rocflu window
194  my_partition.InitRoccomWindows("flu");
195  if(debug && !rank)
196  cout << " window created." << endl;
197  TRAIL_FluRegisterSurfMesh(my_partition);
198  TRAIL_FluRegisterVolSoln(my_partition);
199  TRAIL_FluRegisterSurfSoln(my_partition);
200  my_partition.WindowInitDone();
201  if(debug && !rank)
202  cout << " window data registered." << endl;
203  my_partition.WriteRocstar("Rocflu/Rocin",0.0);
204  // These calls identify the target directory and write all the files
205  // Rocstar needs.
206 // string::size_type y = targ_prefix.find_last_of("/");
207 // string targ_dir = targ_prefix.substr(0,y);
208 // fluregion.WriteRocstar(targ_dir);
209  if(debug && !rank)
210  cout << " hdf files written." << endl;
211 
212  // Clean up after ourselves in Roccom
213  my_partition.DestroyWindows();
214  if(debug && !rank)
215  cout << " window data destroyed." << endl;
216  //#endif
217  if(debug && !rank)
218  cout << "Local partition " << n << " processed." << endl;
219  n++;
220  part_index++;
221  }
222  if(verbose && !rank)
223  std::cout
224  << "All local partitions processed. Waiting for other processors...";
225  MPI_Barrier(MPI_COMM_WORLD);
226  if(verbose && !rank)
227  std::cout << "done." << std::endl;
228 
229  //#ifdef _TRAIL_MPI_
230  MPI_Finalize();
231  //#endif
232 
233  //#ifdef _ROCSTAR_X_
234  COM_finalize();
235  //#endif
236  return(0);
237 }
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 TRAIL_FluWriteMAP(GEM_Partition &gp, unsigned int nproc, unsigned int nregions, const std::string &path)
bool TRAIL_FluInitSolver(GEM_Partition &gp, const std::string &prefix="./")
bool TRAIL_FluInitVolSoln(GEM_Partition &gp)
void COM_set_verbose(int i)
Definition: roccom_c++.h:543
bool TRAIL_FluInitSurfSoln(GEM_DomainBoundary &db, const std::string &, bool all=true)
bool TRAIL_FluRegisterSurfMesh(GEM_Partition &gp)
void COM_finalize()
Definition: roccom_c++.h:59
bool TRAIL_FluPopulatePatches(GEM_Partition &gp)
bool TRAIL_FluRegisterSurfSoln(GEM_DomainBoundary &db, const std::string &wname, bool all=true)
bool TRAIL_FluWriteNative(GEM_Partition &gp, const std::string &path)
const NT & n
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57
static int rank
Definition: advectest.C:66
bool TRAIL_GeoPartReadASCII(GEM_Partition &gp, std::ifstream &Inf)
bool TRAIL_FluRegisterVolSoln(GEM_Partition &gp, bool all=true)

Here is the call graph for this function: