36 #include <boost/algorithm/string.hpp>
52 ProcessOptiExtract::create,
53 "Pulls out blobs for linear elastic solver.");
58 ConfigOption(
false,
"-1",
"Name of mesh file to be combined.");
69 cout <<
"ProcessOptiExtract: ... " << endl;
72 string ins =
m_config[
"insert"].as<
string>();
74 bool extract = boost::iequals(ins,
"-1");
78 vector<ElementSharedPtr> el =
m_mesh->m_element[
m_mesh->m_expDim];
83 vector<ElementSharedPtr> invalid;
86 for (
int i = 0; i < el.size(); ++i)
90 el[i]->GetGeom(
m_mesh->m_spaceDim);
99 invalid.push_back(el[i]);
103 boost::unordered_set<int> inmesh;
105 vector<ElementSharedPtr> totest;
107 for (
int i = 0; i < invalid.size(); i++)
109 t = inmesh.insert(invalid[i]->GetId());
111 m_mesh->m_element[
m_mesh->m_expDim].push_back(invalid[i]);
113 vector<FaceSharedPtr> f = invalid[i]->GetFaceList();
114 for (
int j = 0; j < f.size(); j++)
116 for (
int k = 0; k < f[j]->m_elLink.size(); k++)
118 if (f[j]->m_elLink[k].first->GetId() == invalid[i]->GetId())
121 t = inmesh.insert(f[j]->m_elLink[k].first->GetId());
125 f[j]->m_elLink[k].first);
126 totest.push_back(f[j]->m_elLink[k].first);
132 for (
int i = 0; i < 12; i++)
134 vector<ElementSharedPtr> tmp = totest;
136 for (
int j = 0; j < tmp.size(); j++)
138 vector<FaceSharedPtr> f = tmp[j]->GetFaceList();
139 for (
int k = 0; k < f.size(); k++)
141 for (
int l = 0; l < f[k]->m_elLink.size(); l++)
143 if (f[k]->m_elLink[l].first->GetId() == tmp[j]->GetId())
146 t = inmesh.insert(f[k]->m_elLink[l].first->GetId());
150 f[k]->m_elLink[l].first);
151 totest.push_back(f[k]->m_elLink[l].first);
159 m_mesh->m_vertexSet.clear();
160 m_mesh->m_edgeSet.clear();
161 m_mesh->m_faceSet.clear();
166 cout << el.size() <<
" elements in blobs" << endl;
168 m_mesh->m_faceSet.clear();
171 for (
int i = 0; i < el.size(); ++i)
173 for (
int j = 0; j < el[i]->GetFaceCount(); ++j)
175 pair<FaceSet::iterator, bool> testIns;
176 testIns =
m_mesh->m_faceSet.insert(el[i]->GetFace(j));
181 ->m_elLink.push_back(
182 pair<ElementSharedPtr, int>(el[i], j));
186 el[i]->SetFace(j, *testIns.first);
189 ->m_elLink.push_back(
190 pair<ElementSharedPtr, int>(el[i], j));
196 for (
int i = 0; i < el.size(); i++)
198 vector<FaceSharedPtr> f = el[i]->GetFaceList();
199 for (
int j = 0; j < f.size(); j++)
201 if (f[j]->m_elLink.size() ==
219 for (
int i = 0; i < el.size(); ++i)
221 for (
int j = 0; j < el[i]->GetVertexCount(); ++j)
223 pair<NodeSet::iterator, bool> testIns =
224 m_mesh->m_vertexSet.insert(el[i]->GetVertex(j));
228 el[i]->SetVertex(j, *testIns.first);
232 for (
int i = 0; i < el.size(); ++i)
234 for (
int j = 0; j < el[i]->GetEdgeCount(); ++j)
236 pair<EdgeSet::iterator, bool> testIns;
238 testIns =
m_mesh->m_edgeSet.insert(ed);
243 ed2->m_elLink.push_back(
244 pair<ElementSharedPtr, int>(el[i], j));
249 el[i]->SetEdge(j, e2);
250 if (e2->m_edgeNodes.size() == 0 &&
251 ed->m_edgeNodes.size() > 0)
253 e2->m_curveType = ed->m_curveType;
254 e2->m_edgeNodes = ed->m_edgeNodes;
257 if (e2->m_n1->m_id != ed->m_n1->m_id)
259 reverse(e2->m_edgeNodes.begin(),
260 e2->m_edgeNodes.end());
265 e2->m_elLink.push_back(
266 pair<ElementSharedPtr, int>(el[i], j));
270 for (
int i = 0; i < el.size(); ++i)
272 for (
int j = 0; j < el[i]->GetFaceCount(); ++j)
274 pair<FaceSet::iterator, bool> testIns;
275 testIns =
m_mesh->m_faceSet.insert(el[i]->GetFace(j));
280 ->m_elLink.push_back(
281 pair<ElementSharedPtr, int>(el[i], j));
285 el[i]->SetFace(j, *testIns.first);
288 ->m_elLink.push_back(
289 pair<ElementSharedPtr, int>(el[i], j));
303 mod->RegisterConfig(
"infile", ins);
308 map<int, NodeSharedPtr> nmap;
311 for (nit = inp_mesh->m_vertexSet.begin();
312 nit != inp_mesh->m_vertexSet.end();
315 nmap[(*nit)->m_id] = *nit;
319 for (nit =
m_mesh->m_vertexSet.begin();
320 nit !=
m_mesh->m_vertexSet.end();
323 if (nmap.count((*nit)->m_id) == 1)
326 s = nmap.find((*nit)->m_id);
328 (*nit)->m_x = n->m_x;
329 (*nit)->m_y = n->m_y;
330 (*nit)->m_z = n->m_z;
334 for (eit = inp_mesh->m_edgeSet.begin();
335 eit != inp_mesh->m_edgeSet.end();
339 if (et !=
m_mesh->m_edgeSet.end())
341 (*et)->m_edgeNodes = (*eit)->m_edgeNodes;
342 (*et)->m_curveType = (*eit)->m_curveType;
346 for (fit = inp_mesh->m_faceSet.begin();
347 fit != inp_mesh->m_faceSet.end();
351 if (ft !=
m_mesh->m_faceSet.end())
353 (*ft)->m_faceNodes = (*fit)->m_faceNodes;
354 (*ft)->m_curveType = (*fit)->m_curveType;
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.
map< string, ConfigOption > m_config
List of configuration values.
MeshSharedPtr m_mesh
Mesh object.
ElementFactory & GetElementFactory()
virtual void ClearElementLinks()
boost::shared_ptr< Node > NodeSharedPtr
virtual void ProcessComposites()
Generate composites.
boost::shared_ptr< Module > ModuleSharedPtr
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< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::shared_ptr< Element > ElementSharedPtr
boost::shared_ptr< Geometry > GeometrySharedPtr
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.