diff --git a/Common/GamePad.cpp b/Common/GamePad.cpp index c59107d8ced3beeaba5a0ebbbaa834d964d7f154..f275a26c4b27c91c2b3413edc3b07bb547047a51 100644 --- a/Common/GamePad.cpp +++ b/Common/GamePad.cpp @@ -59,9 +59,10 @@ #include <unistd.h> #endif -GamePad::GamePad() : active(false), frequency(.01), gamepad_fd(0) +GamePad::GamePad() : active(false), frequency(.01) { #if defined(WIN32) + gamepad_fd = 0; for (int i = JOYSTICKID1 ; i < JOYSTICKID2 ; i++) { if(JOYERR_NOERROR == joyGetDevCaps(i, &caps, sizeof(JOYCAPS)) ) { /* diff --git a/Common/GamePad.h b/Common/GamePad.h index 98aac25f71bd43c3cdac85d154ea003d767e5b26..4ec7dbf79fd646cc92441e769a19487768365834 100644 --- a/Common/GamePad.h +++ b/Common/GamePad.h @@ -40,17 +40,16 @@ class GamePad { int button_map[10]; int axe_map[8]; private: - int axe_min[8]; - int axe_max[8]; - int gamepad_fd; char name[256]; #if defined(WIN32) + int gamepad_fd; JOYCAPS caps; JOYINFOEX infoex; JOYINFO info; int axes; int buttons; #elif defined(HAVE_LINUX_JOYSTICK) + int gamepad_fd; js_event event; __u32 version; __u8 axes; diff --git a/Geo/GRbf.cpp b/Geo/GRbf.cpp index d1ad7e50e3a9fc9fe33269583ebcc6d32ac053d8..b2c3f2dcb7d6603e99ef3ea12a3202bbc402818e 100644 --- a/Geo/GRbf.cpp +++ b/Geo/GRbf.cpp @@ -87,7 +87,7 @@ static void exportParametrizedMesh(fullMatrix<double> &UV, int nbNodes) GRbf::GRbf(double sizeBox, int variableEps, int rbfFun, std::map<MVertex*, SVector3> _normals, std::set<MVertex *> allNodes, std::vector<MVertex*> bcNodes, bool _isLocal) - : isLocal(_isLocal), _inUV(0), sBox(sizeBox), variableShapeParam(variableEps), + : isLocal(_isLocal), _inUV(0), sBox(sizeBox), radialFunctionIndex (rbfFun) { @@ -1206,7 +1206,7 @@ bool GRbf::UVStoXYZ(const double u_eval, const double v_eval, return true; } - num_neighbours = std::min(100, nbNodes); + num_neighbours = std::min(num_neighbours, nbNodes); fullMatrix<double> u_vec(num_neighbours,3), xyz_local(num_neighbours,3); fullMatrix<double> u_vec_eval(1, 3), nodes_eval(1,3), xu(1,3), xv(1,3); u_vec_eval(0,0) = u_eval; diff --git a/Geo/GRbf.h b/Geo/GRbf.h index cda79f9c77cd8af2551b0e554bf5879e58cb1629..25962ef955d1810442c3532a9bded0cd5a078f41 100644 --- a/Geo/GRbf.h +++ b/Geo/GRbf.h @@ -39,8 +39,6 @@ class GRbf { int nbNodes; //initial nodes bool isLocal; - int nn; - int num_neighbours; int _inUV; double delta; //offset level set @@ -51,7 +49,6 @@ class GRbf { SVector3 lastDXDU, lastDXDV; double lastX, lastY, lastZ, lastU, lastV; - int variableShapeParam; int radialFunctionIndex; // Index for the radial function used (0 - GA,1 - MQ, ... ) std::set<MVertex *> myNodes; //Used mesh vertices for light rbf @@ -122,7 +119,7 @@ class GRbf { void RbfLapSurface_global_projection2(const fullMatrix<double> &cntrs, const fullMatrix<double> &normals, fullMatrix<double> &Oper); - + // Finds global surface differentiation matrix using the projection method void RbfLapSurface_global_projection(const fullMatrix<double> &cntrs, const fullMatrix<double> &normals, @@ -168,7 +165,7 @@ class GRbf { //indices of the closest points bool UVStoXYZ(const double u_eval, const double v_eval, double &XX, double &YY, double &ZZ, - SVector3 &dXdu, SVector3& dxdv, int num_neighbours=15); + SVector3 &dXdu, SVector3& dxdv, int num_neighbours=100); void solveHarmonicMap(fullMatrix<double> Oper, std::vector<MVertex*> ordered, std::vector<double> coords, std::map<MVertex*, SPoint3> &rbf_param); diff --git a/Geo/gmshLevelset.cpp b/Geo/gmshLevelset.cpp index 16f8fe1b2870599685b3fc4cded22ac8a8b55c82..05c9025a885b58d1989db941c679256a0ea7cd13 100644 --- a/Geo/gmshLevelset.cpp +++ b/Geo/gmshLevelset.cpp @@ -712,7 +712,7 @@ double gLevelsetQuadric::operator()(double x, double y, double z) const gLevelsetShamrock::gLevelsetShamrock(double _xmid, double _ymid, double _zmid, double _a, double _b, int _c, int tag) - : gLevelsetPrimitive(tag), xmid(_xmid), ymid(_ymid), zmid(_zmid), + : gLevelsetPrimitive(tag), xmid(_xmid), a(_a), b(_b), c(_c) { // creating the iso-zero @@ -722,7 +722,6 @@ gLevelsetShamrock::gLevelsetShamrock(double _xmid, double _ymid, double _zmid, r = a+b*sin(c*angle); iso_x.push_back(r*sin(angle)+xmid); iso_y.push_back(r*cos(angle)+xmid); - angle += 2.*M_PI/1000.; } } @@ -888,7 +887,7 @@ void gLevelsetMathEvalAll::hessian(double x, double y, double z, #if defined(HAVE_ANN) gLevelsetDistMesh::gLevelsetDistMesh(GModel *gm, std::string physical, int nbClose, int tag) - : gLevelsetPrimitive(tag), _gm(gm), _nbClose(nbClose) + : gLevelsetPrimitive(tag), _nbClose(nbClose) { std::map<int, std::vector<GEntity*> > groups [4]; gm->getPhysicalGroups(groups); @@ -958,7 +957,7 @@ double gLevelsetDistMesh::operator () (double x, double y, double z) const SPoint3 closest; for (std::set<MElement*>::iterator it = elements.begin(); it != elements.end();++it){ - double distance; + double distance = 0.; MVertex *v1 = (*it)->getVertex(0); MVertex *v2 = (*it)->getVertex(1); SPoint3 p1(v1->x(), v1->y(), v1->z()); @@ -972,8 +971,9 @@ double gLevelsetDistMesh::operator () (double x, double y, double z) const SPoint3 p3(v3->x(), v3->y(), v3->z()); signedDistancePointTriangle(p1, p2, p3,SPoint3(x,y,z),distance,pt); } - else if ((*it)->getDim() == 2){ - Msg::Error("Cannot compute a dsitance to an entity of dim \n"); + else{ + Msg::Error("Cannot compute a dsitance to an entity of dimension %d", + (*it)->getDim()); } if (fabs(distance) < fabs(minDistance)){ minDistance=distance; diff --git a/Geo/gmshLevelset.h b/Geo/gmshLevelset.h index f41b8e3ff32737e8edfb570c41fb400a44fd2ee3..605cac27aff62256ced95d976d6d4b3de8466a11 100644 --- a/Geo/gmshLevelset.h +++ b/Geo/gmshLevelset.h @@ -313,9 +313,9 @@ public: // Rountable (2008)(177–194) class gLevelsetShamrock: public gLevelsetPrimitive { - double xmid, ymid, zmid,a,b; + double xmid, a, b; int c; - std::vector<double> iso_x,iso_y; + std::vector<double> iso_x, iso_y; public: gLevelsetShamrock(double xmid, double ymid, double zmid, double a, double b, int c=3, int tag=1); @@ -368,7 +368,6 @@ public: #if defined(HAVE_ANN) class gLevelsetDistMesh: public gLevelsetPrimitive { - GModel * _gm; const int _nbClose; std::vector<GEntity*> _entities; std::vector<MVertex*> _vertices; diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index 30181680c8c409d3578f6efb5738ca2720e6f26a..a26fdbbb19912211e421356e0bffdec3ef5472ce 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -2351,6 +2351,10 @@ int _edgeSwapQuadsForBetterQuality(GFace *gf, double eps, std::set<MEdge,Less_Ed q1B = new MQuadrangle (v11,v12,v21,v1); q2B = new MQuadrangle (v21,v12,v2,v22); } + else{ + Msg::Error("Something wrong in edgeSwapQuads opti"); + return 0; + } double worst_quality_A = std::min(myShapeMeasure(q1A),myShapeMeasure(q2A)); double worst_quality_B = std::min(myShapeMeasure(q1B),myShapeMeasure(q2B)); diff --git a/Mesh/meshGRegion.h b/Mesh/meshGRegion.h index b0574663dde9f898a61b578ec7f19916ea13800b..af8703ac986b6467783928a4468c04d14c5ac436 100644 --- a/Mesh/meshGRegion.h +++ b/Mesh/meshGRegion.h @@ -57,7 +57,7 @@ void carveHole(GRegion *gr, int num, double distance, std::vector<int> &surfaces typedef std::multimap<MVertex*, std::pair<MTriangle*, GFace*> > fs_cont ; typedef std::multimap<MVertex*, std::pair<MLine*, GEdge*> > es_cont ; -GFace* findInFaceSearchStructure(MVertex *p1, MVertex *p2, MVertex *p3, +GFace* findInFaceSearchStructure(MVertex *p1, MVertex *p2, MVertex *p3, const fs_cont &search); GEdge* findInEdgeSearchStructure(MVertex *p1, MVertex *p2, const es_cont &search); bool buildFaceSearchStructure(GModel *model, fs_cont &search); @@ -65,12 +65,8 @@ bool buildEdgeSearchStructure(GModel *model, es_cont &search); // adapt the mesh of a region class adaptMeshGRegion { - es_cont *_es; - fs_cont *_fs; public : void operator () (GRegion *); }; - - #endif diff --git a/Mesh/meshMetric.cpp b/Mesh/meshMetric.cpp index ff46aa81d31cb6db7d7379874ed4799928044a68..2ebb96843bb60d1ccce1d95330732984c7011cef 100644 --- a/Mesh/meshMetric.cpp +++ b/Mesh/meshMetric.cpp @@ -13,10 +13,8 @@ #include "OS.h" #include <algorithm> - meshMetric::meshMetric(GModel *gm) { - hasAnalyticalMetric = false; _dim = gm->getDim(); std::map<MElement*, MElement*> newP; @@ -42,12 +40,10 @@ meshMetric::meshMetric(GModel *gm) } _octree = new MElementOctree(_elements); buildVertexToElement (_elements,_adj); - } meshMetric::meshMetric(std::vector<MElement*> elements) { - hasAnalyticalMetric = false; _dim = elements[0]->getDim(); @@ -68,22 +64,21 @@ void meshMetric::addMetric(int technique, simpleFunction<double> *fct, std::vector<double> parameters) { needMetricUpdate = true; - + int metricNumber = setOfMetrics.size(); setOfFcts[metricNumber] = fct; setOfParameters[metricNumber] = parameters; setOfTechniques[metricNumber] = technique; - + if (fct->hasDerivatives()) hasAnalyticalMetric = true; - - computeMetric(metricNumber); + computeMetric(metricNumber); } void meshMetric::updateMetrics() { if (!setOfMetrics.size()){ - std::cout << " meshMetric::intersectMetrics: Can't intersect metrics, no metric registered ! " << std::endl; + Msg::Error("Can't intersect metrics, no metric registered"); return; } @@ -223,11 +218,12 @@ void meshMetric::computeValues() vals[ver]= (*_fct)(ver->x(),ver->y(),ver->z()); it++; } - + } // Determines set of vertices to use for least squares -std::vector<MVertex*> getLSBlob(unsigned int minNbPt, v2t_cont::iterator it, v2t_cont &adj) +std::vector<MVertex*> getLSBlob(unsigned int minNbPt, v2t_cont::iterator it, + v2t_cont &adj) { // static const double RADFACT = 3; @@ -310,7 +306,8 @@ void meshMetric::computeHessian() } double duNorm = sqrt(dudx*dudx+dudy*dudy+dudz*dudz); if (duNorm == 0. || _technique == meshMetric::HESSIAN || - _technique == meshMetric::EIGENDIRECTIONS || _technique == meshMetric::EIGENDIRECTIONS_LINEARINTERP_H) duNorm = 1.; + _technique == meshMetric::EIGENDIRECTIONS || + _technique == meshMetric::EIGENDIRECTIONS_LINEARINTERP_H) duNorm = 1.; grads[ver] = SVector3(dudx/duNorm,dudy/duNorm,dudz/duNorm); hessians[ver](0,0) = d2udx2; hessians[ver](0,1) = d2udxy; hessians[ver](0,2) = d2udxz; hessians[ver](1,0) = d2udxy; hessians[ver](1,1) = d2udy2; hessians[ver](1,2) = d2udyz; @@ -318,18 +315,19 @@ void meshMetric::computeHessian() } } -void meshMetric::computeMetricLevelSet(MVertex *ver, SMetric3 &hessian, SMetric3 &metric, double &size, double x, double y, double z) +void meshMetric::computeMetricLevelSet(MVertex *ver, SMetric3 &hessian, + SMetric3 &metric, double &size, + double x, double y, double z) { - double signed_dist; SVector3 gr; - if(ver != NULL){ + if(ver){ signed_dist = vals[ver]; gr = grads[ver]; hessian = hessians[ver]; } - else if (ver == NULL){ - signed_dist = (*_fct)(x,y,z); + else{ + signed_dist = (*_fct)(x,y,z); _fct->gradient(x,y,z,gr(0),gr(1),gr(2)); _fct->hessian(x,y,z, hessian(0,0),hessian(0,1),hessian(0,2), hessian(1,0),hessian(1,1),hessian(1,2), @@ -366,10 +364,11 @@ void meshMetric::computeMetricLevelSet(MVertex *ver, SMetric3 &hessian, SMetric size = std::min(std::min(1/sqrt(lambda1),1/sqrt(lambda2)),1/sqrt(lambda3)); metric = SMetric3(lambda1,lambda2,lambda3,t1,t2,t3); - } -void meshMetric::computeMetricHessian(MVertex *ver, SMetric3 &hessian, SMetric3 &metric, double &size, double x, double y, double z) +void meshMetric::computeMetricHessian(MVertex *ver, SMetric3 &hessian, + SMetric3 &metric, double &size, + double x, double y, double z) { SVector3 gr; @@ -383,7 +382,7 @@ void meshMetric::computeMetricHessian(MVertex *ver, SMetric3 &hessian, SMetric3 hessian(1,0),hessian(1,1),hessian(1,2), hessian(2,0),hessian(2,1),hessian(2,2)); } - + double _epsilonP = 1.; double hminP = 1.e-12; double hmaxP = 1.e+12; @@ -395,28 +394,29 @@ void meshMetric::computeMetricHessian(MVertex *ver, SMetric3 &hessian, SMetric3 double lambda1 = std::min(std::max(fabs(S(0))/_epsilonP,1./(hmaxP*hmaxP)),1./(hminP*hminP)); double lambda2 = std::min(std::max(fabs(S(1))/_epsilonP,1./(hmaxP*hmaxP)),1./(hminP*hminP)); double lambda3 = (_dim == 3) ? std::min(std::max(fabs(S(2))/_epsilonP,1./(hmaxP*hmaxP)),1./(hminP*hminP)) : 1.; - + SVector3 t1 (V(0,0),V(1,0),V(2,0)); SVector3 t2 (V(0,1),V(1,1),V(2,1)); SVector3 t3 = (_dim == 3) ? SVector3(V(0,2),V(1,2),V(2,2)) : SVector3(0.,0.,1.); - + size = std::min(std::min(1/sqrt(lambda1),1/sqrt(lambda2)),1/sqrt(lambda3)); metric = SMetric3(lambda1,lambda2,lambda3,t1,t2,t3); - + } -void meshMetric::computeMetricFrey(MVertex *ver, SMetric3 &hessian, SMetric3 &metric, double &size, double x, double y, double z) +void meshMetric::computeMetricFrey(MVertex *ver, SMetric3 &hessian, + SMetric3 &metric, double &size, + double x, double y, double z) { - double signed_dist; SVector3 gr; - if(ver != NULL){ + if(ver){ signed_dist = vals[ver]; gr = grads[ver]; hessian = hessians[ver]; } - else if (ver == NULL){ - signed_dist = (*_fct)(x,y,z); + else{ + signed_dist = (*_fct)(x,y,z); _fct->gradient(x,y,z,gr(0),gr(1),gr(2)); _fct->hessian(x,y,z, hessian(0,0),hessian(0,1),hessian(0,2), hessian(1,0),hessian(1,1),hessian(1,2), @@ -464,26 +464,27 @@ void meshMetric::computeMetricFrey(MVertex *ver, SMetric3 &hessian, SMetric3 &m } -void meshMetric::computeMetricEigenDir(MVertex *ver, SMetric3 &hessian, SMetric3 &metric, double &size, double x, double y, double z) +void meshMetric::computeMetricEigenDir(MVertex *ver, SMetric3 &hessian, + SMetric3 &metric, double &size, + double x, double y, double z) { - double signed_dist; SVector3 gVec; - if(ver != NULL){ + if(ver){ signed_dist = vals[ver]; gVec = grads[ver]; hessian = hessians[ver]; } - else if (ver == NULL){ - signed_dist = (*_fct)(x,y,z); + else{ + signed_dist = (*_fct)(x,y,z); _fct->gradient(x,y,z,gVec(0),gVec(1),gVec(2)); _fct->hessian(x,y,z, hessian(0,0),hessian(0,1),hessian(0,2), hessian(1,0),hessian(1,1),hessian(1,2), hessian(2,0),hessian(2,1),hessian(2,2)); } - + double dist = fabs(signed_dist); - + const double metric_value_hmax = 1./(hmax*hmax); const double gMag = gVec.norm(), invGMag = 1./gMag; @@ -495,7 +496,7 @@ void meshMetric::computeMetricEigenDir(MVertex *ver, SMetric3 &hessian, SMetric //const double h_dist = hmin + ((hmax-hmin)/_E)*dist; // Characteristic element size in the normal direction - linear interp between hmin and hmax //lambda_n = 1./(h_dist*h_dist); double beta = CTX::instance()->mesh.smoothRatio; - double h_dista = std::min( (hmin+(dist*log(beta))), hmax); + double h_dista = std::min( (hmin+(dist*log(beta))), hmax); lambda_n = 1./(h_dista*h_dista); } else if(_technique==meshMetric::EIGENDIRECTIONS){ @@ -559,21 +560,21 @@ void meshMetric::computeMetricEigenDir(MVertex *ver, SMetric3 &hessian, SMetric metric = mymetric; size = hmax; } - } -void meshMetric::computeMetricIsoLinInterp(MVertex *ver, SMetric3 &hessian, SMetric3 &metric, double &size, double x, double y, double z) +void meshMetric::computeMetricIsoLinInterp(MVertex *ver, SMetric3 &hessian, + SMetric3 &metric, double &size, + double x, double y, double z) { - double signed_dist; SVector3 gr; - if(ver != NULL){ + if(ver){ signed_dist = vals[ver]; gr = grads[ver]; hessian = hessians[ver]; } - else if (ver == NULL){ - signed_dist = (*_fct)(x,y,z); + else{ + signed_dist = (*_fct)(x,y,z); _fct->gradient(x,y,z,gr(0),gr(1),gr(2)); _fct->hessian(x,y,z, hessian(0,0),hessian(0,1),hessian(0,2), hessian(1,0),hessian(1,1),hessian(1,2), @@ -587,15 +588,13 @@ void meshMetric::computeMetricIsoLinInterp(MVertex *ver, SMetric3 &hessian, SMe if ((signed_dist >= 0) && (signed_dist < _E)) size = hmin + ((hmax-hmin)/_E)*dist; else if ((signed_dist < 0) && (signed_dist > _E_moins)) size = hmin - ((hmax-hmin)/_E_moins)*dist; } - + double lambda = 1./size/size; metric(0,0) = lambda; metric(0,1) = 0.; metric(0,2) = 0.; metric(1,0) = 0.; metric(1,1) = lambda; metric(1,2) = 0.; metric(2,0) = 0.; metric(2,1) = 0.; metric(2,2) = (_dim == 3)? lambda : 1.; - } - // this function scales the mesh metric in order // to reach a target number of elements // We know that the number of elements in the final @@ -609,8 +608,8 @@ void meshMetric::computeMetricIsoLinInterp(MVertex *ver, SMetric3 &hessian, SMe // where d is the dimension of the problem. // This means that the metric should be scaled by K^{2/d} where // K is N_target / N -void meshMetric::scaleMetric( int nbElementsTarget, - nodalMetricTensor &nmt ) +void meshMetric::scaleMetric(int nbElementsTarget, + nodalMetricTensor &nmt) { // compute N double N = 0; @@ -655,7 +654,6 @@ void meshMetric::scaleMetric( int nbElementsTarget, void meshMetric::computeMetric(int metricNumber) { - _fct = setOfFcts[metricNumber]; std::vector<double> parameters = setOfParameters[metricNumber]; int technique = setOfTechniques[metricNumber]; @@ -688,11 +686,10 @@ void meshMetric::computeMetric(int metricNumber) setOfSizes[metricNumber].insert(std::make_pair(ver,size)); setOfMetrics[metricNumber].insert(std::make_pair(ver,metric)); - + } - - if( _technique == HESSIAN) scaleMetric(_epsilon, setOfMetrics[metricNumber]); + if( _technique == HESSIAN) scaleMetric(_epsilon, setOfMetrics[metricNumber]); } double meshMetric::operator() (double x, double y, double z, GEntity *ge) @@ -741,7 +738,7 @@ void meshMetric::operator() (double x, double y, double z, SMetric3 &metr, GEnti throw; } metr = SMetric3(1.e-22); - + //RECOMPUTE MESH METRIC AT XYZ if (hasAnalyticalMetric){ int nbMetrics = setOfMetrics.size(); @@ -763,7 +760,7 @@ void meshMetric::operator() (double x, double y, double z, SMetric3 &metr, GEnti newSetOfMetrics[iMetric] = metric; } else{ - //find other metrics here + //find other metrics here SMetric3 metric; SPoint3 xyz(x,y,z), uvw; double initialTol = MElement::getTolerance(); @@ -827,24 +824,24 @@ void meshMetric::operator() (double x, double y, double z, SMetric3 &metr, GEnti } } - } -double meshMetric::getLaplacian (MVertex *v) { +double meshMetric::getLaplacian (MVertex *v) +{ MVertex *vNew = _vertexMap[v->getNum()]; std::map<MVertex*, SMetric3 >::const_iterator it = hessians.find(vNew); SMetric3 h = it->second; return h(0,0)+h(1,1)+h(2,2); } -SVector3 meshMetric::getGradient (MVertex *v) { +SVector3 meshMetric::getGradient (MVertex *v) +{ MVertex *vNew = _vertexMap[v->getNum()]; std::map<MVertex*,SVector3>::const_iterator it = grads.find(vNew); SVector3 gr = it->second; return gr; } - /*void meshMetric::curvatureContributionToMetric (){ std::map<MVertex*,SMetric3>::iterator it = _nodalMetrics.begin(); std::map<MVertex*,double>::iterator its = _nodalSizes.begin();