Skip to content
Snippets Groups Projects
Commit 32d97ee4 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

recoded way to create boundary layers using explicit extrusion directions from...

recoded way to create boundary layers using explicit extrusion directions from vector post-processing view

parent d893afee
No related branches found
No related tags found
No related merge requests found
...@@ -260,6 +260,10 @@ int MergeFile(std::string fileName, bool warnIfMissing) ...@@ -260,6 +260,10 @@ int MergeFile(std::string fileName, bool warnIfMissing)
return MergeFile(noExt); return MergeFile(noExt);
} }
} }
// force reading msh file even if wrong extension if the header
// matches
// if(!strncmp(header, "$MeshFormat", 11)) ext = "";
CTX::instance()->geom.draw = 0; // don't try to draw the model while reading CTX::instance()->geom.draw = 0; // don't try to draw the model while reading
......
...@@ -25,6 +25,7 @@ ExtrudeParams::ExtrudeParams(int ModeEx) : elementMap(this) ...@@ -25,6 +25,7 @@ ExtrudeParams::ExtrudeParams(int ModeEx) : elementMap(this)
geo.Source = -1; geo.Source = -1;
mesh.ExtrudeMesh = false; mesh.ExtrudeMesh = false;
mesh.Recombine = false; mesh.Recombine = false;
mesh.ViewIndex = -1;
} }
void ExtrudeParams::fill(int type, void ExtrudeParams::fill(int type,
......
...@@ -55,6 +55,7 @@ public : ...@@ -55,6 +55,7 @@ public :
std::vector<int> NbElmLayer; std::vector<int> NbElmLayer;
std::vector<double> hLayer; std::vector<double> hLayer;
std::map<int, std::pair<double, std::vector<int> > > Holes; std::map<int, std::pair<double, std::vector<int> > > Holes;
int ViewIndex;
}mesh; }mesh;
struct{ struct{
int Mode; int Mode;
......
...@@ -12,21 +12,42 @@ ...@@ -12,21 +12,42 @@
#include "meshGFace.h" #include "meshGFace.h"
#include "GmshMessage.h" #include "GmshMessage.h"
#if defined(HAVE_POST)
#include "PView.h"
#include "OctreePost.h"
#else
class OctreePost{ int dummy; };
#endif
template<class T> template<class T>
static void addExtrudeNormals(std::vector<T*> &elements, int invert) static void addExtrudeNormals(std::vector<T*> &elements, int invert,
OctreePost *octree)
{ {
for(unsigned int i = 0; i < elements.size(); i++){ if(octree){ // get extrusion direction from post-processing view
MElement *ele = elements[i]; std::set<MVertex*> verts;
for(int j = 0; j < ele->getNumFaces(); j++){ for(unsigned int i = 0; i < elements.size(); i++)
MFace fac = ele->getFace(j); for(int j = 0; j < elements[i]->getNumVertices(); j++)
SVector3 n = fac.normal(); verts.insert(elements[i]->getVertex(j));
if(invert) n *= -1.; for(std::set<MVertex*>::iterator it = verts.begin(); it != verts.end(); it++){
if(n[0] || n[1] || n[2]){ MVertex *v = *it;
double nn[3] = {n[0], n[1], n[2]}; double nn[3];
for(int k = 0; k < fac.getNumVertices(); k++){ octree->searchVector(v->x(), v->y(), v->z(), nn, 0);
MVertex *v = fac.getVertex(k); ExtrudeParams::normals->add(v->x(), v->y(), v->z(), 3, nn);
SPoint3 p(v->x(), v->y(), v->z()); }
ExtrudeParams::normals->add(p[0], p[1], p[2], 3, nn); }
else{ // get extrusion data from Gouraud-shaded element normals
for(unsigned int i = 0; i < elements.size(); i++){
MElement *ele = elements[i];
for(int j = 0; j < ele->getNumFaces(); j++){
MFace fac = ele->getFace(j);
SVector3 n = fac.normal();
if(invert) n *= -1.;
if(n[0] || n[1] || n[2]){
double nn[3] = {n[0], n[1], n[2]};
for(int k = 0; k < fac.getNumVertices(); k++){
MVertex *v = fac.getVertex(k);
ExtrudeParams::normals->add(v->x(), v->y(), v->z(), 3, nn);
}
} }
} }
} }
...@@ -38,6 +59,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) ...@@ -38,6 +59,7 @@ int Mesh2DWithBoundaryLayers(GModel *m)
std::set<GFace*> sourceFaces, otherFaces; std::set<GFace*> sourceFaces, otherFaces;
std::set<GEdge*> sourceEdges, otherEdges; std::set<GEdge*> sourceEdges, otherEdges;
std::map<int, bool> sourceFaceInvert; std::map<int, bool> sourceFaceInvert;
std::map<int, int> sourceUseView;
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++){ for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++){
GFace *gf = *it; GFace *gf = *it;
if(gf->getNativeType() == GEntity::GmshModel && if(gf->getNativeType() == GEntity::GmshModel &&
...@@ -50,6 +72,7 @@ int Mesh2DWithBoundaryLayers(GModel *m) ...@@ -50,6 +72,7 @@ int Mesh2DWithBoundaryLayers(GModel *m)
return 0; return 0;
} }
if(ep->geo.Source < 0) sourceFaceInvert[from->tag()] = true; if(ep->geo.Source < 0) sourceFaceInvert[from->tag()] = true;
if(ep->mesh.ViewIndex >= 0) sourceUseView[from->tag()] = ep->mesh.ViewIndex;
sourceFaces.insert(from); sourceFaces.insert(from);
std::list<GEdge*> e = from->edges(); std::list<GEdge*> e = from->edges();
sourceEdges.insert(e.begin(), e.end()); sourceEdges.insert(e.begin(), e.end());
...@@ -79,10 +102,22 @@ int Mesh2DWithBoundaryLayers(GModel *m) ...@@ -79,10 +102,22 @@ int Mesh2DWithBoundaryLayers(GModel *m)
for(std::set<GFace*>::iterator it = sourceFaces.begin(); for(std::set<GFace*>::iterator it = sourceFaces.begin();
it != sourceFaces.end(); it++){ it != sourceFaces.end(); it++){
GFace *gf = *it; GFace *gf = *it;
addExtrudeNormals(gf->triangles, sourceFaceInvert.count(gf->tag())); int invert = sourceFaceInvert.count(gf->tag());
addExtrudeNormals(gf->quadrangles, sourceFaceInvert.count(gf->tag())); OctreePost *octree = 0;
#if defined(HAVE_POST)
if(sourceUseView.count(gf->tag())){
int index = sourceUseView[gf->tag()];
if(index >= 0 && index < PView::list.size())
octree = new OctreePost(PView::list[index]);
else
Msg::Error("Unknown View[%d]: using normals instead", index);
}
#endif
addExtrudeNormals(gf->triangles, invert, octree);
addExtrudeNormals(gf->quadrangles, invert, octree);
} }
ExtrudeParams::normals->normalize(); if(sourceUseView.empty())
ExtrudeParams::normals->normalize();
// set the position of boundary layer points using the smooth normal // set the position of boundary layer points using the smooth normal
// field // field
......
This diff is collapsed.
...@@ -2626,6 +2626,18 @@ Extrude : ...@@ -2626,6 +2626,18 @@ Extrude :
&extr, $$); &extr, $$);
List_Delete($3); List_Delete($3);
} }
| tExtrude tSTRING '[' FExpr ']' '{' ListOfShapes
{
extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
extr.mesh.ViewIndex = $4;
}
ExtrudeParameters '}'
{
$$ = List_Create(2, 1, sizeof(Shape));
ExtrudeShapes(BOUNDARY_LAYER, $7, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
&extr, $$);
List_Delete($7);
}
// Deprecated extrude commands (for backward compatibility) // Deprecated extrude commands (for backward compatibility)
| tExtrude tPoint '{' FExpr ',' VExpr '}' tEND | tExtrude tPoint '{' FExpr ',' VExpr '}' tEND
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment