24 SmartPointer<
Domain<T, 3>> passedOutputLS, Vec2D<T> passedExtent,
25 const int passedExtrudeDim,
27 : inputLevelSet(passedInputLS), outputLevelSet(passedOutputLS),
28 extent(passedExtent), extrudeDim(passedExtrudeDim),
29 boundaryConds(passedBoundaryConds) {}
59 if (inputLevelSet ==
nullptr) {
61 .addWarning(
"No input Level Set supplied to Extrude! Not converting.")
64 if (outputLevelSet ==
nullptr) {
67 "No output Level Set supplied to Extrude! Not converting.")
73 const auto extrudeDims = getExtrudeDims();
77 const T gridDelta = inputLevelSet->getGrid().getGridDelta();
78 auto minBounds = inputLevelSet->getGrid().getMinBounds();
79 auto maxBounds = inputLevelSet->getGrid().getMaxBounds();
81 double domainBounds[2 * 3];
82 domainBounds[2 * extrudeDim] = extent[0];
83 domainBounds[2 * extrudeDim + 1] = extent[1];
84 domainBounds[2 * extrudeDims[0]] = gridDelta * minBounds[0];
85 domainBounds[2 * extrudeDims[0] + 1] = gridDelta * maxBounds[0];
86 domainBounds[2 * extrudeDims[1]] = gridDelta * minBounds[1];
87 domainBounds[2 * extrudeDims[1] + 1] = gridDelta * maxBounds[1];
89 auto tmpLevelSet = SmartPointer<Domain<T, 3>>::New(
90 domainBounds, boundaryConds.data(), gridDelta);
91 outputLevelSet->deepCopy(tmpLevelSet);
94 auto surface = SmartPointer<Mesh<T>>::New();
97 auto &lines = surface->template getElements<2>();
98 auto &nodes = surface->getNodes();
99 const unsigned numNodes = nodes.size();
102 for (
unsigned i = 0; i < numNodes; i++) {
103 nodes[i][extrudeDims[1]] = nodes[i][1];
104 nodes[i][extrudeDims[0]] = nodes[i][0];
105 nodes[i][extrudeDim] = extent[1];
107 nodes.push_back(nodes[i]);
109 nodes[i][extrudeDim] = extent[0];
113 for (
unsigned i = 0; i < lines.size(); i++) {
114 std::array<unsigned, 3> triangle = {lines[i][1], lines[i][0],
115 lines[i][0] + numNodes};
116 if (extrudeDim == 1) {
117 std::swap(triangle[0], triangle[2]);
119 surface->insertNextTriangle(triangle);
120 triangle[0] = lines[i][0] + numNodes;
121 triangle[1] = lines[i][1] + numNodes;
122 triangle[2] = lines[i][1];
123 if (extrudeDim == 1) {
124 std::swap(triangle[0], triangle[2]);
126 surface->insertNextTriangle(triangle);
128 surface->template getElements<2>().clear();