Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
face Class Reference

#include <face.h>

Collaboration diagram for face:

Public Member Functions

 face (block *source_, nodeMatcher &map, vector< externalBCpatch > &extBCs_, int dir_x_, int dir_y_, const blockSpan &span_)
 
void buildPatches (void)
 
nodenodeForCoord (const blockLoc &at)
 
patchpatchForCoord (const blockLoc &at)
 
 ~face ()
 
blockgetBlock (void) const
 
blockDim getDim (void) const
 
const vector< patch * > & getPatches (void) const
 

Private Member Functions

void fillNeighbors (int x, int y, const node **nbor) const
 
bool nodesMatch (int x, int y, const face *dest, const facetOrientation &o) const
 
int loc2nodeX (const blockLoc &l) const
 
int loc2nodeY (const blockLoc &l) const
 
int loc2node (const blockLoc &l) const
 
blockLoc getSourceLoc (int x, int y) const
 
int markPatched (facet *b, const blockSpan &span)
 

Private Attributes

blocksource
 
vector< externalBCpatchextBCs
 
vector< patch * > patches
 
int dir_x
 
int dir_y
 
blockSpan span
 
node ** nodes
 
int nx
 
int ny
 

Detailed Description

Definition at line 90 of file face.h.

Constructor & Destructor Documentation

face ( block source_,
nodeMatcher map,
vector< externalBCpatch > &  extBCs_,
int  dir_x_,
int  dir_y_,
const blockSpan span_ 
)

Definition at line 131 of file face.cpp.

References adjList::addFace(), BLOCKSPAN_FOR, dir_x, dir_y, blockSpan::end, findOther(), adjList::getLength(), block::getLoc(), block::getOriginalNumber(), i, loc2node(), nodeMatcher::loc2node(), nodes, nx, ny, parameters, adjList::print(), makefloParam::skipAxis, source, span, and blockSpan::start.

134  :source(source_), extBCs(extBCs_), dir_x(dir_x_), dir_y(dir_y_),
135  span(span_)
136 {
140  { //Don't bother about this face-- it's the Z face of a 2D problem
141  nodes=NULL;
142  return;
143  }
144  nodes=new node*[nx*ny];
145  blockLoc i;
146  BLOCKSPAN_FOR(i,span) {
147  vector3d nodeLoc=source->getLoc(i);
148  node *nu=map.loc2node(nodeLoc);
149  nu->addFace(this,i);
150 
151  if (nu->getLength()>(3*8)) {
152  fprintf(stderr,"WARNING: multiply shared node %p: (%d,%d,%d) for block %d:",
153  nu,i[0],i[1],i[2],source->getOriginalNumber()+1);
154  nu->print();
155  }
156  nodes[loc2node(i)]=nu;
157  }
158 }
int getOriginalNumber(void) const
Definition: adj.h:220
int skipAxis
Definition: makeflo.h:92
block * source
Definition: face.h:91
node ** nodes
Definition: face.h:97
void addFace(face *b, const blockLoc &l)
Definition: adj.cpp:105
node * loc2node(const vector3d &loc)
Definition: adj.cpp:230
void print(void) const
Definition: adj.cpp:120
Definition: adj.h:150
#define BLOCKSPAN_FOR(i, span)
Definition: gridutil.h:230
blockLoc start
Definition: gridutil.h:155
static int findOther(int a, int b)
Definition: face.cpp:83
blockLoc i
Definition: read.cpp:79
blockLoc end
Definition: gridutil.h:156
vector< externalBCpatch > extBCs
Definition: face.h:92
int getLength(void) const
Definition: adj.cpp:87
const vector3d & getLoc(const blockLoc &l) const
Definition: adj.h:223
int ny
Definition: face.h:98
int dir_x
Definition: face.h:95
makefloParam parameters
Definition: makeflo.cpp:101
int nx
Definition: face.h:98
blockSpan span
Definition: face.h:96
int loc2node(const blockLoc &l) const
Definition: face.h:117
int dir_y
Definition: face.h:95

Here is the call graph for this function:

~face ( )

Definition at line 160 of file face.cpp.

References i, nodes, and patches.

160  {
161  delete[] nodes;
162  for (unsigned int i=0;i<patches.size();i++)
163  delete patches[i];
164 }
node ** nodes
Definition: face.h:97
blockLoc i
Definition: read.cpp:79
vector< patch * > patches
Definition: face.h:93

Member Function Documentation

void buildPatches ( void  )

Definition at line 227 of file face.cpp.

References by, blockSpan::end, extBCs, block::face2name, fillNeighbors(), getBlock(), block::getBlockNumber(), facetOrientation::getDestLoc(), block::getDim(), facet::getFace(), block::getFaceNo(), block::getOriginalNumber(), getSourceLoc(), orient_t::inverse(), isDisjoint(), markPatched(), matchOrientations(), nodes, nodesMatch(), nx, ny, orient_t::orient, patches, patch::setFace(), source, patch::srcSpan, blockSpan::start, x, and y.

228 {
229 #if 0
230  //Doublecheck that our nodes agree with our location
231  for (int y=0;y<ny;y++)
232  for (int x=0;x<nx;x++) {
233  if (!nodes[(x )+nx*(y )]->hasLoc(this,getSourceLoc(x,y)))
234  {
235  fprintf(stderr,"ERROR! Face/node location disagreement!\n");
236  abort();
237  }
238  }
239 #endif
240  if (nodes==NULL) return; //Disabled face
241 
242  //Build an array showing the connected face
243  // for each *element's* face-- or "facet"
244  int x,y; //Loop indices
245  int bx=nx-1,by=ny-1; //Size of facet array
246  facet *b=new facet[bx*by];//2D facet array (bx x by)
247  for (y=0;y<by;y++)
248  for (x=0;x<bx;x++) {
249  const node *nbor[4];
250  fillNeighbors(x,y,nbor);
251  b[x+bx*y]=facet(nbor,this);
252  }
253 
254  //Keep track of the number of facets patched so far
255  int nFacets=bx*by;
256  int nPatched=0;
257 
258  //Apply the existant internal boundary conditions
259  for (unsigned int ep=0;ep<patches.size();ep++) {
260  nPatched+=markPatched(b,patches[ep]->srcSpan);
261  }
262 
263  //Apply the external boundary conditions
264  for (unsigned int ec=0;ec<extBCs.size();ec++) {
265  const externalBCpatch &ep=extBCs[ec];
266  patch *p=new externalBCpatch(ep);
267  p->setFace(this);
268  patches.push_back(p);
269  nPatched+=markPatched(b,ep.srcSpan);
270  }
271 
272  //Extract each patch from the facet array
273  int itCount=0;//Runaway loop leash
274  while (nPatched<nFacets) {
275  int startX=-1, startY=-1;
276  //Find the first facet not yet patched
277  for (y=0;y<by && startY==-1;y++)
278  for (x=0;x<bx && startX==-1;x++)
279  if (!b[x+bx*y].isPatched()) {
280  startX=x;
281  startY=y;
282  }
283  //This facet touches the face "dest"
284  const facet &destFacet=b[startX+bx*startY];
285  face *dest=destFacet.getFace();
286  const node *nbor[4];
287  fillNeighbors(startX,startY,nbor);
288  facetOrientation o(nbor,this,startX,startY);
289 
290  //Extend the patch as far right as it will go
291  x=startX;
292  y=startY;
293  while (x<bx && b[x+bx*y].matches(destFacet) &&
294  nodesMatch(x,y,dest,o))
295  x++;
296  int endX=x;
297  if (startX==endX) {
298  blockLoc badLoc=getSourceLoc(startX,startY);
299  blockLoc sz=source->getDim();
300  fprintf(stderr,"ERROR! Face of block %d is non-conformal at node (%d,%d,%d) of (%d,%d,%d)\n",1+source->getOriginalNumber(),badLoc[0],badLoc[1],badLoc[2],sz[0],sz[1],sz[2]);
301  abort();
302  }
303  //Extend the patch as far down as it will go,
304  // marking those facets as patched (face=NULL)
305  for (y=startY;y<by;y++) {
306  bool rowValid=true;
307  for (x=startX;x<endX;x++)
308  if (!(b[x+bx*y].matches(destFacet) &&
309  nodesMatch(x,y,dest,o)))
310  rowValid=false;
311  if (!rowValid)
312  break;//Another block encountered
313  //If we get this far, the row is valid-- mark it
314  for (x=startX;x<endX;x++)
315  b[x+bx*y].markPatched();
316  nPatched+=endX-startX;
317  }
318  int endY=y;
319 
320 
321  //Build and return a patch structure
322  patch *p=NULL;
323  blockSpan srcSpan(getSourceLoc(startX,startY),
324  getSourceLoc(endX,endY)+blockLoc(1,1,1)
325  );
326 
327 #if 1 //Make sure new patch is disjoint from all old patches
328  for (unsigned int otherP=0;otherP<patches.size();otherP++)
329  if (!isDisjoint(srcSpan,patches[otherP]->srcSpan)) {
330  fprintf(stderr,"ERROR! Patches not disjoint!\n");
331  abort();
332  }
333 #endif
334 
335  if (dest==NULL)
336  { //An (unexpected) external boundary condition
337  int bcNo=0;//Default boundary condition number
338  p=new externalBCpatch(this,source,srcSpan,bcNo);
339  /* Warn user that we've fabricated a BC */
340  printf("Makeflo WARNING: Missing boundary condition (using zero) for original block %d,\n"
341  " split block %d, %s face, cells (%d,%d,%d) - (%d,%d,%d)\n",
344  1+srcSpan.start[0],1+srcSpan.start[1],1+srcSpan.start[2],
345  srcSpan.end[0],srcSpan.end[1],srcSpan.end[2]);
346  }
347  else
348  { //An internal boundary-- find other block's location
349  //Match up the orientations
350  orient_t src2dest;
351  matchOrientations(src2dest,
352  getSourceLoc(1,0)-getSourceLoc(0,0),
353  getSourceLoc(0,1)-getSourceLoc(0,0),
354  o.getDestLoc(1,0)-o.getDestLoc(0,0),
355  o.getDestLoc(0,1)-o.getDestLoc(0,0)
356  );
357  blockSpan destSpan(
358  o.getDestLoc(startX,startY),
359  o.getDestLoc(endX,endY)+blockLoc(1,1,1)
360  );
361  p=new internalBCpatch(
362  this,source,dest->getBlock(),
363  srcSpan,destSpan,
364  src2dest);
365  orient_t dest2src=src2dest.inverse();
366  destSpan.orient(srcSpan,dest2src);
367  dest->patches.push_back(new internalBCpatch(
368  dest,dest->getBlock(),source,
369  destSpan,srcSpan,
370  dest2src
371  ));
372  }
373  //Return the new patch
374  patches.push_back(p);
375 
376  if (itCount++>2000)
377  { //There can't be 2000 actual patches-- must be an error
378  fprintf(stderr,"ERROR! Runaway patching loop (%s:%d)!\n",
379  __FILE__,__LINE__);
380  abort();
381  }
382  }
383 
384  //Free the temporary block array
385  delete[] b;
386 }
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed by
Definition: roccomf90.h:7
bool isDisjoint(const blockSpan &a, const blockSpan &b)
Definition: face.cpp:167
int getOriginalNumber(void) const
Definition: adj.h:220
block * source
Definition: face.h:91
node ** nodes
Definition: face.h:97
Definition: face.h:90
void int int REAL REAL * y
Definition: read.cpp:74
static void matchOrientations(orient_t &orient, const blockLoc &sX, const blockLoc &sY, const blockLoc &dX, const blockLoc &dY)
Definition: face.cpp:95
Definition: face.cpp:178
block * getBlock(void) const
Definition: face.h:140
face * getFace(void) const
Definition: face.cpp:188
int markPatched(facet *b, const blockSpan &span)
Definition: face.cpp:197
blockSpan srcSpan
Definition: patch.h:79
int getFaceNo(const face *f)
Definition: adj.h:250
Definition: adj.h:150
blockLoc getSourceLoc(int x, int y) const
Definition: face.h:121
orient_t inverse(void) const
Definition: gridutil.h:82
void setFace(face *f_)
Definition: patch.h:81
Definition: patch.h:74
static const char * face2name[nFaces]
Definition: adj.h:236
bool nodesMatch(int x, int y, const face *dest, const facetOrientation &o) const
Definition: face.cpp:217
const blockDim & getDim(void) const
Definition: adj.h:222
void fillNeighbors(int x, int y, const node **nbor) const
Definition: face.h:100
void int int REAL * x
Definition: read.cpp:74
vector< externalBCpatch > extBCs
Definition: face.h:92
int orient[3]
Definition: gridutil.h:78
int ny
Definition: face.h:98
int nx
Definition: face.h:98
vector< patch * > patches
Definition: face.h:93
int getBlockNumber(void) const
Definition: adj.h:219

Here is the call graph for this function:

void fillNeighbors ( int  x,
int  y,
const node **  nbor 
) const
inlineprivate

Definition at line 100 of file face.h.

References nodes, nx, and x.

Referenced by buildPatches().

100  {
101  nbor[0]=nodes[(x )+nx*(y )];
102  nbor[1]=nodes[(x+1)+nx*(y )];
103  nbor[2]=nodes[(x )+nx*(y+1)];
104  nbor[3]=nodes[(x+1)+nx*(y+1)];
105  }
node ** nodes
Definition: face.h:97
void int int REAL REAL * y
Definition: read.cpp:74
void int int REAL * x
Definition: read.cpp:74
int nx
Definition: face.h:98

Here is the caller graph for this function:

block* getBlock ( void  ) const
inline

Definition at line 140 of file face.h.

References source.

Referenced by buildPatches(), and adjRec::print().

140 {return source;}
block * source
Definition: face.h:91

Here is the caller graph for this function:

blockDim getDim ( void  ) const
inline

Definition at line 141 of file face.h.

References blockSpan::end, span, and blockSpan::start.

Referenced by isSmaller().

141 {return span.end-span.start;}
blockLoc start
Definition: gridutil.h:155
blockLoc end
Definition: gridutil.h:156
blockSpan span
Definition: face.h:96

Here is the caller graph for this function:

const vector<patch *>& getPatches ( void  ) const
inline

Definition at line 145 of file face.h.

References patches.

Referenced by buildFaces(), findPartner(), mblockData::blockPatches::init(), and writeBlock().

145 {return patches;}
vector< patch * > patches
Definition: face.h:93

Here is the caller graph for this function:

blockLoc getSourceLoc ( int  x,
int  y 
) const
inlineprivate

Definition at line 121 of file face.h.

References dir_x, dir_y, span, blockSpan::start, x, and y.

Referenced by buildPatches().

122  {
123  blockLoc ret=span.start;
124  ret[dir_x]+=x;
125  ret[dir_y]+=y;
126  return ret;
127  }
void int int REAL REAL * y
Definition: read.cpp:74
blockLoc start
Definition: gridutil.h:155
void int int REAL * x
Definition: read.cpp:74
int dir_x
Definition: face.h:95
blockSpan span
Definition: face.h:96
int dir_y
Definition: face.h:95

Here is the caller graph for this function:

int loc2node ( const blockLoc l) const
inlineprivate

Definition at line 117 of file face.h.

References loc2nodeX(), loc2nodeY(), and nx.

Referenced by face(), and nodeForCoord().

118  {return loc2nodeX(l)+nx*loc2nodeY(l);}
int loc2nodeX(const blockLoc &l) const
Definition: face.h:113
int nx
Definition: face.h:98
int loc2nodeY(const blockLoc &l) const
Definition: face.h:115

Here is the call graph for this function:

Here is the caller graph for this function:

int loc2nodeX ( const blockLoc l) const
inlineprivate

Definition at line 113 of file face.h.

References dir_x, span, and blockSpan::start.

Referenced by loc2node().

114  {return l[dir_x]-span.start[dir_x];}
blockLoc start
Definition: gridutil.h:155
int dir_x
Definition: face.h:95
blockSpan span
Definition: face.h:96

Here is the caller graph for this function:

int loc2nodeY ( const blockLoc l) const
inlineprivate

Definition at line 115 of file face.h.

References dir_y, span, and blockSpan::start.

Referenced by loc2node().

116  {return l[dir_y]-span.start[dir_y];}
blockLoc start
Definition: gridutil.h:155
blockSpan span
Definition: face.h:96
int dir_y
Definition: face.h:95

Here is the caller graph for this function:

int markPatched ( facet b,
const blockSpan span 
)
private

Definition at line 197 of file face.cpp.

References dir_x, dir_y, blockSpan::end, block::getBlockNumber(), facet::markPatched(), nx, s, source, blockSpan::start, x, and y.

Referenced by buildPatches().

198 {
199  int ret=0;
200  int bx=nx-1; /* ,by=ny-1; */ //Size of facet array
201  const blockLoc &s=span.start, &e=span.end;
202  //Mark all those facets as patched
203  for (int y=s[dir_y];y<e[dir_y]-1;y++)
204  for (int x=s[dir_x];x<e[dir_x]-1;x++) {
205  if (b[x+bx*y].isPatched()) {
206  fprintf(stderr,"FATAL ERROR patching block %d> external boundary conditions overlap!\n",
207  source->getBlockNumber()+1);
208  exit(1);
209  }
210  b[x+bx*y].markPatched();
211  ret++;
212  }
213  return ret;
214 }
block * source
Definition: face.h:91
void int int REAL REAL * y
Definition: read.cpp:74
double s
Definition: blastest.C:80
blockLoc start
Definition: gridutil.h:155
void int int REAL * x
Definition: read.cpp:74
blockLoc end
Definition: gridutil.h:156
void markPatched(void)
Definition: face.cpp:190
int dir_x
Definition: face.h:95
int nx
Definition: face.h:98
int getBlockNumber(void) const
Definition: adj.h:219
int dir_y
Definition: face.h:95

Here is the call graph for this function:

Here is the caller graph for this function:

node * nodeForCoord ( const blockLoc at)

Definition at line 113 of file face.cpp.

References dir_x, dir_y, findOther(), loc2node(), nodes, span, and blockSpan::start.

114 {
115  int dir_z=findOther(dir_x,dir_y);
116  if (at[dir_z]!=span.start[dir_z]) return NULL; //Wrong z-plane
117  else return nodes[loc2node(at)];
118 }
node ** nodes
Definition: face.h:97
blockLoc start
Definition: gridutil.h:155
static int findOther(int a, int b)
Definition: face.cpp:83
int dir_x
Definition: face.h:95
blockSpan span
Definition: face.h:96
int loc2node(const blockLoc &l) const
Definition: face.h:117
int dir_y
Definition: face.h:95

Here is the call graph for this function:

bool nodesMatch ( int  x,
int  y,
const face dest,
const facetOrientation o 
) const
private

Definition at line 217 of file face.cpp.

References facetOrientation::getDestLoc(), adjList::hasLoc(), nodes, nx, and x.

Referenced by buildPatches().

219 {
220  if (dest==NULL) return true;
221  return nodes[(x )+nx*(y )]->hasLoc(dest,o.getDestLoc(x ,y ))
222  && nodes[(x+1)+nx*(y+1)]->hasLoc(dest,o.getDestLoc(x+1,y+1));
223 }
node ** nodes
Definition: face.h:97
void int int REAL REAL * y
Definition: read.cpp:74
blockLoc getDestLoc(int x, int y) const
Definition: face.h:82
void int int REAL * x
Definition: read.cpp:74
bool hasLoc(const face *test, const blockLoc &l) const
Definition: adj.cpp:99
int nx
Definition: face.h:98

Here is the call graph for this function:

Here is the caller graph for this function:

patch * patchForCoord ( const blockLoc at)

Definition at line 120 of file face.cpp.

References i, and patches.

Referenced by buildFaces(), and adjList::isExternal().

121 {
122  int i,len=patches.size();
123  for (i=0;i<len;i++)
124  if (patches[i]->srcSpan.contains(at))
125  return patches[i];
126  return NULL;
127 }
blockLoc i
Definition: read.cpp:79
vector< patch * > patches
Definition: face.h:93

Here is the caller graph for this function:

Member Data Documentation

int dir_x
private

Definition at line 95 of file face.h.

Referenced by face(), getSourceLoc(), loc2nodeX(), markPatched(), and nodeForCoord().

int dir_y
private

Definition at line 95 of file face.h.

Referenced by face(), getSourceLoc(), loc2nodeY(), markPatched(), and nodeForCoord().

vector<externalBCpatch> extBCs
private

Definition at line 92 of file face.h.

Referenced by buildPatches().

node** nodes
private

Definition at line 97 of file face.h.

Referenced by buildPatches(), face(), fillNeighbors(), nodeForCoord(), nodesMatch(), and ~face().

int nx
private

Definition at line 98 of file face.h.

Referenced by buildPatches(), face(), fillNeighbors(), loc2node(), markPatched(), and nodesMatch().

int ny
private

Definition at line 98 of file face.h.

Referenced by buildPatches(), and face().

vector<patch *> patches
private

Definition at line 93 of file face.h.

Referenced by buildPatches(), getPatches(), patchForCoord(), and ~face().

block* source
private

Definition at line 91 of file face.h.

Referenced by buildPatches(), face(), getBlock(), and markPatched().

blockSpan span
private

Definition at line 96 of file face.h.

Referenced by face(), getDim(), getSourceLoc(), loc2nodeX(), loc2nodeY(), and nodeForCoord().


The documentation for this class was generated from the following files: