diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index d616473dccfed1ee25b3969aefcc34281f465435..e4b53917a7ebe8fe4f023634d2ab6071063a9b86 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -1361,10 +1361,10 @@ struct quadBlob { bool meshable (int iter) { int ncorners = 0; - MVertex *corners[5]; + MVertex *corners[5] = {0, 0, 0, 0, 0}; for (unsigned int i = 0; i < bnodes.size(); i++){ if (topologicalAngle(bnodes[i]) > 0) ncorners ++; - if (ncorners > 5)return false; + if (ncorners > 5) return false; } if (ncorners != 3 && ncorners != 4 && ncorners != 5){ return false; @@ -1402,7 +1402,7 @@ struct quadBlob { MVertex *v01 = bnodes[a1]; SPoint2 p01; reparamMeshVertexOnFace(v01, gf, p01); MVertex *v12 = bnodes[a1+a3+a2]; SPoint2 p12; reparamMeshVertexOnFace(v12, gf, p12); MVertex *v20 = bnodes[a1+a3+a2+a1+a3]; SPoint2 p20; reparamMeshVertexOnFace(v20, gf, p20); - SPoint2 p012 = (p01+p12+p20)*(1./3.0); MVertex *v012 = createNewVertex (gf, p012); + SPoint2 p012 = (p01+p12+p20)*(1./3.0); std::vector<MVertex*> e012_01 = saturateEdge (gf,p012,p01,a2); std::vector<MVertex*> e012_12 = saturateEdge (gf,p012,p12,a3); @@ -1411,6 +1411,8 @@ struct quadBlob { if (e012_12.size() == 0) return false; if (e012_20.size() == 0) return false; + MVertex *v012 = createNewVertex (gf, p012); + std::vector<MVertex*> e0_01,e01_1,e1_12,e12_2,e2_20,e20_0; for (int i=0;i<a1-1;i++)e0_01.push_back(bnodes[i+1]); for (int i=0;i<a3-1;i++)e01_1.push_back(bnodes[i+1 + a1]); @@ -1550,7 +1552,7 @@ struct quadBlob { MVertex *v23 = bnodes[a1+a3+a2+a4+a3]; SPoint2 p23; reparamMeshVertexOnFace(v23, gf, p23); MVertex *v34 = bnodes[a1+a3+a2+a4+a3+a5+a4]; SPoint2 p34; reparamMeshVertexOnFace(v34, gf, p34); MVertex *v40 = bnodes[a1+a3+a2+a4+a3+a5+a4+a1+a5]; SPoint2 p40; reparamMeshVertexOnFace(v40, gf, p40); - SPoint2 p01234 = (p01+p12+p23+p34+p40)*(1./5.0); MVertex *v01234 = createNewVertex (gf, p01234); + SPoint2 p01234 = (p01+p12+p23+p34+p40)*(1./5.0); std::vector<MVertex*> e01234_01 = saturateEdge (gf,p01234,p01,a2); std::vector<MVertex*> e01234_12 = saturateEdge (gf,p01234,p12,a3); @@ -1563,6 +1565,8 @@ struct quadBlob { if (e01234_34.size() == 0) return false; if (e01234_40.size() == 0) return false; + MVertex *v01234 = createNewVertex (gf, p01234); + std::vector<MVertex*> e0_01,e01_1,e1_12,e12_2,e2_23,e23_3,e3_34,e34_4,e4_40,e40_0; for (int i=0;i<a1-1;i++)e0_01.push_back(bnodes[i+1]); for (int i=0;i<a3-1;i++)e01_1.push_back(bnodes[i+1 + a1]); diff --git a/Solver/elasticitySolver.cpp b/Solver/elasticitySolver.cpp index 6294450b125a467a22217f0d587cd15a99eee2c6..d23ec1b3b49b1f3379e392bdc0aafbda0fe2d84b 100644 --- a/Solver/elasticitySolver.cpp +++ b/Solver/elasticitySolver.cpp @@ -164,7 +164,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "ElasticDomain")){ elasticField field; int physical; - if(fscanf(f, "%d %lf %lf", &physical, &field._E, &field._nu) != 3) return; + if(fscanf(f, "%d %lf %lf", &physical, &field._E, &field._nu) != 3){ + fclose(f); + return; + } field._tag = _tag; field.g = new groupOfElements (_dim, physical); elasticFields.push_back(field); @@ -174,7 +177,10 @@ void elasticitySolver::readInputFile(const std::string &fn) int physical; double d1, d2, d3, val; if(fscanf(f, "%d %lf %lf %lf %lf %lf %d", &physical, &field._tau, - &d1, &d2, &d3, &val, &field._tag) != 7) return; + &d1, &d2, &d3, &val, &field._tag) != 7){ + fclose(f); + return; + } field._tag = _tag; field._d = SVector3(d1, d2, d3); field._f = simpleFunction<double>(val); @@ -184,7 +190,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "Void")){ elasticField field; int physical; - if(fscanf(f, "%d", &physical) != 1) return; + if(fscanf(f, "%d", &physical) != 1){ + fclose(f); + return; + } field._E = field._nu = 0; field.g = new groupOfElements (_dim, physical); field._tag = 0; @@ -193,7 +202,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "NodeDisplacement")){ double val; int node, comp; - if(fscanf(f, "%d %d %lf", &node, &comp, &val) != 3) return; + if(fscanf(f, "%d %d %lf", &node, &comp, &val) != 3){ + fclose(f); + return; + } dirichletBC diri; diri.g = new groupOfElements (0, node); diri._f= new simpleFunction<double>(val); @@ -205,7 +217,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "EdgeDisplacement")){ double val; int edge, comp; - if(fscanf(f, "%d %d %lf", &edge, &comp, &val) != 3) return; + if(fscanf(f, "%d %d %lf", &edge, &comp, &val) != 3){ + fclose(f); + return; + } dirichletBC diri; diri.g = new groupOfElements (1, edge); diri._f= new simpleFunction<double>(val); @@ -217,7 +232,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "FaceDisplacement")){ double val; int face, comp; - if(fscanf(f, "%d %d %lf", &face, &comp, &val) != 3) return; + if(fscanf(f, "%d %d %lf", &face, &comp, &val) != 3){ + fclose(f); + return; + } dirichletBC diri; diri.g = new groupOfElements (2, face); diri._f= new simpleFunction<double>(val); @@ -229,7 +247,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "NodeForce")){ double val1, val2, val3; int node; - if(fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3) != 4) return; + if(fscanf(f, "%d %lf %lf %lf", &node, &val1, &val2, &val3) != 4){ + fclose(f); + return; + } neumannBC neu; neu.g = new groupOfElements (0, node); neu._f= new simpleFunction<SVector3>(SVector3(val1, val2, val3)); @@ -240,7 +261,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "EdgeForce")){ double val1, val2, val3; int edge; - if(fscanf(f, "%d %lf %lf %lf", &edge, &val1, &val2, &val3) != 4) return; + if(fscanf(f, "%d %lf %lf %lf", &edge, &val1, &val2, &val3) != 4){ + fclose(f); + return; + } neumannBC neu; neu.g = new groupOfElements (1, edge); neu._f= new simpleFunction<SVector3>(SVector3(val1, val2, val3)); @@ -251,7 +275,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "FaceForce")){ double val1, val2, val3; int face; - if(fscanf(f, "%d %lf %lf %lf", &face, &val1, &val2, &val3) != 4) return; + if(fscanf(f, "%d %lf %lf %lf", &face, &val1, &val2, &val3) != 4){ + fclose(f); + return; + } neumannBC neu; neu.g = new groupOfElements (2, face); neu._f= new simpleFunction<SVector3>(SVector3(val1, val2, val3)); @@ -262,7 +289,10 @@ void elasticitySolver::readInputFile(const std::string &fn) else if (!strcmp(what, "VolumeForce")){ double val1, val2, val3; int volume; - if(fscanf(f, "%d %lf %lf %lf", &volume, &val1, &val2, &val3) != 4) return; + if(fscanf(f, "%d %lf %lf %lf", &volume, &val1, &val2, &val3) != 4){ + fclose(f); + return; + } neumannBC neu; neu.g = new groupOfElements (3, volume); neu._f= new simpleFunction<SVector3>(SVector3(val1, val2, val3)); @@ -272,26 +302,34 @@ void elasticitySolver::readInputFile(const std::string &fn) } else if (!strcmp(what, "MeshFile")){ char name[245]; - if(fscanf(f, "%s", name) != 1) return; + if(fscanf(f, "%s", name) != 1){ + fclose(f); + return; + } setMesh(name); } else if (!strcmp(what, "CutMeshPlane")){ double a, b, c, d; - if(fscanf(f, "%lf %lf %lf %lf", &a, &b, &c, &d) != 4) return; + if(fscanf(f, "%lf %lf %lf %lf", &a, &b, &c, &d) != 4){ + fclose(f); + return; + } int tag=1; gLevelsetPlane ls(a,b,c,d,tag); pModel = pModel->buildCutGModel(&ls); } else if (!strcmp(what, "CutMeshSphere")){ double x, y, z, r; - if(fscanf(f, "%lf %lf %lf %lf", &x, &y, &z, &r) != 4) return; + if(fscanf(f, "%lf %lf %lf %lf", &x, &y, &z, &r) != 4){ + fclose(f); + return; + } int tag=1; gLevelsetSphere ls(x,y,z,r,tag); pModel = pModel->buildCutGModel(&ls); } else { Msg::Error("Invalid input : '%s'", what); -// return; } } fclose(f);