diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 83f5bc192d73bd786e2bdbffe09cf3c52f488c16..d5fb62376aa11d22f8ac7508e744552bb17a8048 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -1481,7 +1481,10 @@ optionWindow::optionWindow(int deltaFontSize) Fl_Button *b2 = new Fl_Button (L + 2 * WB, 2 * WB + 9 * BH, BW, BH, "Restore all options to default settings"); b2->callback(options_restore_defaults_cb); - b2->labelcolor(FL_DARK_RED); + if(CTX::instance()->guiColorScheme) + b2->color(FL_DARK_RED); + else + b2->labelcolor(FL_DARK_RED); o->end(); } diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp index 00f7dbbea438797cbc74f64486f995c4be5a2dba..e710158ac8a8c0df313a274f4db13f3eff27f03d 100644 --- a/Mesh/BackgroundMesh.cpp +++ b/Mesh/BackgroundMesh.cpp @@ -31,429 +31,10 @@ #include "linearSystemPETSc.h" #endif -// computes the characteristic length of the mesh at a vertex in order -// to have the geometry captured with accuracy. A parameter called -// CTX::instance()->mesh.minCircPoints tells the minimum number of points per -// radius of curvature - #if defined(HAVE_ANN) static int _NBANN = 2; #endif -//SMetric3 buildMetricTangentToCurve(SVector3 &t, double l_t, double l_n) -//{ -// if (l_t == 0.0) return SMetric3(1.e-22); -// SVector3 a; -// if (fabs(t(0)) <= fabs(t(1)) && fabs(t(0)) <= fabs(t(2))){ -// a = SVector3(1,0,0); -// } -// else if (fabs(t(1)) <= fabs(t(0)) && fabs(t(1)) <= fabs(t(2))){ -// a = SVector3(0,1,0); -// } -// else{ -// a = SVector3(0,0,1); -// } -// SVector3 b = crossprod (t,a); -// SVector3 c = crossprod (b,t); -// b.normalize(); -// c.normalize(); -// t.normalize(); -// SMetric3 Metric (1./(l_t*l_t),1./(l_n*l_n),1./(l_n*l_n),t,b,c); -// // printf("bmttc %g %g %g %g %g\n",l_t,l_n,Metric(0,0),Metric(0,1),Metric(1,1)); -// return Metric; -//} - -//SMetric3 buildMetricTangentToSurface(SVector3 &t1, SVector3 &t2, -// double l_t1, double l_t2, double l_n) -//{ -// t1.normalize(); -// t2.normalize(); -// SVector3 n = crossprod (t1,t2); -// n.normalize(); -// -// l_t1 = std::max(l_t1, CTX::instance()->mesh.lcMin); -// l_t2 = std::max(l_t2, CTX::instance()->mesh.lcMin); -// l_t1 = std::min(l_t1, CTX::instance()->mesh.lcMax); -// l_t2 = std::min(l_t2, CTX::instance()->mesh.lcMax); -// SMetric3 Metric (1./(l_t1*l_t1),1./(l_t2*l_t2),1./(l_n*l_n),t1,t2,n); -// return Metric; -//} - -//SMetric3 max_edge_curvature_metric(const GVertex *gv) -//{ -// SMetric3 val (1.e-12); -// std::list<GEdge*> l_edges = gv->edges(); -// for (std::list<GEdge*>::const_iterator ite = l_edges.begin(); -// ite != l_edges.end(); ++ite){ -// GEdge *_myGEdge = *ite; -// Range<double> range = _myGEdge->parBounds(0); -// SMetric3 cc; -// if (gv == _myGEdge->getBeginVertex()) { -// SVector3 t = _myGEdge->firstDer(range.low()); -// t.normalize(); -// double l_t = ((2 * M_PI) /( fabs(_myGEdge->curvature(range.low())) -// * CTX::instance()->mesh.minCircPoints )); -// double l_n = 1.e12; -// cc = buildMetricTangentToCurve(t,l_t,l_n); -// } -// else { -// SVector3 t = _myGEdge->firstDer(range.high()); -// t.normalize(); -// double l_t = ((2 * M_PI) /( fabs(_myGEdge->curvature(range.high())) -// * CTX::instance()->mesh.minCircPoints )); -// double l_n = 1.e12; -// cc = buildMetricTangentToCurve(t,l_t,l_n); -// } -// val = intersection(val,cc); -// } -// return val; -//} - -//SMetric3 max_edge_curvature_metric(const GEdge *ge, double u) -//{ -// SVector3 t = ge->firstDer(u); -// t.normalize(); -// double l_t = ((2 * M_PI) /( fabs(ge->curvature(u)) -// * CTX::instance()->mesh.minCircPoints )); -// double l_n = 1.e12; -// return buildMetricTangentToCurve(t,l_t,l_n); -//} - -//static double max_edge_curvature(const GVertex *gv) -//{ -// double val = 0; -// std::list<GEdge*> l_edges = gv->edges(); -// for (std::list<GEdge*>::const_iterator ite = l_edges.begin(); -// ite != l_edges.end(); ++ite){ -// GEdge *_myGEdge = *ite; -// Range<double> range = _myGEdge->parBounds(0); -// double cc; -// if (gv == _myGEdge->getBeginVertex()) cc = _myGEdge->curvature(range.low()); -// else cc = _myGEdge->curvature(range.high()); -// val = std::max(val, cc); -// } -// return val; -//} -// -//static double max_surf_curvature(const GEdge *ge, double u) -//{ -// double val = 0; -// std::list<GFace *> faces = ge->faces(); -// std::list<GFace *>::iterator it = faces.begin(); -// while(it != faces.end()){ -// if ((*it)->geomType() != GEntity::CompoundSurface && -// (*it)->geomType() != GEntity::DiscreteSurface){ -// SPoint2 par = ge->reparamOnFace((*it), u, 1); -// double cc = (*it)->curvature(par); -// val = std::max(cc, val); -// } -// ++it; -// } -// return val; -//} - - -// static double max_surf_curvature_vertex(const GVertex *gv) -// { -// double val = 0; -// std::list<GEdge*> l_edges = gv->edges(); -// for (std::list<GEdge*>::const_iterator ite = l_edges.begin(); -// ite != l_edges.end(); ++ite){ -// GEdge *_myGEdge = *ite; -// Range<double> bounds = _myGEdge->parBounds(0); -// if (gv == _myGEdge->getBeginVertex()) -// val = std::max(val, max_surf_curvature(_myGEdge, bounds.low())); -// else -// val = std::max(val, max_surf_curvature(_myGEdge, bounds.high())); -// } -// return val; -// } - - -//SMetric3 metric_based_on_surface_curvature(const GFace *gf, double u, double v, -// bool surface_isotropic, -// double d_normal , -// double d_tangent_max) -//{ -// if (gf->geomType() == GEntity::Plane)return SMetric3(1.e-12); -// double cmax, cmin; -// SVector3 dirMax,dirMin; -// cmax = gf->curvatures(SPoint2(u, v),&dirMax, &dirMin, &cmax,&cmin); -// if (cmin == 0)cmin =1.e-12; -// if (cmax == 0)cmax =1.e-12; -// double lambda1 = ((2 * M_PI) /( fabs(cmin) * CTX::instance()->mesh.minCircPoints ) ); -// double lambda2 = ((2 * M_PI) /( fabs(cmax) * CTX::instance()->mesh.minCircPoints ) ); -// SVector3 Z = crossprod(dirMax,dirMin); -// if (surface_isotropic) lambda2 = lambda1 = std::min(lambda2,lambda1); -// dirMin.normalize(); -// dirMax.normalize(); -// Z.normalize(); -// lambda1 = std::max(lambda1, CTX::instance()->mesh.lcMin); -// lambda2 = std::max(lambda2, CTX::instance()->mesh.lcMin); -// lambda1 = std::min(lambda1, CTX::instance()->mesh.lcMax); -// lambda2 = std::min(lambda2, CTX::instance()->mesh.lcMax); -// double lambda3 = std::min(d_normal, CTX::instance()->mesh.lcMax); -// lambda3 = std::max(lambda3, CTX::instance()->mesh.lcMin); -// lambda1 = std::min(lambda1, d_tangent_max); -// lambda2 = std::min(lambda2, d_tangent_max); -// -// SMetric3 curvMetric (1./(lambda1*lambda1),1./(lambda2*lambda2), -// 1./(lambda3*lambda3), -// dirMin, dirMax, Z ); -// return curvMetric; -//} - -//static SMetric3 metric_based_on_surface_curvature(const GEdge *ge, double u, bool iso_surf) -//{ -// const GEdgeCompound* ptrCompoundEdge = dynamic_cast<const GEdgeCompound*>(ge); -// if (ptrCompoundEdge){ -// double cmax, cmin; -// SVector3 dirMax,dirMin; -// cmax = ptrCompoundEdge->curvatures(u,&dirMax, &dirMin, &cmax,&cmin); -// if (cmin == 0)cmin =1.e-12; -// if (cmax == 0)cmax =1.e-12; -// double lambda2 = ((2 * M_PI) /( fabs(cmax) * CTX::instance()->mesh.minCircPoints ) ); -// double lambda1 = ((2 * M_PI) /( fabs(cmin) * CTX::instance()->mesh.minCircPoints ) ); -// SVector3 Z = crossprod(dirMax,dirMin); -// -// lambda1 = std::max(lambda1, CTX::instance()->mesh.lcMin); -// lambda2 = std::max(lambda2, CTX::instance()->mesh.lcMin); -// lambda1 = std::min(lambda1, CTX::instance()->mesh.lcMax); -// lambda2 = std::min(lambda2, CTX::instance()->mesh.lcMax); -// -// SMetric3 curvMetric (1. / (lambda1 * lambda1), 1. / (lambda2 * lambda2), -// 1.e-12, dirMin, dirMax, Z); -// return curvMetric; -// } -// else{ -// SMetric3 mesh_size(1.e-12); -// std::list<GFace *> faces = ge->faces(); -// std::list<GFace *>::iterator it = faces.begin(); -// // we choose the metric eigenvectors to be the ones -// // related to the edge ... -// SMetric3 curvMetric = max_edge_curvature_metric(ge, u); -// while(it != faces.end()){ -// if (((*it)->geomType() != GEntity::CompoundSurface) && -// ((*it)->geomType() != GEntity::DiscreteSurface)){ -// SPoint2 par = ge->reparamOnFace((*it), u, 1); -// SMetric3 m = metric_based_on_surface_curvature (*it, par.x(), par.y(), iso_surf); -// curvMetric = intersection_conserveM1(curvMetric,m); -// } -// ++it; -// } -// -// return curvMetric; -// } -//} - -//static SMetric3 metric_based_on_surface_curvature(const GVertex *gv, bool iso_surf) -//{ -// SMetric3 mesh_size(1.e-15); -// std::list<GEdge*> l_edges = gv->edges(); -// for (std::list<GEdge*>::const_iterator ite = l_edges.begin(); -// ite != l_edges.end(); ++ite){ -// GEdge *_myGEdge = *ite; -// Range<double> bounds = _myGEdge->parBounds(0); -// -// // ES: Added extra if condition to use the code below only with compund curves -// // This is because we want to call the function -// // metric_based_on_surface_curvature(const GEdge *ge, double u) for the case when -// // ge is a compound edge -// if (_myGEdge->geomType() == GEntity::CompoundCurve){ -// if (gv == _myGEdge->getBeginVertex()) -// mesh_size = intersection -// (mesh_size, -// metric_based_on_surface_curvature(_myGEdge, bounds.low(), iso_surf)); -// else -// mesh_size = intersection -// (mesh_size, -// metric_based_on_surface_curvature(_myGEdge, bounds.high(), iso_surf)); -// } -// } -// return mesh_size; -//} - -// the mesh vertex is classified on a model vertex. we compute the -// maximum of the curvature of model faces surrounding this point if -// it is classified on a model edge, we do the same for all model -// faces surrounding it if it is on a model face, we compute the -// curvature at this location - -//static double LC_MVertex_CURV(GEntity *ge, double U, double V) -//{ -// double Crv = 0; -// switch(ge->dim()){ -// case 0: -// Crv = max_edge_curvature((const GVertex *)ge); -// //Crv = std::max(max_surf_curvature_vertex((const GVertex *)ge), Crv); -// // Crv = max_surf_curvature((const GVertex *)ge); -// break; -// case 1: -// { -// GEdge *ged = (GEdge *)ge; -// Crv = ged->curvature(U); -// Crv = std::max(Crv, max_surf_curvature(ged, U)); -// // Crv = max_surf_curvature(ged, U); -// } -// break; -// case 2: -// { -// GFace *gf = (GFace *)ge; -// Crv = gf->curvature(SPoint2(U, V)); -// } -// break; -// } -// double lc = Crv > 0 ? 2 * M_PI / Crv / CTX::instance()->mesh.minCircPoints : MAX_LC; -// return lc; -//} - -//SMetric3 LC_MVertex_CURV_ANISO(GEntity *ge, double U, double V) -//{ -// bool iso_surf = CTX::instance()->mesh.lcFromCurvature == 2; -// -// switch(ge->dim()){ -// case 0: return metric_based_on_surface_curvature((const GVertex *)ge, iso_surf); -// case 1: return metric_based_on_surface_curvature((const GEdge *)ge, U, iso_surf); -// case 2: return metric_based_on_surface_curvature((const GFace *)ge, U, V, iso_surf); -// } -// Msg::Error("Curvature control impossible to compute for a volume!"); -// return SMetric3(); -//} - -// compute the mesh size at a given vertex due to prescribed sizes at -// mesh vertices -//static double LC_MVertex_PNTS(GEntity *ge, double U, double V) -//{ -// switch(ge->dim()){ -// case 0: -// { -// GVertex *gv = (GVertex *)ge; -// double lc = gv->prescribedMeshSizeAtVertex(); -// // FIXME we might want to remove this to make all lc treatment consistent -// if(lc >= MAX_LC) return CTX::instance()->lc / 10.; -// return lc; -// } -// case 1: -// { -// GEdge *ged = (GEdge *)ge; -// GVertex *v1 = ged->getBeginVertex(); -// GVertex *v2 = ged->getEndVertex(); -// if (v1 && v2){ -// Range<double> range = ged->parBounds(0); -// double a = (U - range.low()) / (range.high() - range.low()); -// double lc = (1 - a) * v1->prescribedMeshSizeAtVertex() + -// (a) * v2->prescribedMeshSizeAtVertex() ; -// // FIXME we might want to remove this to make all lc treatment consistent -// if(lc >= MAX_LC) return CTX::instance()->lc / 10.; -// return lc; -// } -// else -// return MAX_LC; -// } -// default: -// return MAX_LC; -// } -//} - -//// This is the only function that is used by the meshers -//double BGM_MeshSize(GEntity *ge, double U, double V, -// double X, double Y, double Z) -//{ -// // default lc (mesh size == size of the model) -// double l1 = CTX::instance()->lc; -// -// // lc from points -// double l2 = MAX_LC; -// if(CTX::instance()->mesh.lcFromPoints && ge->dim() < 2) -// l2 = LC_MVertex_PNTS(ge, U, V); -// -// // lc from curvature -// double l3 = MAX_LC; -// if(CTX::instance()->mesh.lcFromCurvature && ge->dim() < 3) -// l3 = LC_MVertex_CURV(ge, U, V); -// -// // lc from fields -// double l4 = MAX_LC; -// FieldManager *fields = ge->model()->getFields(); -// if(fields->getBackgroundField() > 0){ -// Field *f = fields->get(fields->getBackgroundField()); -// if(f) l4 = (*f)(X, Y, Z, ge); -// } -// -// // take the minimum, then constrain by lcMin and lcMax -// double lc = std::min(std::min(std::min(l1, l2), l3), l4); -// lc = std::max(lc, CTX::instance()->mesh.lcMin); -// lc = std::min(lc, CTX::instance()->mesh.lcMax); -// -// if(lc <= 0.){ -// Msg::Error("Wrong mesh element size lc = %g (lcmin = %g, lcmax = %g)", -// lc, CTX::instance()->mesh.lcMin, CTX::instance()->mesh.lcMax); -// lc = l1; -// } -// -// //Msg::Debug("BGM X,Y,Z=%g,%g,%g L4=%g L3=%g L2=%g L1=%g LC=%g LFINAL=%g DIM =%d ", -// //X, Y, Z, l4, l3, l2, l1, lc, lc * CTX::instance()->mesh.lcFactor, ge->dim()); -// -// //Emi fix -// //if (lc == l1) lc /= 10.; -// -// return lc * CTX::instance()->mesh.lcFactor; -//} - - -//// anisotropic version of the background field -//SMetric3 BGM_MeshMetric(GEntity *ge, -// double U, double V, -// double X, double Y, double Z) -//{ -// -// // Metrics based on element size -// // Element size = min. between default lc and lc from point (if applicable), constrained by lcMin and lcMax -// double lc = CTX::instance()->lc; -// if(CTX::instance()->mesh.lcFromPoints && ge->dim() < 2) lc = std::min(lc, LC_MVertex_PNTS(ge, U, V)); -// lc = std::max(lc, CTX::instance()->mesh.lcMin); -// lc = std::min(lc, CTX::instance()->mesh.lcMax); -// if(lc <= 0.){ -// Msg::Error("Wrong mesh element size lc = %g (lcmin = %g, lcmax = %g)", -// lc, CTX::instance()->mesh.lcMin, CTX::instance()->mesh.lcMax); -// lc = CTX::instance()->lc; -// } -// SMetric3 m0(1./(lc*lc)); -// -// // Intersect with metrics from fields if applicable -// FieldManager *fields = ge->model()->getFields(); -// SMetric3 m1 = m0; -// if(fields->getBackgroundField() > 0){ -// Field *f = fields->get(fields->getBackgroundField()); -// if(f) { -// SMetric3 l4; -// if (!f->isotropic()) (*f)(X, Y, Z, l4, ge); -// else { -// const double L = (*f)(X, Y, Z, ge); -// l4 = SMetric3(1/(L*L)); -// } -// m1 = intersection(l4, m0); -// } -// } -// -// // Intersect with metrics from curvature if applicable -// SMetric3 m = (CTX::instance()->mesh.lcFromCurvature && ge->dim() < 3) ? -// intersection(m1, LC_MVertex_CURV_ANISO(ge, U, V)) : m1; -// -// return m; -// -//} - -//bool Extend1dMeshIn2dSurfaces() -//{ -// return CTX::instance()->mesh.lcExtendFromBoundary ? true : false; -//} - -//bool Extend2dMeshIn3dVolumes() -//{ -// return CTX::instance()->mesh.lcExtendFromBoundary ? true : false; -//} - void backgroundMesh::set(GFace *gf) { if (_current) delete _current; @@ -858,6 +439,7 @@ void backgroundMesh::propagateCrossFieldHJ(GFace *_gf) propagateCrossField (_gf, &ONE); } + void backgroundMesh::propagateCrossField(GFace *_gf, simpleFunction<double> *ONE) { std::map<MVertex*,double> _cosines4,_sines4; diff --git a/Mesh/BackgroundMesh.h b/Mesh/BackgroundMesh.h index 7eeba7034825b7974d7567055b4f85391b010465..812ad9c60b06962b8bc73bed7d03f70cb440d623 100644 --- a/Mesh/BackgroundMesh.h +++ b/Mesh/BackgroundMesh.h @@ -6,7 +6,6 @@ #ifndef _BACKGROUND_MESH_H_ #define _BACKGROUND_MESH_H_ -//#include "STensor3.h" #include <math.h> #include <vector> #include <list> @@ -24,13 +23,13 @@ class GEdge; class MElement; class MVertex; -struct crossField2d +struct crossField2d { double _angle; static void normalizeAngle (double &angle) { - if (angle < 0) + if (angle < 0) while ( angle < 0 ) angle += (M_PI * .5); - else if (angle >= M_PI * .5) + else if (angle >= M_PI * .5) while ( angle >= M_PI * .5 ) angle -= (M_PI * .5); } crossField2d (MVertex*, GEdge*); @@ -45,11 +44,11 @@ class backgroundMesh : public simpleFunction<double> MElementOctree *_octree; std::vector<MVertex*> _vertices; std::vector<MElement*> _triangles; - std::map<MVertex*,double> _sizes; + std::map<MVertex*,double> _sizes; std::map<MVertex*,MVertex*> _3Dto2D; std::map<MVertex*,MVertex*> _2Dto3D; - std::map<MVertex*,double> _distance; - std::map<MVertex*,double> _angles; + std::map<MVertex*,double> _distance; + std::map<MVertex*,double> _angles; static backgroundMesh * _current; backgroundMesh(GFace *, bool dist = false); ~backgroundMesh(); @@ -76,12 +75,12 @@ class backgroundMesh : public simpleFunction<double> void updateSizes(GFace *); double operator () (double u, double v, double w) const; // returns mesh size bool inDomain (double u, double v, double w) const; // returns true if in domain - double getAngle(double u, double v, double w) const ; - double getSmoothness(double u, double v, double w) ; - double getSmoothness(MElement*) ; - void print(const std::string &filename, GFace *gf, + double getAngle(double u, double v, double w) const ; + double getSmoothness(double u, double v, double w) ; + double getSmoothness(MElement*) ; + void print(const std::string &filename, GFace *gf, const std::map<MVertex*, double>&, int smooth = 0) ; - void print(const std::string &filename, GFace *gf, int choice = 0) + void print(const std::string &filename, GFace *gf, int choice = 0) { switch(choice) { case 0 : print(filename, gf, _sizes); return; @@ -102,17 +101,4 @@ class backgroundMesh : public simpleFunction<double> std::vector<MElement*>::const_iterator end_triangles()const{return _triangles.end();} }; -//SMetric3 buildMetricTangentToCurve (SVector3 &t, double l_t, double l_n); -//SMetric3 buildMetricTangentToSurface (SVector3 &t1, SVector3 &t2, double l_t1, double l_t2, double l_n); -//double BGM_MeshSize(GEntity *ge, double U, double V, double X, double Y, double Z); -//SMetric3 BGM_MeshMetric(GEntity *ge, double U, double V, double X, double Y, double Z); -//bool Extend1dMeshIn2dSurfaces(); -//bool Extend2dMeshIn3dVolumes(); -//SMetric3 max_edge_curvature_metric(const GVertex *gv); -//SMetric3 max_edge_curvature_metric(const GEdge *ge, double u, double &l); -//SMetric3 metric_based_on_surface_curvature(const GFace *gf, double u, double v, -// bool surface_isotropic = false, -// double d_normal = 1.e12, -// double d_tangent_max = 1.e12); - #endif diff --git a/Mesh/BackgroundMesh2D.cpp b/Mesh/BackgroundMesh2D.cpp index c8f3bb3ef034863df2d8ece02b97cd17cf26f2f3..d9e3147f416fa8bc8b7084b8c7015e9bbe0c9230 100644 --- a/Mesh/BackgroundMesh2D.cpp +++ b/Mesh/BackgroundMesh2D.cpp @@ -1,4 +1,4 @@ -// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle // // See the LICENSE.txt file for license information. Please report all // bugs and problems to the public mailing list <gmsh@geuz.org>. @@ -44,13 +44,13 @@ class evalDiffusivityFunction : public simpleFunction<double>{ //TODO: move this fct ??? -/* applies rotations of amplitude pi to set the +/* applies rotations of amplitude pi to set the angle in the first quadrant (in [0,pi/2[ ) */ -void normalizeAngle(double &angle) +void normalizeAngle(double &angle) { - if (angle < 0) + if (angle < 0) while ( angle < 0 ) angle += (M_PI * .5); - else if (angle >= M_PI * .5) + else if (angle >= M_PI * .5) while ( angle >= M_PI * .5 ) angle -= (M_PI * .5); } @@ -104,7 +104,7 @@ void backgroundMesh2D::reset(bool erase_2D3D) if (CTX::instance()->mesh.lcFromPoints){ computeSizeField(); } - else + else for (std::map<MVertex*, MVertex*>::iterator itv2 = _2Dto3D.begin() ; itv2 != _2Dto3D.end(); ++itv2) sizeField[itv2->first] = CTX::instance()->mesh.lcMax; @@ -164,8 +164,8 @@ backgroundMesh2D::backgroundMesh2D(GFace *_gf, bool erase_2D3D):BGMBase(2,_gf),s reset(erase_2D3D); if (erase_2D3D){ - // now, the new mesh has been copied in local in backgroundMesh2D, deleting the mesh - // from GFace, back to the previous one ! + // now, the new mesh has been copied in local in backgroundMesh2D, deleting the mesh + // from GFace, back to the previous one ! GFace *face = dynamic_cast<GFace*>(gf); face->triangles = tempTR; } @@ -370,7 +370,7 @@ void frameFieldBackgroundMesh2D::reset(bool erase_2D3D) simpleFunction<double> ONE(1.0); computeCrossField(ONE); computeSmoothness(); - + // evalDiffusivityFunction eval_diff(this); // exportSmoothness("smoothness_iter_0.pos"); // for (int i=1;i<30;i++){ @@ -380,7 +380,7 @@ void frameFieldBackgroundMesh2D::reset(bool erase_2D3D) // stringstream ss; // ss << "smoothness_iter_" << i << ".pos"; // exportSmoothness(ss.str()); -// +// // stringstream sscf; // sscf << "crossfield_iter_" << i << ".pos"; // exportCrossField(sscf.str()); @@ -601,7 +601,7 @@ Pair<SVector3, SVector3> frameFieldBackgroundMesh2D::compute_crossfield_directio SVector3 basis_u = s1; basis_u.normalize(); SVector3 basis_v = crossprod(n,basis_u); - // normalize vector t1 that is tangent to gf at uv + // normalize vector t1 that is tangent to gf at uv SVector3 t1 = basis_u * cos(angle_current) + basis_v * sin(angle_current) ; t1.normalize(); @@ -634,7 +634,7 @@ bool frameFieldBackgroundMesh2D::compute_RK_infos(double u,double v, double x, d n.normalize(); SVector3 basis_u = s1; basis_u.normalize(); SVector3 basis_v = crossprod(n,basis_u); - // normalize vector t1 that is tangent to gf at uv + // normalize vector t1 that is tangent to gf at uv SVector3 t1 = basis_u * cos(angle_current) + basis_v * sin(angle_current) ; t1.normalize(); // compute the second direction t2 and normalize (t1,t2,n) is the tangent frame diff --git a/Mesh/BackgroundMesh2D.h b/Mesh/BackgroundMesh2D.h index 820937bd8127f8cc219303926a4c75cdc8f97636..3b1712dbde45ea46cc593b473403c5074594195f 100644 --- a/Mesh/BackgroundMesh2D.h +++ b/Mesh/BackgroundMesh2D.h @@ -1,4 +1,4 @@ -// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle // // See the LICENSE.txt file for license information. Please report all // bugs and problems to the public mailing list <gmsh@geuz.org>. @@ -32,7 +32,7 @@ class backgroundMesh2D : public BGMBase { virtual inline unsigned int getNumMeshElements()const{return elements.size();} virtual const MElement* getElement(unsigned int i)const; - + virtual GPoint get_GPoint_from_MVertex(const MVertex *) const; // only 2D: @@ -44,7 +44,7 @@ class backgroundMesh2D : public BGMBase { double sizeFactor; - + std::vector<MTriangle*> tempTR; vector<MElement*> elements; vector<MVertex*> vertices; @@ -56,7 +56,7 @@ class backgroundMesh2D : public BGMBase { public: backgroundMesh2D(GFace *, bool erase_2D3D=true); virtual ~backgroundMesh2D(); - + virtual MElementOctree* getOctree(); // TODO: only 2D @@ -65,8 +65,8 @@ class backgroundMesh2D : public BGMBase { // not used !!!! TODO !!! void setSizeFactor (double s) {sizeFactor = s;} - - + + virtual vector<MVertex*>::iterator beginvertices(){return vertices.begin();} virtual vector<MVertex*>::iterator endvertices(){return vertices.end();} virtual vector<MElement*>::iterator beginelements(){return elements.begin();} @@ -94,7 +94,7 @@ class RK_form{// informations for RK at one point // paramt2 = other.paramt2; // angle = other.angle; // } - + SMetric3 metricField; SVector3 t1, t2;// 3D cross field directions SVector3 normal;// 3D cross field directions @@ -121,10 +121,10 @@ class frameFieldBackgroundMesh2D : public backgroundMesh2D{ virtual void reset(bool erase_2D3D=true); - double angle(double u, double v); + double angle(double u, double v); double angle(MVertex *v); - double get_smoothness(double u, double v); + double get_smoothness(double u, double v); double get_smoothness(MVertex *v); void eval_crossfield(double u, double v, STensor3 &cf); diff --git a/Mesh/BackgroundMesh3D.cpp b/Mesh/BackgroundMesh3D.cpp index d2026669a89b8611493376b9be1ef7bdc94a481d..8ab79c42c29c9781797105a5d213446ff38d33c3 100644 --- a/Mesh/BackgroundMesh3D.cpp +++ b/Mesh/BackgroundMesh3D.cpp @@ -1,3 +1,7 @@ +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to the public mailing list <gmsh@geuz.org>. #include <fstream> #include <algorithm> diff --git a/Mesh/BackgroundMesh3D.h b/Mesh/BackgroundMesh3D.h index 344aa8a7c850df2e20c8f36f9ad5d0d2a9a28f7f..078ce130b4cd008ae9ae9349f7295170c88d95b8 100644 --- a/Mesh/BackgroundMesh3D.h +++ b/Mesh/BackgroundMesh3D.h @@ -1,4 +1,4 @@ -// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle // // See the LICENSE.txt file for license information. Please report all // bugs and problems to the public mailing list <gmsh@geuz.org>. diff --git a/Mesh/BackgroundMeshManager.cpp b/Mesh/BackgroundMeshManager.cpp index c863cbc426c04697630574ec79358693ddaa589a..0926f33d8715555e3c81e09c2436376e7c252788 100644 --- a/Mesh/BackgroundMeshManager.cpp +++ b/Mesh/BackgroundMeshManager.cpp @@ -1,3 +1,7 @@ +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to the public mailing list <gmsh@geuz.org>. #include "BackgroundMeshManager.h" #include "BGMBase.h" @@ -7,22 +11,20 @@ #include "GRegion.h" #include "BackgroundMesh3D.h" - - map<GEntity*,BGMBase*> BGMManager::data = map<GEntity*,BGMBase*>(); BGMBase* BGMManager::latest2Dbgm = NULL; bool BGMManager::use_cross_field = true; - -void BGMManager::set_use_cross_field(bool b){ +void BGMManager::set_use_cross_field(bool b) +{ if (b && (BGMManager::use_cross_field==false)){// need to change... data.clear(); } BGMManager::use_cross_field = b; } - -BGMBase* BGMManager::get(GRegion* gf){ +BGMBase* BGMManager::get(GRegion* gf) +{ map<GEntity*,BGMBase*>::iterator itfind = data.find(gf); if (itfind!=data.end()){ return itfind->second; @@ -39,8 +41,8 @@ BGMBase* BGMManager::get(GRegion* gf){ return bgm; } - -BGMBase* BGMManager::get(GFace* gf){ +BGMBase* BGMManager::get(GFace* gf) +{ map<GEntity*,BGMBase*>::iterator itfind = data.find(gf); if (itfind!=data.end()){ latest2Dbgm = itfind->second; @@ -57,10 +59,7 @@ BGMBase* BGMManager::get(GFace* gf){ return bgm; } - -BGMBase* BGMManager::current2D(){return latest2Dbgm;}; - - - - - +BGMBase* BGMManager::current2D() +{ + return latest2Dbgm; +}; diff --git a/Mesh/BackgroundMeshManager.h b/Mesh/BackgroundMeshManager.h index c05bee929364fa931d872fa0ca17f100a12e047f..30388b210db13c22199432ec735e5c7081d086e4 100644 --- a/Mesh/BackgroundMeshManager.h +++ b/Mesh/BackgroundMeshManager.h @@ -1,4 +1,4 @@ -// Gmsh - Copyright (C) 1997-2014 C. Geuzaine, J.-F. Remacle +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle // // See the LICENSE.txt file for license information. Please report all // bugs and problems to the public mailing list <gmsh@geuz.org>. @@ -15,20 +15,16 @@ class GEntity; class GFace; class GRegion; - class BGMManager{ - public: - static BGMBase* get(GFace *gf); - static BGMBase* get(GRegion *gf); - static BGMBase* current2D(); - static void set_use_cross_field(bool b); - private: - static bool use_cross_field; - static BGMBase *latest2Dbgm; - static map<GEntity*,BGMBase*> data; +public: + static BGMBase* get(GFace *gf); + static BGMBase* get(GRegion *gf); + static BGMBase* current2D(); + static void set_use_cross_field(bool b); +private: + static bool use_cross_field; + static BGMBase *latest2Dbgm; + static map<GEntity*,BGMBase*> data; }; - - - #endif diff --git a/Mesh/BackgroundMeshTools.cpp b/Mesh/BackgroundMeshTools.cpp index b9a24773cc4ae295021518410a9238b4b6f37a2d..2c499992d00dd99f43d68e17b175eabccaa1d4f8 100644 --- a/Mesh/BackgroundMeshTools.cpp +++ b/Mesh/BackgroundMeshTools.cpp @@ -1,6 +1,9 @@ +// Gmsh - Copyright (C) 1997-2015 C. Geuzaine, J.-F. Remacle +// +// See the LICENSE.txt file for license information. Please report all +// bugs and problems to the public mailing list <gmsh@geuz.org>. #include "BackgroundMeshTools.h" - #include "GFace.h" #include "GVertex.h" #include "GEdge.h" @@ -10,9 +13,6 @@ #include "Field.h" #include "GModel.h" -#include <iostream> - - static double max_surf_curvature(const GEdge *ge, double u) { double val = 0; @@ -30,8 +30,6 @@ static double max_surf_curvature(const GEdge *ge, double u) return val; } - - static double max_edge_curvature(const GVertex *gv) { double val = 0; @@ -48,7 +46,6 @@ static double max_edge_curvature(const GVertex *gv) return val; } - // the mesh vertex is classified on a model vertex. we compute the // maximum of the curvature of model faces surrounding this point if // it is classified on a model edge, we do the same for all model @@ -83,7 +80,6 @@ static double LC_MVertex_CURV(GEntity *ge, double U, double V) return lc; } - SMetric3 max_edge_curvature_metric(const GEdge *ge, double u) { SVector3 t = ge->firstDer(u); @@ -94,7 +90,6 @@ SMetric3 max_edge_curvature_metric(const GEdge *ge, double u) return buildMetricTangentToCurve(t,l_t,l_n); } - static SMetric3 metric_based_on_surface_curvature(const GEdge *ge, double u, bool iso_surf) { const GEdgeCompound* ptrCompoundEdge = dynamic_cast<const GEdgeCompound*>(ge); @@ -138,7 +133,6 @@ static SMetric3 metric_based_on_surface_curvature(const GEdge *ge, double u, boo } } - static SMetric3 metric_based_on_surface_curvature(const GVertex *gv, bool iso_surf) { SMetric3 mesh_size(1.e-15); @@ -166,7 +160,6 @@ static SMetric3 metric_based_on_surface_curvature(const GVertex *gv, bool iso_su return mesh_size; } - SMetric3 LC_MVertex_CURV_ANISO(GEntity *ge, double U, double V) { bool iso_surf = CTX::instance()->mesh.lcFromCurvature == 2; @@ -180,7 +173,6 @@ SMetric3 LC_MVertex_CURV_ANISO(GEntity *ge, double U, double V) return SMetric3(); } - // compute the mesh size at a given vertex due to prescribed sizes at // mesh vertices static double LC_MVertex_PNTS(GEntity *ge, double U, double V) @@ -217,7 +209,6 @@ static double LC_MVertex_PNTS(GEntity *ge, double U, double V) } } - SMetric3 buildMetricTangentToCurve(SVector3 &t, double l_t, double l_n) { if (l_t == 0.0) return SMetric3(1.e-22); @@ -241,7 +232,6 @@ SMetric3 buildMetricTangentToCurve(SVector3 &t, double l_t, double l_n) return Metric; } - SMetric3 buildMetricTangentToSurface(SVector3 &t1, SVector3 &t2, double l_t1, double l_t2, double l_n) { @@ -258,7 +248,6 @@ SMetric3 buildMetricTangentToSurface(SVector3 &t1, SVector3 &t2, return Metric; } - // This is the only function that is used by the meshers double BGM_MeshSize(GEntity *ge, double U, double V, double X, double Y, double Z) @@ -304,8 +293,6 @@ double BGM_MeshSize(GEntity *ge, double U, double V, return lc * CTX::instance()->mesh.lcFactor; } - - // anisotropic version of the background field SMetric3 BGM_MeshMetric(GEntity *ge, double U, double V, @@ -313,7 +300,9 @@ SMetric3 BGM_MeshMetric(GEntity *ge, { // Metrics based on element size - // Element size = min. between default lc and lc from point (if applicable), constrained by lcMin and lcMax + + // Element size = min. between default lc and lc from point (if applicable), + // constrained by lcMin and lcMax double lc = CTX::instance()->lc; if(CTX::instance()->mesh.lcFromPoints && ge->dim() < 2) lc = std::min(lc, LC_MVertex_PNTS(ge, U, V)); lc = std::max(lc, CTX::instance()->mesh.lcMin); @@ -346,22 +335,18 @@ SMetric3 BGM_MeshMetric(GEntity *ge, intersection(m1, LC_MVertex_CURV_ANISO(ge, U, V)) : m1; return m; - } - bool Extend1dMeshIn2dSurfaces() { return CTX::instance()->mesh.lcExtendFromBoundary ? true : false; } - bool Extend2dMeshIn3dVolumes() { return CTX::instance()->mesh.lcExtendFromBoundary ? true : false; } - SMetric3 max_edge_curvature_metric(const GVertex *gv) { SMetric3 val (1.e-12); @@ -392,7 +377,6 @@ SMetric3 max_edge_curvature_metric(const GVertex *gv) return val; } - SMetric3 metric_based_on_surface_curvature(const GFace *gf, double u, double v, bool surface_isotropic, double d_normal , @@ -425,5 +409,3 @@ SMetric3 metric_based_on_surface_curvature(const GFace *gf, double u, double v, dirMin, dirMax, Z ); return curvMetric; } - - diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index de62b6472ff205584709d70445a84a3a65cea7c6..9494fe7ff0684fea42dba1a16552308ef2c1c4c2 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -363,7 +363,7 @@ static void copyMesh(GFace *source, GFace *target) } count ++; } - + if (!translation){ count = 0; rotation = true; @@ -383,7 +383,7 @@ static void copyMesh(GFace *source, GFace *target) myPlane PLANE_TARGET(SPoint3(mean_target.x,mean_target.y,mean_target.z), SVector3(mean_target.a,mean_target.b,mean_target.c)); LINE = myLine(PLANE_SOURCE, PLANE_TARGET); - + // LINE is the axis of rotation // let us compute the angle of rotation count = 0; @@ -417,7 +417,7 @@ static void copyMesh(GFace *source, GFace *target) } } } - + if (rotation){ Msg::Info("Periodic mesh rotation found: axis (%g,%g,%g) point (%g %g %g) angle %g", LINE.t.x(), LINE.t.y(), LINE.t.z(), LINE.p.x(), LINE.p.y(), LINE.p.z(), diff --git a/doc/VERSIONS.txt b/doc/VERSIONS.txt index 9b90668331f07974df8ff9124b18cd60cbf4673e..8f03e9e6610022874689b3db68fe6a13a3cb7c1b 100644 --- a/doc/VERSIONS.txt +++ b/doc/VERSIONS.txt @@ -1,3 +1,5 @@ +2.9.2: added support for extrusion of embedded points/curves. + 2.9.1 (March 18, 2015): minor bug fixes. 2.9.0 (March 12, 2015): improved robustness of spatial searches (extruded meshes,