diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index 97b84e97fbb9f64e55c97b754bd818d7cc18a3a2..8a65b927c4eb52492744b68389d04e471cf93211 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -58,6 +58,9 @@ vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName, #ifdef GEOTIFF_FOUND return loadImageFromTIFF(fileName, x0, y0, delta); #else + (void)x0; + (void)y0; + (void)delta; ERR("VtkRaster::loadImage(): Tiff file format not supported in this version!"); return nullptr; #endif diff --git a/Applications/DataExplorer/mainwindow.cpp b/Applications/DataExplorer/mainwindow.cpp index 7ff2da2216b29acf180620298ae753cab4ed7b99..a568a5401c6af488a385497700593a193f5207cb 100644 --- a/Applications/DataExplorer/mainwindow.cpp +++ b/Applications/DataExplorer/mainwindow.cpp @@ -925,8 +925,21 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, if (pos != std::string::npos) fname = fname.substr (0, pos); gmsh_command += " -o " + fname + ".msh"; - system(gmsh_command.c_str()); - this->loadFile(ImportFileType::GMSH, fileName.left(fileName.length() - 3).append("msh")); + auto const return_value = system(gmsh_command.c_str()); + if (return_value != 0) + { + QString const message = + "Execution of gmsh command returned non-zero " + "status, " + + QString::number(return_value); + OGSError::box(message, "Error"); + } + else + { + this->loadFile( + ImportFileType::GMSH, + fileName.left(fileName.length() - 3).append("msh")); + } } else OGSError::box("Location of GMSH not specified.", "Error"); @@ -942,7 +955,15 @@ void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries, #endif remove_command += fileName.toStdString(); INFO("remove command: %s", remove_command.c_str()); - system(remove_command.c_str()); + auto const return_value = system(remove_command.c_str()); + if (return_value != 0) + { + QString const message = + "Execution of remove command returned non-zero " + "status, " + + QString::number(return_value); + OGSError::box(message, "Error"); + } } } } diff --git a/Applications/FileIO/Legacy/createSurface.cpp b/Applications/FileIO/Legacy/createSurface.cpp index bb4a0808a7ad05190cbd6726fc8d2b84e3ad30cd..f4f8a1e3fd22c27db2de7d2f62ee2d32af196177 100644 --- a/Applications/FileIO/Legacy/createSurface.cpp +++ b/Applications/FileIO/Legacy/createSurface.cpp @@ -69,7 +69,7 @@ bool createSurface(GeoLib::Polyline const& ply, geo.getGeometryNames(geo_names); FileIO::GMSH::GMSHInterface gmsh_io( geo, false, FileIO::GMSH::MeshDensityAlgorithm::FixedMeshDensity, 0.0, - 0.0, 0.0, geo_names, false, false); + 0.0, 0, geo_names, false, false); gmsh_io.setPrecision(std::numeric_limits<double>::digits10); char file_base_name_c[L_tmpnam]; diff --git a/Applications/Utils/FileConverter/GMSH2OGS.cpp b/Applications/Utils/FileConverter/GMSH2OGS.cpp index 885880d375758048392271c2c23dce2d7bae5756..ca7f96498664b6db97b9b5dada55d1605af3d885 100644 --- a/Applications/Utils/FileConverter/GMSH2OGS.cpp +++ b/Applications/Utils/FileConverter/GMSH2OGS.cpp @@ -81,8 +81,8 @@ int main (int argc, char* argv[]) return -1; } #ifndef WIN32 - unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); - INFO("Mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); + INFO("Mem for mesh: %i MB", + (mem_watch.getVirtMemUsage() - mem_without_mesh) / (1024 * 1024)); #endif INFO("Time for reading: %f seconds.", run_time.elapsed()); diff --git a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp index 829a765f0df88cd54c3af9a9fcf725e6ab846350..417265a726d77829a73157a9a27b6982d6b4d249 100644 --- a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp +++ b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp @@ -202,7 +202,6 @@ int main (int argc, char* argv[]) } if (bool_property_arg.isSet()) { - bool bool_property_val(bool_property_arg.getValue()); resetMeshElementProperty(*mesh, polygon, property_name, bool_property_arg.getValue()); } diff --git a/Applications/Utils/MeshEdit/checkMesh.cpp b/Applications/Utils/MeshEdit/checkMesh.cpp index 0d606e3f093e492954c1889d7e2630a31171c88b..6bce3a310cee8cae24041cbddff7a906c96af835 100644 --- a/Applications/Utils/MeshEdit/checkMesh.cpp +++ b/Applications/Utils/MeshEdit/checkMesh.cpp @@ -55,7 +55,10 @@ int main(int argc, char *argv[]) const unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); if (mem_with_mesh>0) + { INFO ("Memory size: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); + (void)mem_with_mesh; + } INFO ("Time for reading: %g s", run_time.elapsed()); // Geometric information @@ -73,13 +76,34 @@ int main(int argc, char *argv[]) const std::array<unsigned, 7> nr_ele_types(MeshLib::MeshInformation::getNumberOfElementTypes(*mesh)); INFO("Element types:"); unsigned etype = 0; - if (nr_ele_types[etype]>0) INFO("\t%d lines", nr_ele_types[etype]); - if (nr_ele_types[++etype]>0) INFO("\t%d triangles", nr_ele_types[etype]); - if (nr_ele_types[++etype]>0) INFO("\t%d quads", nr_ele_types[etype]); - if (nr_ele_types[++etype]>0) INFO("\t%d tetrahedra", nr_ele_types[etype]); - if (nr_ele_types[++etype]>0) INFO("\t%d hexahedra", nr_ele_types[etype]); - if (nr_ele_types[++etype]>0) INFO("\t%d pyramids", nr_ele_types[etype]); - if (nr_ele_types[++etype]>0) INFO("\t%d prisms", nr_ele_types[etype]); + if (nr_ele_types[etype] > 0) + { + INFO("\t%d lines", nr_ele_types[etype]); + } + if (nr_ele_types[++etype] > 0) + { + INFO("\t%d triangles", nr_ele_types[etype]); + } + if (nr_ele_types[++etype] > 0) + { + INFO("\t%d quads", nr_ele_types[etype]); + } + if (nr_ele_types[++etype] > 0) + { + INFO("\t%d tetrahedra", nr_ele_types[etype]); + } + if (nr_ele_types[++etype] > 0) + { + INFO("\t%d hexahedra", nr_ele_types[etype]); + } + if (nr_ele_types[++etype] > 0) + { + INFO("\t%d pyramids", nr_ele_types[etype]); + } + if (nr_ele_types[++etype] > 0) + { + INFO("\t%d prisms", nr_ele_types[etype]); + } std::vector<std::string> const& vec_names (mesh->getProperties().getPropertyVectorNames()); INFO("There are %d properties in the mesh:", vec_names.size()); @@ -87,14 +111,20 @@ int main(int argc, char *argv[]) { auto vec_bounds (MeshLib::MeshInformation::getValueBounds<int>(*mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<int>::max()) + { INFO("\t%s: [%d, %d]", vec_name.c_str(), vec_bounds.first, vec_bounds.second) + } else { auto vec_bounds (MeshLib::MeshInformation::getValueBounds<double>(*mesh, vec_name)); if (vec_bounds.second != std::numeric_limits<double>::max()) + { INFO("\t%s: [%g, %g]", vec_name.c_str(), vec_bounds.first, vec_bounds.second) + } else + { INFO("\t%s: Unknown properties", vec_name.c_str()) + } } } @@ -109,6 +139,8 @@ int main(int argc, char *argv[]) INFO("%d hole(s) detected within the mesh", n_holes); } else + { INFO ("No holes found within the mesh."); + } } } diff --git a/Applications/Utils/MeshEdit/removeMeshElements.cpp b/Applications/Utils/MeshEdit/removeMeshElements.cpp index 9cfeafd2758b6c6bedcdaf6bbdbe26dd508a9f53..dc8351a47814ccf04fece3541dcc25219cf2ea07 100644 --- a/Applications/Utils/MeshEdit/removeMeshElements.cpp +++ b/Applications/Utils/MeshEdit/removeMeshElements.cpp @@ -104,16 +104,15 @@ int main (int argc, char* argv[]) // search elements IDs to be removed if (zveArg.isSet()) { - const std::size_t n_removed_elements = searcher.searchByContent(); - INFO("%d zero volume elements found.", n_removed_elements); + INFO("%d zero volume elements found.", searcher.searchByContent()); } if (eleTypeArg.isSet()) { const std::vector<std::string> eleTypeNames = eleTypeArg.getValue(); for (const auto& typeName : eleTypeNames) { const MeshLib::MeshElemType type = MeshLib::String2MeshElemType(typeName); if (type == MeshLib::MeshElemType::INVALID) continue; - const std::size_t n_removed_elements = searcher.searchByElementType(type); - INFO("%d %s elements found.", n_removed_elements, typeName.c_str()); + INFO("%d %s elements found.", searcher.searchByElementType(type), + typeName.c_str()); } } @@ -150,9 +149,9 @@ int main (int argc, char* argv[]) ySmallArg.getValue(), zSmallArg.getValue()}}), MathLib::Point3d(std::array<double,3>{{xLargeArg.getValue(), yLargeArg.getValue(), zLargeArg.getValue()}})}}); - const std::size_t n_removed_elements = searcher.searchByBoundingBox( - GeoLib::AABB(extent.begin(), extent.end())); - INFO("%d elements found.", n_removed_elements); + INFO("%d elements found.", + searcher.searchByBoundingBox( + GeoLib::AABB(extent.begin(), extent.end()))); } // remove the elements and create a new mesh object. diff --git a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp index 39dbf7595a7b79919464744273ac50a5d7d5d994..9078083a5581e55f575da83cf4d63018e38648be 100644 --- a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp @@ -37,18 +37,16 @@ std::vector<GeoLib::Point*> *RapidStnInterface::readStationFile(const std::strin return nullptr; } - // buffer file - in.seekg(0, std::ios::end); - std::size_t length = in.tellg(); - in.seekg(0, std::ios::beg); - auto* buffer = new char[length + 1]; - in.read(buffer, length); - buffer[in.gcount()] = '\0'; + // read the file in a buffer + std::stringstream sstr; + sstr << in.rdbuf(); + std::string buffer = sstr.str(); in.close(); // build DOM tree rapidxml::xml_document<> doc; - doc.parse<0>(buffer); + doc.parse<rapidxml::parse_non_destructive>( + const_cast<char*>(buffer.data())); // parse content if (std::string(doc.first_node()->name()) != "OpenGeoSysSTN") @@ -74,7 +72,6 @@ std::vector<GeoLib::Point*> *RapidStnInterface::readStationFile(const std::strin } doc.clear(); - delete [] buffer; return stations; } diff --git a/MathLib/Integration/GaussLegendreTet.cpp b/MathLib/Integration/GaussLegendreTet.cpp index 1faa686b15a83eed368b71e2ee6ebfb0563ece6c..4d2f24531c922279a0ea516a7be62c04d03f966a 100644 --- a/MathLib/Integration/GaussLegendreTet.cpp +++ b/MathLib/Integration/GaussLegendreTet.cpp @@ -37,20 +37,20 @@ std::array<std::array<double, 3>, GaussLegendreTet<3>::NPoints> initGLTet3X() const double e = 0.4544962958743506; const double f = 0.045503704125649; - return {{{a, b, b}, - {b, a, b}, - {b, b, a}, - {b, b, b}, - {c, d, d}, - {d, c, d}, - {d, d, c}, - {d, d, d}, - {e, e, f}, - {e, f, e}, - {e, f, f}, - {f, e, e}, - {f, e, f}, - {f, f, e}}}; + return {{{{a, b, b}}, + {{b, a, b}}, + {{b, b, a}}, + {{b, b, b}}, + {{c, d, d}}, + {{d, c, d}}, + {{d, d, c}}, + {{d, d, d}}, + {{e, e, f}}, + {{e, f, e}}, + {{e, f, f}}, + {{f, e, e}}, + {{f, e, f}}, + {{f, f, e}}}}; } const std::array<std::array<double, 3>, GaussLegendreTet<3>::NPoints> diff --git a/MathLib/LinAlg/Eigen/EigenVector.h b/MathLib/LinAlg/Eigen/EigenVector.h index ffe5221060d1df338cbbb5c57d4c57c02f19c1a1..570356ed1902bd4b78970ec620e7750617e02322 100644 --- a/MathLib/LinAlg/Eigen/EigenVector.h +++ b/MathLib/LinAlg/Eigen/EigenVector.h @@ -43,7 +43,7 @@ public: EigenVector(EigenVector const& src) = default; /// return a vector length - IndexType size() const { return _vec.size(); } + IndexType size() const { return static_cast<IndexType>(_vec.size()); } /// return a start index of the active data range IndexType getRangeBegin() const { return 0;} diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index 9937e9bb863ee8eaceb23a97ea36af7afafb1f27..d4597cad01edf759da38d9b0109d1a7a20a13bb2 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -80,10 +80,10 @@ public: unsigned getDimension() const { return _mesh_dimension; } /// Get the node with the given index. - const Node* getNode(unsigned idx) const { return _nodes[idx]; } + const Node* getNode(std::size_t idx) const { return _nodes[idx]; } /// Get the element with the given index. - const Element* getElement(unsigned idx) const { return _elements[idx]; } + const Element* getElement(std::size_t idx) const { return _elements[idx]; } /// Get the minimum edge length over all elements of the mesh. double getMinEdgeLength() const { return _edge_length.first; } diff --git a/NumLib/DOF/LocalToGlobalIndexMap.cpp b/NumLib/DOF/LocalToGlobalIndexMap.cpp index 92456d96a6a09c5d4d9251c1ed381a9ae2cfc293..5c892d56c4b09e6efcf6a09567af0cf6ea86486b 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.cpp +++ b/NumLib/DOF/LocalToGlobalIndexMap.cpp @@ -304,11 +304,11 @@ LocalToGlobalIndexMap::getNumberOfElementComponents(std::size_t const mesh_item_ return n; } -std::vector<std::size_t> -LocalToGlobalIndexMap::getElementVariableIDs(std::size_t const mesh_item_id) const +std::vector<int> LocalToGlobalIndexMap::getElementVariableIDs( + std::size_t const mesh_item_id) const { - std::vector<std::size_t> vec; - for (unsigned i=0; i<getNumberOfVariables(); i++) + std::vector<int> vec; + for (int i = 0; i < getNumberOfVariables(); i++) { for (int j=0; j<getNumberOfVariableComponents(i); j++) { diff --git a/NumLib/DOF/LocalToGlobalIndexMap.h b/NumLib/DOF/LocalToGlobalIndexMap.h index 0784de22416daf4d7e13ff471846a561943d753d..c40a4d08dd35210a91900bf85344b92cb5a871ef 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.h +++ b/NumLib/DOF/LocalToGlobalIndexMap.h @@ -103,7 +103,10 @@ public: std::size_t size() const; - std::size_t getNumberOfVariables() const { return (_variable_component_offsets.size() - 1); } + int getNumberOfVariables() const + { + return static_cast<int>(_variable_component_offsets.size()) - 1; + } int getNumberOfVariableComponents(int variable_id) const { @@ -119,7 +122,8 @@ public: std::size_t getNumberOfElementComponents(std::size_t const mesh_item_id) const; - std::vector<std::size_t> getElementVariableIDs(std::size_t const mesh_item_id) const; + std::vector<int> getElementVariableIDs( + std::size_t const mesh_item_id) const; GlobalIndexType getGlobalIndex(MeshLib::Location const& l, int const variable_id, diff --git a/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h b/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h index 0b68a86c9c500c89562beb5f5055dc7dbe2cfa67..0082088412ced699d1421ad08a652b82465a1059 100644 --- a/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h +++ b/ProcessLib/LIE/HydroMechanics/LocalAssembler/LocalDataInitializer.h @@ -199,7 +199,7 @@ public: type_idx.name()); auto const n_local_dof = _dof_table.getNumberOfElementDOF(id); - const std::vector<std::size_t> varIDs(_dof_table.getElementVariableIDs(id)); + auto const varIDs = _dof_table.getElementVariableIDs(id); bool const isPressureDeactivated = (varIDs.front()!=0); std::vector<int> involved_varIDs; // including deactived elements involved_varIDs.reserve(varIDs.size()+1); @@ -215,7 +215,7 @@ public: //TODO how to get the shape function order for each variable? vec_n_element_nodes.push_back(mesh_item.getNumberOfBaseNodes()); // pressure auto const max_varID = *std::max_element(varIDs.begin(), varIDs.end()); - for (unsigned i=1; i<max_varID+1; i++) + for (int i = 1; i < max_varID + 1; i++) vec_n_element_nodes.push_back(mesh_item.getNumberOfNodes()); // displacements unsigned local_id = 0; diff --git a/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h b/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h index 2f0ad662cf7bf4ac75e7ca8236105e4b6e2ef9d4..03c768c7d06df5a80b1f0bf96f11568a88d12bf5 100644 --- a/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h +++ b/ProcessLib/LIE/SmallDeformation/LocalAssembler/LocalDataInitializer.h @@ -244,58 +244,51 @@ public: auto const type_idx = std::type_index(typeid(mesh_item)); auto const it = _builder.find(type_idx); - if (it != _builder.end()) + if (it == _builder.end()) + OGS_FATAL( + "You are trying to build a local assembler for an unknown mesh " + "element type (%s)." + " Maybe you have disabled this mesh element type in your build " + "configuration or this process requires higher order elements.", + type_idx.name()); + + auto const n_local_dof = _dof_table.getNumberOfElementDOF(id); + auto const n_global_components = + _dof_table.getNumberOfElementComponents(id); + auto const varIDs = _dof_table.getElementVariableIDs(id); + + std::vector<unsigned> dofIndex_to_localIndex; + if (mesh_item.getDimension() < GlobalDim || + n_global_components > GlobalDim) { - auto const n_local_dof = _dof_table.getNumberOfElementDOF(id); - auto const n_global_components = - _dof_table.getNumberOfElementComponents(id); - const std::vector<std::size_t> varIDs( - _dof_table.getElementVariableIDs(id)); - - std::vector<unsigned> dofIndex_to_localIndex; - if (mesh_item.getDimension() < GlobalDim || - n_global_components > GlobalDim) + dofIndex_to_localIndex.resize(n_local_dof); + unsigned dof_id = 0; + unsigned local_id = 0; + for (auto i : varIDs) { - dofIndex_to_localIndex.resize(n_local_dof); - unsigned dof_id = 0; - unsigned local_id = 0; - for (auto i : varIDs) + for (int j = 0; j < _dof_table.getNumberOfVariableComponents(i); + j++) { - for (int j = 0; - j < _dof_table.getNumberOfVariableComponents(i); j++) + auto& mss = _dof_table.getMeshSubsets(i, j); + assert(mss.size() == 1); + auto mesh_id = mss.getMeshSubset(0).getMeshID(); + for (unsigned k = 0; k < mesh_item.getNumberOfNodes(); k++) { - auto& mss = _dof_table.getMeshSubsets(i, j); - assert(mss.size() == 1); - auto mesh_id = mss.getMeshSubset(0).getMeshID(); - for (unsigned k = 0; k < mesh_item.getNumberOfNodes(); - k++) - { - MeshLib::Location l(mesh_id, - MeshLib::MeshItemType::Node, - mesh_item.getNodeIndex(k)); - auto global_index = - _dof_table.getGlobalIndex(l, i, j); - if (global_index != NumLib::MeshComponentMap::nop) - dofIndex_to_localIndex[dof_id++] = local_id; - local_id++; - } + MeshLib::Location l(mesh_id, + MeshLib::MeshItemType::Node, + mesh_item.getNodeIndex(k)); + auto global_index = _dof_table.getGlobalIndex(l, i, j); + if (global_index != NumLib::MeshComponentMap::nop) + dofIndex_to_localIndex[dof_id++] = local_id; + local_id++; } } } - - data_ptr = it->second(mesh_item, varIDs.size(), n_local_dof, - dofIndex_to_localIndex, - std::forward<ConstructorArgs>(args)...); - } - else - { - OGS_FATAL( - "You are trying to build a local assembler for an unknown mesh " - "element type (%s)." - " Maybe you have disabled this mesh element type in your build " - "configuration or this process requires higher order elements.", - type_idx.name()); } + + data_ptr = it->second(mesh_item, varIDs.size(), n_local_dof, + dofIndex_to_localIndex, + std::forward<ConstructorArgs>(args)...); } private: diff --git a/ProcessLib/ProcessOutput.cpp b/ProcessLib/ProcessOutput.cpp index 5841df4be77c718809a59d1284ee124f959dc7e7..66c4b0abca2da8d431c28efb38bf17042bc6dc04 100644 --- a/ProcessLib/ProcessOutput.cpp +++ b/ProcessLib/ProcessOutput.cpp @@ -211,7 +211,8 @@ void doProcessOutput(std::string const& file_name, external_variable_name); } #else - (void) secondary_variables; + (void)secondary_variables; + (void)t; #endif // USE_PETSC // Write output file diff --git a/Tests/FileIO/TestCsvWriter.cpp b/Tests/FileIO/TestCsvWriter.cpp index 6f1dacfc553b8d21fd9cd5a31ccb965494a0e4f9..ec36d4c5149b8b03ce0dcac498c7310278443332 100644 --- a/Tests/FileIO/TestCsvWriter.cpp +++ b/Tests/FileIO/TestCsvWriter.cpp @@ -33,14 +33,14 @@ TEST(CsvWriter, WriteReadTest) bool added; std::vector<std::string> vec_names { "String Vector", "Int Vector", "Double Vector"}; added = csv.addVectorForWriting(vec_names[0], str_vec); - ASSERT_EQ(true, added); + ASSERT_TRUE(added); added = csv.addVectorForWriting(vec_names[1], int_vec); - ASSERT_EQ(true, added); + ASSERT_TRUE(added); added = csv.addVectorForWriting(vec_names[2], dbl_vec); - ASSERT_EQ(true, added); + ASSERT_TRUE(added); int_vec.push_back(128); added = csv.addVectorForWriting(vec_names[1], int_vec); - ASSERT_EQ(false, added); + ASSERT_FALSE(added); ASSERT_EQ(3, csv.getNArrays()); csv.addIndexVectorForWriting(str_vec.size()); ASSERT_EQ(4, csv.getNArrays());