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

Go to the source code of this file.

Classes

class  bcRecTop
 
class  bcListTop
 

Functions

static void write5 (FILE *out, int face, int l1lo, int l1hi, int l2lo, int l2hi)
 
void node2block (int a, int b, int &o, int &p)
 
static void writeSpan (FILE *out, const blockSpan &s, const blockLoc &sign)
 
static void writePatchStart (FILE *out, int patchType)
 
static void writePatchMiddle (FILE *out, int connBlock)
 
static void writePatchEnd (FILE *out, int coupled)
 
static void writeBlock (FILE *out, const bcListTop &bc, const block *b)
 
const char * writeTop (vector< block * > &blocks, const char *inBcs, const char *outTop)
 

Function Documentation

void node2block ( int  a,
int  b,
int &  o,
int &  p 
)

Definition at line 148 of file writetop.cpp.

Referenced by writeSpan().

148  {
149  if (a<b)
150  { //Nodes are oriented the right way:
151  o=a;
152  p=b-2; //Minus 1 for node->block, minus 1 again for excl->incl
153  } else {//Nodes run the other way:
154  o=a-1;
155  p=b-1;
156  }
157 }

Here is the caller graph for this function:

static void write5 ( FILE *  out,
int  face,
int  l1lo,
int  l1hi,
int  l2lo,
int  l2hi 
)
static

Definition at line 142 of file writetop.cpp.

Referenced by writeSpan(), and externalBCpatch::writeTop().

143 {
144  fprintf(out,"%d %3d %3d %3d %3d ",face,l1lo,l1hi,l2lo,l2hi);
145 }
Definition: face.h:90

Here is the caller graph for this function:

static void writeBlock ( FILE *  out,
const bcListTop bc,
const block b 
)
static

Definition at line 225 of file writetop.cpp.

References d, block::getBlockNumber(), block::getDim(), block::getFace(), block::getOriginalNumber(), face::getPatches(), block::nFaces, makefloParam::nLevels, and parameters.

225  {
226  int blockNo=b->getBlockNumber()+1;
227  int nGridLevels=parameters.nLevels;
228  fprintf(out,
229  "%d %d ! ======== BLOCK %d (Split from source block %d) ========\n",
230  blockNo,nGridLevels,blockNo,b->getOriginalNumber()+1);
231  blockDim d=b->getDim();
232  int f,nPatches=0;
233  for (f=0;f<block::nFaces;f++)
234  nPatches+=b->getFace(f).getPatches().size();
235 
236  fprintf(out,
237  "%d %d %d %d ! number of patches; block size (ni, nj, nk)\n",
238  nPatches,d[0]-1,d[1]-1,d[2]-1);
239 
240  //Loop over the faces, writing out each patch
241  for (f=0;f<block::nFaces;f++) {
242  static int order[6]={0,3,1,4,2,5};
243  const vector<patch *> &patches=b->getFace(order[f]).getPatches();
244  int nPatches=patches.size();
245  //Loop over the patches
246  for (int p=0;p<nPatches;p++) {
247  patches[p]->writeTop(out,bc);
248  }
249  }
250 }
int getOriginalNumber(void) const
Definition: adj.h:220
const vector< patch * > & getPatches(void) const
Definition: face.h:145
const NT & d
int nLevels
Definition: makeflo.h:99
const blockDim & getDim(void) const
Definition: adj.h:222
makefloParam parameters
Definition: makeflo.cpp:101
int getBlockNumber(void) const
Definition: adj.h:219
face & getFace(int faceNo)
Definition: adj.h:248

Here is the call graph for this function:

static void writePatchEnd ( FILE *  out,
int  coupled 
)
static

Definition at line 189 of file writetop.cpp.

Referenced by externalBCpatch::writeTop(), and internalBCpatch::writeTop().

189  {
190  fprintf(out," %d\n",coupled);
191 }

Here is the caller graph for this function:

static void writePatchMiddle ( FILE *  out,
int  connBlock 
)
static

Definition at line 186 of file writetop.cpp.

Referenced by externalBCpatch::writeTop(), and internalBCpatch::writeTop().

186  {
187  fprintf(out,"%5d ",connBlock);
188 }

Here is the caller graph for this function:

static void writePatchStart ( FILE *  out,
int  patchType 
)
static

Definition at line 183 of file writetop.cpp.

Referenced by externalBCpatch::writeTop(), and internalBCpatch::writeTop().

183  {
184  fprintf(out,"%4d ",patchType);
185 }

Here is the caller graph for this function:

static void writeSpan ( FILE *  out,
const blockSpan s,
const blockLoc sign 
)
static

Definition at line 160 of file writetop.cpp.

References blockSpan::end, blockSpan::getFace(), node2block(), blockSpan::start, and write5().

Referenced by externalBCpatch::writeTop(), and internalBCpatch::writeTop().

161 {
162  //Map our face numbering (iMin, jMin, kMin, iMax, ...) to
163  // rocfloMP face numbering (iMin,iMax, jMin,jMax, ...)
164  const static int faceMap[6]=
165  {1,3,5,2,4,6};
166  int face=faceMap[s.getFace()];
167  // l1 and l2 axes parameterize the face
168  int flatAxis=(s.getFace()%3);
169  int l1Axis=(flatAxis+1)%3;
170  int l2Axis=(flatAxis+2)%3;
171 
172  int l1S=s.start[l1Axis], l1E=s.end[l1Axis];
173  int l2S=s.start[l2Axis], l2E=s.end[l2Axis];
174  node2block(l1S,l1E, l1S,l1E);
175  node2block(l2S,l2E, l2S,l2E);
176  int l1Sign=sign[l1Axis];
177  int l2Sign=sign[l2Axis];
178  write5(out,face,
179  l1Sign*(1+l1S),l1Sign*(1+l1E),
180  l2Sign*(1+l2S),l2Sign*(1+l2E));
181 }
Definition: face.h:90
static void write5(FILE *out, int face, int l1lo, int l1hi, int l2lo, int l2hi)
Definition: writetop.cpp:142
blockLoc start
Definition: gridutil.h:155
blockLoc end
Definition: gridutil.h:156
int getFace(void) const
Definition: gridutil.h:191
void node2block(int a, int b, int &o, int &p)
Definition: writetop.cpp:148

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 *  outTop 
)

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: