Commit 6bb4eac4 authored by Alexis SALZMAN's avatar Alexis SALZMAN

[xMapping] rm warning about potential non initialized variable usage

In both files some variable were potentially not initialized and
nevertheless used for some computation.
After checking with N.C. for xLagrangeMapping.cc the case were
knots.size() is null is impossible => assert. Then a simple init with
first point remove the warning and set without ambiguity x1,y1,z1.
For xMapping.cc the switch was not defaulted and thus DetJac may remain
unset. Setting it to 1 and put a default case in switch solve the prb.
parent 22fa74d5
......@@ -273,25 +273,21 @@ xRegularCubeLagrangeMapping::xRegularCubeLagrangeMapping(xReferenceElementType t
const std::vector<xtensor::xPoint> &input_knots)
: xLagrangeMapping(type, input_knots)
{
assert(knots.size());
double x1, y1, z1;
for (size_t i = 0; i < knots.size(); i++)
xtensor::xPoint &p0 = knots[0];
x0 = x1 = p0(0);
y0 = y1 = p0(1);
z0 = z1 = p0(2);
for (size_t i = 1; i < knots.size(); i++)
{
xtensor::xPoint p = knots[i];
if (!i)
{
x0 = x1 = p(0);
y0 = y1 = p(1);
z0 = z1 = p(2);
}
else
{
if (x0 > p(0)) x0 = p(0);
if (y0 > p(1)) y0 = p(1);
if (z0 > p(2)) z0 = p(2);
if (x1 < p(0)) x1 = p(0);
if (y1 < p(1)) y1 = p(1);
if (z1 < p(2)) z1 = p(2);
}
xtensor::xPoint &p = knots[i];
if (x0 > p(0)) x0 = p(0);
if (y0 > p(1)) y0 = p(1);
if (z0 > p(2)) z0 = p(2);
if (x1 < p(0)) x1 = p(0);
if (y1 < p(1)) y1 = p(1);
if (z1 < p(2)) z1 = p(2);
}
dx = x1 - x0;
dy = y1 - y0;
......
......@@ -354,16 +354,13 @@ double xMapping::detJac(const xtensor::xPoint &uvw) const
double xMapping::jacInverse(double u, double v, double w, tensor &Invjac) const
{
double jac[3][3];
double DetJac;
double DetJac = 1;
deval(u, v, w, jac[0][0], jac[0][1], jac[0][2], jac[1][0], jac[1][1], jac[1][2], jac[2][0], jac[2][1], jac[2][2]);
switch (type)
{
case xReferenceElementType::VERTEX:
{
DetJac = 1;
break;
}
// may take into account non x-y elements and curved elements, curved lines,...
// may take into account non x-y elements and curved elements, curved lines,...
case xReferenceElementType::EDGE:
{
DetJac = sqrt(jac[0][0] * jac[0][0] + jac[0][1] * jac[0][1] + jac[0][2] * jac[0][2]);
......@@ -396,8 +393,8 @@ double xMapping::jacInverse(double u, double v, double w, tensor &Invjac) const
jac[2][0] = (jac[0][1] * jac[1][2] - jac[0][2] * jac[1][1]) / DetJac;
jac[2][1] = (jac[0][2] * jac[1][0] - jac[0][0] * jac[1][2]) / DetJac;
jac[2][2] = (jac[0][0] * jac[1][1] - jac[0][1] * jac[1][0]) / DetJac;
break;
}
break;
case xReferenceElementType::TRI:
case xReferenceElementType::QUAD:
{
......@@ -408,8 +405,8 @@ double xMapping::jacInverse(double u, double v, double w, tensor &Invjac) const
jac[2][0] = d1 / DetJac;
jac[2][1] = d2 / DetJac;
jac[2][2] = d3 / DetJac;
break;
}
break;
case xReferenceElementType::TET:
case xReferenceElementType::HEX:
case xReferenceElementType::PRISM:
......@@ -417,8 +414,14 @@ double xMapping::jacInverse(double u, double v, double w, tensor &Invjac) const
{
DetJac = jac[0][0] * jac[1][1] * jac[2][2] + jac[0][2] * jac[1][0] * jac[2][1] + jac[0][1] * jac[1][2] * jac[2][0] -
jac[0][2] * jac[1][1] * jac[2][0] - jac[0][0] * jac[1][2] * jac[2][1] - jac[0][1] * jac[1][0] * jac[2][2];
break;
}
default:
{
std::cout << "Error : DetJac not defined for mapping type " << static_cast<int>(type) << " in " << __FILE__ << ":"
<< __LINE__ << std::endl;
throw -2345;
}
break;
}
Invjac(0, 0) = (jac[1][1] * jac[2][2] - jac[1][2] * jac[2][1]) / DetJac;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment