Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BSMesh.C
Go to the documentation of this file.
1 #include <iomanip>
6 #include <sstream>
7 #include <cstdlib>
8 #include <algorithm>
9 
10 #include "BSMesh.H"
11 
12 namespace Mesh {
15  std::vector<Mesh::IndexType> &gridsizes,
17  {
18  if(gridsizes.size() != 3)
19  return 1;
20  // sizes is ncells
21  Mesh::IndexType ncells_x = gridsizes[0];
22  Mesh::IndexType ncells_y = gridsizes[1];
23  Mesh::IndexType ncells_z = gridsizes[2];
24  Mesh::IndexType nnodes_x = ncells_x + 1;
25  Mesh::IndexType nnodes_y = ncells_y + 1;
26  Mesh::IndexType nnodes_z = ncells_z + 1;
27  std::vector<Mesh::IndexType> flatextent(6);
28  flatextent[0] = 1;
29  flatextent[1] = nnodes_x;
30  flatextent[2] = 1;
31  flatextent[3] = nnodes_y;
32  flatextent[4] = 1;
33  flatextent[5] = nnodes_z;
34  gridextent.Init(flatextent);
35  unsigned int npoints = flatextent[1]*flatextent[3]*flatextent[5];
36  nc.init(npoints);
37  std::vector<double> xcoords(ncells_x+1);
38  std::vector<double> ycoords(ncells_y+1);
39  GeoPrim::CPoint p(box.P2() - box.P1());
40  double h_x = (ncells_x > 0 ? p.x()/ncells_x : 0);
41  double h_y = (ncells_y > 0 ? p.y()/ncells_y : 0);
42  double h_z = (ncells_z > 0 ? p.z()/ncells_z : 0);
43  for(unsigned int i = 0;i < nnodes_y;i++)
44  ycoords[i] = i*h_y + box.P1().y();
45  for(unsigned int i = 0;i < nnodes_x;i++)
46  xcoords[i] = i*h_x + box.P1().x();
47  unsigned int point_id = 1;
48  for(unsigned int k = 0;k < nnodes_z;k++){
49  double z = k*h_z + box.P1().z();
50  for(unsigned int j = 0;j < nnodes_y;j++){
51  for(unsigned int i = 0;i < nnodes_x;i++){
52  GeoPrim::C3Point gridpoint(nc[point_id++]);
53  gridpoint.x() = xcoords[i];
54  gridpoint.y() = ycoords[j];
55  gridpoint.z() = z;
56  }
57  }
58  }
59  }
60 }
/brief Cartesian 3 Vector
int GenerateCartesianGrid(Mesh::NodalCoordinates &nc, Mesh::BSExtent< Mesh::IndexType > &gridextent, std::vector< Mesh::IndexType > &gridsizes, GeoPrim::CBox &box)
j indices k indices k
Definition: Indexing.h:6
const CPoint & P2() const
KD_tree::Box box
Definition: Overlay_0d.C:47
Class Mesh is the main class that holds all information to describe the current state of the mesh...
Definition: Mesh.hpp:19
Block Structured Mesh stuff.
void int int int REAL REAL REAL * z
Definition: write.cpp:76
blockLoc i
Definition: read.cpp:79
j indices j
Definition: Indexing.h:6
void Init(const std::vector< T > &inflatextent)
Definition: BSMesh.H:75
IRAD::Primitive::IndexType IndexType
Definition: Mesh.H:57
Simple Block Structured Mesh object.
Definition: BSMesh.H:16
const CPoint & P1() const