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

Go to the source code of this file.

Classes

class  bcReader
 

Macros

#define BC_EXTENTION   ".inp"
 
#define ERR   "Error reading " BC_EXTENTION " file: "
 

Functions

void checkSpan (const blockSpan &s, const char *what)
 
const char * readBoundaries (vector< block * > &blocks, const char *inMesh)
 

Macro Definition Documentation

#define BC_EXTENTION   ".inp"

Definition at line 132 of file readinp.cpp.

#define ERR   "Error reading " BC_EXTENTION " file: "

Definition at line 133 of file readinp.cpp.

Referenced by readBoundaries().

Function Documentation

void checkSpan ( const blockSpan s,
const char *  what 
)

Definition at line 123 of file readinp.cpp.

References blockSpan::end, makefloParam::levelBad, makefloParam::multigridError(), parameters, and blockSpan::start.

Referenced by readBoundaries().

123  {
124  for (int axis=0;axis<3;axis++)
125  if ((s.start[axis]&parameters.levelBad)
126  ||((s.end[axis]-1)&parameters.levelBad)) {
127  fprintf(stderr,"%s",what);
129  }
130 }
void multigridError(void)
Definition: split.cpp:69
blockLoc start
Definition: gridutil.h:155
blockLoc end
Definition: gridutil.h:156
unsigned int levelBad
Definition: makeflo.h:100
makefloParam parameters
Definition: makeflo.cpp:101

Here is the call graph for this function:

Here is the caller graph for this function:

const char* readBoundaries ( vector< block * > &  blocks,
const char *  inMesh 
)

Definition at line 135 of file readinp.cpp.

References block::addBC(), checkSpan(), ERR, cimg_library::cimg::fopen(), block::getDim(), bcReader::read(), and bcReader::skipLine().

Referenced by main().

137 {
138  FILE *in=fopen(inMesh,"r");
139  if (in==NULL) {
140  fprintf(stderr,"Cannot open boundary condition file '%s'.\n",inMesh);
141  fprintf(stderr,"Continuing without external boundary conditions\n");
142  return NULL;//Ignore missing BC file
143  }
144  bcReader r(in);
145 
146  //Check the file header:
147  int solver;
148  if (!r.read(&solver)) return ERR "Bad file header (line 1)";
149  if (solver!=1) return ERR "Must use Gridgen generic solver";
150  int nBlocks;
151  if (!r.read(&nBlocks)) return ERR "Bad file header (line 2)";
152  if (nBlocks!=(int)blocks.size()) return ERR "mesh's block count does not match";
153 
154  //Read each block
155  for (int bn=0;bn<nBlocks;bn++) {
156  block *b=blocks[bn];
157  //Check the block size
158  blockDim dim;
159  if (!r.read(dim)) return ERR "Cannot read block size";
160  if (dim!=b->getDim()) return ERR "mesh's block size does not match";
161  //Skip over the block name line
162  r.skipLine();
163  r.skipLine();
164 
165  //Get the patch count and loop over patches
166  int nPatch;
167  if (!r.read(&nPatch)) return ERR "Cannot read patch count";
168  for (int p=0;p<nPatch;p++) {
169 
170  //Get the patch dimensions
171  blockSpan span;
172  if (!r.read(span)) return ERR "Cannot read patch dimensions";
173  //Get the patch type and handle patch
174  int type;
175  if (!r.read(&type)) return ERR "Cannot read patch type";
176  if (type>=0)
177  {//External boundary condition--add to block
178  b->addBC(span,type);
179  char errBuf[200];
180  sprintf(errBuf,"Bad boundary condition for block %d\n",1+bn);
181  checkSpan(span,errBuf);
182  }
183  else
184  {//Internal boundary condition-- read and ignore
185  blockSpan dest;
186  if (!r.read(dest)) return ERR "Cannot read internal patch dimensions";
187  int destBlock;
188  if (!r.read(&destBlock)) return ERR "Cannot read destination block";
189  destBlock--; //Make zero-based
190  }
191  }
192  }
193  return NULL;//Everything worked
194 }
void addBC(const blockSpan &span, int bcNo)
Definition: adj.cpp:262
Definition: adj.h:203
const blockDim & getDim(void) const
Definition: adj.h:222
void checkSpan(const blockSpan &s, const char *what)
Definition: readinp.cpp:123
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494
#define ERR
Definition: readinp.cpp:133

Here is the call graph for this function:

Here is the caller graph for this function: