Commit 36a1542f authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Merge branch 'fix/warnings' into 'master'

Fix/warnings

This MR fixes a number of compiler warnings such as unused variables and variables which might be used potentially uninitialised.

See merge request !432
parents 79648ed8 2e643ff8
......@@ -24,7 +24,7 @@ EXTERNALPROJECT_ADD(
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
-DCMAKE_C_FLAGS:STRING=-fPIC
-DCMAKE_C_FLAGS:STRING=-fPIC\ -w
-DGKLIB_PATH:PATH=${TPSRC}/modmetis-5.1.0/GKlib
${TPSRC}/modmetis-5.1.0
)
......
......@@ -92,7 +92,10 @@ namespace Nektar
"Too few elements for this many processes.");
m_shared = shared;
if (m_weightingRequired) WeightElements();
if (m_weightingRequired)
{
WeightElements();
}
CreateGraph(m_mesh);
PartitionGraph(m_mesh, nParts, m_localPartition);
}
......@@ -518,45 +521,10 @@ namespace Nektar
nc = it->second[2];
}
int weight = 0;
int bndWeight = 0;
switch (m_meshComposites[cId].type)
{
case 'A':
weight = StdTetData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdTetData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'R':
weight = StdPrismData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdPrismData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'H':
weight = StdHexData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdHexData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'P':
weight = StdPyrData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdPyrData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'Q':
weight = StdQuadData::getNumberOfCoefficients(na, nb);
bndWeight = StdQuadData::getNumberOfBndCoefficients(na, nb);
break;
case 'T':
weight = StdTriData::getNumberOfCoefficients(na, nb);
bndWeight = StdTriData::getNumberOfBndCoefficients(na, nb);
break;
case 'S':
weight = StdSegData::getNumberOfCoefficients(na);
bndWeight = StdSegData::getNumberOfBndCoefficients(na);
break;
case 'V':
weight = 1;
bndWeight = 1;
break;
default:
break;
}
int weight = CalculateElementWeight(
m_meshComposites[cId].type, false, na, nb, nc);
int bndWeight = CalculateElementWeight(
m_meshComposites[cId].type, true, na, nb, nc);
for (unsigned int j = 0; j < m_meshComposites[cId].list.size(); ++j)
{
......@@ -686,51 +654,13 @@ namespace Nektar
nc = it->second[2];
}
int weight = 0;
int bndWeight = 0;
switch (m_meshComposites[cId].type)
{
case 'A':
weight = StdTetData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdTetData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'R':
weight = StdPrismData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdPrismData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'H':
weight = StdHexData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdHexData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'P':
weight = StdPyrData::getNumberOfCoefficients(na, nb, nc);
bndWeight = StdPyrData::getNumberOfBndCoefficients(na, nb, nc);
break;
case 'Q':
weight = StdQuadData::getNumberOfCoefficients(na, nb);
bndWeight = StdQuadData::getNumberOfBndCoefficients(na, nb);
break;
case 'T':
weight = StdTriData::getNumberOfCoefficients(na, nb);
bndWeight = StdTriData::getNumberOfBndCoefficients(na, nb);
break;
case 'S':
weight = StdSegData::getNumberOfCoefficients(na);
bndWeight = StdSegData::getNumberOfBndCoefficients(na);
break;
case 'V':
weight = 1;
bndWeight = 1;
break;
default:
break;
}
int bndWeight = CalculateElementWeight(
m_meshComposites[cId].type, true, na, nb, nc);
for (unsigned int j = 0; j < m_meshComposites[cId].list.size(); ++j)
{
int elmtId = m_meshComposites[cId].list[j];
m_vertWeights[elmtId][ m_fieldNameToId[it->first]] = bndWeight;
//m_vertWeights[elmtId][ m_fieldNameToId[ it->first ] * 2 + 1 ] = weight*weight;
m_vertWeights[elmtId][m_fieldNameToId[it->first]] = bndWeight;
}
}
} // for i
......@@ -895,7 +825,6 @@ namespace Nektar
{
unsigned int i = 0;
unsigned int cnt = 0;
const unsigned int npart = m_comm->GetRowComm()->GetSize();
bool valid = true;
// Check that every process has at least one element assigned
......@@ -1335,5 +1264,61 @@ namespace Nektar
elmtid.push_back(m_meshElements[m_localPartition[procid][*vertit].id].id);
}
}
int MeshPartition::CalculateElementWeight(
char elmtType,
bool bndWeight,
int na,
int nb,
int nc)
{
int weight = 0;
switch (elmtType)
{
case 'A':
weight = bndWeight ?
StdTetData ::getNumberOfBndCoefficients(na, nb, nc) :
StdTetData ::getNumberOfCoefficients (na, nb, nc);
break;
case 'R':
weight = bndWeight ?
StdPrismData::getNumberOfBndCoefficients(na, nb, nc) :
StdPrismData::getNumberOfCoefficients (na, nb, nc);
break;
case 'H':
weight = bndWeight ?
StdHexData ::getNumberOfBndCoefficients(na, nb, nc) :
StdHexData ::getNumberOfCoefficients (na, nb, nc);
break;
case 'P':
weight = bndWeight ?
StdPyrData ::getNumberOfBndCoefficients(na, nb, nc) :
StdPyrData ::getNumberOfCoefficients (na, nb, nc);
break;
case 'Q':
weight = bndWeight ?
StdQuadData ::getNumberOfBndCoefficients(na, nb) :
StdQuadData ::getNumberOfCoefficients (na, nb);
break;
case 'T':
weight = bndWeight ?
StdTriData ::getNumberOfBndCoefficients(na, nb) :
StdTriData ::getNumberOfCoefficients (na, nb);
break;
case 'S':
weight = bndWeight ?
StdSegData ::getNumberOfBndCoefficients(na) :
StdSegData ::getNumberOfCoefficients (na);
break;
case 'V':
weight = 1;
break;
default:
break;
}
return weight;
}
}
}
......@@ -239,6 +239,7 @@ namespace Nektar
void OutputPartition(SessionReaderSharedPtr& pSession, BoostSubGraph& pGraph, TiXmlElement* pGeometry);
void CheckPartitions(int nParts, Array<OneD, int> &pPart);
int CalculateElementWeight(char elmtType, bool bndWeight, int na, int nb, int nc);
};
typedef boost::shared_ptr<MeshPartition> MeshPartitionSharedPtr;
......
......@@ -1174,7 +1174,7 @@ namespace Nektar
// current scheme
int n;
DoubleArray y_n;
NekDouble t_n;
NekDouble t_n = 0;
DoubleArray dtFy_n;
unsigned int nCurSchemeVals = m_numMultiStepValues; // number of required values of the current scheme
unsigned int nCurSchemeDers = m_numMultiStepDerivs; // number of required derivs of the current scheme
......
......@@ -1829,7 +1829,6 @@ namespace Nektar
const PeriodicMap &perFaces)
{
LocalRegions::ExpansionSharedPtr exp;
int nDim = 0;
int nVert = 0;
int nEdge = 0;
int nFace = 0;
......@@ -1897,7 +1896,6 @@ namespace Nektar
for(i = 0; i < locExpVector.size(); ++i)
{
exp = locExpVector[i];
nDim = exp->GetShapeDimension();
cnt = locExp.GetCoeff_Offset(i);
// Loop over all vertices of element i
......
......@@ -77,9 +77,10 @@ namespace Nektar
const std::string variable):
AssemblyMap(pSession,variable)
{
int i, j, k, cnt, eid, id, id1, order_e,gid;
int i, j, k, cnt, eid, id, id1, gid;
int order_e = 0;
int nTraceExp = trace->GetExpSize();
int nbnd = bndCondExp.num_elements();
int nbnd = bndCondExp.num_elements();
LocalRegions::ExpansionSharedPtr exp;
LocalRegions::ExpansionSharedPtr bndExp;
......
......@@ -881,9 +881,6 @@ namespace Nektar
// Number of elements
int nElements = GetExpSize();
// Number of solution points of each element
int nLocalSolutionPts;
// Initial index of each element
int phys_offset;
......@@ -907,9 +904,6 @@ namespace Nektar
// Set the offset of each element
phys_offset = GetPhys_Offset(n);
// Set the number of solution points of each element
nLocalSolutionPts = (*m_exp)[n]->GetNumPoints(0);
Basis = (*m_exp)[n]->GetBasis(0);
for(v = 0; v < 2; ++v, ++cnt)
......
......@@ -1235,7 +1235,7 @@ namespace Nektar
{
SpatialDomains::PointGeomSharedPtr v;
SpatialDomains::PointGeom w;
NekDouble dist;
NekDouble dist = 0.0;
// Scan all elements and store those which may contain the point
for (int i = 0; i < (*m_exp).size(); ++i)
......@@ -1888,7 +1888,10 @@ namespace Nektar
std::vector<unsigned int> &HomoZIDs,
std::vector<unsigned int> &HomoYIDs)
{
int startenum, endenum, s;
int startenum = (int) LibUtilities::eSegment;
int endenum = (int) LibUtilities::eHexahedron;
int s = 0;
LibUtilities::ShapeType shape;
ASSERTL1(NumHomoDir == HomoBasis.num_elements(),"Homogeneous basis is not the same length as NumHomoDir");
ASSERTL1(NumHomoDir == HomoLen.size(),"Homogeneous length vector is not the same length as NumHomDir");
......@@ -1912,7 +1915,6 @@ namespace Nektar
for(s = startenum; s <= endenum; ++s)
{
LibUtilities::ShapeType shape;
std::vector<unsigned int> elementIDs;
std::vector<LibUtilities::BasisType> basis;
std::vector<unsigned int> numModes;
......@@ -1922,14 +1924,15 @@ namespace Nektar
bool UniOrder = true;
int n;
shape = (LibUtilities::ShapeType) s;
for(int i = 0; i < (*m_exp).size(); ++i)
{
if((*m_exp)[i]->GetGeom()->GetShapeType() == (LibUtilities::ShapeType) s)
if((*m_exp)[i]->GetGeom()->GetShapeType() == shape)
{
elementIDs.push_back((*m_exp)[i]->GetGeom()->GetGlobalID());
if(first)
{
shape = (LibUtilities::ShapeType) s;
for(int j = 0; j < (*m_exp)[i]->GetNumBases(); ++j)
{
basis.push_back((*m_exp)[i]->GetBasis(j)->GetBasisType());
......
......@@ -58,10 +58,10 @@ namespace Nektar
ExpListHomogeneous2D(pSession,HomoBasis_y,HomoBasis_z,lhom_y,lhom_z,useFFT,dealiasing)
{
int n,nel;
int nyz = m_ny*m_nz;
ASSERTL1(nyz == points.num_elements(),"Size of basis number of points and number of lines are not the same");
ASSERTL1(m_ny*m_nz == points.num_elements(),
"Size of basis number of points and number of lines are "
"not the same");
for(n = 0; n < points.num_elements(); ++n)
{
......
......@@ -655,8 +655,8 @@ namespace Nektar
Array<OneD, NekDouble> &coeffs)
{
int i,n;
int offset = 0;
int nzmodes;
int offset = 0;
int nzmodes = 1;
int datalen = fielddata.size()/fielddef->m_fields.size();
std::vector<unsigned int> fieldDefHomoZids;
......
......@@ -124,6 +124,10 @@ namespace Nektar
{
vCG = false;
}
else
{
ASSERTL0(false, "Unknown map type");
}
bool dirForcCalculated = (bool) pDirForcing.num_elements();
int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
......
......@@ -270,7 +270,9 @@ namespace Nektar
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{
int i, n;
NekDouble c0, c1, c2;
NekDouble c0 = 0.0;
NekDouble c1 = 0.0;
NekDouble c2 = 0.0;
int nquad0, nquad1, nquad2;
int nmodes0, nmodes1, nmodes2;
Array<OneD, LibUtilities::BasisSharedPtr> base;
......
......@@ -76,7 +76,7 @@ namespace Nektar
const Array<OneD, Array<OneD, NekDouble> > &inarray,
Array<OneD, Array<OneD, NekDouble> > &outarray)
{
int nBndEdgePts, i, j, k;
int nBndEdgePts, i, j, k, e;
int nDim = fields[0]->GetCoordim(0);
int nPts = fields[0]->GetTotPoints();
int nCoeffs = fields[0]->GetNcoeffs();
......@@ -165,7 +165,7 @@ namespace Nektar
num_elements();
int cnt = 0;
for (int i = 0; i < nBndRegions; ++i)
for (i = 0; i < nBndRegions; ++i)
{
// Number of boundary expansion related to that region
int nBndEdges = fields[0]->
......@@ -173,7 +173,7 @@ namespace Nektar
// Weakly impose boundary conditions by modifying flux
// values
for (int e = 0; e < nBndEdges ; ++e)
for (e = 0; e < nBndEdges ; ++e)
{
nBndEdgePts = fields[0]->GetBndCondExpansions()[i]
->GetExp(e)->GetTotPoints();
......@@ -182,7 +182,7 @@ namespace Nektar
fields[0]->GetTraceMap()
->GetBndCondTraceToGlobalTraceMap(cnt++));
for (int k = 0; k < nBndEdgePts; ++k)
for (k = 0; k < nBndEdgePts; ++k)
{
BwdMuVar[id2+k] = 0.0;
}
......@@ -191,7 +191,7 @@ namespace Nektar
for(i = 0; i < numConvFields; ++i)
{
for(int k = 0; k < nTracePts; ++k)
for(k = 0; k < nTracePts; ++k)
{
flux[0][i][k] =
0.5 * (FwdMuVar[k] + BwdMuVar[k]) * flux[0][i][k];
......
......@@ -324,7 +324,9 @@ namespace Nektar
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{
int i, n;
NekDouble c0, c1, c2;
NekDouble c0 = 0.0;
NekDouble c1 = 0.0;
NekDouble c2 = 0.0;
int nquad0, nquad1, nquad2;
int nmodes0, nmodes1, nmodes2;
Array<OneD, LibUtilities::BasisSharedPtr> base;
......
......@@ -375,7 +375,9 @@ namespace Nektar
Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
{
int i, n;
NekDouble c0, c1, c2;
NekDouble c0 = 0.0;
NekDouble c1 = 0.0;
NekDouble c2 = 0.0;
int nquad0, nquad1, nquad2;
int nmodes0, nmodes1, nmodes2;
Array<OneD, LibUtilities::BasisSharedPtr> base;
......
......@@ -110,7 +110,6 @@ namespace Nektar
{
Array<OneD, NekDouble> tmpworkd;
bool random;
int nq = m_equ[0]->UpdateFields()[0]->GetNcoeffs(); // Number of points in the mesh
int n = m_nfields*nq; // Number of points in eigenvalue calculation
......
......@@ -1361,9 +1361,9 @@ namespace Nektar
{
bool flag = FieldDef[i]->m_fields[j] ==
m_session->GetVariable(j);
ASSERTL1(flag, (std::string("Order of ") + pInfile
ASSERTL0(flag, (std::string("Order of ") + pInfile
+ std::string(" data and that defined in "
"m_boundaryconditions differs")).c_str());
"the session differs")).c_str());
m_base[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
FieldDef[i]->m_fields[j],
......
......@@ -133,12 +133,7 @@ namespace Nektar
const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields,
const NekDouble &time)
{
int i, nPoints = pFields[0]->GetNpoints(), nPlanePts = 0;
if (m_homogeneous)
{
nPlanePts = pFields[0]->GetPlane(0)->GetNpoints();
}
int i, nPoints = pFields[0]->GetNpoints();
m_index++;
......
......@@ -640,9 +640,8 @@ namespace Nektar
{
bool flag =
FieldDef[i]->m_fields[j] == m_session->GetVariable(j);
ASSERTL1(flag,
(std::string("Order of ") + pInfile
ASSERTL0(flag, (std::string("Order of ") + pInfile
+ std::string(" data and that defined in "
"m_boundaryconditions differs")).c_str());
......
......@@ -132,14 +132,14 @@ namespace Nektar
if (attrName == "DIM")
{
int err = attr->QueryIntValue(&meshDim);
ASSERTL1(err==TIXML_SUCCESS, "Unable to read mesh dimension.");
ASSERTL0(err==TIXML_SUCCESS, "Unable to read mesh dimension.");
break;
}
else
{
std::string errstr("Unknown attribute: ");
errstr += attrName;
ASSERTL1(false, errstr.c_str());
ASSERTL0(false, errstr.c_str());
}
// Get the next attribute.
......
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