diff --git a/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.cpp b/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.cpp index cff644fde76c02d405d2123168cf1257f3b70718..15efa9d3204cc37d4c4ccd8778ea13769ef655b8 100644 --- a/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.cpp +++ b/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.cpp @@ -49,16 +49,16 @@ std::vector<T> readStringToVector(std::string s) std::string readElement(std::string line) { - size_t elemStart = line.find('<')+1; + const size_t elemStart = line.find('<')+1; // size_t elemEnd = line.find("/>", elemStart); - size_t nameLen = line.find(' ', elemStart)-elemStart; + const size_t nameLen = line.find(' ', elemStart)-elemStart; return line.substr(elemStart, nameLen); } std::string readAttribute(std::string line, std::string attributeName) { - size_t attributeStart = line.find(attributeName)+attributeName.size() + 2; // add 2 for '="' - size_t attributeLen = line.find("\"", attributeStart)-attributeStart; + const size_t attributeStart = line.find(attributeName)+attributeName.size() + 2; // add 2 for '="' + const size_t attributeLen = line.find("\"", attributeStart)-attributeStart; return line.substr(attributeStart, attributeLen); } @@ -94,7 +94,7 @@ void VTKFile::readHeader() getline(file, line); // </ImageData getline(file, line); // AppendedData - int offset = int(file.tellg())+sizeof(char)+4; // skip underscore and bytesPerVal + const int offset = int(file.tellg())+sizeof(char)+4; // skip underscore and bytesPerVal for(auto& quantity: this->quantities) { @@ -118,7 +118,7 @@ void VTKFile::readHeader() } -bool VTKFile::markNANs(const std::vector<uint>& readIndices) +bool VTKFile::markNANs(const std::vector<uint>& readIndices) const { std::ifstream buf(fileName.c_str(), std::ios::in | std::ios::binary); @@ -126,7 +126,7 @@ bool VTKFile::markNANs(const std::vector<uint>& readIndices) tmp.reserve(readIndices.size()); buf.seekg(this->quantities[0].offset); buf.read((char*) tmp.data(), sizeof(double)*readIndices.size()); - auto firstNAN = std::find_if(tmp.begin(), tmp.end(), [](auto it){ return isnan(it); }); + const auto firstNAN = std::find_if(tmp.begin(), tmp.end(), [](auto it){ return isnan(it); }); return firstNAN != tmp.end(); } @@ -391,7 +391,7 @@ void VTKReader::fillArrays(std::vector<real>& coordsY, std::vector<real>& coords uint VTKReader::getWriteIndex(int level, int id, int linearIndex) { - auto it = std::find(this->writeIndices[level][id].begin(), this->writeIndices[level][id].end(), linearIndex); + const auto it = std::find(this->writeIndices[level][id].begin(), this->writeIndices[level][id].end(), linearIndex); const uint idx = it-this->writeIndices[level][id].begin(); if(it==this->writeIndices[level][id].end()) { diff --git a/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h b/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h index e0db8c2e67de51f0c9774303b5fc954e193f377e..5b9ea91a831da4d9bf189418e0e3eaaf8abd7357 100644 --- a/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h +++ b/src/gpu/GridGenerator/TransientBCSetter/TransientBCSetter.h @@ -41,7 +41,7 @@ public: }; void getData(real* data, uint numberOfNodes, const std::vector<uint>& readIndices, const std::vector<uint>& writeIndices, uint offsetRead, uint offsetWrite); - bool markNANs(const std::vector<uint>& readIndices); + bool markNANs(const std::vector<uint>& readIndices) const; bool inBoundingBox(real posX, real posY, real posZ){return inXBounds(posX) && inYBounds(posY) && inZBounds(posZ); }; bool inXBounds(real posX){ return posX<=maxX && posX>=minX; }; bool inYBounds(real posY){ return posY<=maxY && posY>=minY; };