Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test_2d.C
Go to the documentation of this file.
1 #include "Mesh.H"
2 
3 int main(int argc,char *argv[])
4 {
6  Mesh::Connectivity con(6);
7  Mesh::Connectivity dual_con;
8  std::cout << "Setting nodes." << std::endl;
9  nc.init_node(1,GeoPrim::CPoint(0,0,0));
10  nc.init_node(2,GeoPrim::CPoint(1,0,0));
11  nc.init_node(3,GeoPrim::CPoint(1,1,0));
12  nc.init_node(4,GeoPrim::CPoint(0,1,0));
13  nc.init_node(5,GeoPrim::CPoint(0,0,1));
14  nc.init_node(6,GeoPrim::CPoint(1,0,1));
15  nc.init_node(7,GeoPrim::CPoint(1,1,1));
16  nc.init_node(8,GeoPrim::CPoint(0,1,1));
17  std::cout << "Building Mesh." << std::endl;
18  con[0].push_back(1); con[0].push_back(2);
19  con[0].push_back(3); con[0].push_back(4);
20  con[1].push_back(5); con[1].push_back(6);
21  con[1].push_back(7); con[1].push_back(8);
22  con[2].push_back(1); con[2].push_back(2);
23  con[2].push_back(6); con[2].push_back(5);
24  con[3].push_back(2); con[3].push_back(3);
25  con[3].push_back(7); con[3].push_back(6);
26  con[4].push_back(3); con[4].push_back(4);
27  con[4].push_back(8); con[4].push_back(7);
28  con[5].push_back(4); con[5].push_back(1);
29  con[5].push_back(5); con[5].push_back(8);
30  con.Sync();
31  std::cout << "Getting Inverse." << std::endl;
32  con.Inverse(dual_con,8);
33  std::cout << "Creating points." << std::endl;
34  std::vector<GeoPrim::CPoint> points;
35  GeoPrim::CPoint point1(.5,.5,0);
36  GeoPrim::CPoint point2(.5,0,0);
37  GeoPrim::CPoint point3(.5,1,0);
38  GeoPrim::CPoint point4(0,.5,0);
39  GeoPrim::CPoint point5(1,.5,0);
40  GeoPrim::CPoint point6(.5,.5,1);
41  GeoPrim::CPoint point7(.5,.5,2);
42  GeoPrim::CPoint point8(2,.5,1);
43  points.push_back(point1); points.push_back(point2);
44  points.push_back(point3); points.push_back(point4);
45  points.push_back(point5); points.push_back(point6);
46  points.push_back(point7); points.push_back(point8);
47  std::cout << "Building box." << std::endl;
49  GeoPrim::CVector natc;
50  std::cout << "Searching for points" << std::endl;
51  std::vector<GeoPrim::CPoint>::iterator pi = points.begin();
52  while(pi != points.end()){
53  Mesh::IndexType point_number = pi - points.begin() + 1;
54  Mesh::IndexType element_id = FindPointInMesh_2(*pi++,nc,con,dual_con,box,natc);
55  if(!element_id)
56  std::cout << "Could not find point " << point_number
57  << " in the mesh" << std::endl;
58  else {
59  std::cout << "Found point " << point_number << " in element "
60  << element_id << " with natc = " << natc << std::endl;
61  GeoPrim::CVector nodal_coords[4];
62  nodal_coords[0].init(nc[con[element_id-1][0]]);
63  nodal_coords[1].init(nc[con[element_id-1][1]]);
64  nodal_coords[2].init(nc[con[element_id-1][2]]);
65  nodal_coords[3].init(nc[con[element_id-1][3]]);
66  Mesh::GenericCell_2 cell(4);
67  GeoPrim::CVector point_coords;
68  cell.interpolate(nodal_coords,natc,point_coords);
69  std::cout << "The interpolated coordinates are: " << point_coords << std::endl;
70  }
71  }
72  return(0);
73 }
void Sync()
Definition: Mesh.C:246
General connectivity object.
Definition: Mesh.H:334
KD_tree::Box box
Definition: Overlay_0d.C:47
Mesh Stuff.
Definition: points.h:30
Mesh::IndexType FindPointInMesh_2(const GeoPrim::CPoint &p, const NodalCoordinates &nc, const Connectivity &ec, const Connectivity &dc, const GeoPrim::CBox &box, GeoPrim::CVector &natc)
Locate element containing given physical point.
void Inverse(Connectivity &, IndexType nnodes=0) const
Definition: Mesh.C:312
CVector & init(const CPoint &p)
void interpolate(const GeoPrim::CVector f[], const GeoPrim::CVector &nc, GeoPrim::CVector &) const
Definition: Mesh.C:810
int main(int argc, char *argv[])
Definition: blastest.C:94
const double pi
IRAD::Primitive::IndexType IndexType
Definition: Mesh.H:57
void init_node(IndexType n, const GeoPrim::CPoint &)
Definition: Mesh.C:78