75 void swap(
int &a,
int &b) {
int tmp=a;a=b;b=tmp;}
81 for (
unsigned int p=0;p<
patches[f].size();p++)
83 if (retFace!=NULL) *retFace=f;
88 fprintf(stderr,
"Can't match patch in %s!\n",__FILE__);
129 if (hisFace!=NULL) *hisFace=
face;
135 const char *outMblock)
138 for (
unsigned int b=0;b<blocks.size();b++) {
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);
150 sprintf(fName,
"%s%05d.mblk",outMblock,b);
151 FILE *fm=
fopen(fName,
"wb");
152 if (fm==NULL)
return "Couldn't create .bblk file";
154 blocks[b]->getDim().getSize(),fm);
171 fprintf(out,
"# Charm++ Mblock framework block boundary condition file\n");
172 fprintf(out,
"1.0 # Version number\n");
173 fprintf(out,
"%d %d %d %d # Block number and size\n",b->
getBlockNumber(),
178 fprintf(out,
"\n%d # Number of patches on this face\n",
180 for (
unsigned int p=0;p<
patches[f].size();p++)
189 fprintf(out,
" %d %d %d %d %d %d \n",
190 s[0],e[0],
s[1],e[1],
s[2],e[2]);
196 fprintf(out,
"%d ",bcNo);
204 fprintf(out,
" %d %d ",dest->getBlockNumber(),
207 for (
int srcAxis=0;srcAxis<3;srcAxis++) {
208 int destAxis=orient[srcAxis];
210 if (destSpan.end[destAxis]<destSpan.start[destAxis])
212 fprintf(out,
"%c%d ",isFlipped?
'-':
'+',destAxis+1);
void write(FILE *out, mblockData &d, block *b)
const char * writeMblock(vector< block * > &blocks, const char *outMblock)
vector< block * > & blocks
const vector< patch * > & getPatches(void) const
virtual void writeMblock(FILE *out, mblockData &d)
void write(block *b, FILE *out)
int fclose(std::FILE *file)
Close a file, and check for possible errors.
void int int int REAL REAL REAL const char * fName
int fwrite(const T *ptr, const unsigned int nmemb, std::FILE *stream)
Write data to a file, and check for possible errors.
static void printSpan(FILE *out, const blockSpan &sp)
const blockDim & getDim(void) const
int totalPatches(void) const
int getPatchNumber(patch *forPatch, int *retFace=NULL)
bool blocks
Input data is block-structured grid.
vector< patch * > & getPatchListWith(block *dest, patch *partner, int *hisFace=NULL)
vector< patch * > patches[block::nFaces]
static T_VertexSet * face
blockPatches * block2patches
virtual void writeMblock(FILE *out, mblockData &d)
mblockData(vector< block * > &blocks_)
int getBlockNumber(void) const
internalBCpatch * createSendPatch(internalBCpatch *recv, int faceNo)
std::FILE * fopen(const char *const path, const char *const mode)
Open a file, and check for possible errors.
face & getFace(int faceNo)
void swap(int &a, int &b)
int getPatchNumber(block *dest, patch *partner)