62 int nLayers =
m_config[
"layers"].as<
int>();
68 "Extrude should only be called for a two dimensional mesh");
75 vector<ElementSharedPtr> el =
m_mesh->m_element[2];
81 cout <<
"Boundary composites" << endl;
82 for (
auto &it : oldComp)
84 if (it.second->m_tag !=
"E")
88 cout << it.first <<
"\t" << it.second->m_tag;
89 for (
int i = 0; i < it.second->m_items.size(); ++i)
91 cout <<
"\t" << it.second->m_items[i]->GetId()
92 <<
" (" << it.second->m_items[i]->GetVertex(0)
93 <<
", " << it.second->m_items[i]->GetVertex(1) <<
")";
94 vector<NodeSharedPtr> vv = it.second->m_items[i]->GetVertexList();
95 cout <<
"\t(" << vv[0]->GetID()<<
", " << vv[1]->GetID() <<
")";
102 for (
int d = 0; d <= 3; ++d)
104 m_mesh->m_element[d].clear();
109 map<int, NodeSharedPtr> id2node;
111 for (
auto &n : nodes)
113 id2node[n->m_id] = n;
119 for (
int i = 1; i < nLayers + 1; ++i)
121 for (
auto &n : nodes)
125 new Node(i * nodes.size() + n->m_id, n->m_x, n->m_y,
127 m_mesh->m_vertexSet.insert(newNode);
128 id2node[i * nodes.size() + n->m_id] = newNode;
134 for (
int j = 0; j < nLayers; ++j)
136 for (
int i = 0; i < el.size(); ++i)
138 vector<NodeSharedPtr> verts = el[i]->GetVertexList();
139 if (verts.size() == 4)
141 vector<NodeSharedPtr> nodeList(8);
142 nodeList[0] = id2node[verts[0]->m_id + j * nodes.size()];
143 nodeList[1] = id2node[verts[1]->m_id + j * nodes.size()];
144 nodeList[2] = id2node[verts[2]->m_id + j * nodes.size()];
145 nodeList[3] = id2node[verts[3]->m_id + j * nodes.size()];
146 nodeList[4] = id2node[verts[0]->m_id + (j + 1) * nodes.size()];
147 nodeList[5] = id2node[verts[1]->m_id + (j + 1) * nodes.size()];
148 nodeList[6] = id2node[verts[2]->m_id + (j + 1) * nodes.size()];
149 nodeList[7] = id2node[verts[3]->m_id + (j + 1) * nodes.size()];
160 m_mesh->m_element[3].push_back(E);
164 vector<NodeSharedPtr> nodeList(6);
165 nodeList[0] = id2node[verts[0]->m_id + (j + 1) * nodes.size()];
166 nodeList[1] = id2node[verts[1]->m_id + (j + 1) * nodes.size()];
167 nodeList[2] = id2node[verts[1]->m_id + j * nodes.size()];
168 nodeList[3] = id2node[verts[0]->m_id + j * nodes.size()];
169 nodeList[4] = id2node[verts[2]->m_id + (j + 1) * nodes.size()];
170 nodeList[5] = id2node[verts[2]->m_id + j * nodes.size()];
179 m_mesh->m_element[3].push_back(E);
190 for (
auto &edge : es)
192 if (edge->m_edgeNodes.size() > 0)
194 for (
int j = 0; j < nLayers + 1; ++j)
196 vector<NodeSharedPtr> ns(edge->m_edgeNodes.size());
197 for (
int i = 0; i < ns.size(); i++)
200 ns[i] = std::shared_ptr<Node>(
201 new Node(0, n->m_x, n->m_y, n->m_z + j * dz));
205 new Edge(id2node[edge->m_n1->m_id + j * nodes.size()],
206 id2node[edge->m_n2->m_id + j * nodes.size()]));
208 auto f =
m_mesh->m_edgeSet.find(e);
212 (*f)->m_curveType = edge->m_curveType;
214 if ((*f)->m_n1 == e->m_n1)
216 (*f)->m_edgeNodes = ns;
220 reverse(ns.begin(), ns.end());
221 (*f)->m_edgeNodes = ns;
228 unsigned int maxCompId = 0;
229 for (
auto &it : oldComp)
231 if(it.second->m_id >= maxCompId)
233 maxCompId = it.second->m_id;
238 int outCompId = maxCompId + 1;
239 std::vector<int> toErase;
240 for (
auto &it2 :
m_mesh->m_composite)
242 if (it2.second->m_id > maxCompId)
247 if (it2.second->m_tag ==
"H" || it2.second->m_tag ==
"R")
249 it2.second->m_id = outCompId;
250 m_mesh->m_composite.insert(std::make_pair(outCompId,
252 toErase.push_back(it2.first);
257 for (
auto &e : toErase)
259 m_mesh->m_composite.erase(e);
265 for (
auto &it2 :
m_mesh->m_composite)
267 if (it2.second->m_tag ==
"H" || it2.second->m_tag ==
"R")
269 for (
auto &it1 : oldComp)
271 if (it2.second->m_tag ==
"H" && it1.second->m_tag ==
"Q")
273 it2.second->m_id = it1.second->m_id;
274 m_mesh->m_composite.insert(std::make_pair(it1.second->m_id,
276 toErase.push_back(it2.first);
277 oldComp.erase(it1.first);
280 else if (it2.second->m_tag ==
"R" && it1.second->m_tag ==
"T")
282 it2.second->m_id = it1.second->m_id;
283 m_mesh->m_composite.insert(std::make_pair(it1.second->m_id,
285 toErase.push_back(it2.first);
286 oldComp.erase(it1.first);
293 for (
auto &e : toErase)
295 m_mesh->m_composite.erase(e);
300 comp->m_id = ++maxCompId;
301 unsigned int compAllFaceId = maxCompId;
303 m_mesh->m_composite.insert(std::make_pair(maxCompId, comp));
306 auto allFaceC =
m_mesh->m_composite.find(maxCompId);
309 cout <<
"Faces boundary list" << endl;
311 for (
auto &it :
m_mesh->m_faceSet)
314 if ( it->m_elLink.size() < 2 )
316 if(it->m_vertexList.size() == 3)
325 allFaceC->second->m_items.push_back(E);
327 else if(it->m_vertexList.size() == 4)
336 allFaceC->second->m_items.push_back(E);
342 for (
auto &itOc : oldComp)
345 comp->m_id = itOc.second->m_id;
347 m_mesh->m_composite.insert(std::make_pair(itOc.second->m_id, comp));
350 for (
int i = 0; i < 2; i++)
353 comp->m_id = ++maxCompId;
355 m_mesh->m_composite.insert(std::make_pair(maxCompId, comp));
359 for (
auto &itQ : allFaceC->second->m_items)
362 for (
auto &itOc : oldComp)
364 for (
int iEd = 0; iEd < itOc.second->m_items.size(); ++iEd)
367 for (
int iV = 0; iV < itQ->GetVertexList().size(); iV++)
369 for(
int j = 0; j < 2; j++)
371 if (abs(itQ->GetVertex(iV)->m_x -
372 itOc.second->m_items[iEd]->GetVertex(j)->m_x) <
374 abs(itQ->GetVertex(iV)->m_y -
375 itOc.second->m_items[iEd]->GetVertex(j)->m_y) <
389 cout <<
"Face " << itQ->GetId() <<
"\t" 390 <<
"Composite " << itOc.second->m_id <<
"\t" 393 auto newC =
m_mesh->m_composite.find(itOc.second->m_id);
402 E->SetId(itQ->GetId());
403 newC->second->m_items.push_back(E);
412 for (
int iV = 0; iV < itQ->GetVertexList().size(); iV++)
414 zdist += itQ->GetVertex(iV)->m_z;
416 zdist = zdist / itQ->GetVertexList().size();
417 unsigned int compPerId = 0;
420 compPerId = maxCompId-1;
424 compPerId = maxCompId;
426 if(compPerId > 0 && itQ->GetVertexList().size() == 3)
429 auto perC =
m_mesh->m_composite.find(compPerId);
435 E->SetId(itQ->GetId());
436 perC->second->m_items.push_back(E);
438 else if(compPerId > 0 && itQ->GetVertexList().size() == 4)
441 auto perC =
m_mesh->m_composite.find(compPerId);
447 E->SetId(itQ->GetId());
448 perC->second->m_items.push_back(E);
452 m_mesh->m_composite.erase(compAllFaceId);
#define ASSERTL0(condition, msg)
Basic information about an element.
Represents an edge which joins two points.
std::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
std::map< unsigned int, CompositeSharedPtr > CompositeMap
Container of composites; key is the composite id, value is the composite.
MeshSharedPtr m_mesh
Mesh object.
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
ElementFactory & GetElementFactory()
std::shared_ptr< Node > NodeSharedPtr
std::unordered_set< NodeSharedPtr, NodeHash > NodeSet
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
A composite is a collection of elements.
static const NekDouble kNekZeroTol
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
std::shared_ptr< Element > ElementSharedPtr
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
std::map< std::string, ConfigOption > m_config
List of configuration values.
std::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.