50 ProcessDetectSurf::create,
51 "Process elements to detect a surface.");
56 ConfigOption(
false,
"-1",
"Tag identifying surface to process.");
77 cerr <<
"Surface detection only implemented for 2D meshes" << endl;
82 string surf =
m_config[
"vol"].as<
string>();
85 vector<unsigned int> surfs;
89 sort(surfs.begin(), surfs.end());
95 cout <<
"ProcessDetectSurf: detecting surfaces";
98 cout <<
" for surface" << (surfs.size() == 1 ?
"" :
"s") <<
" " 103 vector<ElementSharedPtr> &el =
m_mesh->m_element[
m_mesh->m_expDim];
104 map<int, EdgeInfo> edgeCount;
109 for (i = 0; i < el.size(); ++i)
112 if (surfs.size() > 0)
114 vector<int> inter, tags = el[i]->GetTagList();
116 sort(tags.begin(), tags.end());
117 set_intersection(surfs.begin(),
121 back_inserter(inter));
124 if (inter.size() != 1)
132 for (j = 0; j < elmt->GetEdgeCount(); ++j)
136 edgeCount[eId].count++;
137 edgeCount[eId].edge = e;
140 doneIds.insert(elmt->GetId());
141 ASSERTL0(idMap.count(elmt->GetId()) == 0,
"Shouldn't happen");
142 idMap[elmt->GetId()] = i;
145 unsigned int maxId = 0;
147 for (
auto &cIt :
m_mesh->m_composite)
149 maxId = (std::max)(cIt.first, maxId);
154 while (doneIds.size() > 0)
157 m_mesh->m_element[
m_mesh->m_expDim][idMap[*(doneIds.begin())]];
159 vector<ElementSharedPtr> block;
161 ASSERTL0(block.size() > 0,
"Contiguous block not found");
164 for (i = 0; i < block.size(); ++i)
169 for (j = 0; j < elmt->GetEdgeCount(); ++j)
171 auto eIt = edgeCount.find(elmt->GetEdge(j)->m_id);
172 ASSERTL0(eIt != edgeCount.end(),
"Couldn't find edge");
173 eIt->second.group = maxId;
180 for (
auto &eIt : edgeCount)
182 if (eIt.second.count > 1)
187 unsigned int compId = eIt.second.group;
188 auto cIt =
m_mesh->m_composite.find(compId);
190 if (cIt ==
m_mesh->m_composite.end())
196 m_mesh->m_composite.insert(std::make_pair(compId, comp)).first;
201 vector<NodeSharedPtr> nodeList(2);
202 nodeList[0] = eIt.second.edge->m_n1;
203 nodeList[1] = eIt.second.edge->m_n2;
208 elmt->SetEdgeLink(eIt.second.edge);
210 cIt->second->m_items.push_back(elmt);
216 vector<ElementSharedPtr> &block)
218 block.push_back(start);
219 doneIds.erase(start->GetId());
221 vector<EdgeSharedPtr> edges = start->GetEdgeList();
223 for (
int i = 0; i < edges.size(); ++i)
225 for (
int j = 0; j < edges[i]->m_elLink.size(); ++j)
233 if (doneIds.count(elmt->GetId()) == 0)
virtual ~ProcessDetectSurf()
#define ASSERTL0(condition, msg)
void FindContiguousSurface(NekMeshUtils::ElementSharedPtr start, std::set< int > &doneIds, std::vector< NekMeshUtils::ElementSharedPtr > &block)
Basic information about an element.
MeshSharedPtr m_mesh
Mesh object.
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
ElementFactory & GetElementFactory()
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
A composite is a collection of elements.
std::pair< ModuleType, std::string > ModuleKey
std::shared_ptr< Element > ElementSharedPtr
Represents a command-line configuration option.
virtual void Process()
Write mesh to output file.
std::map< std::string, ConfigOption > m_config
List of configuration values.
Abstract base class for processing modules.
std::shared_ptr< Composite > CompositeSharedPtr
Shared pointer to a composite.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
static bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector. ...