Skip to content
Snippets Groups Projects
Commit 425ab7c4 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

more coverity fixes

parent 4a9275a2
No related branches found
No related tags found
No related merge requests found
......@@ -1361,7 +1361,7 @@ 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;
......@@ -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]);
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment