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

#include <FloGrid.H>

Collaboration diagram for FloGridBlock:

Public Member Functions

 FloGridBlock ()
 
 FloGridBlock (unsigned int i, unsigned int j, unsigned int k)
 
 FloGridBlock (const FloGridBlock &inblock)
 
void DestroyGrid ()
 
void SetGhostLayers (unsigned int n)
 
unsigned int NGhostLayers () const
 
int CreateSoln ()
 
unsigned int NNodes () const
 
unsigned int NumCells () const
 
unsigned int NTotalCells () const
 
std::vector< double > & Solution ()
 
const std::vector< double > & Solution () const
 
void FloLayout ()
 
void MeshLayout ()
 
FloGridBlockoperator= (const FloGridBlock &inblock)
 
unsigned int isize () const
 
unsigned int jsize () const
 
unsigned int ksize () const
 
unsigned int * NCells ()
 
const unsigned int * NCells () const
 
void Resize (unsigned int i, unsigned int j, unsigned int k)
 
void ResizeSoln (unsigned int i, unsigned int j, unsigned int k, unsigned int ng)
 
std::vector< double > & Coords ()
 
const std::vector< double > & Coords () const
 
int ReadBlock (std::istream &BlockIn)
 
int ReadBlockSoln (std::istream &BlockSolnIn)
 
int WriteBlockSoln (std::ostream &Ouf)
 

Protected Attributes

unsigned int _ncells [3]
 
std::vector< double > _incoords
 
unsigned int _ng
 
std::vector< double > _soln
 
unsigned int _grid_no
 

Private Attributes

bool flolayout
 

Detailed Description

Definition at line 27 of file FloGrid.H.

Constructor & Destructor Documentation

FloGridBlock ( )
inline

Definition at line 37 of file FloGrid.H.

References _grid_no, _incoords, _ncells, _ng, _soln, and flolayout.

38  {
39  _ncells[0] = _ncells[1] = _ncells[2] = _ng = 0;
40  _incoords.resize(0);
41  _soln.resize(0);
42  _grid_no = 0;
43  flolayout = false;
44  };
unsigned int _grid_no
Definition: FloGrid.H:33
std::vector< double > _incoords
Definition: FloGrid.H:30
unsigned int _ng
Definition: FloGrid.H:31
unsigned int _ncells[3]
Definition: FloGrid.H:29
bool flolayout
Definition: FloGrid.H:35
std::vector< double > _soln
Definition: FloGrid.H:32
FloGridBlock ( unsigned int  i,
unsigned int  j,
unsigned int  k 
)
inline

Definition at line 45 of file FloGrid.H.

References _grid_no, _incoords, _ncells, _ng, flolayout, i, j, and k.

46  {
47  _ncells[0] = i;
48  _ncells[1] = j;
49  _ncells[2] = k;
50  _ng = 0;
51  _grid_no = 0;
52  _incoords.resize(3*(i+1)*(j+1)*(k+1));
53  flolayout = false;
54  };
unsigned int _grid_no
Definition: FloGrid.H:33
std::vector< double > _incoords
Definition: FloGrid.H:30
unsigned int _ng
Definition: FloGrid.H:31
j indices k indices k
Definition: Indexing.h:6
unsigned int _ncells[3]
Definition: FloGrid.H:29
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
bool flolayout
Definition: FloGrid.H:35
FloGridBlock ( const FloGridBlock inblock)
inline

Definition at line 55 of file FloGrid.H.

References _grid_no, _incoords, _ncells, _ng, _soln, flolayout, and ni.

56  {
57  _ncells[0] = inblock._ncells[0];
58  _ncells[1] = inblock._ncells[1];
59  _ncells[2] = inblock._ncells[2];
60  _grid_no = inblock._grid_no;
61  _incoords.resize(3*(inblock._ncells[0]+1)*(inblock._ncells[1]+1)*
62  (inblock._ncells[2]+1));
63  std::vector<double>::const_iterator ii = inblock._incoords.begin();
64  std::vector<double>::iterator ni = _incoords.begin();
65  while(ni != _incoords.end())
66  *ni++ = *ii++;
67  flolayout = inblock.flolayout;
68  _soln = inblock._soln;
69  _ng = inblock._ng;
70  };
unsigned int _grid_no
Definition: FloGrid.H:33
std::vector< double > _incoords
Definition: FloGrid.H:30
unsigned int _ng
Definition: FloGrid.H:31
unsigned int _ncells[3]
Definition: FloGrid.H:29
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
bool flolayout
Definition: FloGrid.H:35
std::vector< double > _soln
Definition: FloGrid.H:32

Member Function Documentation

std::vector<double>& Coords ( )
inline

Definition at line 161 of file FloGrid.H.

References _incoords.

161 { return _incoords; };
std::vector< double > _incoords
Definition: FloGrid.H:30
const std::vector<double>& Coords ( ) const
inline

Definition at line 162 of file FloGrid.H.

References _incoords.

162 { return _incoords; };
std::vector< double > _incoords
Definition: FloGrid.H:30
int CreateSoln ( )
inline

Definition at line 82 of file FloGrid.H.

References _soln, and NTotalCells().

83  {
84  _soln.resize(5*NTotalCells());
85  };
unsigned int NTotalCells() const
Definition: FloGrid.H:88
std::vector< double > _soln
Definition: FloGrid.H:32

Here is the call graph for this function:

void DestroyGrid ( )
inline

Definition at line 71 of file FloGrid.H.

References _incoords, and swap().

72  {
73  _incoords.resize(0);
74  // release the memory for real...
75  std::vector<double>(_incoords).swap(_incoords);
76  };
std::vector< double > _incoords
Definition: FloGrid.H:30
void swap(int &a, int &b)
Definition: buildface.cpp:88

Here is the call graph for this function:

void FloLayout ( )
inline

Definition at line 91 of file FloGrid.H.

References _incoords, flolayout, i, and NNodes().

92  {
93  if(!flolayout){
94  flolayout = true;
95  unsigned int nnodes = NNodes();
96  std::vector<double> coordcopy(3*nnodes);
97  std::vector<double>::iterator ci = _incoords.begin();
98  std::vector<double>::iterator cci = coordcopy.begin();
99  while(ci != _incoords.end())
100  *cci++ = *ci++;
101  for(int i = 0;i < nnodes;i++){
102  _incoords[i] = coordcopy[3*i];
103  _incoords[nnodes+i] = coordcopy[(3*i) + 1];
104  _incoords[2*nnodes+i] = coordcopy[(3*i) + 2];
105  }
106 
107  }
108  };
std::vector< double > _incoords
Definition: FloGrid.H:30
unsigned int NNodes() const
Definition: FloGrid.H:86
blockLoc i
Definition: read.cpp:79
bool flolayout
Definition: FloGrid.H:35

Here is the call graph for this function:

unsigned int isize ( ) const
inline

Definition at line 143 of file FloGrid.H.

References _ncells.

143 { return _ncells[0]; };
unsigned int _ncells[3]
Definition: FloGrid.H:29
unsigned int jsize ( ) const
inline

Definition at line 144 of file FloGrid.H.

References _ncells.

144 { return _ncells[1]; };
unsigned int _ncells[3]
Definition: FloGrid.H:29
unsigned int ksize ( ) const
inline

Definition at line 145 of file FloGrid.H.

References _ncells.

Referenced by turb_flowlmupdateloglay().

145 { return _ncells[2]; };
unsigned int _ncells[3]
Definition: FloGrid.H:29

Here is the caller graph for this function:

void MeshLayout ( )
inline

Definition at line 109 of file FloGrid.H.

References _incoords, flolayout, i, and NNodes().

110  {
111  if(flolayout){
112  flolayout = false;
113  unsigned int nnodes = NNodes();
114  std::vector<double> coordcopy(3*nnodes);
115  std::vector<double>::iterator ci = _incoords.begin();
116  std::vector<double>::iterator cci = coordcopy.begin();
117  while(ci != _incoords.end())
118  *cci++ = *ci++;
119  for(int i = 0;i < nnodes;i++){
120  _incoords[3*i] = coordcopy[i];
121  _incoords[3*i+1] = coordcopy[nnodes + i];
122  _incoords[3*i+2] = coordcopy[(2*nnodes) + i];
123  }
124 
125  }
126  };
std::vector< double > _incoords
Definition: FloGrid.H:30
unsigned int NNodes() const
Definition: FloGrid.H:86
blockLoc i
Definition: read.cpp:79
bool flolayout
Definition: FloGrid.H:35

Here is the call graph for this function:

unsigned int* NCells ( )
inline

Definition at line 146 of file FloGrid.H.

References _ncells.

146 { return (_ncells); };
unsigned int _ncells[3]
Definition: FloGrid.H:29
const unsigned int* NCells ( ) const
inline

Definition at line 147 of file FloGrid.H.

References _ncells.

147 { return(_ncells); };
unsigned int _ncells[3]
Definition: FloGrid.H:29
unsigned int NGhostLayers ( ) const
inline

Definition at line 81 of file FloGrid.H.

References _ng.

81 {return (_ng); };
unsigned int _ng
Definition: FloGrid.H:31
unsigned int NNodes ( ) const
inline

Definition at line 86 of file FloGrid.H.

References _ncells.

Referenced by FloLayout(), and MeshLayout().

86 { return ((_ncells[0]+1)*(_ncells[1]+1)*(_ncells[2]+1)); };
unsigned int _ncells[3]
Definition: FloGrid.H:29

Here is the caller graph for this function:

unsigned int NTotalCells ( ) const
inline

Definition at line 88 of file FloGrid.H.

References _ncells, and _ng.

Referenced by CreateSoln().

88 { return ((_ncells[0]+(2*_ng))*(_ncells[1]+(2*_ng))*(_ncells[2]+(2*_ng))); };
unsigned int _ng
Definition: FloGrid.H:31
unsigned int _ncells[3]
Definition: FloGrid.H:29

Here is the caller graph for this function:

unsigned int NumCells ( ) const
inline

Definition at line 87 of file FloGrid.H.

References _ncells.

Referenced by ReadBlockSoln().

87 { return (_ncells[0]*_ncells[1]*_ncells[2]); };
unsigned int _ncells[3]
Definition: FloGrid.H:29

Here is the caller graph for this function:

FloGridBlock& operator= ( const FloGridBlock inblock)
inline

Definition at line 128 of file FloGrid.H.

References _incoords, _ncells, flolayout, and ni.

129  {
130  _ncells[0] = inblock._ncells[0];
131  _ncells[1] = inblock._ncells[1];
132  _ncells[2] = inblock._ncells[2];
133 
134  _incoords.resize(3*(inblock._ncells[0]+1)*(inblock._ncells[1]+1)*
135  (inblock._ncells[2]+1));
136  std::vector<double>::const_iterator ii = inblock._incoords.begin();
137  std::vector<double>::iterator ni = _incoords.begin();
138  while(ni != _incoords.end())
139  *ni++ = *ii++;
140  flolayout = inblock.flolayout;
141 
142  };
std::vector< double > _incoords
Definition: FloGrid.H:30
unsigned int _ncells[3]
Definition: FloGrid.H:29
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
bool flolayout
Definition: FloGrid.H:35
int ReadBlock ( std::istream &  BlockIn)
inline

Definition at line 163 of file FloGrid.H.

References _grid_no, _incoords, flolayout, max(), min(), ni, nj, nk, Resize(), CPoint::x(), CPoint::y(), and CPoint::z().

Referenced by FloGrid::BlockCount(), FloGrid::ReadAllBlocks(), and FloGrid::ReadNBlocks().

164  {
165  std::string line;
166  std::getline(BlockIn,line);
167  if(line.empty())
168  return(1);
169  std::istringstream Istr(line);
170  unsigned int ni = 0;
171  unsigned int nj = 0;
172  unsigned int nk = 0;
173  Istr >> _grid_no >> ni >> nj >> nk;
174  if((_grid_no <= 0) || (ni <= 0) || (nj <= 0) || (nk <= 0)){
175  std::cout << "FloGridBlock::ReadBlock: Error reading block" << std::endl
176  << "FloGridBlock::ReadBlock: line:" << line << std::endl
177  << "FloGridBlock::ReadBlock: grid no: " << _grid_no << "ni = " << ni
178  << " nj = " << nj << " nk = " << nk << std::endl;
179  return(1);
180  }
181  unsigned int number_of_nodes = (ni+1)*(nj+1)*(nk+1);
182  // std::cout << "Partition " << grid_no << ": (" << ni
183  // << "," << nj << "," << nk << ")" << std::endl
184  // << "npts = " << number_of_nodes << std::endl;
185  this->Resize(ni,nj,nk);
186  double VERYSMALL = std::numeric_limits<double>::min();
187  double VERYLARGE = std::numeric_limits<double>::max();
188  std::vector<double>::iterator ici = _incoords.begin();
189  while(ici != _incoords.end())
190  BlockIn >> *ici++;
191  std::getline(BlockIn,line);
192  GeoPrim::CPoint minp(VERYLARGE,VERYLARGE,VERYLARGE);
193  GeoPrim::CPoint maxp(-1.0*VERYLARGE,-1.0*VERYLARGE,-1.0*VERYLARGE);
194  ici = _incoords.begin();
195  unsigned int ncount = 0;
196  while(ici != _incoords.end()){
197  double *minval = NULL;
198  double *maxval = NULL;
199  double value = *ici++;
200  if(ncount < number_of_nodes){
201  minval = &minp.x();
202  maxval = &maxp.x();
203  }
204  else if(ncount < 2*number_of_nodes){
205  minval = &minp.y();
206  maxval = &maxp.y();
207  }
208  else {
209  minval = &minp.z();
210  maxval = &maxp.z();
211  }
212  ncount++;
213  if (value < *minval)
214  *minval = value;
215  if (value > *maxval)
216  *maxval = value;
217  }
218  // std::cout << "Mesh limits: " << std::endl
219  // << "Minimum point: " << minp << std::endl
220  // << "Maximum point: " << maxp << std::endl;
221  flolayout = true;
222  return(0);
223  };
unsigned int _grid_no
Definition: FloGrid.H:33
std::vector< double > _incoords
Definition: FloGrid.H:30
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
void int int * nk
Definition: read.cpp:74
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void int * nj
Definition: read.cpp:74
void Resize(unsigned int i, unsigned int j, unsigned int k)
Definition: FloGrid.H:148
bool flolayout
Definition: FloGrid.H:35

Here is the call graph for this function:

Here is the caller graph for this function:

int ReadBlockSoln ( std::istream &  BlockSolnIn)
inline

Definition at line 224 of file FloGrid.H.

References _grid_no, _soln, ni, nj, nk, NumCells(), and ResizeSoln().

225  {
226  std::string line;
227  std::getline(BlockSolnIn,line);
228  if(line.empty())
229  return(1);
230  std::istringstream Istr(line);
231  unsigned int grid_no = 0;
232  unsigned int ni = 0;
233  unsigned int nj = 0;
234  unsigned int nk = 0;
235  unsigned int ng = 0;
236  Istr >> grid_no >> ni >> nj >> nk >> ng;
237  if(_grid_no != grid_no) std::cout << "grid " << _grid_no << " tried to read soln for block " << grid_no << std::endl;
238  assert(_grid_no == grid_no);
239  if((grid_no <= 0) || (ni <= 0) || (nj <= 0) || (nk <= 0)){
240  std::cout << "FloGridBlock::ReadBlockSoln: Error reading block" << std::endl
241  << "FloGridBlock::ReadBlockSoln: line:" << line << std::endl
242  << "FloGridBlock::ReadBlockSoln: grid no: " << grid_no << "ni = " << ni
243  << " nj = " << nj << " nk = " << nk << std::endl;
244  return(1);
245  }
246  unsigned int number_of_total_cells = (ni+(2*ng))*(nj+(2*ng))*(nk+(2*ng));
247  unsigned int number_of_real_cells = (ni*nj*nk);
248  assert(number_of_real_cells == NumCells());
249  // std::cout << "Partition " << grid_no << ": (" << ni
250  // << "," << nj << "," << nk << ")" << std::endl
251  // << "npts = " << number_of_nodes << std::endl;
252  this->ResizeSoln(ni,nj,nk,ng);
253  std::vector<double>::iterator ici = _soln.begin();
254  while(ici != _soln.end())
255  BlockSolnIn >> *ici++;
256  std::getline(BlockSolnIn,line);
257  return(0);
258  };
unsigned int _grid_no
Definition: FloGrid.H:33
unsigned int NumCells() const
Definition: FloGrid.H:87
void ResizeSoln(unsigned int i, unsigned int j, unsigned int k, unsigned int ng)
Definition: FloGrid.H:154
void int int * nk
Definition: read.cpp:74
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
void int * nj
Definition: read.cpp:74
std::vector< double > _soln
Definition: FloGrid.H:32

Here is the call graph for this function:

void Resize ( unsigned int  i,
unsigned int  j,
unsigned int  k 
)
inline

Definition at line 148 of file FloGrid.H.

References _incoords, _ncells, flolayout, i, j, and k.

Referenced by ReadBlock().

149  {
150  _ncells[0] = i; _ncells[1] = j; _ncells[2] = k;
151  _incoords.resize(3*(i+1)*(j+1)*(k+1));
152  flolayout = false;
153  };
std::vector< double > _incoords
Definition: FloGrid.H:30
j indices k indices k
Definition: Indexing.h:6
unsigned int _ncells[3]
Definition: FloGrid.H:29
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
bool flolayout
Definition: FloGrid.H:35

Here is the caller graph for this function:

void ResizeSoln ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  ng 
)
inline

Definition at line 154 of file FloGrid.H.

References _ncells, _ng, _soln, i, j, and k.

Referenced by ReadBlockSoln().

155  {
156  _ncells[0] = i; _ncells[1] = j; _ncells[2] = k;
157  _ng = ng;
158  _soln.resize(5*((i+(2*ng))*(j+(2*ng))*(k+(2*ng))));
159  // flolayout = false;
160  };
unsigned int _ng
Definition: FloGrid.H:31
j indices k indices k
Definition: Indexing.h:6
unsigned int _ncells[3]
Definition: FloGrid.H:29
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
std::vector< double > _soln
Definition: FloGrid.H:32

Here is the caller graph for this function:

void SetGhostLayers ( unsigned int  n)
inline

Definition at line 77 of file FloGrid.H.

References _ng, and n.

78  {
79  _ng = n;
80  };
unsigned int _ng
Definition: FloGrid.H:31
const NT & n
std::vector<double>& Solution ( )
inline

Definition at line 89 of file FloGrid.H.

References _soln.

89 { return (_soln); };
std::vector< double > _soln
Definition: FloGrid.H:32
const std::vector<double>& Solution ( ) const
inline

Definition at line 90 of file FloGrid.H.

References _soln.

90 { return (_soln); };
std::vector< double > _soln
Definition: FloGrid.H:32
int WriteBlockSoln ( std::ostream &  Ouf)
inline

Definition at line 259 of file FloGrid.H.

References _grid_no, _ncells, _ng, and _soln.

260  {
261  std::ostringstream Ostr;
262  Ostr << _grid_no << " " << _ncells[0] << " " << _ncells[1]
263  << " " << _ncells[2] << " " << _ng << std::endl;
264  std::vector<double>::iterator si = _soln.begin();
265  while(si != _soln.end()){
266  Ostr << std::scientific << std::setprecision(16) << *si++ << " ";
267  }
268  Ostr << std::endl;
269  Ouf << Ostr.str();
270  return(Ostr.str().size());
271  };
unsigned int _grid_no
Definition: FloGrid.H:33
unsigned int _ng
Definition: FloGrid.H:31
unsigned int _ncells[3]
Definition: FloGrid.H:29
std::vector< double > _soln
Definition: FloGrid.H:32

Member Data Documentation

unsigned int _grid_no
protected

Definition at line 33 of file FloGrid.H.

Referenced by FloGridBlock(), ReadBlock(), ReadBlockSoln(), and WriteBlockSoln().

std::vector<double> _incoords
protected
unsigned int _ncells[3]
protected
unsigned int _ng
protected
std::vector<double> _soln
protected

Definition at line 32 of file FloGrid.H.

Referenced by CreateSoln(), FloGridBlock(), ReadBlockSoln(), ResizeSoln(), Solution(), and WriteBlockSoln().

bool flolayout
private

Definition at line 35 of file FloGrid.H.

Referenced by FloGridBlock(), FloLayout(), MeshLayout(), operator=(), ReadBlock(), and Resize().


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