52 "Process elements to detect a surface.");
57 "Tag identifying surface to process.");
75 cerr <<
"Surface detection only implemented for 2D meshes" << endl;
80 string surf =
m_config[
"vol"].as<
string>();
83 vector<unsigned int> surfs;
87 sort(surfs.begin(), surfs.end());
93 cout <<
"ProcessDetectSurf: detecting surfaces";
96 cout <<
" for surface" << (surfs.size() == 1 ?
"" :
"s")
97 <<
" " << surf << endl;
101 vector<ElementSharedPtr> &el =
m_mesh->m_element[
m_mesh->m_expDim];
102 map<int, EdgeInfo> edgeCount;
107 for (i = 0; i < el.size(); ++i)
110 if (surfs.size() > 0)
112 vector<int> inter, tags = el[i]->GetTagList();
114 sort(tags.begin(), tags.end());
115 set_intersection(surfs.begin(), surfs.end(),
116 tags .begin(), tags .end(),
117 back_inserter(inter));
120 if (inter.size() != 1)
128 for (j = 0; j < elmt->GetEdgeCount(); ++j)
132 edgeCount[eId].count++;
133 edgeCount[eId].edge = e;
136 doneIds.insert(elmt->GetId());
137 ASSERTL0(idMap.count(elmt->GetId()) == 0,
"Shouldn't happen");
138 idMap[elmt->GetId()] = i;
142 unsigned int maxId = 0;
144 for (cIt =
m_mesh->m_composite.begin(); cIt !=
m_mesh->m_composite.end(); ++cIt)
146 maxId = (std::max)(cIt->first, maxId);
153 while (doneIds.size() > 0)
156 =
m_mesh->m_element[
m_mesh->m_expDim][idMap[*(doneIds.begin())]];
158 vector<ElementSharedPtr> block;
160 ASSERTL0(block.size() > 0,
"Contiguous block not found");
163 for (i = 0; i < block.size(); ++i)
168 for (j = 0; j < elmt->GetEdgeCount(); ++j)
170 eIt = edgeCount.find(elmt->GetEdge(j)->m_id);
171 ASSERTL0(eIt != edgeCount.end(),
"Couldn't find edge");
172 eIt->second.group = maxId;
179 for (eIt = edgeCount.begin(); eIt != edgeCount.end(); ++eIt)
181 if (eIt->second.count > 1)
186 unsigned int compId = eIt->second.group;
189 if (cIt ==
m_mesh->m_composite.end())
194 cIt =
m_mesh->m_composite.insert(std::make_pair(compId, comp)).first;
199 vector<NodeSharedPtr> nodeList(2);
200 nodeList[0] = eIt->second.edge->m_n1;
201 nodeList[1] = eIt->second.edge->m_n2;
206 elmt->SetEdgeLink(eIt->second.edge);
208 cIt->second->m_items.push_back(elmt);
215 vector<ElementSharedPtr> &block)
217 block.push_back(start);
218 doneIds.erase(start->GetId());
220 vector<EdgeSharedPtr> edges = start->GetEdgeList();
222 for (
int i = 0; i < edges.size(); ++i)
224 for (
int j = 0; j < edges[i]->m_elLink.size(); ++j)
232 if (doneIds.count(elmt->GetId()) == 0)