51 ProcessDetectSurf::create,
52 "Process elements to detect a surface.");
57 ConfigOption(
false,
"-1",
"Tag identifying surface to process.");
78 cerr <<
"Surface detection only implemented for 2D meshes" << endl;
86 vector<unsigned int> surfs;
90 sort(surfs.begin(), surfs.end());
96 cout <<
"ProcessDetectSurf: detecting surfaces";
99 cout <<
" for surface" << (surfs.size() == 1 ?
"" :
"s") <<
" "
104 vector<ElementSharedPtr> &el =
m_mesh->m_element[
m_mesh->m_expDim];
105 map<int, EdgeInfo> edgeCount;
110 for (i = 0; i < el.size(); ++i)
113 if (surfs.size() > 0)
115 vector<int> inter, tags = el[i]->GetTagList();
117 sort(tags.begin(), tags.end());
118 set_intersection(surfs.begin(),
122 back_inserter(inter));
125 if (inter.size() != 1)
133 for (j = 0; j < elmt->GetEdgeCount(); ++j)
137 edgeCount[eId].count++;
138 edgeCount[eId].edge = e;
141 doneIds.insert(elmt->GetId());
142 ASSERTL0(idMap.count(elmt->GetId()) == 0,
"Shouldn't happen");
143 idMap[elmt->GetId()] = i;
147 unsigned int maxId = 0;
149 for (cIt =
m_mesh->m_composite.begin(); cIt !=
m_mesh->m_composite.end();
152 maxId = (std::max)(cIt->first, maxId);
159 while (doneIds.size() > 0)
162 m_mesh->m_element[
m_mesh->m_expDim][idMap[*(doneIds.begin())]];
164 vector<ElementSharedPtr> block;
166 ASSERTL0(block.size() > 0,
"Contiguous block not found");
169 for (i = 0; i < block.size(); ++i)
174 for (j = 0; j < elmt->GetEdgeCount(); ++j)
176 eIt = edgeCount.find(elmt->GetEdge(j)->m_id);
177 ASSERTL0(eIt != edgeCount.end(),
"Couldn't find edge");
178 eIt->second.group = maxId;
185 for (eIt = edgeCount.begin(); eIt != edgeCount.end(); ++eIt)
187 if (eIt->second.count > 1)
192 unsigned int compId = eIt->second.group;
195 if (cIt ==
m_mesh->m_composite.end())
201 m_mesh->m_composite.insert(std::make_pair(compId, comp)).first;
206 vector<NodeSharedPtr> nodeList(2);
207 nodeList[0] = eIt->second.edge->m_n1;
208 nodeList[1] = eIt->second.edge->m_n2;
213 elmt->SetEdgeLink(eIt->second.edge);
215 cIt->second->m_items.push_back(elmt);
221 vector<ElementSharedPtr> &block)
223 block.push_back(start);
224 doneIds.erase(start->GetId());
226 vector<EdgeSharedPtr> edges = start->GetEdgeList();
228 for (
int i = 0; i < edges.size(); ++i)
230 for (
int j = 0; j < edges[i]->m_elLink.size(); ++j)
238 if (doneIds.count(elmt->GetId()) == 0)
virtual ~ProcessDetectSurf()
#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.
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)
void FindContiguousSurface(ElementSharedPtr start, std::set< int > &doneIds, std::vector< ElementSharedPtr > &block)
boost::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
virtual void Process()
Write mesh to output file.
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
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.