Commit 9fd91fac authored by Christophe Geuzaine's avatar Christophe Geuzaine

Merge branch 'master' of https://gitlab.onelab.info/gmsh/gmsh

parents 8894f633 efd6a55c
This diff is collapsed.
......@@ -28,6 +28,7 @@ public:
// 2 - elements
int vectorDim; // Number of dimensions in a vector
// (only relevant for a 2D mesh)
bool structuredMesh; // = 1 if structured mesh, = 0 if un-structured mesh
bool writeBC;
bool writeUserDef; // T - write user-defined elements for
// element types unsupported by CGNS
......@@ -44,6 +45,7 @@ public:
bocoLocation = 0;
normalSource = 1;
vectorDim = 2;
structuredMesh = 0;
writeBC = true;
writeUserDef = false;
}
......
This diff is collapsed.
......@@ -3020,21 +3020,38 @@ GenericField::~GenericField(){};
double GenericField::operator()(double x, double y, double z, GEntity *ge)
{
std::vector<double> sizes(cbs.size());
std::vector<ptrfunction>::iterator itcbs = cbs.begin();
std::vector<void *>::iterator itdata = user_data.begin();
for(std::vector<double>::iterator it = sizes.begin(); it != sizes.end();
it++, itdata++, itcbs++) {
bool ok = (*itcbs)(x, y, z, (*itdata), (*it));
if(!ok) {
std::vector<double> sizes(cbs_with_data.size() + cbs_extended_with_data.size());
std::vector<double>::iterator it = sizes.begin();
// Go over all callback functions
for(std::vector<std::pair<ptrfunction, void*> >::iterator itcbs = cbs_with_data.begin();
itcbs != cbs_with_data.end(); itcbs++, it++){
bool ok = (itcbs->first)(x, y, z, itcbs->second, (*it));
if (!ok){
Msg::Warning("GenericField::ERROR from callback ");
}
}
// Go over all extended callback functions
for (std::vector<std::pair<ptrfunctionextended, void*> >::iterator itcbs = cbs_extended_with_data.begin();
itcbs != cbs_extended_with_data.end(); itcbs++, it++){
bool ok = (itcbs->first)(x, y, z, ge, itcbs->second, (*it));
if (!ok){
Msg::Warning("GenericField::ERROR from callback ");
}
}
// Take minimum value
return (*std::min_element(sizes.begin(), sizes.end()));
}
void GenericField::setCallbackWithData(ptrfunction fct, void *data)
{
user_data.push_back(data);
cbs.push_back(fct);
cbs_with_data.push_back(std::make_pair(fct, data));
}
void GenericField::setCallbackWithData(ptrfunctionextended fct, void *data)
{
cbs_extended_with_data.push_back(std::make_pair(fct, data));
}
......@@ -452,6 +452,8 @@ public:
// callback prototypes:
// this callback is called with a void* previously given to the GenericField !
typedef bool (*ptrfunction)(double, double, double, void *, double &);
// this callback also takes the GEntity object into account
typedef bool (*ptrfunctionextended)(double, double, double, void*, void*, double&);
GenericField();
~GenericField();
......@@ -461,10 +463,11 @@ public:
// sets the callbacks
void setCallbackWithData(ptrfunction fct, void *data);
void setCallbackWithData(ptrfunctionextended fct, void *data);
private:
std::vector<ptrfunction> cbs; // the callbacks
std::vector<void *> user_data; // the data to be sent to the callbacks
std::vector<std::pair<ptrfunction, void*> > cbs_with_data; // the callbacks with the data to be sent to them
std::vector<std::pair<ptrfunctionextended, void*> > cbs_extended_with_data; // the extended callbacks with the data to be sent to them
};
#endif
......@@ -123,6 +123,7 @@ void buildMeshGenerationDataStructures(
setLcs(gf->triangles[i], vSizesMap, data);
// take care of embedded vertices
std::set<MVertex *> embeddedVertices;
{
std::set<GVertex *> emb_vertx = gf->embeddedVertices();
std::set<GVertex *>::iterator itvx = emb_vertx.begin();
......@@ -131,6 +132,7 @@ void buildMeshGenerationDataStructures(
MVertex *v = *((*itvx)->mesh_vertices.begin());
vSizesMap[v] =
std::min(vSizesMap[v], (*itvx)->prescribedMeshSizeAtVertex());
embeddedVertices.insert(v);
}
++itvx;
}
......@@ -174,14 +176,23 @@ void buildMeshGenerationDataStructures(
it != vSizesMap.end(); ++it) {
SPoint2 param;
reparamMeshVertexOnFace(it->first, gf, param);
data.addVertex(it->first, param[0], param[1], it->second, it->second);
// Add size of background mesh to embedded vertices. For the other nodes, use the size in vSizesMap
const double lcBGM = (embeddedVertices.count(it->first) > 0) ?
BGM_MeshSize(gf, param[0], param[1], it->first->x(), it->first->y(), it->first->z()) : it->second;
data.addVertex (it->first, param[0], param[1], it->second, lcBGM);
}
for(unsigned int i = 0; i < gf->triangles.size(); i++) {
double lc = 0.3333333333 *
(data.vSizes[data.getIndex(gf->triangles[i]->getVertex(0))] +
data.vSizes[data.getIndex(gf->triangles[i]->getVertex(1))] +
data.vSizes[data.getIndex(gf->triangles[i]->getVertex(2))]);
AllTris.insert(new MTri3(gf->triangles[i], lc, 0, &data, gf));
double lcBGM = 0.3333333333 *
(data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(0))] +
data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(1))] +
data.vSizesBGM[data.getIndex(gf->triangles[i]->getVertex(2))]);
double LL = Extend1dMeshIn2dSurfaces() ? std::min(lc, lcBGM) : lcBGM;
AllTris.insert(new MTri3(gf->triangles[i], LL, 0, &data, gf));
}
gf->triangles.clear();
connectTriangles(AllTris);
......
This diff is collapsed.
//+
Point(1) = {-10.0, -10.0, 0, 0.1};
//+
Point(2) = {-10.0, 10.0, 0, 0.1};
//+
Point(3) = {-3.0, -10.0, 0, 0.1};
//+
Point(4) = {-3.0, 10.0, 0, 0.1};
//+
Point(5) = {11.0, -10.0, 0, 0.1};
//+
Point(6) = {11.0, 10.0, 0, 0.1};
//+
Point(7) = {40.0, -10.0, 0, 0.1};
//+
Point(8) = {40.0, 10.0, 0, 0.1};
//+
Point(9) = {-10.0, -3.75, 0, 0.1};
//+
Point(10) = {-10.0, 3.75, 0, 0.1};
//+
Point(11) = {40.0, -3.75, 0, 0.1};
//+
Point(12) = {40.0, 3.75, 0, 0.1};
//+
Point(13) = {-3.25, -4.25, 0, 0.1};
//+
Point(14) = {-3.25, 4.25, 0, 0.1};
//+
Point(15) = {9.5, -3.5, 0, 0.1};
//+
Point(16) = {9.5, 3.5, 0, 0.1};
//+
Point(17) = {0.0, 0.0, 0, 0.1};
//+
Point(18) = {-4.128, 0.0, 0, 0.1};
//+
Point(19) = {9.792, 0.0, 0, 0.1};
//+
Point(20) = {2.9, -4.783, 0, 0.1};
//+
Point(21) = {2.9, 4.783, 0, 0.1};
//+
Point(22) = {-0.707107, -0.707107, 0, 0.1};
//+
Point(23) = {-0.707107, 0.707107, 0, 0.1};
//+
Point(24) = {0.707107, 0.707107, 0, 0.1};
//+
Point(25) = {0.707107, -0.707107, 0, 0.1};
//+
Point(26) = {0.0, 1.0, 0, 0.1};
//+
Point(27) = {0.0, -1.0, 0, 0.1};
//+
Point(28) = {1.0, 0.0, 0, 0.1};
//+
Point(29) = {-1.0, 0.0, 0, 0.1};
//+
Circle(1) = {23, 17, 24};
//+
Circle(2) = {24, 17, 25};
//+
Circle(3) = {25, 17, 22};
//+
Circle(4) = {22, 17, 23};
//+
Spline(5) = {14, 21, 16};
//+
Spline(6) = {16, 19, 15};
//+
Spline(7) = {15, 20, 13};
//+
Spline(8) = {13, 18, 14};
//+
Line(9) = {23, 14};
//+
Line(10) = {24, 16};
//+
Line(11) = {25, 15};
//+
Line(12) = {22, 13};
//+
Line(13) = {1, 3};
//+
Line(14) = {3, 5};
//+
Line(15) = {5, 7};
//+
Line(16) = {2, 4};
//+
Line(17) = {4, 6};
//+
Line(18) = {6, 8};
//+
Line(19) = {1, 9};
//+
Line(20) = {9, 10};
//+
Line(21) = {10, 2};
//+
Line(22) = {7, 11};
//+
Line(23) = {11, 12};
//+
Line(24) = {12, 8};
//+
Line(25) = {13, 3};
//+
Line(26) = {13, 9};
//+
Line(27) = {14, 10};
//+
Line(28) = {14, 4};
//+
Line(29) = {16, 6};
//+
Line(30) = {16, 12};
//+
Line(31) = {15, 5};
//+
Line(32) = {15, 11};
//+
Curve Loop(1) = {25, -13, 19, -26};
//+
Surface(1) = {1};
//+
Curve Loop(2) = {14, -31, 7, 25};
//+
Surface(2) = {2};
//+
Curve Loop(3) = {32, -22, -15, -31};
//+
Surface(3) = {3};
//+
Curve Loop(4) = {20, -27, -8, 26};
//+
Surface(4) = {4};
//+
Curve Loop(5) = {6, 32, 23, -30};
//+
Surface(5) = {5};
//+
Curve Loop(6) = {27, 21, 16, -28};
//+
Surface(6) = {6};
//+
Curve Loop(7) = {28, 17, -29, -5};
//+
Surface(7) = {7};
//+
Curve Loop(8) = {29, 18, -24, -30};
//+
Surface(8) = {8};
//+
Curve Loop(9) = {8, -9, -4, 12};
//+
Surface(9) = {9};
//+
Curve Loop(10) = {9, 5, -10, -1};
//+
Surface(10) = {10};
//+
Curve Loop(11) = {10, 6, -11, -2};
//+
Surface(11) = {11};
//+
Curve Loop(12) = {11, 7, -12, -3};
//+
Surface(12) = {12};
//+
Transfinite Curve {13, 26, 27, 16} = 41 Using Progression 1.0;
//+
Transfinite Curve {14, 7, 3, 1, 5, 17} = 61 Using Progression 1.0;
//+
Transfinite Curve {15, 32, 30, 18} = 121 Using Progression 1.0;
//+
Transfinite Curve {19, 25, 31, 22} = 51 Using Progression 1.0;
//+
Transfinite Curve {20, 8, 4, 2, 6, 23} = 61 Using Progression 1.0;
//+
Transfinite Curve {21, 28, 29, 24} = 51 Using Progression 1.0;
//+
Transfinite Curve {9, 10, 11, 12} = 91 Using Progression 1.025;
//+
Transfinite Surface {1} = {1, 3, 13, 9};
//+
Transfinite Surface {2} = {3, 5, 15, 13};
//+
Transfinite Surface {3} = {5, 7, 11, 15};
//+
Transfinite Surface {4} = {9, 13, 14, 10};
//+
Transfinite Surface {5} = {15, 11, 12, 16};
//+
Transfinite Surface {6} = {10, 14, 4, 2};
//+
Transfinite Surface {7} = {14, 16, 6, 4};
//+
Transfinite Surface {8} = {16, 12, 8, 6};
//+
Transfinite Surface {9} = {22, 23, 14, 13};
//+
Transfinite Surface {10} = {24, 16, 14, 23};
//+
Transfinite Surface {11} = {25, 15, 16, 24};
//+
Transfinite Surface {12} = {22, 13, 15, 25};
//+
Recombine Surface {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
//+
Physical Curve("INLET") = {21, 20, 19};
//+
Physical Curve("OUTLET") = {24, 23, 22};
//+
Physical Curve("TOP") = {18, 17, 16};
//+
Physical Curve("BOTTOM") = {13, 14, 15};
//+
Physical Curve("CYLINDER") = {3, 2, 1, 4};
//+
Physical Surface("AIR") = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
//+
Mesh 2;
Mesh.RecombineAll = 1;
Mesh.Format = 32; //CGNS - need to choose option through GUI to write out Structured mesh - command prompt version won't do
//+Mesh.Format = 28; //P3D
//+
PostProcessing.SaveMesh = 1;
lc=1000;
Point(1) = {0, 0, 0,lc*.1};
Point(2) = {0, 10, 0,lc};
Point(3) = {10, 10, 0,lc};
Point(4) = {10, 0, 0,lc};
Line(1) = {2, 3};
Line(2) = {3, 4};
Line(3) = {4, 1};
Line(4) = {1, 2};
Line Loop(5) = {1, 2, 3, 4};
Plane Surface(10) = {5};
Transfinite Curve {3, 2, 1, 4} = 11 Using Progression 1;
Transfinite Surface {10} = {1, 4, 3, 2};
Recombine Surface {10};
Physical Curve("TOP") = {1};
Physical Curve("BOTTOM") = {3};
Physical Curve("LEFT") = {4};
Physical Curve("RIGHT") = {2};
Mesh 2;
Mesh.RecombineAll = 1;
Mesh.Format = 32; //CGNS - User has to choose "Write Structured mesh" option from GUI to write "Recombined mesh" - command prompt version will not do
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment