Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
makeflo.h File Reference
#include <cstring>
#include <cstdlib>
#include "adj.h"
#include "util.h"
Include dependency graph for makeflo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  makefloParam
 

Macros

#define MAKEFLO_VERSION   "1.93"
 

Functions

void checkQuality (const block &b)
 
const char * readBoundaries (vector< block * > &blocks, const char *inMesh)
 
const char * splitBlocks (vector< block * > &blocks, int nPieces)
 
void buildFaces (vector< block * > &blocks, bool buildTypeTwo)
 
const char * writeFlo (vector< block * > &blocks, int nPEs, const char *inBcs, const char *out)
 
const char * writeTop (vector< block * > &blocks, const char *inBcs, const char *out)
 
const char * writeMblock (vector< block * > &blocks, const char *outMblock)
 
const char * writeBlocks (vector< block * > &blocks, const char *outMesh)
 

Variables

makefloParam parameters
 

Macro Definition Documentation

#define MAKEFLO_VERSION   "1.93"

Definition at line 65 of file makeflo.h.

Referenced by printUsage().

Function Documentation

void buildFaces ( vector< block * > &  blocks,
bool  buildTypeTwo 
)

Definition at line 123 of file buildface.cpp.

References buildFaces(), dirToCorner(), block::face2name, findPartner(), block::getBlockNumber(), patch::getFace(), block::getFace(), block::getLoc(), face::getPatches(), i, patch::isExternal(), adjList::isExternal(), isSmaller(), nodeMatcher::loc2node(), n, block::nFaces, internalBCpatch::partner, face::patchForCoord(), and internalBCpatch::type.

Referenced by buildFaces(), and main().

124 {
125  int f; unsigned int bNo;
126  /* Build each block's faces, which matches up the nodes*/
127  nodeMatcher map;
128  for (bNo=0;bNo<blocks.size();bNo++)
129  blocks[bNo]->buildFaces(map);
130 
131  /* Build each face's patches, which aggregates matched nodes
132  into rectangular patches.*/
133  for (bNo=0;bNo<blocks.size();bNo++)
134  for (f=0;f<block::nFaces;f++)
135  blocks[bNo]->getFace(f).buildPatches();
136 
137  /*Match up facing internal patches*/
138  for (bNo=0;bNo<blocks.size();bNo++)
139  for (f=0;f<block::nFaces;f++) {
140  const vector<patch *> &patches=
141  blocks[bNo]->getFace(f).getPatches();
142  for (unsigned int pNo=0;pNo<patches.size();pNo++) {
143  patch *p=patches[pNo];
144  if (p->isExternal()) continue;
146  }
147  }
148 
149  if (!buildTypeTwo) return;
150  /*
151  Determine which patches should be "type two"--
152  patches whose neighbors get pulled around by
153  mesh motion, but don't move themselves.
154  Such patches touch a corner node that faces the
155  exterior; but none of them are exterior themselves.
156  */
157  const int nCorners=8;
158  blockLoc cornDirs[nCorners]={
159  blockLoc(0,0,0),
160  blockLoc(0,0,1),
161  blockLoc(0,1,0),
162  blockLoc(0,1,1),
163  blockLoc(1,0,0),
164  blockLoc(1,0,1),
165  blockLoc(1,1,0),
166  blockLoc(1,1,1)
167  };
168  /*Loop over blocks*/
169  for (bNo=0;bNo<blocks.size();bNo++) {
170  block *b=blocks[bNo];
171  /*Loop over corners*/
172  for (int cNo=0;cNo<nCorners;cNo++) {
173  blockLoc c=dirToCorner(b,cornDirs[cNo]);
174  /*Determine if this corner faces external world*/
175  node *n=map.loc2node(b->getLoc(c));
176  if (!n->isExternal())
177  continue; /*Nothing to do*/
178  /*Corner faces outside-- check if any of our patches do:*/
179  bool hasExternalFace=false;
180  for (f=0;f<block::nFaces;f++) {
181  patch *p=b->getFace(f).patchForCoord(c);
182  if (p!=NULL && p->isExternal())
183  hasExternalFace=true;
184  }
185  if (hasExternalFace)
186  continue; /*Nothing to do*/
187  /*Corner is outside, but none of our faces are:
188  mark all patches as type 2.
189  */
190  printf("Corner %d of block %d is external> patches on ",
191  cNo,b->getBlockNumber()+1);
192  for (f=0;f<block::nFaces;f++) {
193  patch *p=b->getFace(f).patchForCoord(c);
194  if (p!=NULL) {
195  printf("%s ",block::face2name[f]);
196  ((internalBCpatch *)p)->setType(2);
197  }
198  }
199  printf("are all type 2\n");
200  }
201  }
202  /*Loop over patches, eliminating facing pairs of type 2 boundaries*/
203  for (bNo=0;bNo<blocks.size();bNo++) {
204  block *b=blocks[bNo];
205  for (f=0;f<block::nFaces;f++) {
206  const vector<patch *> &patches=b->getFace(f).getPatches();
207  for (unsigned int pNo=0;pNo<patches.size();pNo++) {
208  patch *p=patches[pNo];
209  if (!p->isExternal()) {
211  if (i->type==2 && i->partner->type==2)
212  /*A facing pair of type 2's!*/
213  i->type=i->partner->type=1;
214  }
215  }
216  }
217  }
218 
219  /*Loop over patches one final time, adding type 2's to the
220  smaller face of each pair.*/
221  for (bNo=0;bNo<blocks.size();bNo++) {
222  block *b=blocks[bNo];
223  for (f=0;f<block::nFaces;f++) {
224  const vector<patch *> &patches=b->getFace(f).getPatches();
225  for (unsigned int pNo=0;pNo<patches.size();pNo++) {
226  patch *p=patches[pNo];
227  if (!p->isExternal()) {
229  if (i->type==1 && i->partner->type==1
230  && isSmaller(i->getFace(),i->partner->getFace()))
231  i->type=2;
232  }
233  }
234  }
235  }
236 
237 }
blockLoc dirToCorner(block *b, const blockLoc &dir)
Definition: buildface.cpp:66
internalBCpatch * partner
Definition: patch.h:124
const vector< patch * > & getPatches(void) const
Definition: face.h:145
node * loc2node(const vector3d &loc)
Definition: adj.cpp:230
face * getFace(void) const
Definition: patch.h:82
Definition: adj.h:150
bool isSmaller(face *a, face *b)
Definition: buildface.cpp:117
patch * patchForCoord(const blockLoc &at)
Definition: face.cpp:120
Definition: adj.h:203
Definition: patch.h:74
static const char * face2name[nFaces]
Definition: adj.h:236
blockLoc i
Definition: read.cpp:79
const NT & n
void findPartner(internalBCpatch *p)
Definition: buildface.cpp:100
virtual bool isExternal(void) const
Definition: buildface.cpp:63
const vector3d & getLoc(const blockLoc &l) const
Definition: adj.h:223
bool isExternal(void) const
Definition: buildface.cpp:76
int getBlockNumber(void) const
Definition: adj.h:219
face & getFace(int faceNo)
Definition: adj.h:248
void buildFaces(vector< block * > &blocks, bool buildTypeTwo)
Definition: buildface.cpp:123

Here is the call graph for this function:

Here is the caller graph for this function:

void checkQuality ( const block b)

Definition at line 74 of file volume.cpp.

References CkSampleT< real, ret >::add(), BLOCKSPAN_FOR, vector3d::cross(), vector3d::dist(), block::getDim(), block::getLoc(), block::getOriginalNumber(), i, j, k, vector3d::max(), CkSampleT< real, ret >::printMinAveMax(), and volume().

Referenced by main().

75 {
76  int nBadVol=0, nBadFace=0;
77  double minVolRatio=1.0;
78  blockLoc aBadVol, aBadFace;
79  CkSample edgeStats, volumeStats, volRatioStats, faceRatioStats;
80  /* loop over all cells in the block */
81  blockLoc cellCoor;
82  blockSpan cells(blockLoc(0,0,0),b.getDim()-blockLoc(1,1,1));
83 
84  enum {nCorners=8,nEdges=12,nFaces=6};
85  vector3d c[nCorners];
86  int i,j,k,f,e;
87 
88  /* Check the quality of each cell */
89  BLOCKSPAN_FOR(cellCoor,cells) {
90 
91  // Copy out the locations of the cell corners
92  for (k=0;k<2;k++) for (j=0;j<2;j++) for (i=0;i<2;i++)
93  c[i+2*j+4*k]=b.getLoc(cellCoor+blockLoc(i,j,k));
94 
95  /* Find the minimum edge length for this cell.
96  FIXME: Rocflo's criterion depends on the minimum edge
97  length for *any* cell in the (partitioned) block. This means
98  our per-cell criterion is actually more stringent than Rocflo's.
99  */
100  double minEdge=1.0e30;
101 
102  // Compute the length of the shortest edge
103  const static int edges[nEdges][2]={
104  {0,1}, {1,3}, {3,2}, {2,0},
105  {4,5}, {5,7}, {7,6}, {6,4},
106  {0,4}, {1,5}, {3,7}, {2,6}
107  };
108  for (e=0;e<nEdges;e++) {
109  double l=c[edges[e][0]].dist(c[edges[e][1]]);
110  if (l<minEdge) minEdge=l;
111  edgeStats.add(l);
112  }
113 
114  // Compute the outward-pointing normals of the faces
115  const static int faces[nFaces][4]={
116  {0,4,6,2}, {1,3,7,5}, /* imin, imax */
117  {0,1,5,4}, {2,6,7,3}, /* jmin, jmax */
118  {0,2,3,1}, {4,5,7,6} /* kmin, kmax */
119  };
120  vector3d normals[nFaces]; // area-scaled normal vector
121  vector3d center[nFaces]; // position of centroid
122  for (f=0;f<nFaces;f++)
123  { // Area and normal come from face diagonals:
124  vector3d diagA=c[faces[f][2]]-c[faces[f][0]];
125  vector3d diagB=c[faces[f][3]]-c[faces[f][1]];
126  normals[f]=0.5*diagA.cross(diagB);
127  center[f]=0.25*(c[faces[f][0]]+c[faces[f][1]]+
128  c[faces[f][2]]+c[faces[f][3]]);
129  }
130 
131  // Check face vector sum (closedness, smaller is better)
132  vector3d faceVecSum=
133  normals[0]+normals[1]+
134  normals[2]+normals[3]+
135  normals[4]+normals[5];
136  double faceRatio=faceVecSum.max()/(minEdge*minEdge);
137  if (faceRatio>0.1) { /* non-closed face */
138  nBadFace++;
139  aBadFace=cellCoor;
140  }
141 
142  // Compute volume of cell relative to smallest edge (fullness, bigger is better)
143  double volume=0.0;
144  for (f=0;f<nFaces;f++)
145  volume+=(1.0/3.0)*normals[f].dot(center[f]);
146 
147  double volRatio=volume/(minEdge*minEdge*minEdge);
148  if (volRatio<0.1) { /* bad skinny cell */
149  nBadVol++;
150  if (volRatio<minVolRatio) {
151  minVolRatio=volRatio;
152  aBadVol=cellCoor;
153  }
154  }
155 
156  // Update statistics
157  faceRatioStats.add(faceRatio);
158  volumeStats.add(volume);
159  volRatioStats.add(volRatio);
160  }
161 
162  printf("Original block %d mesh quality:\n",1+b.getOriginalNumber());
163  printf(" cell volumes: "); volumeStats.printMinAveMax(stdout);
164  printf(" edge lengths: "); edgeStats.printMinAveMax(stdout);
165  printf(" volume ratio (fullness): "); volRatioStats.printMinAveMax(stdout);
166  printf(" face ratio (skewness): "); faceRatioStats.printMinAveMax(stdout);
167 
168  if (nBadVol>0) {
169  printf("WARNING: detected %d bad-volume cells in original block %d: \n"
170  " the worst of which is cell (%d,%d,%d), with ratio %.3f\n",
171  nBadVol, b.getOriginalNumber(),
172  1+aBadVol[0],1+aBadVol[1],1+aBadVol[2], minVolRatio);
173  }
174 }
CkSampleT represents a statistical &quot;sample&quot; of some data values.
Definition: ckstatistics.h:79
int getOriginalNumber(void) const
Definition: adj.h:220
vector3d cross(const vector3d &b) const
Definition: vector3d.h:146
real dist(const vector3d &b) const
Definition: vector3d.h:136
j indices k indices k
Definition: Indexing.h:6
void printMinAveMax(FILE *dest)
Print a terse textual description of this sample to this FILE.
Definition: ckstatistics.h:153
#define BLOCKSPAN_FOR(i, span)
Definition: gridutil.h:230
int volume(const block *b)
Definition: split.cpp:181
const blockDim & getDim(void) const
Definition: adj.h:222
blockLoc i
Definition: read.cpp:79
void add(real r)
Add this value to the sample set.
Definition: ckstatistics.h:95
const vector3d & getLoc(const blockLoc &l) const
Definition: adj.h:223
j indices j
Definition: Indexing.h:6
real max(void)
Definition: vector3d.h:151

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:

const char* splitBlocks ( vector< block * > &  blocks,
int  nPieces 
)

Definition at line 205 of file split.cpp.

References bRec::less(), parameters, makefloParam::splithalf, and volume().

Referenced by main().

207 {
208  if ((int)blocks.size()>=nPieces)
209  return NULL;//Already have enough blocks
210 
211 
212 //We try to split so that the resulting blocks
213 // have about the same volume-- distribute pieces
214 // to blocks by volume
215  unsigned int b,nBlocks=blocks.size();
216 
217  int *nSplit=new int[nBlocks];
218 
219  if (parameters.splithalf == 1) {
220  // split every block in half
221  for (b=0;b<nBlocks;b++) {
222  nSplit[b]=2;
223  }
224  }
225  else { // regular split
226  //Create max-heap of blocks, ordered by output volume
227  vector<bRec> heap(nBlocks);
228  for (b=0;b<nBlocks;b++) {
229  heap[b]=bRec(b,volume(blocks[b]));
230  nSplit[b]=1;
231  }
232 
233  std::make_heap(heap.begin(),heap.end(),bRec::less);
234 
235  //Allocate remaining output blocks to the most needy
236  int nRemaining=nPieces-nBlocks;
237  while (nRemaining-->0) {
238  std::pop_heap(heap.begin(),heap.end(),bRec::less);
239  bRec &r=heap[nBlocks-1];
240  r.n=++(nSplit[r.b]);
241  std::push_heap(heap.begin(),heap.end(),bRec::less);
242  }
243  } // end of parameters.splithalf
244 
245  //Split the blocks
246  vector<block *> split;//Accumulates split blocks
247  for (b=0;b<nBlocks;b++) {
248  printf("Input block %d splits into %d pieces (%d-%d)\n",
249  b+1,nSplit[b],(int)(1+split.size()),(int)(1+split.size()+nSplit[b]-1));
250  blocks[b]->split(nSplit[b],split);
251  }
252  delete[] nSplit;
253 
254 //Check the load balance
255  double maxVol=-1e100,minVol=1e100,sumVol=0;
256  for (b=0;b<split.size();b++) {
257  double vol=volume(split[b]);
258  sumVol+=vol;
259  if (maxVol<vol) maxVol=vol;
260  if (minVol>vol) minVol=vol;
261  }
262  double avgVol=sumVol/split.size();
263  printf("Static load balance results:\n"
264  " %.2f blocks per processor, %.0f nodes per block\n"
265  " Heaviest block is %.02f times the average\n"
266  " Lightest block is %.02f times the average\n",
267  ((double)split.size())/nPieces,avgVol,
268  maxVol/avgVol,minVol/avgVol);
269 
270 //Return split blocks to caller
271  blocks=split;
272  return NULL;
273 }
int splithalf
Definition: makeflo.h:97
int volume(const block *b)
Definition: split.cpp:181
static bool less(const bRec &a, const bRec &b)
Definition: split.cpp:198
Definition: split.cpp:186
makefloParam parameters
Definition: makeflo.cpp:101
int n
Definition: split.cpp:190

Here is the call graph for this function:

Here is the caller graph for this function:

const char* writeBlocks ( vector< block * > &  blocks,
const char *  outMesh 
)

Definition at line 147 of file write.cpp.

References endsWith(), FC_GLOBAL, i, incrementAscii(), write_fortran(), write_grda(), write_grdb(), write_hdf(), and write_msh().

Referenced by main().

149 {
150  char oName[1024];
151  bool isFortran=false, isHDF=false;
152  bool incrementFilenames=true;
153  fn_fortran_write writeFn=NULL;
154  strcpy(oName,outMesh);
155  if (endsWith(outMesh,".msh"))
156  { //Write .msh files:
157  isFortran=true;
158  writeFn=FC_GLOBAL(write_msh,WRITE_MSH);
159  }
160  else if (endsWith(outMesh,"1")||
161  endsWith(outMesh,".grda")||
162  endsWith(outMesh,".grdb"))
163  { //Probably a grda or grdb file:
164  isFortran=true;
165  incrementFilenames=false; //Same filename every time
166  char tmp[1024];
167  strcpy(tmp,outMesh);
168  //Clip off any trailing numbers:
169  int endIdx=strlen(tmp)-1;
170  while (endIdx>0&&(isdigit(tmp[endIdx])||(tmp[endIdx]=='_')))
171  tmp[endIdx--]=0;
172  if (endsWith(tmp,".grda"))
173  writeFn=FC_GLOBAL(write_grda,WRITE_GRDA);
174  else if (endsWith(tmp,".grdb"))
175  writeFn=FC_GLOBAL(write_grdb,WRITE_GRDB);
176  else return "Unrecognized output mesh extension! (2)";
177  }
178 #ifdef USE_HDF
179  else if (endsWith(outMesh,".hdf"))
180  {
181  isHDF=true;
182  }
183 #endif
184  else if (endsWith(outMesh,".null"))
185  {/*Just skip output*/}
186  else
187  return "Unrecognized output mesh file extension! (1)";
188 
189 
190  for (unsigned int i=0;i<blocks.size();i++) {
191  const blockDim &dim=blocks[i]->getDim();
192  const vector3d *locs=&blocks[i]->getLoc(blockLoc(0,0,0));
193 
194  if (isFortran)
195  if (i+1==blocks.size())
196  { /* Last time around, pass a negative block number
197  so fortran code can close its file. */
198  write_fortran(-(i+1),dim,locs,oName,writeFn);
199  } else {
200  write_fortran( i+1 ,dim,locs,oName,writeFn);
201  }
202 
203 #ifdef USE_HDF
204  else if (isHDF)
205  write_hdf(dim,locs,oName);
206 #endif
207 
208  printf("."); fflush(stdout);
209  if (incrementFilenames) {
210  if (!incrementAscii(oName))
211  return "Cannot increment output filename! Use something like 'foo_0001.msh'\n";
212  }
213  }
214  printf("\n");
215 
216  return NULL;
217 }
bool incrementAscii(char *cur)
subroutine write_grda(iblock, ni, nj, nk, x, y, z, F_name)
Definition: writegrda.f90:64
subroutine write_grdb(iblock, ni, nj, nk, x, y, z, F_name)
Definition: writegrdb.f90:64
void(* fn_fortran_write)(int *block, int *ni, int *nj, int *nk, REAL *x, REAL *y, REAL *z, const char *fName)
Definition: write.cpp:70
bool endsWith(const char *a, const char *suffix)
subroutine write_msh(iblock, ni, nj, nk, x, y, z, F_name)
Definition: writemsh.f90:58
blockLoc i
Definition: read.cpp:79
#define FC_GLOBAL(name, NAME)
Definition: FC.h:5
const char * write_hdf(const blockDim &dim, const vector3d *locs, const char *filename)
Definition: writehdf.cpp:77
static void write_fortran(int block, blockDim dim, const vector3d *locs, const char *fName, fn_fortran_write writeFn)
Definition: write.cpp:85

Here is the call graph for this function:

Here is the caller graph for this function:

const char* writeFlo ( vector< block * > &  blocks,
int  nPEs,
const char *  inBcs,
const char *  out 
)

Definition at line 230 of file writeflo.cpp.

References cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), writeBlock(), and writeHeader().

Referenced by main().

234 {
235  FILE *bcs=fopen(inBcs,"r");
236  if (bcs==NULL) {
237  char *ret=(char *)malloc(sizeof(char)*1000);
238  sprintf(ret,"Couldn't open input .bc file '%s'!\n",inBcs);
239  return ret;
240  }
241  bcList bc(bcs);
242  fclose(bcs);
243 
244  FILE *flo=fopen(outFlo,"w");
245  if (flo==NULL) return "Couldn't open output .flo file!\n";
246 
247  //Print the .flo file header
248  int nBlocks=blocks.size();
249  writeHeader(flo,nBlocks,nPEs);
250 
251  //Print out each block
252  for (int bn=0;bn<nBlocks;bn++)
253  writeBlock(flo,bc,blocks[bn]);
254  fclose(flo);
255  return NULL; //Everything worked!
256 }
void writeBlock(FILE *out, const bcList &bc, const block *b)
Definition: writeflo.cpp:198
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
void writeHeader(FILE *out, int nBlocks, int nPEs)
Definition: writeflo.cpp:148
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

const char* writeMblock ( vector< block * > &  blocks,
const char *  outMblock 
)

Definition at line 134 of file writemblock.cpp.

References d, cimg_library::cimg::fclose(), fName, cimg_library::cimg::fopen(), cimg_library::cimg::fwrite(), parameters, makefloParam::topologyOnly, and mblockData::write().

Referenced by main(), and mblockData::blockPatches::write().

136 {
137  mblockData d(blocks);
138  for (unsigned int b=0;b<blocks.size();b++) {
139  char fName[1024];
140 
141  //Write the boundary descriptions
142  sprintf(fName,"%s%05d.bblk",outMblock,b);
143  FILE *fb=fopen(fName,"w");
144  if (fb==NULL) return "Couldn't create .bblk file";
145  d.write(blocks[b],fb);
146  fclose(fb);
147 
148  //Write the mesh locations themselves
149  if (!parameters.topologyOnly) {
150  sprintf(fName,"%s%05d.mblk",outMblock,b);
151  FILE *fm=fopen(fName,"wb");
152  if (fm==NULL) return "Couldn't create .bblk file";
153  fwrite(&blocks[b]->getLoc(blockLoc(0,0,0)),sizeof(vector3d),
154  blocks[b]->getDim().getSize(),fm);
155  fclose(fm);
156  }
157  }
158  return NULL;
159 }
const NT & d
int topologyOnly
Definition: makeflo.h:93
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
void int int int REAL REAL REAL const char * fName
Definition: write.cpp:76
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
Definition: CImg.h:5587
makefloParam parameters
Definition: makeflo.cpp:101
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

const char* writeTop ( vector< block * > &  blocks,
const char *  inBcs,
const char *  out 
)

Definition at line 252 of file writetop.cpp.

References cimg_library::cimg::fclose(), cimg_library::cimg::fopen(), and writeBlock().

Referenced by main().

255 {
256  FILE *bcs=fopen(inBcs,"r");
257  if (bcs==NULL) {
258  char *ret=(char *)malloc(sizeof(char)*1000);
259  sprintf(ret,"Couldn't open input .bcmp file '%s'!\n",inBcs);
260  return ret;
261  }
262  bcListTop bc(bcs);
263  fclose(bcs);
264 
265  FILE *top=fopen(outTop,"w");
266  if (top==NULL) return "Couldn't open output .top file!\n";
267 
268  //Print the .top file header
269  int nBlocks=blocks.size();
270  fprintf(top,"# RocfloMP topology file, generated by makeflo\n"
271  "# \n"
272  "%d ! Total number of blocks in this file\n",
273  nBlocks);
274 
275  //Print out each block
276  for (int bn=0;bn<nBlocks;bn++)
277  writeBlock(top,bc,blocks[bn]);
278  fclose(top);
279  return NULL; //Everything worked!
280 }
void writeBlock(FILE *out, const bcList &bc, const block *b)
Definition: writeflo.cpp:198
int fclose(std::FILE *file)
Close a file, and check for possible errors.
Definition: CImg.h:5507
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
Definition: CImg.h:5494

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation