#1292 Fixed CppCheck Issues in GeoMech

This commit is contained in:
Jacob Støren 2017-03-06 11:18:12 +01:00
parent c22c2c9a00
commit c7c01e346c
10 changed files with 22 additions and 50 deletions

View File

@ -26,6 +26,8 @@
class RigFemFaceComparator class RigFemFaceComparator
{ {
public: public:
RigFemFaceComparator() : m_minMainFaceNodeIdx(INT_MAX), m_faceIdxToMinMainFaceNodeIdx(0) {}
void setMainFace(const int* elmNodes, const int * localFaceIndices, int faceNodeCount) void setMainFace(const int* elmNodes, const int * localFaceIndices, int faceNodeCount)
{ {
m_canonizedMainFaceIdxes.resize(faceNodeCount); m_canonizedMainFaceIdxes.resize(faceNodeCount);

View File

@ -27,7 +27,7 @@ class RigFemPart;
class RigFemPartGrid : public cvf::StructGridInterface class RigFemPartGrid : public cvf::StructGridInterface
{ {
public: public:
RigFemPartGrid(const RigFemPart* femPart); explicit RigFemPartGrid(const RigFemPart* femPart);
virtual ~RigFemPartGrid(); virtual ~RigFemPartGrid();
virtual bool ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const; virtual bool ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const;

View File

@ -535,15 +535,11 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSEM(in
frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName));
frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.setNextProgressIncrement(this->frameCount());
RigFemScalarResultFrames * sa11 = nullptr; RigFemScalarResultFrames * sa11 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S11"));
RigFemScalarResultFrames * sa22 = nullptr;
RigFemScalarResultFrames * sa33 = nullptr;
sa11 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S11"));
frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount());
sa22 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S22")); RigFemScalarResultFrames * sa22 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S22"));
frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount());
sa33 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S33")); RigFemScalarResultFrames * sa33 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S33"));
RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
@ -581,12 +577,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSFI(int partInde
frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName));
frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.setNextProgressIncrement(this->frameCount());
RigFemScalarResultFrames * se1Frames = nullptr; RigFemScalarResultFrames * se1Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S1"));
RigFemScalarResultFrames * se3Frames = nullptr;
se1Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S1"));
frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount());
se3Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S3")); RigFemScalarResultFrames * se3Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S3"));
RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
@ -617,7 +610,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSFI(int partInde
} }
else else
{ {
dstFrameData[vIdx] = ((cohPrFricAngle + 0.5*(se1Data[vIdx] + se3Data[vIdx])) * sin(m_frictionAngleRad)) / (0.5*(se1Data[vIdx] - se3Data[vIdx])); dstFrameData[vIdx] = ((cohPrFricAngle + 0.5*(se1Data[vIdx] + se3Data[vIdx])) * sinFricAng ) / (0.5*(se1Data[vIdx] - se3Data[vIdx]));
} }
} }
@ -638,12 +631,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDSM(int partInde
frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName));
frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.setNextProgressIncrement(this->frameCount());
RigFemScalarResultFrames * se1Frames = nullptr; RigFemScalarResultFrames * se1Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S1"));
RigFemScalarResultFrames * se3Frames = nullptr;
se1Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S1"));
frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount());
se3Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S3")); RigFemScalarResultFrames * se3Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "S3"));
RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
@ -690,10 +680,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateFOS(int partInde
frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName));
frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.setNextProgressIncrement(this->frameCount());
RigFemScalarResultFrames * dsmFrames = nullptr; RigFemScalarResultFrames * dsmFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "DSM"));
RigFemScalarResultFrames * se3Frames = nullptr;
dsmFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SE", "DSM"));
RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
@ -730,17 +717,12 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSTM(in
caf::ProgressInfo frameCountProgress(this->frameCount() * 4, ""); caf::ProgressInfo frameCountProgress(this->frameCount() * 4, "");
frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName));
frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.setNextProgressIncrement(this->frameCount());
RigFemScalarResultFrames * st11 = nullptr; RigFemScalarResultFrames * st11 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S11"));
RigFemScalarResultFrames * st22 = nullptr;
RigFemScalarResultFrames * st33 = nullptr;
st11 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S11"));
frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount());
st22 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S22")); RigFemScalarResultFrames * st22 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S22"));
frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount());
st33 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S33")); RigFemScalarResultFrames * st33 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S33"));
RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
@ -2109,7 +2091,6 @@ RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPar
if ( closestLocalNode >= 0 ) if ( closestLocalNode >= 0 )
{ {
float scalarValue = std::numeric_limits<float>::infinity();
int nodeIdx = elmentConn[closestLocalNode]; int nodeIdx = elmentConn[closestLocalNode];
m_closestElementNodeResIdx = static_cast<int>(femPart->elementNodeResultIdx(elementIndex, closestLocalNode)); m_closestElementNodeResIdx = static_cast<int>(femPart->elementNodeResultIdx(elementIndex, closestLocalNode));
@ -2138,7 +2119,6 @@ RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPar
int closestLocalElmNode = -1; int closestLocalElmNode = -1;
{ {
RigElementType elmType = femPart->elementType(elementIndex); RigElementType elmType = femPart->elementType(elementIndex);
int faceCount = RigFemTypes::elmentFaceCount(elmType);
const int* elmNodeIndices = femPart->connectivities(elementIndex); const int* elmNodeIndices = femPart->connectivities(elementIndex);
int faceNodeCount = 0; int faceNodeCount = 0;
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(elmType, m_face, &faceNodeCount); const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(elmType, m_face, &faceNodeCount);

View File

@ -28,7 +28,7 @@
class RigFemScalarResultFrames: public cvf::Object class RigFemScalarResultFrames: public cvf::Object
{ {
public: public:
RigFemScalarResultFrames(int frameCount); explicit RigFemScalarResultFrames(int frameCount);
virtual ~RigFemScalarResultFrames(); virtual ~RigFemScalarResultFrames();
void enableAsSingleFrameResult(); void enableAsSingleFrameResult();

View File

@ -35,7 +35,7 @@ class RigFemPartResultsCollection;
class RigGeoMechCaseData: public cvf::Object class RigGeoMechCaseData: public cvf::Object
{ {
public: public:
RigGeoMechCaseData(const std::string& fileName); explicit RigGeoMechCaseData(const std::string& fileName);
~RigGeoMechCaseData(); ~RigGeoMechCaseData();
bool openAndReadFemParts(std::string* errorMessage); bool openAndReadFemParts(std::string* errorMessage);

View File

@ -216,10 +216,6 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c
{ {
if((*cellVisibility)[cellIndex]) if((*cellVisibility)[cellIndex])
{ {
RigElementType eType = grid->elementType(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
const int* elmNodeIndices = grid->connectivities(cellIndex);
for(int fpIdx = 0; fpIdx < 24; ++fpIdx) for(int fpIdx = 0; fpIdx < 24; ++fpIdx)
{ {
double scalarValue = resVals[cellIndex*24 + fpIdx]; double scalarValue = resVals[cellIndex*24 + fpIdx];

View File

@ -43,7 +43,7 @@ private:
class RivFemPartGeometryGenerator : public cvf::Object class RivFemPartGeometryGenerator : public cvf::Object
{ {
public: public:
RivFemPartGeometryGenerator(const RigFemPart* part); explicit RivFemPartGeometryGenerator(const RigFemPart* part);
~RivFemPartGeometryGenerator(); ~RivFemPartGeometryGenerator();
// Setup methods // Setup methods

View File

@ -47,7 +47,7 @@ class RigFemPart;
class RivFemPartPartMgr: public cvf::Object class RivFemPartPartMgr: public cvf::Object
{ {
public: public:
RivFemPartPartMgr(const RigFemPart* femPart); explicit RivFemPartPartMgr(const RigFemPart* femPart);
~RivFemPartPartMgr(); ~RivFemPartPartMgr();
void setTransform(cvf::Transform* scaleTransform); void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(cvf::UByteArray* cellVisibilities ); void setCellVisibility(cvf::UByteArray* cellVisibilities );

View File

@ -40,7 +40,7 @@ class RivGeoMechVizLogic : public cvf::Object
{ {
public: public:
RivGeoMechVizLogic(RimGeoMechView * geomView); explicit RivGeoMechVizLogic(RimGeoMechView * geomView);
virtual ~RivGeoMechVizLogic(); virtual ~RivGeoMechVizLogic();
void appendNoAnimPartsToModel(cvf::ModelBasicList* model); void appendNoAnimPartsToModel(cvf::ModelBasicList* model);

View File

@ -52,7 +52,7 @@
class RifOdbBulkDataGetter class RifOdbBulkDataGetter
{ {
public: public:
RifOdbBulkDataGetter(const odb_FieldBulkData& bulkData) : m_bulkData(bulkData) {}; explicit RifOdbBulkDataGetter(const odb_FieldBulkData& bulkData) : m_bulkData(bulkData) {};
virtual ~RifOdbBulkDataGetter() {}; virtual ~RifOdbBulkDataGetter() {};
float* data() float* data()
@ -329,8 +329,6 @@ bool RifOdbReader::readFemParts(RigFemPartCollection* femParts)
CVF_ASSERT(femParts); CVF_ASSERT(femParts);
CVF_ASSERT(m_odb != NULL); CVF_ASSERT(m_odb != NULL);
odb_Assembly& rootAssembly = m_odb->rootAssembly();
odb_InstanceRepository instanceRepository = m_odb->rootAssembly().instances(); odb_InstanceRepository instanceRepository = m_odb->rootAssembly().instances();
odb_InstanceRepositoryIT iter(instanceRepository); odb_InstanceRepositoryIT iter(instanceRepository);
@ -378,7 +376,7 @@ bool RifOdbReader::readFemParts(RigFemPartCollection* femParts)
int elmCount = elements.size(); int elmCount = elements.size();
femPart->preAllocateElementStorage(elmCount); femPart->preAllocateElementStorage(elmCount);
std::map<std::string, RigElementType>::const_iterator it;
std::vector<int> indexBasedConnectivities; std::vector<int> indexBasedConnectivities;
m_elementIdToIdxMaps.push_back(std::map<int, int>()); m_elementIdToIdxMaps.push_back(std::map<int, int>());
@ -589,7 +587,6 @@ odb_Instance* RifOdbReader::instance(int instanceIndex)
{ {
CVF_ASSERT(m_odb != NULL); CVF_ASSERT(m_odb != NULL);
odb_Assembly& rootAssembly = m_odb->rootAssembly();
odb_InstanceRepository& instanceRepository = m_odb->rootAssembly().instances(); odb_InstanceRepository& instanceRepository = m_odb->rootAssembly().instances();
odb_InstanceRepositoryIT iter(instanceRepository); odb_InstanceRepositoryIT iter(instanceRepository);
@ -784,7 +781,6 @@ void RifOdbReader::readNodeField(const std::string& fieldName, int partIndex, in
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::NODAL); const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::NODAL);
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks(); const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size(); int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++) for (int block = 0; block < numBlocks; block++)
{ {
@ -842,7 +838,6 @@ void RifOdbReader::readElementNodeField(const std::string& fieldName,
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex]; std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
CVF_ASSERT(elementIdToIdxMap.size() > 0); CVF_ASSERT(elementIdToIdxMap.size() > 0);
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size(); int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++) for (int block = 0; block < numBlocks; block++)
{ {
@ -909,7 +904,6 @@ void RifOdbReader::readIntegrationPointField(const std::string& fieldName, int p
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex]; std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
CVF_ASSERT(elementIdToIdxMap.size() > 0); CVF_ASSERT(elementIdToIdxMap.size() > 0);
size_t dataIndex = 0;
int numBlocks = seqFieldBulkData.size(); int numBlocks = seqFieldBulkData.size();
for (int block = 0; block < numBlocks; block++) for (int block = 0; block < numBlocks; block++)
{ {