Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "SundanceExtrusionMeshTransformation.hpp"
00044 #include "PlayaExceptions.hpp"
00045 #include "SundanceOut.hpp"
00046
00047 using namespace Sundance;
00048 using namespace Sundance;
00049
00050 using namespace Teuchos;
00051 using namespace Sundance;
00052
00053
00054
00055 Mesh ExtrusionMeshTransformation::apply(const Mesh& inputMesh) const
00056 {
00057 TEUCHOS_TEST_FOR_EXCEPTION(inputMesh.spatialDim() != 2, std::runtime_error,
00058 "ExtrusionMeshTransformation::applyLocal() given mesh with "
00059 "dimension " << inputMesh.spatialDim() << ". The "
00060 "extrusion filter expects a 2D mesh as input");
00061
00062
00063 Mesh outputMesh = createMesh(3, inputMesh.comm());
00064
00065
00066
00067
00068 int nPts = inputMesh.numCells(0);
00069
00070
00071 int pointCount = 0;
00072 outputMesh.estimateNumVertices(nzLevels_ * nPts);
00073
00074 for (int i=0; i<nPts; i++)
00075 {
00076 const Point& p = inputMesh.nodePosition(i);
00077 for (int j=0; j<=nzLevels_; j++, pointCount++)
00078 {
00079 double z = z0_ + (z1_-z0_)*j/((double) nzLevels_);
00080 outputMesh.addVertex(pointCount, Point(p[0], p[1], z), 0, 0);
00081 }
00082 }
00083
00084
00085
00086 int nTri = inputMesh.numCells(2);
00087
00088
00089
00090
00091 outputMesh.estimateNumElements(3*nTri*nzLevels_);
00092
00093 Array<int> facetNodes(3);
00094 Array<int> facetOrientations(3);
00095
00096 int tetCount = 0;
00097
00098 TEUCHOS_TEST_FOR_EXCEPTION(inputMesh.cellType(2) != TriangleCell,
00099 std::runtime_error,
00100 "ExtrusionMeshTransformation::applyLocal() detected a "
00101 "non-triangular mesh");
00102 for (int i=0; i<nTri; i++)
00103 {
00104 inputMesh.getFacetArray(2, i, 0, facetNodes, facetOrientations);
00105
00106 SUNDANCE_OUT(this->verb()==3,
00107 "triangle=" << i << " facet nodes are " << facetNodes);
00108
00109
00110
00111 std::sort(facetNodes.begin(), facetNodes.end());
00112
00113 SUNDANCE_OUT(this->verb()==3,
00114 "triangle=" << i << " sorted facet nodes are "
00115 << facetNodes);
00116
00117 int a0 = facetNodes[0]*(nzLevels_+1);
00118 int b0 = facetNodes[1]*(nzLevels_+1);
00119 int c0 = facetNodes[2]*(nzLevels_+1);
00120
00121 for (int j=0; j<nzLevels_; j++, tetCount+=3)
00122 {
00123 int a = a0 + j;
00124 int b = b0 + j;
00125 int c = c0 + j;
00126 int a1 = a+1;
00127 int b1 = b+1;
00128 int c1 = c+1;
00129 outputMesh.addElement(tetCount, tuple(a, a1, b1, c1), 0, 0);
00130 outputMesh.addElement(tetCount+1, tuple(a, b, b1, c1), 0, 0);
00131 outputMesh.addElement(tetCount+2, tuple(a, b, c, c1), 0, 0);
00132 }
00133 }
00134
00135 return outputMesh;
00136
00137 }
00138