51 ProcessExtractSurf::create,
52 "Process elements to extract a specified surface(s) or composites(s).");
57 false,
"NotSet",
"Tag identifying surface/composite to process.");
59 ConfigOption(
false,
"-1",
"Tag to detect on boundary composites");
70 bool detectbnd =
m_config[
"detectbnd"].beenSet;
73 vector<unsigned int> surfs;
75 "Failed to interp surf string. Have you specified this string?");
76 sort(surfs.begin(), surfs.end());
81 cout <<
"ProcessExtractSurf: extracting surface"
82 << (surfs.size() > 1 ?
"s" :
"") <<
" " << surf << endl;
86 vector<ElementSharedPtr> el =
m_mesh->m_element[
m_mesh->m_expDim - 1];
93 m_mesh->m_vertexSet.clear();
98 for (i = 0; i < el.size(); ++i)
100 vector<EdgeSharedPtr> edges = el[i]->GetEdgeList();
101 for (j = 0; j < edges.size(); ++j)
103 edges[j]->m_elLink.clear();
109 for (j = 0; j < f->m_edgeList.size(); ++j)
111 f->m_edgeList[j]->m_elLink.clear();
117 boost::unordered_set<int> keptIds;
122 for (i = 0; i < el.size(); ++i)
125 vector<int> inter, tags = el[i]->GetTagList();
127 sort(tags.begin(), tags.end());
128 set_intersection(surfs.begin(),
132 back_inserter(inter));
135 if (inter.size() != 1)
142 vector<NodeSharedPtr> verts = elmt->GetVertexList();
143 vector<EdgeSharedPtr> edges = elmt->GetEdgeList();
146 for (j = 0; j < verts.size(); ++j)
148 m_mesh->m_vertexSet.insert(verts[j]);
159 elmt->SetId(e->m_id);
163 for (j = 0; j < f->m_vertexList.size(); j++)
165 elmt->SetVertex(j, f->m_vertexList[j]);
169 for (j = 0; j < edges.size(); ++j)
171 m_mesh->m_edgeSet.insert(f->m_edgeList[j]);
172 elmt->SetEdge(j, f->m_edgeList[j]);
173 f->m_edgeList[j]->m_elLink.push_back(std::make_pair(elmt, j));
177 edit = bndEdgeSet.find(f->m_edgeList[j]);
178 if (edit != bndEdgeSet.end())
181 bndEdgeSet.erase(edit);
185 bndEdgeSet.insert(f->m_edgeList[j]);
188 elmt->SetVolumeNodes(f->m_faceNodes);
189 elmt->SetId(f->m_id);
190 elmt->SetCurveType(f->m_curveType);
194 for (j = 0; j < edges.size(); ++j)
196 m_mesh->m_edgeSet.insert(edges[j]);
203 keptIds.insert(elmt->GetId());
206 m_mesh->m_element[
m_mesh->m_expDim - 1].push_back(elmt);
218 m_mesh->m_composite.clear();
223 for (it = tmp.begin(); it != tmp.end(); ++it)
225 if (it->second->m_items[0]->GetDim() !=
m_mesh->m_expDim)
230 vector<ElementSharedPtr> el = it->second->m_items;
231 it->second->m_items.clear();
233 for (i = 0; i < el.size(); ++i)
235 if (keptIds.count(el[i]->GetId()) > 0)
237 it->second->m_items.push_back(el[i]);
241 if (it->second->m_items.size() == 0)
246 m_mesh->m_composite.insert(*it);
250 maxId = (std::max)(maxId, (
int)it->second->m_id) + 1;
253 tmp =
m_mesh->m_composite;
254 m_mesh->m_composite.clear();
259 for (it = tmp.begin(); it != tmp.end(); ++it)
262 vector<ElementSharedPtr> el = c->m_items;
265 string initialTag = el[0]->GetTag();
266 c->m_items.resize(1);
267 c->m_tag = initialTag;
271 map<string, CompositeSharedPtr> newComps;
272 newComps[initialTag] = c;
276 for (i = 1; i < el.size(); ++i)
281 string tag = el[i]->GetTag();
282 it2 = newComps.find(tag);
283 if (it2 == newComps.end())
286 newComp->m_id = maxId++;
287 newComp->m_tag = tag;
288 newComp->m_items.push_back(el[i]);
289 newComps[tag] = newComp;
293 it2->second->m_items.push_back(el[i]);
298 if (
m_mesh->m_verbose && newComps.size() > 1)
300 cout <<
"- Mapping composite " << it->first <<
" ->";
304 for (i = 0, it2 = newComps.begin(); it2 != newComps.end(); ++it2, ++i)
306 if (
m_mesh->m_verbose && newComps.size() > 1)
308 cout << (i > 0 ?
", " :
" ") << it2->second->m_id <<
"("
309 << it2->second->m_tag <<
")";
311 m_mesh->m_composite[it2->second->m_id] = it2->second;
314 if (
m_mesh->m_verbose && newComps.size() > 1)
328 if (
m_mesh->m_expDim != 2)
330 cerr <<
"Surface boundary detection only implemented for 2D meshes"
335 map<int, EdgeSet> surfBndEdgeSet;
337 map<int, string> surfLabels;
340 for (i = 0; i < el.size(); ++i)
343 vector<int> inter, tags = el[i]->GetTagList();
345 ASSERTL0(tags.size() == 1,
"Not sure what mutliple tags implies");
347 sort(tags.begin(), tags.end());
348 set_intersection(surfs.begin(),
352 back_inserter(inter));
355 if (inter.size() == 1)
363 if (
m_mesh->m_faceLabels.count(surf))
370 vector<EdgeSharedPtr> edges = elmt->GetEdgeList();
375 for (j = 0; j < edges.size(); ++j)
379 if (surfBndEdgeSet.count(surf))
381 edit = surfBndEdgeSet[
surf].find(f->m_edgeList[j]);
382 if (edit != surfBndEdgeSet[surf].end())
385 surfBndEdgeSet[
surf].erase(edit);
389 surfBndEdgeSet[
surf].insert(f->m_edgeList[j]);
395 surfBndEdgeSet[
surf] = newEdgeSet;
396 surfBndEdgeSet[
surf].insert(f->m_edgeList[j]);
402 m_mesh->m_faceLabels.clear();
406 for (esetit = surfBndEdgeSet.begin(); esetit != surfBndEdgeSet.end();
410 newComp->m_id = maxId;
411 newComp->m_tag =
"E";
413 if (surfLabels.count(esetit->first))
415 newComp->m_label = surfLabels[esetit->first];
418 for (edit = esetit->second.begin(); edit != esetit->second.end();
422 if ((locit = bndEdgeSet.find(*edit)) != bndEdgeSet.end())
428 tags.push_back(maxId);
431 vector<NodeSharedPtr> nodeList;
432 nodeList.push_back((*locit)->m_n1);
433 nodeList.push_back((*locit)->m_n2);
437 elType, conf, nodeList, tags);
438 E->SetId((*locit)->m_id);
439 m_mesh->m_element[E->GetDim()].push_back(E);
440 newComp->m_items.push_back(E);
444 if (newComp->m_items.size())
446 m_mesh->m_composite[maxId++] = newComp;
#define ASSERTL0(condition, msg)
Basic information about an element.
pair< ModuleType, string > ModuleKey
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
std::map< unsigned int, CompositeSharedPtr > CompositeMap
Container of composites; key is the composite id, value is the composite.
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
ElementFactory & GetElementFactory()
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
boost::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
boost::shared_ptr< GeometryVector > Composite
Represents a command-line configuration option.
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
boost::shared_ptr< Element > ElementSharedPtr
boost::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
boost::shared_ptr< Face > FaceSharedPtr
Shared pointer to a face.
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.