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

Go to the source code of this file.

Functions

void checkError (const char *errCode)
 
void printUsage (const char *why)
 
int main (int argc, char *argv[])
 

Variables

makefloParam parameters
 

Function Documentation

void checkError ( const char *  errCode)

Definition at line 62 of file makeflo.cpp.

Referenced by main().

62  {
63  if (errCode==NULL) return; //No problem
64  fprintf(stderr,"FATAL ERROR! %s\n",errCode);
65  exit(1);
66 }

Here is the caller graph for this function:

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

Definition at line 103 of file makeflo.cpp.

References blocks, buildFaces(), checkError(), checkQuality(), endsWith(), i, printUsage(), blockConsumer::read(), readBoundaries(), replaceExtention(), makefloParam::setLevel(), makefloParam::splitAxis, splitBlocks(), makefloParam::splithalf, makefloParam::splitRCB, writeBlocks(), writeFlo(), and writeTop().

104 {
105 //Parse the command line arguments
106  if (argc<5) printUsage("Not enough command-line arguments");
107  int curArg=1;
108  while (argv[curArg][0]=='-')
109  {//Parse a flag argument
110  const char *flag=argv[curArg++];
111  if (0==strcmp(flag,"-h") ||
112  0==strcmp(flag,"-?") ||
113  0==strcmp(flag,"--help"))
114  printUsage(NULL);
115  else if (0==strcmp(flag,"-splitaxis")) {
116  if (1!=sscanf(argv[curArg++],"%d",&parameters.splitAxis))
117  printUsage("Must pass 0,1, or 2 to -splitaxis");
118  }
119  else if (0==strcmp(flag,"-splitrcb")) {
121  }
122  else if (0==strcmp(flag,"-splithalf")) {
124  }
125  else if (0==strcmp(flag,"-multilevel")) {
126  int level=0;
127  if ((1!=sscanf(argv[curArg++],"%d",&level))||(level<=0))
128  printUsage("Must pass a positive integer to -multilevel");
129  parameters.setLevel(level);
130  }
131  else printUsage("Unrecognized flag");
132  }
133  if (curArg+4!=argc) printUsage("Too many arguments");
134  const char *inMesh=argv[curArg+0];
135  string inpFile=replaceExtention(argv[curArg+0],".inp");
136  int nPieces=atoi(argv[curArg+1]);
137  const char *floFile=argv[curArg+2];
138  const char *outMesh=argv[curArg+3];
139 
140  bool forFlo;
141  const char *bcExt="?";
142  if (endsWith(floFile,".flo")) {
143  forFlo=true;
144  bcExt=".bc";
145  }
146  else if (endsWith(floFile,".top")) {
147  forFlo=false;
148  bcExt=".bcmp";
149  }
150  else {
151  printf("UNRECOGNIZED TOPOLOGY NAME: '%s'\n",floFile);
152  exit(1);
153  }
154  string bcFile=replaceExtention(argv[curArg+0],bcExt);
155 
156  vector<block *> blocks;
157 
158 //Read the blocks of the mesh
159  { //<- scoping block so r's destructor gets called
160  blockReader r(blocks);
161  checkError(r.read(inMesh));
162  printf("Mesh file read successfully.\n");
163  }
164 
165 // Check the quality of the mesh
166  for (unsigned int i=0;i<blocks.size();i++)
167  checkQuality(*blocks[i]);
168 
169 //Read the boundary conditions
170  checkError(readBoundaries(blocks,inpFile.c_str()));
171  printf("Boundary conditions read successfully.\n");
172 
173  if (parameters.splithalf) {
174  // split in half for every block
175  nPieces = blocks.size()*2;
176  printf("Split every block in half for %d pieces.\n", nPieces);
177  }
178 
179 //Split the blocks (for greater parallelism)
180  checkError(splitBlocks(blocks,nPieces));
181  printf("Split blocks for %d PEs (%d blocks generated).\n",
182  nPieces,(int)blocks.size());
183 
184 //Build the block faces & associate all shared nodes
185  buildFaces(blocks,forFlo);
186  printf("Nodes matched successfully.\n");
187 
188 //Write out the block patches to the topology file
189  if (forFlo) {
190  checkError(writeFlo(blocks,nPieces,bcFile.c_str(),floFile));
191  printf(".flo file written successfully\n");
192  } else /*forTop*/ {
193  checkError(writeTop(blocks,bcFile.c_str(),floFile));
194  printf(".top file written successfully\n");
195  }
196 
197 //Write out the blocks themselves
198  checkError(writeBlocks(blocks,outMesh));
199  printf("Program finished successfully\n");
200  return 0;
201 }
int splithalf
Definition: makeflo.h:97
void setLevel(int n)
Definition: makeflo.h:111
int splitAxis
Definition: makeflo.h:95
const char * writeBlocks(vector< block * > &blocks, const char *outMesh)
Definition: write.cpp:147
void printUsage(const char *why)
Definition: makeflo.cpp:68
bool endsWith(const char *a, const char *suffix)
string replaceExtention(const string &a, const string &newSuffix)
const char * writeTop(vector< block * > &blocks, const char *inBcs, const char *out)
Definition: writetop.cpp:252
void checkQuality(const block &b)
Definition: volume.cpp:74
void checkError(const char *errCode)
Definition: makeflo.cpp:62
blockLoc i
Definition: read.cpp:79
const char * splitBlocks(vector< block * > &blocks, int nPieces)
Definition: split.cpp:205
bool blocks
Input data is block-structured grid.
Definition: hdf2pltV2.C:51
makefloParam parameters
Definition: makeflo.cpp:101
const char * readBoundaries(vector< block * > &blocks, const char *inMesh)
Definition: readinp.cpp:135
const char * writeFlo(vector< block * > &blocks, int nPEs, const char *inBcs, const char *out)
Definition: writeflo.cpp:230
int splitRCB
Definition: makeflo.h:96
void buildFaces(vector< block * > &blocks, bool buildTypeTwo)
Definition: buildface.cpp:123

Here is the call graph for this function:

void printUsage ( const char *  why)

Definition at line 68 of file makeflo.cpp.

References MAKEFLO_VERSION.

Referenced by ComSwitch::initializeFileStreams(), main(), and ComSwitch::parseOptions().

69 {
70  printf("Usage: makeflo [ -splitaxis <-1, 0, 1, or 2)> ]\n"
71  " [ -splitrcb ] [ -splithalf ]\n"
72  " [ -multilevel <maximum level> ]\n"
73  " <.grd, .grdb, .msh, or .hdf; and .inp and .bc file> \n"
74  " <# PEs> <.flo or .top output file> <.msh or .hdf output file>\n"
75  "\n"
76  " Makeflo reads a mesh (first parameter) and boundary condition\n"
77  "(.inp) list and description (.bc), partitions the mesh into the\n"
78  "requested number of processors, and writes out a rocflo control\n"
79  "file (.flo or .top) and the partitioned mesh (last parameter).\n"
80  " The mesh formats supported are:\n"
81  "<*.grd> A Gridgen ASCII double-precision mesh description\n"
82  "<*.msh> A double-precision binary Rocflo mesh file\n"
83  "<*.hdf> A double-precision 3D HDF mesh file\n"
84  " When the mesh consists of multiple files, give only the name of\n"
85  "the first file (e.g., 'tstflo_001.hdf'). The number of blocks and\n"
86  "numeric format will be automatically determined.\n"
87  "\n"
88  "Options:\n"
89  " -splitaxis <-1, 0, 1, or 2)>: axis to split along. \n"
90  " -splitrcb: split using recursive bisection.\n"
91  " -multilevel <maximum level>: number of multigrid levels to create \n"
92  " -splithalf: split every block in half, <# PEs> is ignored.\n"
93  "\n"
94  "Part of the CSAR Tools. Version " MAKEFLO_VERSION "\n"
95  );
96  if (why!=NULL)
97  printf("Exiting> %s\n",why);
98  exit(1);
99 }
#define MAKEFLO_VERSION
Definition: makeflo.h:65

Here is the caller graph for this function:

Variable Documentation