18 #if defined(HAVE_POST)
31 int size = elem_verts.size();
33 for(
int i = 0; i < size - 1; i++)
34 ave += elem_verts[i]->
distance(elem_verts[i + 1]);
35 ave += elem_verts[0]->distance(elem_verts[size - 1]);
45 if(index < 0 || index > 1) {
46 Msg::Error(
"Boundary layer index should be 0 or 1");
50 if(octree && !gouraud) {
51 std::set<MVertex *> verts;
52 for(std::size_t i = 0; i < elements.size(); i++) {
54 for(std::size_t j = 0; j < elements[i]->getNumVertices(); j++)
55 verts.insert(elements[i]->getVertex(j));
58 std::vector<MVertex *> elem_verts;
59 elements[i]->getVertices(elem_verts);
63 for(std::size_t j = 0; j < elem_verts.size(); j++) {
64 verts.insert(elem_verts[j]);
70 elem_verts[j]->x(), elem_verts[j]->y(), elem_verts[j]->
z(),
75 for(
auto it = verts.begin(); it != verts.end(); it++) {
77 double nn[3] = {0., 0., 0.};
78 #if defined(HAVE_POST)
85 for(std::size_t i = 0; i < elements.size(); i++) {
90 else if(ele->
getDim() == 1)
93 double nn[3] = {n[0], n[1], n[2]};
101 std::vector<MVertex *> elem_verts;
102 double aveLength = 0.0;
103 elements[i]->getVertices(elem_verts);
108 for(std::size_t j = 0; j < elem_verts.size(); j++) {
110 elem_verts[j]->x(), elem_verts[j]->y(), elem_verts[j]->
z(), 3, nn);
113 elem_verts[j]->x(), elem_verts[j]->y(), elem_verts[j]->
z(),
121 typedef std::set<std::pair<bool, std::pair<int, int> > >
infoset;
131 std::map<int, infoset> &infos,
132 std::map<int, bool> &skipScaleCalcMap)
134 bool normalize =
true, special3dbox =
false, extrudeField =
false;
135 #if defined(HAVE_POST)
136 std::vector<PViewData *> datas;
139 for(
auto it = entities.begin(); it != entities.end(); it++) {
141 infoset info = infos[ge->tag()];
142 for(
auto it2 = info.begin(); it2 != info.end(); it2++) {
143 bool invert = it2->first;
144 int index = it2->second.first;
145 int view = it2->second.second;
148 #if defined(HAVE_POST)
152 if(
PView::list[view]->getData()->getNumVectors()) gouraud =
false;
155 else if(view == -3) {
160 else if(view == -5) {
165 Msg::Error(
"Unknown View[%d]: using normals instead", view);
168 bool skipScaleCalc =
true;
169 auto itskip = skipScaleCalcMap.find(ge->tag());
170 if(itskip != skipScaleCalcMap.end())
171 skipScaleCalc = skipScaleCalcMap[ge->tag()];
175 else if(ge->
dim() == 2) {
177 index, skipScaleCalc);
179 index, skipScaleCalc);
198 for(
int i = 0; i < 2; i++) {
203 for(
int j = 0; j < 3; j++) {
204 if(it->vals[j] < -0.1)
206 else if(it->vals[j] > 0.1)
220 double radius = (*f)(it->x, it->y, it->z);
221 for(
int k = 0; k < 3; k++) it->vals[k] *= radius;
225 #if defined(HAVE_POST)
229 for(std::size_t j = 0; j < datas.size(); j++) {
230 double d, dist = -1.;
231 if(datas[j]->searchScalarClosest(it->x, it->y, it->z, dist, &d, 0)) {
232 for(
int k = 0; k < 3; k++) it->vals[k] *= d;
259 std::map<int, bool> &edgeSkipScaleCalc)
261 unsigned int num_changed = 0;
268 std::vector<GFace *> reg_faces = (*itreg)->faces();
269 for(
auto itface = reg_faces.begin(); itface != reg_faces.end(); itface++) {
275 faceSkipScaleCalc[(*itface)->tag()] =
false;
288 std::vector<GEdge *> f_edges = (*it)->edges();
289 for(
auto itedge = f_edges.begin(); itedge != f_edges.end(); itedge++) {
295 edgeSkipScaleCalc[(*itedge)->tag()] =
false;
306 std::set<GFace *> sourceFaces, otherFaces;
307 std::set<GEdge *> sourceEdges, otherEdges;
308 std::map<int, infoset> sourceFaceInfo, sourceEdgeInfo;
309 std::map<int, bool> faceSkipScaleCalc, edgeSkipScaleCalc;
322 Msg::Error(
"Unknown source curve %d for boundary layer",
326 std::pair<bool, std::pair<int, int> >
tags(
329 sourceEdgeInfo[from->
tag()].insert(
tags);
330 sourceEdges.insert(from);
338 edgeSkipScaleCalc[from->
tag()] =
false;
355 Msg::Error(
"Unknown source face %d for boundary layer",
359 std::pair<bool, std::pair<int, int> >
tags(
362 sourceFaceInfo[from->
tag()].insert(
tags);
363 sourceFaces.insert(from);
371 faceSkipScaleCalc[from->
tag()] =
false;
375 std::vector<GEdge *>
const &e = from->
edges();
376 sourceEdges.insert(e.begin(), e.end());
377 for(
auto ite = e.begin(); ite != e.end(); ite++) {
378 if(edgeSkipScaleCalc.find((*ite)->tag()) == edgeSkipScaleCalc.end())
379 edgeSkipScaleCalc[(*ite)->tag()] =
true;
380 if(ep->
mesh.
ScaleLast) edgeSkipScaleCalc[(*ite)->tag()] =
false;
386 if(sourceEdges.empty() && sourceFaces.empty())
return 0;
395 unsigned int num_changed =
399 "%d entities were changed from ScaleLast = false to ScaleLast = true",
404 std::set<GFace *> sourceFacesDependencies;
405 for(
auto it = sourceFaces.begin(); it != sourceFaces.end(); it++)
407 Msg::Info(
"%d dependencies in mesh of source faces",
408 sourceFacesDependencies.size());
409 for(
auto it = sourceFacesDependencies.begin();
410 it != sourceFacesDependencies.end(); it++) {
411 std::vector<GEdge *>
const &e = (*it)->edges();
412 sourceEdges.insert(e.begin(), e.end());
417 if(sourceEdges.find(*it) == sourceEdges.end()) otherEdges.insert(*it);
419 if(sourceFaces.find(*it) == sourceFaces.end() &&
420 sourceFacesDependencies.find(*it) == sourceFacesDependencies.end())
421 otherFaces.insert(*it);
427 for(
auto it = sourceFacesDependencies.begin();
428 it != sourceFacesDependencies.end(); it++) {
437 for(
auto it = sourceFaces.begin(); it != sourceFaces.end(); it++)
443 std::for_each(sourceFaces.begin(), sourceFaces.end(),
orientMeshGFace());
446 for(
int i = 0; i < 2; i++) {
450 if(sourceFaces.empty())
484 std::for_each(otherFaces.begin(), otherFaces.end(),
deMeshGFace());
485 for(
auto it = otherEdges.begin(); it != otherEdges.end(); it++)
501 for(
auto it = otherFaces.begin(); it != otherFaces.end(); it++) {
507 for(
auto it = otherFaces.begin(); it != otherFaces.end(); it++)