Commit 98c13274 authored by Oliver Sander's avatar Oliver Sander

Create unitsquare grids for UGGrid directly instead of loading them from disk

[[Imported from SVN: r84]]
parent 397091b2
# edited by PB 23 Sep 2005
nNodes 4
define Quadrilaterals 1
Parameters {
Materials {
Substrat1 {
Color 0.8 0.1 0.1
}
Substrat2 {
Color 0.1 0.1 0.8
}
}
ContentType "HxTriangularGrid",
CreateMagnitude 1
}
Nodes { float[2] Coordinates } @1
Quadrilaterals { int[4] Nodes } @2
Quadrilaterals { byte Materials } @3
# Data section follows
@1
0.0 0.0
1.0 0.0
0.0 1.0
1.0 1.0
@2
1 2 4 3
@3
1
nNodes 4
nTriangles 2
Parameters {
Materials {
Substrat1 {
Color 0.8 0.1 0.1
}
Substrat2 {
Color 0.1 0.1 0.8
}
}
ContentType "HxTriangularGrid",
CreateMagnitude 1
}
Nodes { float[2] Coordinates } @1
TriangleData { int[3] Nodes } @2
TriangleData { byte Materials } @3
# Data section follows
@1
0.0 0.0
1.0 0.0
0.0 1.0
1.0 1.0
@2
1 2 3
3 2 4
@3
1
2
......@@ -58,7 +58,35 @@ public:
UnitCube () : grid_(800,10)
{
Dune::AmiraMeshReader<Dune::UGGrid<2,2> >::read(grid_,"grids/quadgrid.am");
// Start grid creation
grid_.createBegin();
// Insert vertices
Dune::FieldVector<double,2> pos;
pos[0] = 0; pos[1] = 0;
grid_.insertVertex(pos);
pos[0] = 1; pos[1] = 0;
grid_.insertVertex(pos);
pos[0] = 0; pos[1] = 1;
grid_.insertVertex(pos);
pos[0] = 1; pos[1] = 1;
grid_.insertVertex(pos);
// Insert element
std::vector<unsigned int> cornerIDs(4);
cornerIDs[0] = 0;
cornerIDs[1] = 1;
cornerIDs[2] = 2;
cornerIDs[3] = 3;
grid_.insertElement(Dune::GeometryType(Dune::GeometryType::cube,2), cornerIDs);
// Finish initialization
grid_.createEnd();
}
Dune::UGGrid<2,2>& grid ()
......@@ -79,7 +107,35 @@ public:
UnitCube () : grid_(800,10)
{
Dune::AmiraMeshReader<Dune::UGGrid<2,2> >::read(grid_,"grids/trianggrid.am");
// Start grid creation
grid_.createBegin();
// Insert vertices
Dune::FieldVector<double,2> pos;
pos[0] = 0; pos[1] = 0;
grid_.insertVertex(pos);
pos[0] = 1; pos[1] = 0;
grid_.insertVertex(pos);
pos[0] = 0; pos[1] = 1;
grid_.insertVertex(pos);
pos[0] = 1; pos[1] = 1;
grid_.insertVertex(pos);
// Insert element
std::vector<unsigned int> cornerIDs(3);
cornerIDs[0] = 0; cornerIDs[1] = 1; cornerIDs[2] = 2;
grid_.insertElement(Dune::GeometryType(Dune::GeometryType::simplex,2), cornerIDs);
cornerIDs[0] = 2; cornerIDs[1] = 1; cornerIDs[2] = 3;
grid_.insertElement(Dune::GeometryType(Dune::GeometryType::simplex,2), cornerIDs);
// Finish initialization
grid_.createEnd();
}
Dune::UGGrid<2,2>& grid ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment