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

Go to the source code of this file.

Functions

blockLoc dirToCorner (block *b, const blockLoc &dir)
 
void swap (int &a, int &b)
 
patchfindPatch (const blockSpan &at, const vector< patch * > &from)
 
void findPartner (internalBCpatch *p)
 
bool isSmaller (face *a, face *b)
 
void buildFaces (vector< block * > &blocks, bool buildTypeTwo)
 

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:

blockLoc dirToCorner ( block b,
const blockLoc dir 
)

Definition at line 66 of file buildface.cpp.

References block::getDim(), and i.

Referenced by buildFaces().

67 {
68  blockLoc ret(0,0,0);
69  for (int i=0;i<3;i++)
70  if (dir[i])
71  ret[i] = b->getDim()[i]-1;
72  return ret;
73 }
const blockDim & getDim(void) const
Definition: adj.h:222
blockLoc i
Definition: read.cpp:79

Here is the call graph for this function:

Here is the caller graph for this function:

void findPartner ( internalBCpatch p)

Definition at line 100 of file buildface.cpp.

References d, internalBCpatch::dest, internalBCpatch::destSpan, findPatch(), block::getBlockNumber(), block::getFace(), face::getPatches(), block::nFaces, blockSpan::orient(), and internalBCpatch::setPartner().

Referenced by buildFaces().

101 {
102  //First orient the start and end locations:
103  blockSpan d=p->destSpan;
104  d.orient();
105  patch *partner=NULL;
106  for (int f=0;partner==NULL && f<block::nFaces;f++)
107  partner=findPatch(d,p->dest->getFace(f).getPatches());
108  if (partner==NULL) {
109  fprintf(stderr,"Couldn't find match for internal patch on block %d!\n",
110  p->dest->getBlockNumber()+1);
111  abort();
112  }
113  p->setPartner((internalBCpatch *)partner);
114 }
const vector< patch * > & getPatches(void) const
Definition: face.h:145
const NT & d
void orient(void)
Definition: gridutil.h:165
Definition: patch.h:74
block * dest
Definition: patch.h:122
void setPartner(internalBCpatch *p)
Definition: patch.h:125
blockSpan destSpan
Definition: patch.h:123
patch * findPatch(const blockSpan &at, const vector< patch * > &from)
Definition: buildface.cpp:90
int getBlockNumber(void) const
Definition: adj.h:219
face & getFace(int faceNo)
Definition: adj.h:248

Here is the call graph for this function:

Here is the caller graph for this function:

patch* findPatch ( const blockSpan at,
const vector< patch * > &  from 
)

Definition at line 90 of file buildface.cpp.

Referenced by findPartner().

91 {
92  int p,len=from.size();
93  for (p=0;p<len;p++)
94  if (from[p]->srcSpan==at)
95  return from[p];
96  return NULL;
97 }

Here is the caller graph for this function:

bool isSmaller ( face a,
face b 
)

Definition at line 117 of file buildface.cpp.

References face::getDim(), and blockDim::getSize().

Referenced by buildFaces().

117  {
118  int a_area=a->getDim().getSize();
119  int b_area=b->getDim().getSize();
120  return a_area<=b_area;
121 }
blockDim getDim(void) const
Definition: face.h:141
int getSize(void) const
Definition: gridutil.h:126

Here is the call graph for this function:

Here is the caller graph for this function: