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

more work on boundary layers

parent 370dd86c
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
#include "ExtrudeParams.h"
smooth_data* ExtrudeParams::normals[2] = {0, 0};
std::vector<SPoint3> ExtrudeParams::normalsCoherence;
static void Projette(double p[3], double mat[3][3])
{
......@@ -95,7 +96,8 @@ void ExtrudeParams::Extrude(double t, double &x, double &y, double &z)
z += dz;
break;
case BOUNDARY_LAYER:
if(normals[mesh.BoundaryLayerIndex])
if(mesh.BoundaryLayerIndex >= 0 && mesh.BoundaryLayerIndex <= 1 &&
normals[mesh.BoundaryLayerIndex])
normals[mesh.BoundaryLayerIndex]->get(x, y, z, 3, n);
x += n[0] * t;
y += n[1] * t;
......
......@@ -10,6 +10,7 @@
#include <map>
#include <string>
#include "SmoothData.h"
#include "SPoint3.h"
#include "MElement.h"
// geo.Mode
......@@ -37,7 +38,6 @@ public :
bool empty();
void propagatePartitionInformation(std::vector<int>* partitionSizes = NULL);
} elementMap;
static smooth_data *normals[2];
ExtrudeParams(int Mode = EXTRUDED_ENTITY);
void fill(int type,
double T0, double T1, double T2,
......@@ -64,6 +64,10 @@ public :
double trans[3];
double axe[3], pt[3], angle;
}geo;
// for boundary layers
static smooth_data *normals[2];
static std::vector<SPoint3> normalsCoherence;
};
#endif
......@@ -53,31 +53,28 @@ static void addExtrudeNormals(std::vector<T*> &elements, int invert,
else if(ele->getDim() == 1) // FIXME only valid in XY-plane
n = crossprod(ele->getEdge(0).tangent(), SVector3(0, 0, 1));
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 < ele->getNumVertices(); k++){
MVertex *v = ele->getVertex(k);
ExtrudeParams::normals[index]->add(v->x(), v->y(), v->z(), 3, nn);
}
double nn[3] = {n[0], n[1], n[2]};
for(int k = 0; k < ele->getNumVertices(); k++){
MVertex *v = ele->getVertex(k);
ExtrudeParams::normals[index]->add(v->x(), v->y(), v->z(), 3, nn);
}
}
}
}
typedef std::set<std::pair<bool, int> > infoset;
typedef std::set<std::pair<bool, std::pair<int, int> > > infoset;
template<class T>
static void addExtrudeNormals(std::set<T*> &entities,
std::map<int, infoset> &infos,
std::map<int, int> &views)
std::map<int, infoset> &infos)
{
for(typename std::set<T*>::iterator it = entities.begin(); it != entities.end(); it++){
T *ge = *it;
int view = views[ge->tag()];
infoset info = infos[ge->tag()];
for(infoset::iterator it2 = info.begin(); it2 != info.end(); it2++){
bool invert = it2->first;
int index = it2->second;
int index = it2->second.first;
int view = it2->second.second;
OctreePost *octree = 0;
#if defined(HAVE_POST)
if(view >= 0){
......@@ -102,7 +99,7 @@ int Mesh2DWithBoundaryLayers(GModel *m)
std::set<GFace*> sourceFaces, otherFaces;
std::set<GEdge*> sourceEdges, otherEdges;
std::map<int, infoset> sourceFaceInfo, sourceEdgeInfo;
std::map<int, int> sourceFaceView, sourceEdgeView;
bool normalize = true;
// 2D boundary layers
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++){
......@@ -116,9 +113,10 @@ int Mesh2DWithBoundaryLayers(GModel *m)
Msg::Error("Unknown source curve %d for boundary layer", ep->geo.Source);
return 0;
}
std::pair<bool, int> tags(ep->geo.Source < 0, ep->mesh.BoundaryLayerIndex);
if(ep->mesh.ViewIndex >= 0) normalize = false;
std::pair<bool, std::pair<int, int> > tags(ep->geo.Source < 0, std::pair<int, int>
(ep->mesh.BoundaryLayerIndex, ep->mesh.ViewIndex));
sourceEdgeInfo[from->tag()].insert(tags);
sourceEdgeView[from->tag()] = ep->mesh.ViewIndex;
sourceEdges.insert(from);
}
}
......@@ -136,9 +134,10 @@ int Mesh2DWithBoundaryLayers(GModel *m)
Msg::Error("Unknown source face %d for boundary layer", ep->geo.Source);
return 0;
}
std::pair<bool, int> tags(ep->geo.Source < 0, ep->mesh.BoundaryLayerIndex);
if(ep->mesh.ViewIndex >= 0) normalize = false;
std::pair<bool, std::pair<int, int> > tags(ep->geo.Source < 0, std::pair<int, int>
(ep->mesh.BoundaryLayerIndex, ep->mesh.ViewIndex));
sourceFaceInfo[from->tag()].insert(tags);
sourceFaceView[from->tag()] = ep->mesh.ViewIndex;
sourceFaces.insert(from);
std::list<GEdge*> e = from->edges();
sourceEdges.insert(e.begin(), e.end());
......@@ -170,10 +169,22 @@ int Mesh2DWithBoundaryLayers(GModel *m)
ExtrudeParams::normals[i] = new smooth_data();
}
if(sourceFaces.empty())
addExtrudeNormals(sourceEdges, sourceEdgeInfo, sourceEdgeView);
addExtrudeNormals(sourceEdges, sourceEdgeInfo);
else
addExtrudeNormals(sourceFaces, sourceFaceInfo, sourceFaceView);
if(sourceEdgeView.empty() && sourceFaceView.empty())
addExtrudeNormals(sourceFaces, sourceFaceInfo);
// enforce coherent normals at some points if necessary
for(int i = 0; i < ExtrudeParams::normalsCoherence.size(); i++){
SPoint3 &p(ExtrudeParams::normalsCoherence[i]);
double n0[3], n1[3];
ExtrudeParams::normals[0]->get(p.x(), p.y(), p.z(), 3, n0);
ExtrudeParams::normals[1]->get(p.x(), p.y(), p.z(), 3, n1);
ExtrudeParams::normals[0]->add(p.x(), p.y(), p.z(), 3, n1);
ExtrudeParams::normals[1]->add(p.x(), p.y(), p.z(), 3, n0);
}
// normalize normals if not using post-processing views
if(normalize)
for(int i = 0; i < 2; i++)
ExtrudeParams::normals[i]->normalize();
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -2626,22 +2626,6 @@ Extrude :
&extr, $$);
List_Delete($3);
}
| tExtrude tSTRING '[' FExpr ']' '{' ListOfShapes
{
extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
if(!strcmp($2, "Index"))
extr.mesh.BoundaryLayerIndex = $4;
else if(!strcmp($2, "View"))
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)
| tExtrude tPoint '{' FExpr ',' VExpr '}' tEND
{
......@@ -2893,6 +2877,14 @@ ExtrudeParameter :
}
List_Delete($6);
}
| tUsing tSTRING '[' FExpr ']' tEND
{
if(!strcmp($2, "Index"))
extr.mesh.BoundaryLayerIndex = $4;
else if(!strcmp($2, "View"))
extr.mesh.ViewIndex = $4;
Free($2);
}
;
// T R A N S F I N I T E , R E C O M B I N E & S M O O T H I N G
......@@ -3361,6 +3353,33 @@ Coherence :
yymsg(0, "Unknown coherence command");
Free($2);
}
| tCoherence tPoint '{' RecursiveListOfDouble '}' tEND
{
if(List_Nbr($4) >= 2){
double d;
List_Read($4, 0, &d);
Vertex *target = FindPoint((int)d);
if(!target) yymsg(0, "Could not find Point %d", (int)d);
double x = target->Pos.X, y = target->Pos.Y, z = target->Pos.Z;
for(int i = 1; i < List_Nbr($4); i++){
List_Read($4, i, &d);
Vertex *source = FindPoint((int)d);
if(!source) yymsg(0, "Could not find Point %d", (int)d);
if(target && source){
source->Typ = target->Typ;
source->Pos.X = x;
source->Pos.Y = y;
source->Pos.Z = z;
source->boundaryLayerIndex = target->boundaryLayerIndex;
}
}
ExtrudeParams::normalsCoherence.push_back(SPoint3(x, y, z));
}
else
yymsg(0, "Need at least two points to merge");
ReplaceAllDuplicates();
List_Delete($4);
}
;
......
Point(1) = {0,0,0,0.1};
Point(2) = {1,0,0,0.1};
Line(1) = {1, 2};
tmp1[] = Extrude { Line{1}; Layers{5, 0.1}; Recombine; Using Index[0]; };
tmp2[] = Extrude { Line{-1}; Layers{5, 0.1}; Recombine; Using Index[1]; };
/*
(10)---6-----(9)
8 7
(1)----1-----(2)
3 4
(5)----2-----(6)
*/
Point(1) = {0,0,0,0.1};
Point(2) = {1,0,0,0.1};
Point(3) = {0,0,1,0.1};
Point(4) = {1,0,1,0.1};
Line(1) = {1, 2};
Line(2) = {1, 3};
Line(3) = {3, 4};
Line(4) = {4, 2};
Line Loop(5) = {1, -4, -3, -2};
Plane Surface(6) = {5};
tmp1[] = Extrude { Surface{6}; Layers{5, 0.1}; Recombine; Using Index[0]; };
tmp2[] = Extrude { Surface{-6}; Layers{5, 0.1}; Recombine; Using Index[1]; };
......@@ -39,6 +39,10 @@ Ruled Surface(26) = {25};
Line Loop(27) = {-4,12,-6};
Ruled Surface(28) = {27};
tmp[] = Extrude View [0] {
Surface{14:28:2}; Layers{5, 0.2}; Recombine;
tmp[] = Extrude {
Surface{14:28:2}; Layers{5, 0.2}; Recombine; Using View[0]; Using Index[0];
};
// test 2nd bnd layer
Extrude { Surface{14:28:2}; Layers{5, -0.2}; Recombine; Using View[0]; Using Index[1]; }
lc = 0.2;
Point(1) = {0.0,0.0,0.0,lc};
Point(2) = {1,0.0,0.0,lc};
Point(3) = {0,1,0.0,lc};
Circle(1) = {2,1,3};
Point(4) = {-1,0,0.0,lc};
Point(5) = {0,-1,0.0,lc};
Circle(2) = {3,1,4};
Circle(3) = {4,1,5};
Circle(4) = {5,1,2};
Point(6) = {0,0,-1,lc};
Point(7) = {0,0,1,lc};
Circle(5) = {3,1,6};
Circle(6) = {6,1,5};
Circle(7) = {5,1,7};
Circle(8) = {7,1,3};
Circle(9) = {2,1,7};
Circle(10) = {7,1,4};
Circle(11) = {4,1,6};
Circle(12) = {6,1,2};
Line Loop(13) = {2,8,-10};
Ruled Surface(14) = {13};
Line Loop(15) = {10,3,7};
Ruled Surface(16) = {15};
Line Loop(17) = {-8,-9,1};
Ruled Surface(18) = {17};
Line Loop(19) = {-11,-2,5};
Ruled Surface(20) = {19};
Line Loop(21) = {-5,-12,-1};
Ruled Surface(22) = {21};
Line Loop(23) = {-3,11,6};
Ruled Surface(24) = {23};
Line Loop(25) = {-7,4,9};
Ruled Surface(26) = {25};
Line Loop(27) = {-4,12,-6};
Ruled Surface(28) = {27};
Extrude { Surface{14:28:2}; Layers{5, 0.1}; Recombine; Using Index[0]; }
Extrude { Surface{-14,-16,-18,-20,-22,-24,-26,-28}; Layers{5, 0.1}; Recombine; Using Index[1]; }
Point(1) = {0, 0.5, 0, 0.1};
Point(2) = {0.1, 0.7, 0, 0.1};
Point(3) = {0.3, 0.8, 0, 0.1};
Point(4) = {1, 0.8, 0, 0.1};
Point(5) = {2.1, 0.5, 0, 0.1};
Point(6) = {3, 0.5, 0, 0.1};
Point(7) = {1, 0.4, 0, 0.1};
Point(8) = {0.3, 0.4, 0, 0.1};
Point(9) = {0.1, 0.4, 0, 0.1};
BSpline(1) = {5, 4, 3, 2, 1};
BSpline(2) = {1, 9, 8, 7, 5};
Line(3) = {5, 6};
Extrude { Line{1,-3}; Layers{5,0.1}; Using Index[0]; }
Extrude { Line{2,3}; Layers{5,0.1}; Using Index[1]; }
// fix leading edge by hand
Coherence Point {25, 16};
Point(31) = {-0.5, 1.5, 0, 0.2};
Point(32) = {-0.5, -0.5, 0, 0.2};
Point(33) = {3.5, -0.5, 0, 0.2};
Point(34) = {3.5, 1.5, 0, 0.2};
Line(20) = {32, 33};
Line(21) = {33, 34};
Line(22) = {34, 31};
Line(23) = {31, 32};
Line Loop(24) = {22, 23, 20, 21};
Line Loop(25) = {4, 12, 16, -18, 9, 8};
Plane Surface(26) = {24, 25};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment