diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index bb67288dab6d5cb623f1844d70aa58bbe62a5bb5..f959749a0e8cc626993413bccf34157d5efcbc07 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -112,7 +112,8 @@ void Msg::Exit(int level) PetscFinalize(); #endif #if defined(HAVE_MPI) - if(level!=0) MPI_Abort(MPI_COMM_WORLD,level); // if abnormal exit on one cpu only + // force general abort (wven if the fatal error occurred on 1 cpu only) + MPI_Abort(MPI_COMM_WORLD, level); MPI_Finalize(); #endif FinalizeOnelab(); diff --git a/Common/onelab.h b/Common/onelab.h index afdaa1b6f7ec76c1c118417493050d4c2f2f4054..32ed1533606dcb71cbd144f5a5a22a87849fcb4f 100644 --- a/Common/onelab.h +++ b/Common/onelab.h @@ -45,11 +45,11 @@ namespace onelab{ // numbers to force their relative ordering (such numbers are // automatically hidden in the interface). std::string _name; - // help strings (the short serves as a better way to display the - // parameter in the interface). Should allow richer encoding (UTF? - // HTML?) + // help strings (if provided, the short help serves as a better + // way to display the parameter in the interface). Richer encoding + // (UTF? HTML?) might be used in the future. std::string _shortHelp, _help; - // clients (computing steps) that use this parameter + // clients that use this parameter std::set<std::string> _clients; // flag to check if the parameter has been changed since the last // run() @@ -106,6 +106,15 @@ namespace onelab{ const std::set<std::string> &getClients() const { return _clients; } static char charSep() { return '\0'; } static double maxNumber() { return 1e200; } + static std::string version() { return "1.0"; } + static std::string getNextToken(const std::string &msg, + std::string::size_type &first) + { + std::string::size_type last = msg.find_first_of(charSep(), first); + std::string next = msg.substr(first, last - first); + first = (last == std::string::npos) ? last : last + 1; + return next; + } std::string sanitize(const std::string &in) const { std::string out(in); @@ -113,11 +122,10 @@ namespace onelab{ if(out[i] == charSep()) out[i] = ' '; return out; } - std::string getOnelabVersion() const { return "1.0"; } virtual std::string toChar() const { std::ostringstream sstream; - sstream << getOnelabVersion() << charSep() << getType() << charSep() + sstream << version() << charSep() << getType() << charSep() << sanitize(getName()) << charSep() << sanitize(getShortHelp()) << charSep() << sanitize(getHelp()) << charSep() @@ -136,7 +144,7 @@ namespace onelab{ virtual std::string::size_type fromChar(const std::string &msg) { std::string::size_type pos = 0; - if(getNextToken(msg, pos) != getOnelabVersion()) return 0; + if(getNextToken(msg, pos) != version()) return 0; if(getNextToken(msg, pos) != getType()) return 0; setName(getNextToken(msg, pos)); setShortHelp(getNextToken(msg, pos)); @@ -154,14 +162,6 @@ namespace onelab{ } return pos; } - static std::string getNextToken(const std::string &msg, - std::string::size_type &first) - { - std::string::size_type last = msg.find_first_of(charSep(), first); - std::string next = msg.substr(first, last - first); - first = (last == std::string::npos) ? last : last + 1; - return next; - } static void getInfoFromChar(const std::string &msg, std::string &version, std::string &type, std::string &name) { @@ -183,8 +183,8 @@ namespace onelab{ // The number class. Numbers are stored internally as double // precision real numbers. Currently all more complicated types // (complex numbers, vectors, etc.) are supposed to be encapsulated - // in functions. We will probably add more base types in the future - // to make the interface nicer. + // in functions. We might add more base types in the future to make + // the interface more expressive. class number : public parameter{ private: double _value, _min, _max, _step; @@ -524,7 +524,7 @@ namespace onelab{ if(client.empty() || (*it)->hasClient(client)) (*it)->setChanged(changed); } - // print the parameter space (optinally only print those + // serialize the parameter space (optinally only serialize those // parameters that depend on the given client) std::string toChar(const std::string &client="") const { @@ -546,7 +546,7 @@ namespace onelab{ std::string _name; // the id of the client, used to create a unique socket for this client int _id; - // the index of the client in an external solver list (if any) + // the index of the client in an external client list (if any) int _index; public: client(const std::string &name) : _name(name), _id(0), _index(-1){} diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index e20384c23f7e10aeecebcf50190ad3bfc328c086..8a5ba76b0034adf985e01238390e1c9c07e02829 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -299,6 +299,7 @@ static void printFandPrimitive(int tag, std::vector<IntPoint> &Points) char name[256]; sprintf(name, "line%d.dat", tag); FILE *f = fopen(name, "w"); + if(!f) return; for (unsigned int i = 0; i < Points.size(); i++){ const IntPoint &P = Points[i]; fprintf(f, "%g %g %g %g\n", P.t, 1./P.lc, P.p,P.lc); @@ -394,9 +395,9 @@ void meshGEdge::operator() (GEdge *ge) CTX::instance()->mesh.lcIntegrationPrecision); // FIXME JF : MAYBE WE SHOULD NOT ALWAYS SMOOTH THE 1D MESH SIZE FIELD ?? - printFandPrimitive(ge->tag(), Points); + //printFandPrimitive(ge->tag(), Points); a = smoothPrimitive (ge,CTX::instance()->mesh.smoothRatio*CTX::instance()->mesh.smoothRatio,Points); - printFandPrimitive(ge->tag()+10000, Points); + //printFandPrimitive(ge->tag()+10000, Points); N = std::max(ge->minimumMeshSegments() + 1, (int)(a + 1.)); } diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index a33434abe0ac5ffe8aed7ad8a79288fbf650553c..4e98273cce1248eea074f52b084da4324e5a338b 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1099,10 +1099,10 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, gf->meshStatistics.status = GFace::DONE; // fill the small gmsh structures - BDS2GMSH ( m, gf, recoverMap); + BDS2GMSH(m, gf, recoverMap); // BOUNDARY LAYER - if (!onlyInitialMesh)modifyInitialMeshForTakingIntoAccountBoundaryLayers (gf); + if (!onlyInitialMesh) modifyInitialMeshForTakingIntoAccountBoundaryLayers(gf); // the delaunay algo is based directly on internal gmsh structures // BDS mesh is passed in order not to recompute local coordinates of @@ -1120,7 +1120,7 @@ bool meshGenerator(GFace *gf, int RECUR_ITER, bowyerWatson(gf); meshGFaceBamg(gf); } - laplaceSmoothing(gf,CTX::instance()->mesh.nbSmoothing); + laplaceSmoothing(gf, CTX::instance()->mesh.nbSmoothing); } if(debug){ diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index b460178831ec028e0268a72161f9ac13b674fb6f..1389906e108016f6a90cfa70eff1525fc4f415af 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -257,19 +257,21 @@ void buildListOfEdgeAngle(e2t_cont adj, std::vector<edge_angle> &edges_detected, std::sort(edges_detected.begin(), edges_detected.end()); } -void parametricCoordinates(MElement *t, GFace *gf, double u[4], double v[4], MVertex *close = 0) +void parametricCoordinates(MElement *t, GFace *gf, double u[4], double v[4], + MVertex *close = 0) { for(int j = 0; j < t->getNumVertices(); j++){ MVertex *ver = t->getVertex(j); SPoint2 param, dummy; - if (!close)reparamMeshVertexOnFace(ver, gf, param); + if (!close) reparamMeshVertexOnFace(ver, gf, param); else reparamMeshEdgeOnFace(ver, close, gf, param, dummy); u[j] = param[0]; v[j] = param[1]; } } -double surfaceFaceUV(MElement *t,GFace *gf){ +double surfaceFaceUV(MElement *t,GFace *gf) +{ double u[4],v[4]; parametricCoordinates(t,gf,u,v); if (t->getNumVertices() == 3) @@ -480,7 +482,8 @@ static int _removeTwoQuadsNodes(GFace *gf) return vtouched.size(); } -int removeTwoQuadsNodes(GFace *gf){ +int removeTwoQuadsNodes(GFace *gf) +{ int nbRemove = 0; while(1){ int x = _removeTwoQuadsNodes(gf); @@ -491,7 +494,6 @@ int removeTwoQuadsNodes(GFace *gf){ return nbRemove; } - static bool _isItAGoodIdeaToCollapseThatVertex (GFace *gf, std::vector<MElement*> &e1, std::vector<MElement*> &e2, @@ -1009,15 +1011,16 @@ static void _relocateVertexConstrained (GFace *gf, } } -static void _relocateVertex (GFace *gf, - MVertex *ver, - const std::vector<MElement*> <){ - - double R; SPoint3 c; bool isSphere = gf->isSphere(R,c); - if( ver->onWhat()->dim() == 2){ +static void _relocateVertex(GFace *gf, MVertex *ver, + const std::vector<MElement*> <) +{ + double R; + SPoint3 c; + bool isSphere = gf->isSphere(R, c); + if(ver->onWhat()->dim() == 2){ MFaceVertex *fv = dynamic_cast<MFaceVertex*>(ver); - if (fv->bl_data)return; + if(fv->bl_data) return; double initu,initv; ver->getParameter(0, initu); @@ -1080,9 +1083,9 @@ void laplaceSmoothing(GFace *gf, int niter) buildVertexToElement(gf->triangles, adj); buildVertexToElement(gf->quadrangles, adj); for(int i = 0; i < niter; i++){ - v2t_cont :: iterator it = adj.begin(); + v2t_cont::iterator it = adj.begin(); while (it != adj.end()){ - _relocateVertex(gf,it->first,it->second); + _relocateVertex(gf, it->first, it->second); ++it; } } @@ -1094,17 +1097,16 @@ void laplaceSmoothingConstrained(GFace *gf) buildVertexToElement(gf->triangles, adj); buildVertexToElement(gf->quadrangles, adj); for(int i = 0; i < 5; i++){ - v2t_cont :: iterator it = adj.begin(); + v2t_cont::iterator it = adj.begin(); while (it != adj.end()){ - _relocateVertexConstrained(gf,it->first,it->second); + _relocateVertexConstrained(gf, it->first, it->second); ++it; } } } - - -int _edgeSwapQuadsForBetterQuality ( GFace *gf ) { +int _edgeSwapQuadsForBetterQuality(GFace *gf) +{ e2t_cont adj; // buildEdgeToElement(gf->triangles, adj); buildEdgeToElement(gf->quadrangles, adj); @@ -2114,7 +2116,7 @@ void recombineIntoQuads(GFace *gf, _recombineIntoQuads(gf, 0); if(haveParam) laplaceSmoothing(gf, CTX::instance()->mesh.nbSmoothing); _recombineIntoQuads(gf, 0); - if(haveParam) laplaceSmoothing(gf, CTX::instance()->mesh.nbSmoothing); + if(haveParam) laplaceSmoothing(gf, CTX::instance()->mesh.nbSmoothing); if (saveAll) gf->model()->writeMSH("after.msh");