Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
face.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Illinois Open Source License *
3  * *
4  * University of Illinois/NCSA *
5  * Open Source License *
6  * *
7  * Copyright@2008, University of Illinois. All rights reserved. *
8  * *
9  * Developed by: *
10  * *
11  * Center for Simulation of Advanced Rockets *
12  * *
13  * University of Illinois *
14  * *
15  * www.csar.uiuc.edu *
16  * *
17  * Permission is hereby granted, free of charge, to any person *
18  * obtaining a copy of this software and associated documentation *
19  * files (the "Software"), to deal with the Software without *
20  * restriction, including without limitation the rights to use, *
21  * copy, modify, merge, publish, distribute, sublicense, and/or *
22  * sell copies of the Software, and to permit persons to whom the *
23  * Software is furnished to do so, subject to the following *
24  * conditions: *
25  * *
26  * *
27  * @ Redistributions of source code must retain the above copyright *
28  * notice, this list of conditions and the following disclaimers. *
29  * *
30  * @ Redistributions in binary form must reproduce the above *
31  * copyright notice, this list of conditions and the following *
32  * disclaimers in the documentation and/or other materials *
33  * provided with the distribution. *
34  * *
35  * @ Neither the names of the Center for Simulation of Advanced *
36  * Rockets, the University of Illinois, nor the names of its *
37  * contributors may be used to endorse or promote products derived *
38  * from this Software without specific prior written permission. *
39  * *
40  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48  *********************************************************************
49  * Please acknowledge The University of Illinois Center for *
50  * Simulation of Advanced Rockets in works and publications *
51  * resulting from this software or its derivatives. *
52  *********************************************************************/
53 /*
54 A face is one side of a block of data, which
55 may be adjacent to many other faces and/or the
56 outside world.
57 Faces are split up into homogenous, rectangular
58 "patches" for output.
59 
60 Orion Sky Lawlor, olawlor@acm.org, 6/8/2001
61 */
62 #ifndef __CSAR_FACE_H
63 #define __CSAR_FACE_H
64 
65 #include "adj.h"
66 
67 //A facet orientation, mapping from face coordinates
68 // to destination coordinates.
70  blockLoc start;//Our starting location on dest
71  blockLoc orientX,orientY; //Our orientation on dest
72  int startX,startY;//Offset to start location
73 public:
74  facetOrientation(const node **nbor,const face *source,
75  int startX_,int startY_)
76  :startX(startX_),startY(startY_)
77  {
78  node::intersect(nbor,source,&start,&orientX,&orientY);
79  }
80 
81  //Map a face index to destination location
82  blockLoc getDestLoc(int x,int y) const {
83  return start+(x-startX)*orientX+(y-startY)*orientY;
84  }
85 };
86 
87 class facet;
88 
89 //A 2D face of a 3D grid block
90 class face {
91  block *source;//The block we front
92  vector<externalBCpatch> extBCs;//External boundary conditions
93  vector<patch *> patches; //All boundary conditions for this face
94 
95  int dir_x,dir_y;//Direction indices-- the 3D (i,j,k) for our 2D (x,y)
96  blockSpan span;//3D location in source block
97  node **nodes; //2D node* array (nx x ny)
98  int nx,ny;//Width and height of node array
99  //Fill this 4-long neighbors array
100  void fillNeighbors(int x,int y,const node **nbor) const {
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  }
106 
107  //Check if this facet orientation matches the nodes around (x,y)
108  bool nodesMatch(int x,int y,
109  const face *dest,
110  const facetOrientation &o) const;
111 
112  //Map a grid location to a node array index
113  int loc2nodeX(const blockLoc &l) const
114  {return l[dir_x]-span.start[dir_x];}
115  int loc2nodeY(const blockLoc &l) const
116  {return l[dir_y]-span.start[dir_y];}
117  int loc2node(const blockLoc &l) const
118  {return loc2nodeX(l)+nx*loc2nodeY(l);}
119 
120  //Map a node array index to a source grid location
121  blockLoc getSourceLoc(int x,int y) const
122  {
123  blockLoc ret=span.start;
124  ret[dir_x]+=x;
125  ret[dir_y]+=y;
126  return ret;
127  }
128  //Mark these facets as patched
129  int markPatched(facet *b,const blockSpan &span);
130 public:
131  //Attach the block to all this face's nodes
132  face(block *source_,nodeMatcher &map,
133  vector<externalBCpatch> &extBCs_,int dir_x_,int dir_y_,
134  const blockSpan &span_);
135  void buildPatches(void);
136  node *nodeForCoord(const blockLoc &at);
137  patch *patchForCoord(const blockLoc &at);
138  ~face();
139 
140  block *getBlock(void) const {return source;}
141  blockDim getDim(void) const {return span.end-span.start;}
142 
143  //Find all the patch structures for this face.
144  //Must be called after all faces have been created.
145  const vector<patch *> &getPatches(void) const {return patches;}
146 };
147 
148 #endif
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
~face()
Definition: face.cpp:160
int loc2nodeX(const blockLoc &l) const
Definition: face.h:113
block * source
Definition: face.h:91
face(block *source_, nodeMatcher &map, vector< externalBCpatch > &extBCs_, int dir_x_, int dir_y_, const blockSpan &span_)
Definition: face.cpp:131
node ** nodes
Definition: face.h:97
const vector< patch * > & getPatches(void) const
Definition: face.h:145
Definition: face.h:90
void int int REAL REAL * y
Definition: read.cpp:74
Definition: face.cpp:178
block * getBlock(void) const
Definition: face.h:140
node * nodeForCoord(const blockLoc &at)
Definition: face.cpp:113
int markPatched(facet *b, const blockSpan &span)
Definition: face.cpp:197
int startX
Definition: face.h:72
Definition: adj.h:150
int startY
Definition: face.h:72
blockLoc getSourceLoc(int x, int y) const
Definition: face.h:121
patch * patchForCoord(const blockLoc &at)
Definition: face.cpp:120
Definition: adj.h:203
Definition: patch.h:74
blockLoc getDestLoc(int x, int y) const
Definition: face.h:82
facetOrientation(const node **nbor, const face *source, int startX_, int startY_)
Definition: face.h:74
bool nodesMatch(int x, int y, const face *dest, const facetOrientation &o) const
Definition: face.cpp:217
blockLoc start
Definition: gridutil.h:155
void fillNeighbors(int x, int y, const node **nbor) const
Definition: face.h:100
void int int REAL * x
Definition: read.cpp:74
blockLoc end
Definition: gridutil.h:156
blockDim getDim(void) const
Definition: face.h:141
vector< externalBCpatch > extBCs
Definition: face.h:92
blockLoc orientY
Definition: face.h:71
static face * intersect(const node **nodes, const face *notHim=NULL, blockLoc *loc=NULL, blockLoc *oX=NULL, blockLoc *oY=NULL)
Definition: adj.cpp:136
int ny
Definition: face.h:98
int dir_x
Definition: face.h:95
void buildPatches(void)
Definition: face.cpp:227
int nx
Definition: face.h:98
blockSpan span
Definition: face.h:96
int loc2nodeY(const blockLoc &l) const
Definition: face.h:115
vector< patch * > patches
Definition: face.h:93
blockLoc orientX
Definition: face.h:71
int loc2node(const blockLoc &l) const
Definition: face.h:117
blockLoc start
Definition: face.h:70
int dir_y
Definition: face.h:95