diff --git a/Applications/ApplicationsLib/LinearSolverLibrarySetup.h b/Applications/ApplicationsLib/LinearSolverLibrarySetup.h index c6506b1bcc6b7ca2d3bc2cdfe86910605886b362..721f65f281cf27d646b1dbe157930c1bd199d1a8 100644 --- a/Applications/ApplicationsLib/LinearSolverLibrarySetup.h +++ b/Applications/ApplicationsLib/LinearSolverLibrarySetup.h @@ -71,5 +71,5 @@ struct LinearSolverLibrarySetup final NumLib::cleanupGlobalMatrixProviders(); } }; -} // ApplicationsLib +} // namespace ApplicationsLib #endif diff --git a/Applications/ApplicationsLib/LogogSetup.h b/Applications/ApplicationsLib/LogogSetup.h index 7b0a01d49cba82856ca5b1cab64de4585e04a740..7a06b03289f628c7f83e4eb42097ae7708546bc5 100644 --- a/Applications/ApplicationsLib/LogogSetup.h +++ b/Applications/ApplicationsLib/LogogSetup.h @@ -80,4 +80,4 @@ private: std::unique_ptr<logog::Cout> logog_cout; }; -} // ApplicationsLib +} // namespace ApplicationsLib diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index 28e1e84b6849d3416a9513e38adf9eeb3e760791..433f2d55372e4976b480567dd53c4ad3f9474248 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -278,8 +278,10 @@ void ProjectData::parseProcessVariables( auto pv = ProcessLib::ProcessVariable{var_config, mesh, _mesh_vec, _parameters}; if (!names.insert(pv.getName()).second) + { OGS_FATAL("A process variable with name `%s' already exists.", pv.getName().c_str()); + } _process_variables.push_back(std::move(pv)); } @@ -299,8 +301,10 @@ void ProjectData::parseParameters(BaseLib::ConfigTree const& parameters_config) auto p = ProcessLib::createParameter(parameter_config, _mesh_vec, _curves); if (!names.insert(p->name).second) + { OGS_FATAL("A parameter with name `%s' already exists.", p->name.c_str()); + } _parameters.push_back(std::move(p)); } @@ -310,14 +314,18 @@ void ProjectData::parseParameters(BaseLib::ConfigTree const& parameters_config) ProcessLib::DeactivatedSubdomain::zero_parameter_name, 0.0)); for (auto& parameter : _parameters) + { parameter->initialize(_parameters); + } } void ProjectData::parseMedia( boost::optional<BaseLib::ConfigTree> const& media_config) { if (!media_config) + { return; + } DBUG("Reading media:"); @@ -821,7 +829,9 @@ void ProjectData::parseCurves( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return; + } DBUG("Reading curves configuration."); diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index 76fdc683bbb5082705f5b3ed225f8c9f404b2a3c..7fab427db703d29fcb7e9a5d8726a8451a6a6d55 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -118,7 +118,9 @@ int main(int argc, char* argv[]) // deactivate buffer for standard output if specified if (unbuffered_cout_arg.isSet()) + { std::cout.setf(std::ios::unitbuf); + } ApplicationsLib::LogogSetup logog_setup; logog_setup.setLevel(log_level_arg.getValue()); @@ -129,11 +131,13 @@ int main(int argc, char* argv[]) #ifndef _WIN32 // On windows this command line option is not present. // Enable floating point exceptions if (enable_fpe_arg.isSet()) + { #ifdef __APPLE__ _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID); #else feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); #endif // __APPLE__ + } #endif // _WIN32 #ifdef OGS_USE_PYTHON diff --git a/Applications/DataHolderLib/BoundaryCondition.cpp b/Applications/DataHolderLib/BoundaryCondition.cpp index b6fc9e9dd55a739ebf410ef1157686c2dc7924a5..47fd4726e9c7bc708d2d2e16dbc24b6a8db0349d 100644 --- a/Applications/DataHolderLib/BoundaryCondition.cpp +++ b/Applications/DataHolderLib/BoundaryCondition.cpp @@ -25,15 +25,25 @@ BoundaryCondition::ConditionType BoundaryCondition::convertStringToType( std::string const& str) { if (str == "Dirichlet") + { return ConditionType::DIRICHLET; - else if (str == "NonuniformDirichlet") + } + if (str == "NonuniformDirichlet") + { return ConditionType::NONUNIFORMDIRICHLET; + } else if (str == "Neumann") + { return ConditionType::NEUMANN; + } else if (str == "NonuniformNeumann") + { return ConditionType::NONUNIFORMNEUMANN; + } else if (str == "Robin") + { return ConditionType::ROBIN; + } return ConditionType::NONE; } @@ -41,15 +51,25 @@ BoundaryCondition::ConditionType BoundaryCondition::convertStringToType( std::string BoundaryCondition::convertTypeToString(ConditionType type) { if (type == ConditionType::DIRICHLET) + { return "Dirichlet"; - else if (type == ConditionType::NONUNIFORMDIRICHLET) + } + if (type == ConditionType::NONUNIFORMDIRICHLET) + { return "NonuniformDirichlet"; + } else if (type == ConditionType::NEUMANN) + { return "Neumann"; + } else if (type == ConditionType::NONUNIFORMNEUMANN) + { return "NonuniformNeumann"; + } else if (type == ConditionType::ROBIN) + { return "Robin"; + } return ""; } diff --git a/Applications/DataHolderLib/Color.cpp b/Applications/DataHolderLib/Color.cpp index 200a4a4550447ede5f032e3ab74f66a0c638e440..ebc31eb04ae8dbfbca8d0f4cd0ad426fa86e1b02 100644 --- a/Applications/DataHolderLib/Color.cpp +++ b/Applications/DataHolderLib/Color.cpp @@ -47,7 +47,9 @@ Color const getColor(const std::string &id, std::map<std::string, Color> &colors for (auto it = colors.begin(); it != colors.end(); ++it) { if (id == it->first) + { return it->second; + } } WARN("Key '%s' not found in color lookup table.", id.c_str()); Color c = getRandomColor(); @@ -55,4 +57,4 @@ Color const getColor(const std::string &id, std::map<std::string, Color> &colors return c; } -} +} // namespace DataHolderLib diff --git a/Applications/DataHolderLib/Color.h b/Applications/DataHolderLib/Color.h index 40e286378b7b28ff4778dd227646317e56286fcc..7b245c2f70bf85d67b859bb55ef6e07898a03c76 100644 --- a/Applications/DataHolderLib/Color.h +++ b/Applications/DataHolderLib/Color.h @@ -36,4 +36,4 @@ Color const getColor(const std::string &id, std::map<std::string, DataHolderLib: /// Convenience function to use the getColor method with numbers as identifiers. Color const getColor(double id, std::map<std::string, DataHolderLib::Color> &colors); -} // namespace +} // namespace DataHolderLib diff --git a/Applications/DataHolderLib/ColorLookupTable.cpp b/Applications/DataHolderLib/ColorLookupTable.cpp index b5c04cbe036ee5fbd376645ca27c5e888255ae21..53539425d12ca3c8cada6b93232704e1258986e7 100644 --- a/Applications/DataHolderLib/ColorLookupTable.cpp +++ b/Applications/DataHolderLib/ColorLookupTable.cpp @@ -23,14 +23,18 @@ ColorLookupTable::ColorLookupTable() void ColorLookupTable::setTableRange(double min, double max) { - if (min<max) + if (min < max) + { _range = std::make_pair(min, max); + } } void ColorLookupTable::setColor(double id, DataHolderLib::Color const& color) { - if ((id>_range.first) && (id<_range.second)) + if ((id > _range.first) && (id < _range.second)) + { _lut.emplace_back(id, color, ""); + } } void ColorLookupTable::setColor(std::string const& name, DataHolderLib::Color const& color) @@ -38,6 +42,4 @@ void ColorLookupTable::setColor(std::string const& name, DataHolderLib::Color co _lut.emplace_back(0, color, name); } - - -} // namespace +} // namespace DataHolderLib diff --git a/Applications/DataHolderLib/ColorLookupTable.h b/Applications/DataHolderLib/ColorLookupTable.h index a159f7816840af7df0462f821ab259ba4bdcab34..317e54b258becc57174df2fc0a3d1fc09ef7ac81 100644 --- a/Applications/DataHolderLib/ColorLookupTable.h +++ b/Applications/DataHolderLib/ColorLookupTable.h @@ -65,4 +65,4 @@ private: std::pair<double, double> _range; }; -} // namespace +} // namespace DataHolderLib diff --git a/Applications/DataHolderLib/Project.cpp b/Applications/DataHolderLib/Project.cpp index e556cfb77a82bda9d41f839ab5df497ec9511290..14ec2dd263e163098405a2102e14d3e4e1e5f601 100644 --- a/Applications/DataHolderLib/Project.cpp +++ b/Applications/DataHolderLib/Project.cpp @@ -80,11 +80,17 @@ bool Project::getUniqueName(std::string &name) const // If the original name already exists we start to add numbers to name for // as long as it takes to make the name unique. if (count > 1) + { cpName = cpName + "-" + std::to_string(count); + } - for (auto & mesh : _mesh_vec) - if ( cpName == mesh->getName()) + for (auto& mesh : _mesh_vec) + { + if (cpName == mesh->getName()) + { isUnique = false; + } + } } // At this point cpName is a unique name and isUnique is true. @@ -102,15 +108,23 @@ void Project::removePrimaryVariable(std::string const primary_var_name) { std::size_t const n_bc(_boundary_conditions.size()); for (int i = n_bc - 1; i >= 0; --i) + { if (_boundary_conditions[i]->getProcessVarName() == primary_var_name) + { removeBoundaryCondition(primary_var_name, _boundary_conditions[i]->getParamName()); + } + } std::size_t const n_st(_source_terms.size()); for (int i = n_st - 1; i >= 0; --i) + { if (_source_terms[i]->getProcessVarName() == primary_var_name) + { removeSourceTerm(primary_var_name, _source_terms[i]->getParamName()); + } + } } void Project::removeBoundaryCondition(std::string const& primary_var_name, @@ -145,4 +159,4 @@ void Project::removeSourceTerm(std::string const& primary_var_name, } } -} //namespace +} // namespace DataHolderLib diff --git a/Applications/DataHolderLib/Project.h b/Applications/DataHolderLib/Project.h index 09d334968ed3e0660c2f86fb99e104b732c86f03..0b31b4ba1ac8b6431d69a22c4481de35914b5dc4 100644 --- a/Applications/DataHolderLib/Project.h +++ b/Applications/DataHolderLib/Project.h @@ -122,4 +122,4 @@ private: std::vector<std::unique_ptr<SourceTerm>> _source_terms; }; -} // namespace +} // namespace DataHolderLib diff --git a/Applications/DataHolderLib/SourceTerm.cpp b/Applications/DataHolderLib/SourceTerm.cpp index 4dc786bf22c36cde720eb0a4cbf4e3ac8b9fce32..2da166bf44b9632c142490193e35970f3b2c83d9 100644 --- a/Applications/DataHolderLib/SourceTerm.cpp +++ b/Applications/DataHolderLib/SourceTerm.cpp @@ -23,9 +23,13 @@ SourceTerm::ConditionType SourceTerm::convertStringToType( std::string const& str) { if (str == "Nodal") + { return ConditionType::NODAL; - else if (str == "Volume") + } + if (str == "Volume") + { return ConditionType::VOLUME; + } return ConditionType::NONE; } @@ -33,9 +37,13 @@ SourceTerm::ConditionType SourceTerm::convertStringToType( std::string SourceTerm::convertTypeToString(ConditionType type) { if (type == ConditionType::NODAL) + { return "Nodal"; - else if (type == ConditionType::VOLUME) + } + if (type == ConditionType::VOLUME) + { return "Volume"; + } return ""; } diff --git a/Applications/FileIO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp index 4ef1bae1149e4fa81fb44d35a0d8e8ba7843cecd..129f7527964fb7eaeb9692eecc9651ddaab546b4 100644 --- a/Applications/FileIO/AsciiRasterInterface.cpp +++ b/Applications/FileIO/AsciiRasterInterface.cpp @@ -29,9 +29,13 @@ GeoLib::Raster* AsciiRasterInterface::readRaster(std::string const& fname) std::string ext (BaseLib::getFileExtension(fname)); std::transform(ext.begin(), ext.end(), ext.begin(), tolower); if (ext == "asc") + { return getRasterFromASCFile(fname); + } if (ext == "grd") + { return getRasterFromSurferFile(fname); + } return nullptr; } @@ -77,14 +81,22 @@ bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader { in >> value; header.n_cols = atoi(value.c_str()); - } else return false; + } + else + { + return false; + } in >> tag; if (tag == "nrows") { in >> value; header.n_rows = atoi(value.c_str()); - } else return false; + } + else + { + return false; + } header.n_depth = 1; @@ -94,7 +106,11 @@ bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader in >> value; header.origin[0] = strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); - } else return false; + } + else + { + return false; + } in >> tag; if (tag == "yllcorner" || tag == "yllcenter") @@ -102,7 +118,11 @@ bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader in >> value; header.origin[1] = strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); - } else return false; + } + else + { + return false; + } header.origin[2] = 0; in >> tag; @@ -111,7 +131,11 @@ bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader in >> value; header.cell_size = strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); - } else return false; + } + else + { + return false; + } in >> tag; if (tag == "NODATA_value" || tag == "nodata_value") @@ -119,7 +143,11 @@ bool AsciiRasterInterface::readASCHeader(std::ifstream &in, GeoLib::RasterHeader in >> value; header.no_data = strtod(BaseLib::replaceString(",", ".", value).c_str(), nullptr); - } else return false; + } + else + { + return false; + } return true; } @@ -188,7 +216,9 @@ bool AsciiRasterInterface::readSurferHeader( if (ceil((max - min) / static_cast<double>(header.n_rows)) == ceil(header.cell_size)) + { header.cell_size = ceil(header.cell_size); + } else { ERR("Error in readSurferHeader() - Anisotropic cellsize detected."); @@ -237,7 +267,10 @@ static bool allRastersExist(std::vector<std::string> const& raster_paths) for (const auto& raster_path : raster_paths) { std::ifstream file_stream(raster_path, std::ifstream::in); - if (!file_stream.good()) return false; + if (!file_stream.good()) + { + return false; + } file_stream.close(); } return true; @@ -246,12 +279,17 @@ static bool allRastersExist(std::vector<std::string> const& raster_paths) boost::optional<std::vector<GeoLib::Raster const*>> readRasters( std::vector<std::string> const& raster_paths) { - if (!allRastersExist(raster_paths)) return boost::none; + if (!allRastersExist(raster_paths)) + { + return boost::none; + } std::vector<GeoLib::Raster const*> rasters; rasters.reserve(raster_paths.size()); for (auto const& path : raster_paths) + { rasters.push_back(FileIO::AsciiRasterInterface::readRaster(path)); + } return boost::make_optional(rasters); } } // end namespace FileIO diff --git a/Applications/FileIO/CsvInterface.cpp b/Applications/FileIO/CsvInterface.cpp index 3f9cf03763ac5f11162d38de4b6fdf08c8b82503..de5f8eaace6662654a11bbe76cbf0cea003bfb75 100644 --- a/Applications/FileIO/CsvInterface.cpp +++ b/Applications/FileIO/CsvInterface.cpp @@ -90,13 +90,15 @@ int CsvInterface::readPoints(std::string const& fname, char delim, (z_column_name.empty()) ? CsvInterface::findColumn(line, delim, y_column_name) : CsvInterface::findColumn(line, delim, z_column_name) }}; - for (std::size_t i=0; i<3; ++i) + for (std::size_t i = 0; i < 3; ++i) + { if (column_idx[i] == std::numeric_limits<std::size_t>::max()) { ERR("Column '%s' not found in file header.", column_names[i].c_str()); return -1; } + } return readPoints(in, delim, points, column_idx); } @@ -115,7 +117,9 @@ int CsvInterface::readPoints(std::string const& fname, char delim, } if (z_column_idx == std::numeric_limits<std::size_t>::max()) + { z_column_idx = y_column_idx; + } std::array<std::size_t, 3> const column_idx = {{ x_column_idx, y_column_idx, z_column_idx }}; return readPoints(in, delim, points, column_idx); @@ -172,19 +176,25 @@ std::size_t CsvInterface::findColumn(std::string const& line, char delim, std::s { std::list<std::string> const fields = BaseLib::splitString(line, delim); if (fields.empty()) + { return std::numeric_limits<std::size_t>::max(); + } std::size_t count(0); for (const auto& field : fields) { if (field == column_name) + { break; + } count++; } if (count == fields.size()) + { return std::numeric_limits<std::size_t>::max(); + } return count; } @@ -210,8 +220,10 @@ bool CsvInterface::write() if (_writeCsvHeader) { _out << _vec_names[0]; - for (std::size_t i=1; i<n_vecs; ++i) + for (std::size_t i = 1; i < n_vecs; ++i) + { _out << "\t" << _vec_names[i]; + } _out << "\n"; } @@ -231,22 +243,34 @@ bool CsvInterface::write() std::size_t CsvInterface::getVectorSize(std::size_t idx) const { if (_data[idx].type() == typeid(std::vector<std::string>)) + { return boost::any_cast<std::vector<std::string>>(_data[idx]).size(); + } if (_data[idx].type() == typeid(std::vector<double>)) + { return boost::any_cast<std::vector<double>>(_data[idx]).size(); + } if (_data[idx].type() == typeid(std::vector<int>)) + { return boost::any_cast<std::vector<int>>(_data[idx]).size(); + } return 0; } void CsvInterface::writeValue(std::size_t vec_idx, std::size_t in_vec_idx) { if (_data[vec_idx].type() == typeid(std::vector<std::string>)) + { _out << boost::any_cast<std::vector<std::string>>(_data[vec_idx])[in_vec_idx]; + } else if (_data[vec_idx].type() == typeid(std::vector<double>)) + { _out << boost::any_cast<std::vector<double>>(_data[vec_idx])[in_vec_idx]; + } else if (_data[vec_idx].type() == typeid(std::vector<int>)) + { _out << boost::any_cast<std::vector<int>>(_data[vec_idx])[in_vec_idx]; + } } } // end namespace FileIO diff --git a/Applications/FileIO/CsvInterface.h b/Applications/FileIO/CsvInterface.h index ad488877d5de78f73376f6db45b9afe4d5137601..0206d0c99ab83d36ecb74fbc5a2bb1cb5922d1c0 100644 --- a/Applications/FileIO/CsvInterface.h +++ b/Applications/FileIO/CsvInterface.h @@ -238,4 +238,4 @@ private: std::vector< boost::any > _data; }; -} // FileIO +} // namespace FileIO diff --git a/Applications/FileIO/GMSInterface.cpp b/Applications/FileIO/GMSInterface.cpp index d5761533b86dffb1aa3da52cff42cd5e9f555b3f..357ba8a78534d6010640bb959662cff14e682dde 100644 --- a/Applications/FileIO/GMSInterface.cpp +++ b/Applications/FileIO/GMSInterface.cpp @@ -117,7 +117,9 @@ int GMSInterface::readBoreholesFromGMS(std::vector<GeoLib::Point*>* boreholes, in.close(); if (boreholes->empty()) + { return 0; + } return 1; } @@ -154,7 +156,9 @@ void GMSInterface::writeBoreholesToGMS(const std::vector<GeoLib::Point*>* statio for (std::size_t i = 1; i < nLayers; i++) { if ((i > 1) && (soilNames[i] == soilNames[i - 1])) + { continue; + } // idx = getSoilID(soilID, soilNames[i]); current_soil_name = soilNames[i]; @@ -177,8 +181,12 @@ void GMSInterface::writeBoreholesToGMS(const std::vector<GeoLib::Point*>* statio std::size_t GMSInterface::getSoilID(std::vector<std::string> &soilID, std::string &soilName) { for (std::size_t j = 0; j < soilID.size(); j++) + { if (soilID[j] == soilName) + { return j; + } + } soilID.push_back(soilName); return soilID.size() - 1; } @@ -194,7 +202,10 @@ int GMSInterface::writeSoilIDTable(const std::vector<std::string> &soilID, // write table std::size_t nIDs = soilID.size(); for (std::size_t i = 0; i < nIDs; i++) - out << i << "\t" << std::fixed << soilID[i] << "\t" << "\n"; + { + out << i << "\t" << std::fixed << soilID[i] << "\t" + << "\n"; + } out.close(); return 1; @@ -208,11 +219,13 @@ std::vector<std::string> GMSInterface::readSoilIDfromFile(const std::string &fil std::ifstream in( filename.c_str() ); if (in.is_open()) + { while ( getline(in, line) ) { BaseLib::trim(line); soilID.push_back(line); } + } in.close(); return soilID; @@ -309,10 +322,12 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) elements.push_back(new MeshLib::Pyramid(pyramid_nodes)); mat_ids.push_back(mat_id); } - else if (element_id == "ND ") // Node + else if (element_id == "ND ") + { // Node continue; // skip because nodes have already been read - else //default + } + else // default { WARN( "GMSInterface::readGMS3DMMesh() - Element type '%s' not " @@ -335,9 +350,13 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) { ERR("Could not create PropertyVector for material ids."); for (auto element : elements) + { delete element; + } for (auto node : nodes) + { delete node; + } return nullptr; } opt_pv->reserve(mat_ids.size()); @@ -349,4 +368,4 @@ MeshLib::Mesh* GMSInterface::readGMS3DMMesh(const std::string &filename) return new MeshLib::Mesh(mesh_name, nodes, elements, properties); } -} +} // namespace FileIO diff --git a/Applications/FileIO/GMSInterface.h b/Applications/FileIO/GMSInterface.h index 269c2058c92e4bb30ee80cfc5d2c0de3147c1f3c..c9ef4b3d55bd466b551d66398bca265d51a846cb 100644 --- a/Applications/FileIO/GMSInterface.h +++ b/Applications/FileIO/GMSInterface.h @@ -78,4 +78,4 @@ private: static std::size_t getSoilID(std::vector<std::string> &soilID, std::string &soilName); }; -} +} // namespace FileIO diff --git a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp index d33b60070a06cd057eae56a6a68f037afedf7fe3..061ba0ce1c468c21fa43a0ec548bb205d625fa8c 100644 --- a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp +++ b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.cpp @@ -54,11 +54,19 @@ void GMSHAdaptiveMeshDensity::initialize(std::vector<GeoLib::Point const*> const std::size_t n_pnts(pnts.size()); for (std::size_t k(1); k<n_pnts; k++) { for (std::size_t j(0); j < 2; j++) + { if ((*(pnts[k]))[j] < min[j]) + { min[j] = (*(pnts[k]))[j]; + } + } for (std::size_t j(0); j < 2; j++) + { if ((*(pnts[k]))[j] > max[j]) + { max[j] = (*(pnts[k]))[j]; + } + } } min[2] = 0.0; max[2] = 0.0; @@ -79,7 +87,9 @@ void GMSHAdaptiveMeshDensity::addPoints(std::vector<GeoLib::Point const*> const& const std::size_t n_pnts(pnts.size()); DBUG("GMSHAdaptiveMeshDensity::addPoints(): Inserting %d points into quadtree.", n_pnts); for (std::size_t k(0); k < n_pnts; k++) + { _quad_tree->addPoint(pnts[k]); + } DBUG("GMSHAdaptiveMeshDensity::addPoints(): \tok."); _quad_tree->balance(); } @@ -158,6 +168,6 @@ void GMSHAdaptiveMeshDensity::getQuadTreeGeometry(std::vector<GeoLib::Point*> &p } } #endif -} +} // namespace GMSH } // end namespace FileIO diff --git a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h index 2a3e41e79b5079269a118de0af3a1cc9cd258456..f1036515ddf62819d2120a813606eaaa2385e265 100644 --- a/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h +++ b/Applications/FileIO/Gmsh/GMSHAdaptiveMeshDensity.h @@ -52,5 +52,5 @@ private: GeoLib::QuadTree<GeoLib::Point> *_quad_tree; }; -} +} // namespace GMSH } // end namespace FileIO diff --git a/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.cpp b/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.cpp index 08f9593b8cebaac7bd27e7ff560afb08a3800cd8..1a5198facb3b27666816dec5a4b537202942440a 100644 --- a/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.cpp +++ b/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.cpp @@ -36,5 +36,5 @@ double GMSHFixedMeshDensity::getMeshDensityAtStation(GeoLib::Point const*const) return _mesh_density; } -} +} // namespace GMSH } // end namespace FileIO diff --git a/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h b/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h index 23d3f8b577b1190f52a985a8b0b32db25fe5bcd2..c3f1814cd7dc22607fae2805a0454ca7f7e27db2 100644 --- a/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h +++ b/Applications/FileIO/Gmsh/GMSHFixedMeshDensity.h @@ -30,5 +30,5 @@ private: double _mesh_density; }; -} +} // namespace GMSH } // end namespace FileIO diff --git a/Applications/FileIO/Gmsh/GMSHInterface.cpp b/Applications/FileIO/Gmsh/GMSHInterface.cpp index d814c1b02402c9c33640477f2a5e87dda7a5b0d2..94bf289ef3c35fc818202bfae5538af3ed028406 100644 --- a/Applications/FileIO/Gmsh/GMSHInterface.cpp +++ b/Applications/FileIO/Gmsh/GMSHInterface.cpp @@ -62,10 +62,14 @@ GMSHInterface::GMSHInterface( GMSHInterface::~GMSHInterface() { - for (auto * gmsh_pnt : _gmsh_pnts) + for (auto* gmsh_pnt : _gmsh_pnts) + { delete gmsh_pnt; - for (auto * polygon_tree : _polygon_tree_list) + } + for (auto* polygon_tree : _polygon_tree_list) + { delete polygon_tree; + } } bool GMSHInterface::write() @@ -84,13 +88,17 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) DBUG("GMSHInterface::writeGMSHInputFile(): get data from GEOObjects."); if (_selected_geometries.empty()) + { return 1; + } // *** get and merge data from _geo_objs if (_selected_geometries.size() > 1) { _gmsh_geo_name = "GMSHGeometry"; if (_geo_objs.mergeGeometries(_selected_geometries, _gmsh_geo_name)) + { return 2; + } } else { _gmsh_geo_name = _selected_geometries[0]; _keep_preprocessed_geometry = true; @@ -114,7 +122,9 @@ int GMSHInterface::writeGMSHInputFile(std::ostream& out) _inverse_rot_mat(1,1) = 1.0; _inverse_rot_mat(2,2) = 1.0; for (auto pnt : *merged_pnts) + { (*pnt)[2] = 0.0; + } } std::vector<GeoLib::Polyline*> const* merged_plys( diff --git a/Applications/FileIO/Gmsh/GMSHLineLoop.cpp b/Applications/FileIO/Gmsh/GMSHLineLoop.cpp index 6d357623128e9b13bf8fab902775806af9e30f5c..f18bd2a4254fb5c1ccf1060897a85da1f8a80c39 100644 --- a/Applications/FileIO/Gmsh/GMSHLineLoop.cpp +++ b/Applications/FileIO/Gmsh/GMSHLineLoop.cpp @@ -43,7 +43,9 @@ void GMSHLineLoop::write(std::ostream &os, std::size_t line_offset, std::size_t } os << "Line Loop(" << line_offset+n_lines << ") = {"; for (std::size_t k(0); k < n_lines - 1; k++) + { os << line_offset + k << ","; + } os << line_offset + n_lines - 1 << "};\n"; if (_is_sfc) { diff --git a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp index 873328c51ae702a18b074ef7ea486d69b71eb2e9..0502c11b867e139da4cfbf2919cc6dd54619168a 100644 --- a/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp +++ b/Applications/FileIO/Gmsh/GMSHPolygonTree.cpp @@ -40,8 +40,10 @@ GMSHPolygonTree::~GMSHPolygonTree() // the polylines are processed also by the children, but the root is // responsible to cleanup up if (_parent == nullptr) { // root - for (auto * polyline : _plys) + for (auto* polyline : _plys) + { delete polyline; + } } // member of GeoLib::SimplePolygonTree, but the ownership is not transmitted delete _node_polygon; @@ -50,19 +52,26 @@ GMSHPolygonTree::~GMSHPolygonTree() void GMSHPolygonTree::markSharedSegments() { if (_children.empty()) + { return; + } if (_parent == nullptr) + { return; + } for (auto& child : _children) { std::size_t const n_pnts(child->getPolygon()->getNumberOfPoints()); for (std::size_t k(1); k<n_pnts; k++) { if (GeoLib::containsEdge(*(_parent->getPolygon()), - _node_polygon->getPointID(k-1), - _node_polygon->getPointID(k))) - static_cast<GeoLib::PolygonWithSegmentMarker*>(_node_polygon)->markSegment(k, true); + _node_polygon->getPointID(k - 1), + _node_polygon->getPointID(k))) + { + static_cast<GeoLib::PolygonWithSegmentMarker*>(_node_polygon) + ->markSegment(k, true); + } } } } @@ -77,7 +86,9 @@ bool GMSHPolygonTree::insertStation(GeoLib::Point const* station) bool rval(dynamic_cast<GMSHPolygonTree*>((*it))->insertStation (station)); // stop recursion if sub SimplePolygonTree is a leaf if (rval && (*it)->getNumberOfChildren() == 0) - _stations.push_back (station); + { + _stations.push_back(station); + } return rval; } } @@ -91,7 +102,9 @@ bool GMSHPolygonTree::insertStation(GeoLib::Point const* station) void GMSHPolygonTree::insertPolyline(GeoLib::PolylineWithSegmentMarker * ply) { if (!_node_polygon->isPartOfPolylineInPolygon(*ply)) + { return; + } // check if polyline segments are inside of the polygon, intersect the // polygon or are part of the boundary of the polygon @@ -108,7 +121,9 @@ void GMSHPolygonTree::insertPolyline(GeoLib::PolylineWithSegmentMarker * ply) ++segment_it) { if (ply->isSegmentMarked(segment_it.getSegmentNumber())) + { continue; + } if (_node_polygon->containsSegment(*segment_it)) { ply->markSegment(segment_it.getSegmentNumber(), true); @@ -261,7 +276,9 @@ void GMSHPolygonTree::createGMSHPoints(std::vector<GMSHPoint*> & gmsh_pnts) cons GeoLib::Point const*const pnt(_node_polygon->getPoint(k)); // if this point was already part of another polyline if (gmsh_pnts[id] != nullptr) + { continue; + } gmsh_pnts[id] = new GMSHPoint( *pnt, id, _mesh_density_strategy.getMeshDensityAtPoint(pnt)); } @@ -274,7 +291,9 @@ void GMSHPolygonTree::createGMSHPoints(std::vector<GMSHPoint*> & gmsh_pnts) cons const std::size_t id (_plys[k]->getPointID(j)); // if this point was already part of another polyline if (gmsh_pnts[id] != nullptr) + { continue; + } GeoLib::Point const*const pnt(_plys[k]->getPoint(j)); gmsh_pnts[id] = new GMSHPoint( *pnt, id, diff --git a/Applications/FileIO/Gmsh/GmshReader.cpp b/Applications/FileIO/Gmsh/GmshReader.cpp index 49d06e72af2b9fa44036d299e19287ccd2cc924e..cbbf36bd239de042f2f3ef427fadc5de493a5ae2 100644 --- a/Applications/FileIO/Gmsh/GmshReader.cpp +++ b/Applications/FileIO/Gmsh/GmshReader.cpp @@ -83,7 +83,9 @@ std::pair<MeshLib::Element*, int> readElement( // skip tags for (std::size_t j = 2; j < n_tags; j++) + { in >> dummy; + } switch (type) { @@ -107,35 +109,45 @@ std::pair<MeshLib::Element*, int> readElement( readNodeIDs(in, 4, node_ids, id_map); auto quad_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k < 4; k++) + { quad_nodes[k] = nodes[node_ids[k]]; + } return std::make_pair(new MeshLib::Quad(quad_nodes), mat_id); } case 4: { readNodeIDs(in, 4, node_ids, id_map); auto tet_nodes = new MeshLib::Node*[5]; for (unsigned k(0); k < 4; k++) + { tet_nodes[k] = nodes[node_ids[k]]; + } return std::make_pair(new MeshLib::Tet(tet_nodes), mat_id); } case 5: { readNodeIDs(in, 8, node_ids, id_map); auto hex_nodes = new MeshLib::Node*[8]; for (unsigned k(0); k < 8; k++) + { hex_nodes[k] = nodes[node_ids[k]]; + } return std::make_pair(new MeshLib::Hex(hex_nodes), mat_id); } case 6: { readNodeIDs(in, 6, node_ids, id_map); auto prism_nodes = new MeshLib::Node*[6]; for (unsigned k(0); k < 6; k++) + { prism_nodes[k] = nodes[node_ids[k]]; + } return std::make_pair(new MeshLib::Prism(prism_nodes), mat_id); } case 7: { readNodeIDs(in, 5, node_ids, id_map); auto pyramid_nodes = new MeshLib::Node*[5]; for (unsigned k(0); k < 5; k++) + { pyramid_nodes[k] = nodes[node_ids[k]]; + } return std::make_pair(new MeshLib::Pyramid(pyramid_nodes), mat_id); } case 15: @@ -231,7 +243,9 @@ MeshLib::Mesh* readGMSHMesh(std::string const& fname) std::size_t n_lines(0); in >> n_lines >> std::ws; // number-of-lines for (std::size_t i = 0; i < n_lines; i++) + { getline(in, line); + } getline(in, line); // END keyword } } diff --git a/Applications/FileIO/Legacy/OGSIOVer4.cpp b/Applications/FileIO/Legacy/OGSIOVer4.cpp index d29437f6cb15c32f5853532e12490a5f4fae0830..5b9fbfa18b644b23d7cf96529468f7a7c7589697 100644 --- a/Applications/FileIO/Legacy/OGSIOVer4.cpp +++ b/Applications/FileIO/Legacy/OGSIOVer4.cpp @@ -88,9 +88,13 @@ std::string readPoints(std::istream &in, std::vector<GeoLib::Point*>* pnt_vec, { std::size_t end_pos ((line.substr (pos + 6)).find(' ')); if (end_pos != std::string::npos) + { (*pnt_id_name_map)[line.substr (pos + 6, end_pos)] = id; + } else - (*pnt_id_name_map)[line.substr (pos + 6)] = id; + { + (*pnt_id_name_map)[line.substr(pos + 6)] = id; + } } std::size_t id_pos (line.find("$ID")); @@ -157,8 +161,10 @@ std::string readPolyline(std::istream &in, // Schleife ueber alle Phasen bzw. Komponenten do { in >> line; - if (line.find("$ID") != std::string::npos) // subkeyword found CC - in >> line; // read value + if (line.find("$ID") != std::string::npos) + { // subkeyword found CC + in >> line; // read value + } //.................................................................... if (line.find("$NAME") != std::string::npos) // subkeyword found { @@ -172,34 +178,47 @@ std::string readPolyline(std::istream &in, type = static_cast<std::size_t>(strtol(line.c_str(), nullptr, 0)); } //.................................................................... - if (line.find("$EPSILON") != std::string::npos) // subkeyword found - in >> line; // read value + if (line.find("$EPSILON") != std::string::npos) + { // subkeyword found + in >> line; // read value + } //.................................................................... - if (line.find("$MAT_GROUP") != std::string::npos) // subkeyword found - in >> line; // read value + if (line.find("$MAT_GROUP") != std::string::npos) + { // subkeyword found + in >> line; // read value + } //.................................................................... if (line.find("$POINTS") != std::string::npos) // subkeyword found { // read the point ids in >> line; if (type != 100) + { while (!in.eof() && !in.fail() && !line.empty() && (line.find('#') == std::string::npos) && (line.find('$') == std::string::npos)) { auto pnt_id(BaseLib::str2number<std::size_t>(line)); if (!zero_based_indexing) + { pnt_id--; // one based indexing + } std::size_t ply_size(ply->getNumberOfPoints()); if (ply_size > 0) { if (ply->getPointID(ply_size - 1) != pnt_id_map[pnt_id]) + { ply->addPoint(pnt_id_map[pnt_id]); + } } else + { ply->addPoint(pnt_id_map[pnt_id]); + } in >> line; } - else { + } + else + { WARN("readPolyline(): polyline is an arc *** reading not implemented"); errors.emplace_back( "[readPolyline] reading polyline as an arc is not " @@ -250,9 +269,12 @@ std::string readPolylines(std::istream &in, std::vector<GeoLib::Polyline*>* ply_ } std::string tag("#POLYLINE"); - while (!in.eof() && !in.fail() && tag.find("#POLYLINE") != std::string::npos) + while (!in.eof() && !in.fail() && + tag.find("#POLYLINE") != std::string::npos) + { tag = readPolyline(in, ply_vec, ply_vec_names, pnt_vec, zero_based_indexing, pnt_id_map, path, errors); + } return tag; } @@ -285,8 +307,10 @@ std::string readSurface(std::istream& in, do { in >> line; - if (line.find("$ID") != std::string::npos) // subkeyword found CC - in >> line; // read value + if (line.find("$ID") != std::string::npos) + { // subkeyword found CC + in >> line; // read value + } //.................................................................... if (line.find("$NAME") != std::string::npos) // subkeyword found { @@ -300,8 +324,10 @@ std::string readSurface(std::istream& in, type = strtol(line.c_str(), nullptr, 0); } //.................................................................... - if (line.find("$EPSILON") != std::string::npos) // subkeyword found - in >> line; // read value + if (line.find("$EPSILON") != std::string::npos) + { // subkeyword found + in >> line; // read value + } //.................................................................... if (line.find("$TIN") != std::string::npos) // subkeyword found { @@ -310,8 +336,10 @@ std::string readSurface(std::istream& in, sfc = GeoLib::IO::TINInterface::readTIN(file_name, pnt_vec, &errors); } //.................................................................... - if (line.find("$MAT_GROUP") != std::string::npos) // subkeyword found - in >> line; // read value + if (line.find("$MAT_GROUP") != std::string::npos) + { // subkeyword found + in >> line; // read value + } //.................................................................... if (line.find("$POLYLINES") != std::string::npos) // subkeyword found { // read the name of the polyline(s) @@ -323,9 +351,13 @@ std::string readSurface(std::istream& in, // we did read the name of a polyline -> search the id for polyline auto it(ply_vec_names.find(line)); if (it != ply_vec_names.end()) + { ply_id = it->second; + } else + { ply_id = ply_vec.size(); + } if (ply_id == ply_vec.size()) { WARN("readSurface(): polyline for surface not found!"); @@ -352,11 +384,16 @@ std::string readSurface(std::istream& in, } while (line.find('#') == std::string::npos && !line.empty() && in); if (!name.empty()) - sfc_names.insert(std::pair<std::string,std::size_t>(name,sfc_vec.size())); + { + sfc_names.insert( + std::pair<std::string, std::size_t>(name, sfc_vec.size())); + } if (sfc) + { // surface create by TIN sfc_vec.push_back (sfc); + } else { // surface created by polygon @@ -424,8 +461,10 @@ std::string readSurfaces( } } } - for (auto & k : polygon_vec) + for (auto& k : polygon_vec) + { delete k; + } return tag; } @@ -446,7 +485,9 @@ bool readGLIFileV4(const std::string& fname, std::string tag; while (tag.find("#POINTS") == std::string::npos && !in.eof()) - getline (in, tag); + { + getline(in, tag); + } // read names of points into vector of strings auto pnt_id_names_map = @@ -461,8 +502,10 @@ bool readGLIFileV4(const std::string& fname, unique_name = BaseLib::extractBaseName(fname); if (!pnt_vec->empty()) + { geo.addPointVec(std::move(pnt_vec), unique_name, std::move(pnt_id_names_map), 1e-6); + } // extract path for reading external files const std::string path = BaseLib::extractPath(fname); @@ -486,8 +529,10 @@ bool readGLIFileV4(const std::string& fname, INFO("GeoLib::readGLIFile(): tag #POLYLINE not found."); if (!ply_vec->empty()) + { geo.addPolylineVec(std::move(ply_vec), unique_name, std::move(ply_names)); + } // Since ply_names is a unique_ptr and is given to the GEOObject instance // geo it is not usable anymore. For this reason a copy is necessary. @@ -523,9 +568,11 @@ bool readGLIFileV4(const std::string& fname, in.close(); if (!sfc_vec->empty()) + { geo.addSurfaceVec( std::move(sfc_vec), unique_name, std::move(sfc_names)); // KR: insert into GEOObjects if not empty + } return errors.empty(); } @@ -590,14 +637,18 @@ void writeGLIFileV4 (const std::string& fname, os << " $NAME " << "\n" << " " << polyline_name << "\n"; os << " $POINTS" << "\n"; for (std::size_t j(0); j < ply->getNumberOfPoints(); j++) + { os << " " << ply->getPointID(j) << "\n"; + } } } // writing surfaces as TIN files const GeoLib::SurfaceVec* sfcs_vec (geo.getSurfaceVecObj (geo_name)); if (sfcs_vec) + { writeTINSurfaces(os, sfcs_vec, 0, BaseLib::extractPath(fname)); + } os << "#STOP" << "\n"; os.close (); @@ -652,8 +703,11 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects if (pnts) { for (std::size_t k(0); k < pnts->size(); k++) - os << k + pnts_offset << " " << *((*pnts)[k]) << " $NAME " << - static_cast<GeoLib::Station*>((*pnts)[k])->getName() << "\n"; + { + os << k + pnts_offset << " " << *((*pnts)[k]) << " $NAME " + << static_cast<GeoLib::Station*>((*pnts)[k])->getName() + << "\n"; + } pnts_offset += pnts->size(); pnts_id_offset.push_back (pnts_offset); } @@ -671,14 +725,20 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects os << "#POLYLINE" << "\n"; std::string ply_name; os << " $NAME\n"; - if (plys_vec->getNameOfElementByID (plys_cnt, ply_name)) + if (plys_vec->getNameOfElementByID(plys_cnt, ply_name)) + { os << " " << ply_name << "\n"; + } else + { os << " " << geo_names[j] << "-" << plys_cnt << "\n"; + } os << " $POINTS" << "\n"; for (std::size_t l(0); l < ply->getNumberOfPoints(); l++) - os << " " << pnts_id_offset[j] + - ply->getPointID(l) << "\n"; + { + os << " " << pnts_id_offset[j] + ply->getPointID(l) + << "\n"; + } plys_cnt++; } } @@ -690,12 +750,14 @@ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects { const GeoLib::SurfaceVec* sfcs_vec (geo.getSurfaceVecObj (geo_name)); if (sfcs_vec) + { sfcs_cnt += writeTINSurfaces(os, sfcs_vec, sfcs_cnt, path); + } } os << "#STOP" << "\n"; os.close (); } -} +} // namespace Legacy } // end namespace FileIO diff --git a/Applications/FileIO/Legacy/OGSIOVer4.h b/Applications/FileIO/Legacy/OGSIOVer4.h index f5998e0ffd778d9a44cdec8b4cd692d5c0be7b03..b66f900c232f0280c2fb4e4b39c1d3fec3296874 100644 --- a/Applications/FileIO/Legacy/OGSIOVer4.h +++ b/Applications/FileIO/Legacy/OGSIOVer4.h @@ -42,5 +42,5 @@ void writeGLIFileV4 (const std::string& fname, /** Writes all geometric information to a gli-file */ void writeAllDataToGLIFileV4 (const std::string& fname, const GeoLib::GEOObjects& geo); -} +} // namespace Legacy } // end namespace FileIO diff --git a/Applications/FileIO/Legacy/createSurface.cpp b/Applications/FileIO/Legacy/createSurface.cpp index b7ad63fd19ef8b4f4d3fa8649bb4d32108008e1e..0a6a3a2d3c1c10c574d7488fc0ceef8266e18369 100644 --- a/Applications/FileIO/Legacy/createSurface.cpp +++ b/Applications/FileIO/Legacy/createSurface.cpp @@ -53,13 +53,17 @@ bool createSurface(GeoLib::Polyline const& ply, GeoLib::GEOObjects geo; auto ply_points = ply.getPointsVec(); for (auto p : ply_points) + { polyline_points->push_back(new GeoLib::Point(*p)); + } std::string ply_name = "temporary_polyline_name"; geo.addPointVec(std::move(polyline_points), ply_name); auto polyline = std::make_unique<GeoLib::Polyline>(*geo.getPointVec(ply_name)); for (std::size_t k(0); k < ply.getNumberOfPoints(); ++k) + { polyline->addPoint(ply.getPointID(k)); + } auto polylines = std::make_unique<std::vector<GeoLib::Polyline*>>(); polylines->push_back(polyline.release()); geo.addPolylineVec(std::move(polylines), ply_name); @@ -123,4 +127,4 @@ bool createSurface(GeoLib::Polyline const& ply, return true; } -} // end namespace +} // namespace FileIO diff --git a/Applications/FileIO/Legacy/createSurface.h b/Applications/FileIO/Legacy/createSurface.h index e559fe1a96266816fadecd4f66e0663022f2f1c2..36162aa13a4e4467b5aae887e5852a442304ec49 100644 --- a/Applications/FileIO/Legacy/createSurface.h +++ b/Applications/FileIO/Legacy/createSurface.h @@ -27,4 +27,4 @@ namespace FileIO bool createSurface(GeoLib::Polyline const& polyline, GeoLib::GEOObjects& geometries, std::string const& geometry_name); -} +} // namespace FileIO diff --git a/Applications/FileIO/PetrelInterface.cpp b/Applications/FileIO/PetrelInterface.cpp index 1888fd9da924e05a81d65fab2de1e228f844419e..5fbc8a43a3a0505da0411b62d95cae247845ebf5 100644 --- a/Applications/FileIO/PetrelInterface.cpp +++ b/Applications/FileIO/PetrelInterface.cpp @@ -68,13 +68,17 @@ PetrelInterface::PetrelInterface(std::list<std::string> &sfc_fnames, geo_obj->addPointVec(std::unique_ptr<std::vector<GeoLib::Point*>>(pnt_vec), _unique_name); if (!well_vec->empty()) + { geo_obj->addStationVec( std::unique_ptr<std::vector<GeoLib::Point*>>(well_vec), _unique_name); + } if (!ply_vec->empty()) + { geo_obj->addPolylineVec( std::unique_ptr<std::vector<GeoLib::Polyline*>>(ply_vec), _unique_name); + } } void PetrelInterface::readPetrelSurface(std::istream &in) @@ -113,7 +117,9 @@ void PetrelInterface::readPetrelSurface(std::istream &in) pnt_vec->pop_back(); } else + { idx++; + } } } else WARN( diff --git a/Applications/FileIO/SHPInterface.cpp b/Applications/FileIO/SHPInterface.cpp index 35090a4dbd84ee09bbea59e645ea55264f7158c8..8958f4d00eeb0109715a91df16a4b9a990f02fac 100644 --- a/Applications/FileIO/SHPInterface.cpp +++ b/Applications/FileIO/SHPInterface.cpp @@ -39,7 +39,9 @@ bool SHPInterface::readSHPInfo(const std::string &filename, int &shapeType, int { SHPHandle hSHP = SHPOpen(filename.c_str(), "rb"); if (!hSHP) + { return false; + } double padfMinBound[4], padfMaxBound[4]; @@ -60,15 +62,24 @@ void SHPInterface::readSHPFile(const std::string &filename, OGSType choice, cons SHPGetInfo(hSHP, &numberOfElements, &shapeType, padfMinBound, padfMaxBound); if (((shapeType - 1) % 10 == 0) && (choice == SHPInterface::OGSType::POINT)) + { readPoints(hSHP, numberOfElements, listName); - if (((shapeType - 1) % 10 == 0) && (choice == SHPInterface::OGSType::STATION)) + } + if (((shapeType - 1) % 10 == 0) && + (choice == SHPInterface::OGSType::STATION)) + { readStations(hSHP, numberOfElements, listName); - if (((shapeType - 3) % 10 == 0 || (shapeType - 5) % 10 == 0) && (choice - == SHPInterface::OGSType::POLYLINE)) + } + if (((shapeType - 3) % 10 == 0 || (shapeType - 5) % 10 == 0) && + (choice == SHPInterface::OGSType::POLYLINE)) + { readPolylines(hSHP, numberOfElements, listName); - if (((shapeType - 3) % 10 == 0 || (shapeType - 5) % 10 == 0) && (choice - == SHPInterface::OGSType::POLYGON)) + } + if (((shapeType - 3) % 10 == 0 || (shapeType - 5) % 10 == 0) && + (choice == SHPInterface::OGSType::POLYGON)) + { readPolygons(hSHP, numberOfElements, listName); + } } void SHPInterface::readPoints(const SHPHandle &hSHP, int numberOfElements, std::string listName) @@ -115,7 +126,9 @@ void SHPInterface::readStations(const SHPHandle &hSHP, int numberOfElements, std void SHPInterface::readPolylines(const SHPHandle &hSHP, int numberOfElements, std::string listName) { if (numberOfElements <= 0) + { return; + } auto pnts = std::make_unique<std::vector<GeoLib::Point*>>(); auto lines = std::make_unique<std::vector<GeoLib::Polyline*>>(); @@ -279,4 +292,4 @@ bool SHPInterface::write2dMeshToSHP(const std::string &file_name, const MeshLib: return true; } -} +} // namespace FileIO diff --git a/Applications/FileIO/SHPInterface.h b/Applications/FileIO/SHPInterface.h index adfadab5718946190d53dee89d61272d7ed4c0b9..cdcc554bbe2af1863f63c0710d55681a5c39490c 100644 --- a/Applications/FileIO/SHPInterface.h +++ b/Applications/FileIO/SHPInterface.h @@ -83,4 +83,4 @@ private: GeoLib::GEOObjects& _geoObjects; }; -} +} // namespace FileIO diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index 73ad1f91eb37a6d80f21f6538fac50ba146c67d0..49ad36708674b41bf1be8018c38fc99054754b58 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -59,8 +59,10 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, if (!readNodesFromStream (poly_stream, nodes)) { // remove nodes read until now - for (auto & node : nodes) + for (auto& node : nodes) + { delete node; + } return false; } const std::size_t nNodes (nodes.size()); @@ -79,8 +81,10 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, if (!parseSmeshFacets(poly_stream, *surfaces, *geo_objects.getPointVec(geo_name), id_map)) { // remove surfaces read until now but keep the points - for (std::size_t k=0; k<surfaces->size(); k++) + for (std::size_t k = 0; k < surfaces->size(); k++) + { delete (*surfaces)[k]; + } } geo_objects.addSurfaceVec(std::move(surfaces), geo_name); @@ -100,14 +104,18 @@ std::size_t TetGenInterface::getNFacets(std::ifstream &input) } BaseLib::simplify(line); - if (line.empty() || line.compare(0,1,"#") == 0) + if (line.empty() || line.compare(0, 1, "#") == 0) + { continue; + } const std::list<std::string> fields = BaseLib::splitString(line, ' '); auto it = fields.begin(); const auto nFacets(BaseLib::str2number<std::size_t>(*it)); if (fields.size() > 1) + { _boundary_markers = BaseLib::str2number<std::size_t>(*(++it)) != 0; + } return nFacets; } return 0; @@ -155,8 +163,12 @@ bool TetGenInterface::parseSmeshFacets(std::ifstream &input, const std::size_t point_field_size = (_boundary_markers) ? nPoints+1 : nPoints; if (point_fields.size() > point_field_size) { - for (std::size_t j(0); j<nPoints; ++j) - point_ids.push_back(pnt_id_map[BaseLib::str2number<std::size_t>(*(++it))-offset]); + for (std::size_t j(0); j < nPoints; ++j) + { + point_ids.push_back( + pnt_id_map[BaseLib::str2number<std::size_t>(*(++it)) - + offset]); + } const std::size_t sfc_marker = (_boundary_markers) ? BaseLib::str2number<std::size_t>(*(++it)) : 0; const std::size_t idx = std::find(idx_map.begin(), idx_map.end(), sfc_marker) - idx_map.begin(); @@ -178,10 +190,14 @@ bool TetGenInterface::parseSmeshFacets(std::ifstream &input, // here the poly-file potentially defines a number of region attributes, these are ignored for now std::size_t nTotalTriangles (0); - for (auto & surface : surfaces) + for (auto& surface : surfaces) + { nTotalTriangles += surface->getNumberOfTriangles(); + } if (nTotalTriangles == nFacets) + { return true; + } ERR ("TetGenInterface::parseFacets(): Number of expected total triangles (%d) does not match number of found triangles (%d).", surfaces.size(), nTotalTriangles); return false; @@ -261,9 +277,13 @@ bool TetGenInterface::readNodesFromStream (std::ifstream &ins, // read header line bool header_okay = parseNodesFileHeader(line, n_nodes, dim, n_attributes, boundary_markers); if (!header_okay) + { return false; + } if (!parseNodes(ins, nodes, n_nodes, dim)) + { return false; + } return true; } return false; @@ -330,7 +350,9 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, if (pos_beg != std::string::npos && pos_end != std::string::npos) { id = BaseLib::str2number<std::size_t> (line.substr(pos_beg, pos_end - pos_beg)); if (k == 0 && id == 0) + { _zero_based_idx = true; + } } else { ERR("TetGenInterface::parseNodes(): Error reading ID of node %d.", k); delete [] coordinates; @@ -341,10 +363,16 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, for (std::size_t i(0); i < dim; i++) { pos_beg = line.find_first_not_of(' ', pos_end); pos_end = line.find_first_of(" \n", pos_beg); - if (pos_end == std::string::npos) pos_end = line.size(); + if (pos_end == std::string::npos) + { + pos_end = line.size(); + } if (pos_beg != std::string::npos) + { coordinates[i] = BaseLib::str2number<double>(line.substr(pos_beg, pos_end-pos_beg)); - else { + } + else + { ERR("TetGenInterface::parseNodes(): error reading coordinate %d of node %d.", i, k); delete [] coordinates; return false; @@ -383,9 +411,19 @@ bool TetGenInterface::readElementsFromStream(std::ifstream &ins, // read header line bool header_okay = parseElementsFileHeader(line, n_tets, n_nodes_per_tet, region_attributes); if (!header_okay) + { return false; - if (!parseElements(ins, elements, materials, nodes, n_tets, n_nodes_per_tet, region_attributes)) + } + if (!parseElements(ins, + elements, + materials, + nodes, + n_tets, + n_nodes_per_tet, + region_attributes)) + { return false; + } return true; } return false; @@ -402,8 +440,11 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, pos_beg = line.find_first_not_of (' '); pos_end = line.find_first_of(' ', pos_beg); if (pos_beg != std::string::npos && pos_end != std::string::npos) + { n_tets = BaseLib::str2number<std::size_t> (line.substr(pos_beg, pos_end - pos_beg)); - else { + } + else + { ERR("TetGenInterface::parseElementsFileHeader(): Could not read number of tetrahedra specified in header."); return false; } @@ -415,7 +456,9 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, pos_beg = line.find_first_not_of (" \t", pos_end); pos_end = line.find_first_of(" \t\n", pos_beg); if (pos_end == std::string::npos) + { pos_end = line.size(); + } region_attribute = line.substr(pos_beg, pos_end - pos_beg) == "1"; return true; @@ -467,9 +510,13 @@ bool TetGenInterface::parseElements(std::ifstream& ins, pos_beg = line.find_first_not_of(' ', pos_end); pos_end = line.find_first_of(' ', pos_beg); if (pos_end == std::string::npos) + { pos_end = line.size(); + } if (pos_beg != std::string::npos && pos_end != std::string::npos) + { ids[i] = BaseLib::str2number<std::size_t>(line.substr(pos_beg, pos_end - pos_beg)) - offset; + } else { ERR("TetGenInterface::parseElements(): Error reading node %d of tetrahedron %d.", i, k); @@ -482,10 +529,16 @@ bool TetGenInterface::parseElements(std::ifstream& ins, if (region_attribute) { pos_beg = line.find_first_not_of(' ', pos_end); pos_end = line.find_first_of(' ', pos_beg); - if (pos_end == std::string::npos) pos_end = line.size(); + if (pos_end == std::string::npos) + { + pos_end = line.size(); + } if (pos_beg != std::string::npos && pos_end != std::string::npos) + { region = BaseLib::str2number<int> (line.substr(pos_beg, pos_end - pos_beg)); - else { + } + else + { ERR("TetGenInterface::parseElements(): Error reading region attribute of tetrahedron %d.", k); return false; } @@ -525,13 +578,18 @@ bool TetGenInterface::writeTetGenSmesh(const std::string &file_name, const std::size_t nPoints (points->size()); out << nPoints << " 3\n"; // the point list - for (std::size_t i=0; i<nPoints; ++i) - out << i << " " << (*(*points)[i])[0] << " " << (*(*points)[i])[1] << " " << (*(*points)[i])[2] << "\n"; + for (std::size_t i = 0; i < nPoints; ++i) + { + out << i << " " << (*(*points)[i])[0] << " " << (*(*points)[i])[1] + << " " << (*(*points)[i])[2] << "\n"; + } // the surfaces header const std::size_t nSurfaces = (surfaces) ? surfaces->size() : 0; std::size_t nTotalTriangles (0); - for (std::size_t i=0; i<nSurfaces; ++i) + for (std::size_t i = 0; i < nSurfaces; ++i) + { nTotalTriangles += (*surfaces)[i]->getNumberOfTriangles(); + } out << nTotalTriangles << " 1\n"; for (std::size_t i=0; i<nSurfaces; ++i) @@ -548,13 +606,19 @@ bool TetGenInterface::writeTetGenSmesh(const std::string &file_name, out << "0\n"; // the polygon holes list // the region attributes list if (attribute_points.empty()) + { out << "0\n"; + } else { const std::size_t nAttributePoints (attribute_points.size()); out << nAttributePoints << "\n"; - for (std::size_t i=0; i<nAttributePoints; ++i) - out << i+1 << " " << attribute_points[i][0] << " " << attribute_points[i][1] << " " << attribute_points[i][2] << " " << 10*attribute_points[i].getID() << "\n"; + for (std::size_t i = 0; i < nAttributePoints; ++i) + { + out << i + 1 << " " << attribute_points[i][0] << " " + << attribute_points[i][1] << " " << attribute_points[i][2] + << " " << 10 * attribute_points[i].getID() << "\n"; + } } INFO ("TetGenInterface::writeTetGenSmesh() - %d points and %d surfaces successfully written.", nPoints, nSurfaces); out.close(); @@ -566,7 +630,9 @@ bool TetGenInterface::writeTetGenSmesh(const std::string &file_name, std::vector<MeshLib::Node> &attribute_points) const { if (mesh.getDimension() == 1) + { return false; + } const std::vector<MeshLib::Node*> &nodes = mesh.getNodes(); @@ -576,25 +642,38 @@ bool TetGenInterface::writeTetGenSmesh(const std::string &file_name, const std::size_t nPoints (nodes.size()); out << nPoints << " 3\n"; // the point list - for (std::size_t i=0; i<nPoints; ++i) - out << i << " " << (*nodes[i])[0] << " " << (*nodes[i])[1] << " " << (*nodes[i])[2] << "\n"; + for (std::size_t i = 0; i < nPoints; ++i) + { + out << i << " " << (*nodes[i])[0] << " " << (*nodes[i])[1] << " " + << (*nodes[i])[2] << "\n"; + } if (mesh.getDimension() == 2) + { write2dElements(out, mesh); + } else + { write3dElements(out, mesh, attribute_points); + } out << "0\n"; // the polygon holes list // the region attributes list if (attribute_points.empty()) + { out << "0\n"; + } else { const std::size_t nAttributePoints (attribute_points.size()); out << nAttributePoints << "\n"; - for (std::size_t i=0; i<nAttributePoints; ++i) - out << i+1 << " " << attribute_points[i][0] << " " << attribute_points[i][1] << " " << attribute_points[i][2] << " " << 10*attribute_points[i].getID() << "\n"; + for (std::size_t i = 0; i < nAttributePoints; ++i) + { + out << i + 1 << " " << attribute_points[i][0] << " " + << attribute_points[i][1] << " " << attribute_points[i][2] + << " " << 10 * attribute_points[i].getID() << "\n"; + } } INFO ("TetGenInterface::writeTetGenPoly() - %d points and %d surfaces successfully written.", nPoints, mesh.getNumberOfElements()); @@ -631,7 +710,9 @@ void TetGenInterface::write3dElements(std::ofstream &out, const std::vector<MeshLib::Element*> &elements = mesh.getElements(); const std::size_t nElements (elements.size()); if (!attribute_points.empty()) + { attribute_points.clear(); + } // get position where number of facets need to be written and figure out worst case of chars that are needed const std::streamoff before_elems_pos (out.tellp()); @@ -643,7 +724,9 @@ void TetGenInterface::write3dElements(std::ofstream &out, for (std::size_t i=0; i<nElements; ++i) { if (elements[i]->getDimension() < 3) + { continue; + } const unsigned nFaces (elements[i]->getNumberOfNeighbors()); std::string const mat_id_str = @@ -652,16 +735,21 @@ void TetGenInterface::write3dElements(std::ofstream &out, { MeshLib::Element const*const neighbor ( elements[i]->getNeighbor(j) ); - if (neighbor && materialIds && (*materialIds)[i] <= (*materialIds)[neighbor->getID()]) + if (neighbor && materialIds && + (*materialIds)[i] <= (*materialIds)[neighbor->getID()]) + { continue; + } std::unique_ptr<MeshLib::Element const> const face (elements[i]->getFace(j)); this->writeElementToFacets(out, *face, element_count, mat_id_str); } if (materialIds) + { attribute_points.emplace_back( elements[i]->getCenterOfGravity().getCoords(), (*materialIds)[i]); + } } // add number of facets at correct position and jump back const std::streamoff after_elems_pos (out.tellp()); @@ -674,7 +762,9 @@ void TetGenInterface::writeElementToFacets(std::ofstream &out, const MeshLib::El { element_count++; if (element.getGeomType() == MeshLib::MeshElemType::TRIANGLE) + { out << "3 " << element.getNodeIndex(0) << " " << element.getNodeIndex(1) << " " << element.getNodeIndex(2) << " " << matId << " # " << element_count << "\n"; + } else if (element.getGeomType() == MeshLib::MeshElemType::QUAD) { out << "3 " << element.getNodeIndex(0) << " " << element.getNodeIndex(1) << " " << element.getNodeIndex(2) << " " << matId << " # " << element_count << "\n"; diff --git a/Applications/FileIO/TetGenInterface.h b/Applications/FileIO/TetGenInterface.h index 18c3b0f6e684a523ab74e7ff7ac27f25a5c74d32..c02358ac359c8cd239e7a0dea08d50d257cc2321 100644 --- a/Applications/FileIO/TetGenInterface.h +++ b/Applications/FileIO/TetGenInterface.h @@ -214,4 +214,4 @@ private: /// true if boundary markers are set, false otherwise bool _boundary_markers; }; -} +} // namespace FileIO diff --git a/Applications/FileIO/readGeometryFromFile.cpp b/Applications/FileIO/readGeometryFromFile.cpp index e1bb9791732f44780aaa50c7e116efd15e217f8c..4f355b73ac87f5917ce3fadd0a47077f65627149 100644 --- a/Applications/FileIO/readGeometryFromFile.cpp +++ b/Applications/FileIO/readGeometryFromFile.cpp @@ -42,4 +42,4 @@ readGeometryFromFile(std::string const& fname, GeoLib::GEOObjects & geo_objs) "Something is wrong in the reading function."); } } -} +} // namespace FileIO diff --git a/Applications/FileIO/writeGeometryToFile.cpp b/Applications/FileIO/writeGeometryToFile.cpp index c7a528198f2ba439a938d4d12ae9e1a157c9e3c9..0c279cbde36e941f097aeb64608cf4e74ac4acdc 100644 --- a/Applications/FileIO/writeGeometryToFile.cpp +++ b/Applications/FileIO/writeGeometryToFile.cpp @@ -34,4 +34,4 @@ void writeGeometryToFile(std::string const& geo_name, " the required format from file extension."); } } -} +} // namespace FileIO diff --git a/Applications/Utils/FileConverter/TIN2VTK.cpp b/Applications/Utils/FileConverter/TIN2VTK.cpp index 2c3ce8cd6d0583e43cd232ef2b2d7f14df79a38a..9b5d3cbdd375083d80715ed449772c80a1db53ef 100644 --- a/Applications/Utils/FileConverter/TIN2VTK.cpp +++ b/Applications/Utils/FileConverter/TIN2VTK.cpp @@ -61,7 +61,9 @@ int main (int argc, char* argv[]) std::unique_ptr<GeoLib::Surface> sfc( GeoLib::IO::TINInterface::readTIN(tinFileName, point_vec)); if (!sfc) + { return EXIT_FAILURE; + } INFO("TIN read: %d points, %d triangles", point_vec.size(), sfc->getNumberOfTriangles()); diff --git a/Applications/Utils/FileConverter/TecPlotTools.cpp b/Applications/Utils/FileConverter/TecPlotTools.cpp index 356ddd58457640c8dbc02435bd9beffe7c926f8e..951578be01a6d94e9334fa06d2e998c140d19bdf 100644 --- a/Applications/Utils/FileConverter/TecPlotTools.cpp +++ b/Applications/Utils/FileConverter/TecPlotTools.cpp @@ -142,7 +142,9 @@ void resetDataStructures(std::size_t const& n_scalars, scalars.clear(); scalars.reserve(n_scalars); for (std::size_t i = 0; i < n_scalars; ++i) + { scalars.push_back(std::vector<double>(0)); + } val_count = 0; } @@ -231,7 +233,9 @@ void skipGeometrySection(std::ifstream& in, std::string& line) if ((line.find("TITLE") != std::string::npos) || (line.find("VARIABLES") != std::string::npos) || (line.find("ZONE") != std::string::npos)) + { return; + } } } @@ -247,23 +251,29 @@ int splitFile(std::ifstream& in, std::string file_name) if (line.find("TITLE") != std::string::npos) { if (dataCountError(out, name, val_count, val_total)) + { return -3; + } writeTecPlotSection(out, file_name, write_count, val_count, val_total); out << line << "\n"; continue; } - else if (line.find("VARIABLES") != std::string::npos) + if (line.find("VARIABLES") != std::string::npos) { if (dataCountError(out, name, val_count, val_total)) + { return -3; + } writeTecPlotSection(out, file_name, write_count, val_count, val_total); out << line << "\n"; continue; } - else if (line.find("ZONE") != std::string::npos) + if (line.find("ZONE") != std::string::npos) { if (dataCountError(out, name, val_count, val_total)) + { return -3; + } writeTecPlotSection(out, file_name, write_count, val_count, val_total); out << line << "\n"; name = getName(line); @@ -277,7 +287,9 @@ int splitFile(std::ifstream& in, std::string file_name) val_count++; } if (dataCountError(out, name, val_count, val_total)) + { return -3; + } INFO("Writing time step #%i", write_count); out.close(); INFO("Finished split."); @@ -296,14 +308,20 @@ int convertFile(std::ifstream& in, std::string file_name) while (std::getline(in, line)) { if (line.find("GEOMETRY") != std::string::npos) + { skipGeometrySection(in, line); + } if (line.empty()) + { continue; - else if (line.find("TITLE") != std::string::npos) + } + if (line.find("TITLE") != std::string::npos) { if (dataCountError(name, val_count, val_total)) + { return -3; + } if (val_count != 0) { writeDataToMesh(file_name, write_count, var_names, scalars, dims); @@ -316,7 +334,9 @@ int convertFile(std::ifstream& in, std::string file_name) if (val_count != 0) { if (dataCountError(name, val_count, val_total)) + { return -3; + } writeDataToMesh(file_name, write_count, var_names, scalars, dims); } var_names.clear(); @@ -329,7 +349,9 @@ int convertFile(std::ifstream& in, std::string file_name) if (val_count != 0) { if (dataCountError(name, val_count, val_total)) + { return -3; + } writeDataToMesh(file_name, write_count, var_names, scalars, dims); resetDataStructures(var_names.size(), scalars, val_count); } @@ -361,7 +383,9 @@ int convertFile(std::ifstream& in, std::string file_name) val_count++; } if (dataCountError(name, val_count, val_total)) + { return -3; + } writeDataToMesh(file_name, write_count, var_names, scalars, dims); INFO("Finished conversion."); return 0; @@ -429,9 +453,13 @@ int main(int argc, char* argv[]) output_arg.getValue() : input_arg.getValue(); int return_val(0); if (split_arg.getValue()) + { return_val = splitFile(in, filename); + } else if (convert_arg.getValue()) + { return_val = convertFile(in, filename); + } in.close(); return return_val; diff --git a/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp b/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp index 5ddfc81804c3f3f4e84af5c7736316d2b357e416..c92811f33926790701a03d5f13a5133e6c0dda9c 100644 --- a/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp +++ b/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp @@ -79,7 +79,9 @@ int main (int argc, char* argv[]) if (out_prop.is_open()) { for (std::size_t i = 0; i < n_properties; ++i) + { out_prop << i << "\t" << (*materialIds)[i] << "\n"; + } out_prop.close(); } else diff --git a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp index 5dc7be5d413bbf1604daa38ef5c3d41ae7206ad0..4924585d25559232a412206eb3607ac3f1204fa6 100644 --- a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp +++ b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp @@ -97,8 +97,9 @@ void writeBCsAndGeometry(GeoLib::GEOObjects& geometry_sets, bool liquid_flow(false); if (bc_type == "LIQUID_FLOW") + { liquid_flow = true; - + } GeoLib::PointVec const* pnt_vec_objs(geometry_sets.getPointVecObj(geo_name)); std::vector<GeoLib::Point*> const& pnts(*(pnt_vec_objs->getVector())); @@ -107,9 +108,13 @@ void writeBCsAndGeometry(GeoLib::GEOObjects& geometry_sets, std::string const& pnt_name(pnt_vec_objs->getItemNameByID(k)); if (!pnt_name.empty()) { if (liquid_flow) + { writeLiquidFlowPointBC(bc_out, pnt_name); + } else + { writeGroundwaterFlowPointBC(bc_out, pnt_name, (*pnts[k])[2]); + } } } bc_out << "#STOP\n"; @@ -217,7 +222,9 @@ int main (int argc, char* argv[]) std::vector<std::size_t> ids (mesh_searcher.getMeshNodeIDsAlongPolyline(*((*plys)[k]))); if (ids.empty()) + { continue; + } std::string geo_name("Polyline-"+std::to_string(k)); convertMeshNodesToGeometry(surface_mesh->getNodes(), ids, geo_name, geometry_sets); @@ -233,7 +240,9 @@ int main (int argc, char* argv[]) std::string merge_name("AllMeshNodesAlongPolylines"); if (geometry_sets.mergeGeometries(geo_names, merge_name) == 2) + { merge_name = geo_names[0]; + } GeoLib::PointVec const* pnt_vec(geometry_sets.getPointVecObj(merge_name)); std::vector<GeoLib::Point*> const* merged_pnts(pnt_vec->getVector()); diff --git a/Applications/Utils/MeshEdit/ExtractSurface.cpp b/Applications/Utils/MeshEdit/ExtractSurface.cpp index 1f2ff9598c3d967ca4108a9a871108cf5c478169..ff587b3a638813d446a609134ba3492249d2a3ff 100644 --- a/Applications/Utils/MeshEdit/ExtractSurface.cpp +++ b/Applications/Utils/MeshEdit/ExtractSurface.cpp @@ -104,7 +104,9 @@ int main (int argc, char* argv[]) std::string out_fname(mesh_out.getValue()); if (out_fname.empty()) + { out_fname = BaseLib::dropFileExtension(mesh_in.getValue()) + "_sfc.vtu"; + } MeshLib::IO::writeMeshToFile(*surface_mesh, out_fname); return EXIT_SUCCESS; diff --git a/Applications/Utils/MeshEdit/NodeReordering.cpp b/Applications/Utils/MeshEdit/NodeReordering.cpp index 8a7a5d43c02bd0c853f966dcb57930d981d44392..034d9991a052dcbd17f78f60c40eafeeafaca8d4 100644 --- a/Applications/Utils/MeshEdit/NodeReordering.cpp +++ b/Applications/Utils/MeshEdit/NodeReordering.cpp @@ -33,7 +33,9 @@ void reorderNodes(std::vector<MeshLib::Element*> &elements) for (std::size_t i=0; i<nElements; ++i) { if (elements[i]->testElementNodeOrder()) + { continue; + } n_corrected_elements++; const unsigned nElemNodes (elements[i]->getNumberOfBaseNodes()); @@ -42,12 +44,16 @@ void reorderNodes(std::vector<MeshLib::Element*> &elements) switch (elements[i]->getGeomType()) { case MeshLib::MeshElemType::TETRAHEDRON: - for(std::size_t j = 0; j < 4; ++j) - elements[i]->setNode(j, nodes[(j+1)%4]); + for (std::size_t j = 0; j < 4; ++j) + { + elements[i]->setNode(j, nodes[(j + 1) % 4]); + } break; case MeshLib::MeshElemType::PYRAMID: - for(std::size_t j = 0; j < 5; ++j) - elements[i]->setNode(j, nodes[(j+1)%5]); + for (std::size_t j = 0; j < 5; ++j) + { + elements[i]->setNode(j, nodes[(j + 1) % 5]); + } break; case MeshLib::MeshElemType::PRISM: for(std::size_t j = 0; j < 3; ++j) @@ -64,8 +70,10 @@ void reorderNodes(std::vector<MeshLib::Element*> &elements) } break; default: - for(std::size_t j = 0; j < nElemNodes; ++j) + for (std::size_t j = 0; j < nElemNodes; ++j) + { elements[i]->setNode(j, nodes[nElemNodes - j - 1]); + } } } @@ -81,7 +89,8 @@ void reorderNodes2(std::vector<MeshLib::Element*> &elements) const unsigned nElemNodes (elements[i]->getNumberOfBaseNodes()); std::vector<MeshLib::Node*> nodes(elements[i]->getNodes(), elements[i]->getNodes() + nElemNodes); - for(std::size_t j = 0; j < nElemNodes; ++j) + for (std::size_t j = 0; j < nElemNodes; ++j) + { if (elements[i]->getGeomType() == MeshLib::MeshElemType::PRISM) { for(std::size_t j = 0; j < 3; ++j) @@ -91,6 +100,7 @@ void reorderNodes2(std::vector<MeshLib::Element*> &elements) } break; } + } } } @@ -100,10 +110,16 @@ void reorderNonlinearNodes(MeshLib::Mesh &mesh) std::vector<MeshLib::Node*> nonlinear_nodes; for (MeshLib::Element const* e : mesh.getElements()) { - for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) + for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++) + { base_nodes.push_back(const_cast<MeshLib::Node*>(e->getNode(i))); - for (unsigned i=e->getNumberOfBaseNodes(); i<e->getNumberOfNodes(); i++) - nonlinear_nodes.push_back(const_cast<MeshLib::Node*>(e->getNode(i))); + } + for (unsigned i = e->getNumberOfBaseNodes(); i < e->getNumberOfNodes(); + i++) + { + nonlinear_nodes.push_back( + const_cast<MeshLib::Node*>(e->getNode(i))); + } } BaseLib::makeVectorUnique(base_nodes, @@ -159,11 +175,17 @@ int main (int argc, char* argv[]) INFO("Reordering nodes... "); if (!method_arg.isSet() || method_arg.getValue() == 1) + { reorderNodes(const_cast<std::vector<MeshLib::Element*>&>(mesh->getElements())); + } else if (method_arg.getValue() == 2) + { reorderNodes2(const_cast<std::vector<MeshLib::Element*>&>(mesh->getElements())); + } else if (method_arg.getValue() == 3) + { reorderNonlinearNodes(*mesh); + } else { ERR ("Unknown re-ordering method. Exit program..."); diff --git a/Applications/Utils/MeshEdit/UnityPreprocessing.cpp b/Applications/Utils/MeshEdit/UnityPreprocessing.cpp index 083896733b660a46b56669d2cccf7561d72ff831..8659d23c86a40c09aa251dc97a61a24d6e7a3c3b 100644 --- a/Applications/Utils/MeshEdit/UnityPreprocessing.cpp +++ b/Applications/Utils/MeshEdit/UnityPreprocessing.cpp @@ -32,7 +32,9 @@ bool containsCellVecs(MeshLib::Mesh const& mesh) MeshLib::Properties const& props (mesh.getProperties()); std::vector<std::string> const& vec_names(props.getPropertyVectorNames(MeshLib::MeshItemType::Cell)); if (vec_names.empty()) + { return false; + } return true; } @@ -61,7 +63,9 @@ bool fillPropVec(MeshLib::Properties const& props, std::size_t total_nodes) { if (!props.existsPropertyVector<T>(name)) + { return false; + } MeshLib::PropertyVector<T> const*const vec = props.getPropertyVector<T>(name); if (vec->getNumberOfComponents() != 1) @@ -81,8 +85,10 @@ bool fillPropVec(MeshLib::Properties const& props, for (std::size_t i = 0; i<n_nodes; ++i) { std::size_t const n_nodes = node_map[i].size(); - for (std::size_t j = 0; j<n_nodes; ++j) + for (std::size_t j = 0; j < n_nodes; ++j) + { (*new_vec)[node_map[i][j]] = (*vec)[i]; + } } } else if (vec->getMeshItemType() == MeshLib::MeshItemType::Cell) @@ -92,8 +98,10 @@ bool fillPropVec(MeshLib::Properties const& props, for (std::size_t i = 0; i<n_elems; ++i) { std::size_t const n_nodes = elems[i]->getNumberOfNodes(); - for (std::size_t j = 0; j<n_nodes; ++j) + for (std::size_t j = 0; j < n_nodes; ++j) + { (*new_vec)[elems[i]->getNodeIndex(j)] = (*vec)[i]; + } } } return true; @@ -109,11 +117,18 @@ MeshLib::Properties constructProperties(MeshLib::Properties const& props, for (std::string const& name : names) { if (fillPropVec<int>(props, name, new_props, elems, node_map, n_nodes)) + { continue; - if (fillPropVec<double>(props, name, new_props, elems, node_map, n_nodes)) + } + if (fillPropVec<double>(props, name, new_props, elems, node_map, + n_nodes)) + { continue; + } if (fillPropVec<long>(props, name, new_props, elems, node_map, n_nodes)) + { continue; + } } return new_props; } @@ -129,19 +144,33 @@ MeshLib::Mesh* constructMesh(MeshLib::Mesh const& mesh) for (MeshLib::Element* elem : elems) { if (elem->getGeomType() == MeshLib::MeshElemType::LINE) + { new_elems.push_back(createElement<MeshLib::Line>(*elem, new_nodes, node_map)); + } else if (elem->getGeomType() == MeshLib::MeshElemType::TRIANGLE) + { new_elems.push_back(createElement<MeshLib::Tri>(*elem, new_nodes, node_map)); + } else if (elem->getGeomType() == MeshLib::MeshElemType::QUAD) + { new_elems.push_back(createElement<MeshLib::Quad>(*elem, new_nodes, node_map)); + } else if (elem->getGeomType() == MeshLib::MeshElemType::TETRAHEDRON) + { new_elems.push_back(createElement<MeshLib::Tet>(*elem, new_nodes, node_map)); + } else if (elem->getGeomType() == MeshLib::MeshElemType::HEXAHEDRON) + { new_elems.push_back(createElement<MeshLib::Hex>(*elem, new_nodes, node_map)); + } else if (elem->getGeomType() == MeshLib::MeshElemType::PYRAMID) + { new_elems.push_back(createElement<MeshLib::Pyramid>(*elem, new_nodes, node_map)); + } else if (elem->getGeomType() == MeshLib::MeshElemType::PRISM) + { new_elems.push_back(createElement<MeshLib::Prism>(*elem, new_nodes, node_map)); + } else { ERR("Error: Unknown element type."); @@ -182,7 +211,9 @@ int main (int argc, char* argv[]) INFO("Reading mesh '%s' ... ", mesh_arg.getValue().c_str()); std::unique_ptr<MeshLib::Mesh> mesh {MeshLib::IO::readMeshFromFile(mesh_arg.getValue())}; if (!mesh) + { return EXIT_FAILURE; + } INFO("done.\n"); INFO("Checking for line elements..."); @@ -209,7 +240,9 @@ int main (int argc, char* argv[]) INFO("Checking for cell-arrays..."); if (containsCellVecs(*result)) + { result.reset(constructMesh(*result)); + } else INFO("No cell arrays found, keeping mesh structure.\n"); diff --git a/Applications/Utils/MeshEdit/checkMesh.cpp b/Applications/Utils/MeshEdit/checkMesh.cpp index d3ca67c1bdb1a4fa5371ae91ac31b522e6941a3a..4636a5b3d30e8ae25f077153f88fe6144e0a80bb 100644 --- a/Applications/Utils/MeshEdit/checkMesh.cpp +++ b/Applications/Utils/MeshEdit/checkMesh.cpp @@ -58,7 +58,9 @@ int main(int argc, char *argv[]) std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::IO::readMeshFromFile(mesh_arg.getValue())); if (!mesh) + { return EXIT_FAILURE; + } const unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); if (mem_with_mesh>0) diff --git a/Applications/Utils/MeshEdit/convertToLinearMesh.cpp b/Applications/Utils/MeshEdit/convertToLinearMesh.cpp index 449054adb0405c14c1963d005da16a6c97e13c97..93333baa20a3fbc57d58193e8539af4c9b9b4aec 100644 --- a/Applications/Utils/MeshEdit/convertToLinearMesh.cpp +++ b/Applications/Utils/MeshEdit/convertToLinearMesh.cpp @@ -45,7 +45,9 @@ int main(int argc, char *argv[]) std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::IO::readMeshFromFile(input_arg.getValue())); if (!mesh) + { return EXIT_FAILURE; + } if (!mesh->isNonlinear()) { ERR("The input mesh is not non-linear. Exit."); diff --git a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp index 9c0240dac05ff6737f73871ec35757d84097ecd2..2cd9ca66ba3b6d5e65dbe9dd158743d7b46eb1fa 100644 --- a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp +++ b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp @@ -42,7 +42,9 @@ int readRasterPaths(std::string const& raster_list_file, std::vector<std::string while (getline(in, line)) { if (line.empty()) + { continue; + } raster_path_vec.push_back(line); } if (raster_path_vec.size()<2) @@ -115,20 +117,28 @@ int main (int argc, char* argv[]) std::vector<std::string> raster_paths; if (readRasterPaths(raster_path_arg.getValue(), raster_paths) != 0) + { return EXIT_FAILURE; + } MeshLib::MeshLayerMapper mapper; if (auto rasters = FileIO::readRasters(raster_paths)) { if (!mapper.createLayers(*sfc_mesh, *rasters, min_thickness)) + { return EXIT_FAILURE; + } } else + { return EXIT_FAILURE; + } std::string output_name (mesh_out_arg.getValue()); if (!BaseLib::hasFileExtension("vtu", output_name)) + { output_name.append(".vtu"); + } INFO("Writing mesh '%s' ... ", output_name.c_str()); MeshLib::IO::writeMeshToFile(*(mapper.getMesh("SubsurfaceMesh").release()), output_name); INFO("done."); diff --git a/Applications/Utils/MeshEdit/createQuadraticMesh.cpp b/Applications/Utils/MeshEdit/createQuadraticMesh.cpp index 26ec98ef27ed92890d09235bc9245e4d9385effd..b6af02c6a737a636947b5be38399c6eeae4620d6 100644 --- a/Applications/Utils/MeshEdit/createQuadraticMesh.cpp +++ b/Applications/Utils/MeshEdit/createQuadraticMesh.cpp @@ -45,7 +45,9 @@ int main(int argc, char *argv[]) std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::IO::readMeshFromFile(input_arg.getValue())); if (!mesh) + { return EXIT_FAILURE; + } INFO("Create a quadratic order mesh"); auto new_mesh(MeshLib::createQuadraticOrderMesh(*mesh)); diff --git a/Applications/Utils/MeshEdit/moveMeshNodes.cpp b/Applications/Utils/MeshEdit/moveMeshNodes.cpp index 6eac256e0fedf27c96835efc8648fa18effcb4dd..a2d0af625ed449c7691837b294512168f1b1fd5f 100644 --- a/Applications/Utils/MeshEdit/moveMeshNodes.cpp +++ b/Applications/Utils/MeshEdit/moveMeshNodes.cpp @@ -49,8 +49,14 @@ int find_closest_point(MeshLib::Node const*const point, std::vector<MeshLib::Nod bool containsPoint(MeshLib::Node const& pnt, MathLib::Point3d const& min, MathLib::Point3d const& max) { - if (pnt[0] < min[0] || max[0] < pnt[0]) return false; - if (pnt[1] < min[1] || max[1] < pnt[1]) return false; + if (pnt[0] < min[0] || max[0] < pnt[0]) + { + return false; + } + if (pnt[1] < min[1] || max[1] < pnt[1]) + { + return false; + } return true; } @@ -94,12 +100,14 @@ int main (int argc, char* argv[]) } bool is_keyword(false); - for (auto & keyword : keywords) + for (auto& keyword : keywords) + { if (current_key == keyword) { is_keyword = true; break; } + } if (!is_keyword) { @@ -172,8 +180,10 @@ int main (int argc, char* argv[]) if (is_inside) { int idx = find_closest_point(nodes[i], ground_truth_nodes, max_dist); - if (idx>=0) - (*nodes[i])[2] = (*(ground_truth_nodes[idx]))[2]-offset; + if (idx >= 0) + { + (*nodes[i])[2] = (*(ground_truth_nodes[idx]))[2] - offset; + } } } } @@ -186,27 +196,35 @@ int main (int argc, char* argv[]) std::vector<MeshLib::Node*> nodes (mesh->getNodes()); std::vector<double> elevation(nNodes); - for (std::size_t i=0; i<nNodes; i++) + for (std::size_t i = 0; i < nNodes; i++) + { elevation[i] = (*nodes[i])[2]; + } for (std::size_t i=0; i<nNodes; i++) { const std::vector<MeshLib::Node*> conn_nodes (nodes[i]->getConnectedNodes()); const unsigned nConnNodes (conn_nodes.size()); elevation[i] = (2*(*nodes[i])[2]); - for (std::size_t j=0; j<nConnNodes; ++j) + for (std::size_t j = 0; j < nConnNodes; ++j) + { elevation[i] += (*conn_nodes[j])[2]; + } elevation[i] /= (nConnNodes+2); } - for (std::size_t i=0; i<nNodes; i++) + for (std::size_t i = 0; i < nNodes; i++) + { (*nodes[i])[2] = elevation[i]; + } } /**** add other keywords here ****/ std::string const new_mesh_name (msh_name.substr(0, msh_name.length() - 4) + "_new.vtu"); if (MeshLib::IO::writeMeshToFile(*mesh, new_mesh_name) != 0) + { return EXIT_FAILURE; + } INFO("Result successfully written."); return EXIT_SUCCESS; diff --git a/Applications/Utils/MeshEdit/queryMesh.cpp b/Applications/Utils/MeshEdit/queryMesh.cpp index 5b5d888a2823bb3db6dc07c82ad6c0e93dd77d77..3ed896685a3630876acd388bc0ba3078c8db2625 100644 --- a/Applications/Utils/MeshEdit/queryMesh.cpp +++ b/Applications/Utils/MeshEdit/queryMesh.cpp @@ -53,7 +53,9 @@ int main(int argc, char *argv[]) auto const mesh = std::unique_ptr<MeshLib::Mesh>( MeshLib::IO::readMeshFromFile(filename)); if (!mesh) + { return EXIT_FAILURE; + } std::vector<std::size_t> selected_node_ids; if (showNodeWithMaxEle_arg.getValue()) @@ -79,18 +81,27 @@ int main(int argc, char *argv[]) out << "# Element " << ele->getID() << std::endl; out << "Type : " << CellType2String(ele->getCellType()) << std::endl; if (materialIds) + { out << "Mat ID : " << (*materialIds)[ele_id] << std::endl; + } out << "Nodes: " << std::endl; - for (unsigned i=0; i<ele->getNumberOfNodes(); i++) - out << ele->getNode(i)->getID() << " " << *ele->getNode(i) << std::endl; + for (unsigned i = 0; i < ele->getNumberOfNodes(); i++) + { + out << ele->getNode(i)->getID() << " " << *ele->getNode(i) + << std::endl; + } out << "Content: " << ele->getContent() << std::endl; out << "Neighbors: "; for (unsigned i=0; i<ele->getNumberOfNeighbors(); i++) { if (ele->getNeighbor(i)) + { out << ele->getNeighbor(i)->getID() << " "; + } else + { out << "none "; + } } out << std::endl; INFO("%s", out.str().c_str()); @@ -107,11 +118,15 @@ int main(int argc, char *argv[]) out << "Coordinates: " << *node << std::endl; out << "Connected elements (" << node->getNumberOfElements() << "): "; for (auto ele : node->getElements()) + { out << ele->getID() << " "; + } out << std::endl; out << "Connected nodes (" << node->getConnectedNodes().size() << "): "; for (auto nd : node->getConnectedNodes()) + { out << nd->getID() << " "; + } out << std::endl; INFO("%s", out.str().c_str()); } diff --git a/Applications/Utils/MeshEdit/removeMeshElements.cpp b/Applications/Utils/MeshEdit/removeMeshElements.cpp index c55940490f3fa4ef500af2c0e5e6d191e980a703..648e91665bbfa7860c1f1a794bee426878acb4c2 100644 --- a/Applications/Utils/MeshEdit/removeMeshElements.cpp +++ b/Applications/Utils/MeshEdit/removeMeshElements.cpp @@ -36,8 +36,10 @@ void searchByPropertyValue(std::string const& property_name, std::size_t n_marked_elements = searcher.searchByPropertyValue<double>( property_name, property_value); if (n_marked_elements == 0) + { n_marked_elements = searcher.searchByPropertyValue<int>( property_name, property_value); + } INFO("%d elements with property value %s found.", n_marked_elements, std::to_string(property_value).c_str()); @@ -53,9 +55,11 @@ void searchByPropertyRange(std::string const& property_name, property_name, min_value, max_value, outside); if (n_marked_elements == 0) + { n_marked_elements = searcher.searchByPropertyValueRange<int>( property_name, static_cast<int>(min_value), static_cast<int>(max_value), outside); + } // add checks for other data types here (if n_marked_elements remains 0) @@ -145,7 +149,9 @@ int main (int argc, char* argv[]) std::unique_ptr<MeshLib::Mesh const> mesh( MeshLib::IO::readMeshFromFile(mesh_in.getValue())); if (mesh == nullptr) + { return EXIT_FAILURE; + } INFO("Mesh read: %d nodes, %d elements.", mesh->getNumberOfNodes(), mesh->getNumberOfElements()); MeshLib::ElementSearch searcher(*mesh); @@ -158,7 +164,10 @@ int main (int argc, char* argv[]) 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; + if (type == MeshLib::MeshElemType::INVALID) + { + continue; + } INFO("%d %s elements found.", searcher.searchByElementType(type), typeName.c_str()); } @@ -230,7 +239,9 @@ int main (int argc, char* argv[]) aabb_error = true; } if (aabb_error) + { return EXIT_FAILURE; + } std::array<MathLib::Point3d, 2> extent({{ MathLib::Point3d(std::array<double,3>{{xSmallArg.getValue(), @@ -246,7 +257,9 @@ int main (int argc, char* argv[]) *mesh, searcher.getSearchedElementIDs(), mesh->getName())); if (new_mesh == nullptr) + { return EXIT_FAILURE; + } // write into a file MeshLib::IO::writeMeshToFile(*new_mesh, mesh_out.getValue()); diff --git a/Applications/Utils/MeshEdit/reviseMesh.cpp b/Applications/Utils/MeshEdit/reviseMesh.cpp index c03308af52be303a93577821361858d241f49768..dbd87f3ab37360223a0a51cc1c7fe9f81f75ba73 100644 --- a/Applications/Utils/MeshEdit/reviseMesh.cpp +++ b/Applications/Utils/MeshEdit/reviseMesh.cpp @@ -57,7 +57,9 @@ int main(int argc, char *argv[]) std::unique_ptr<MeshLib::Mesh> org_mesh( MeshLib::IO::readMeshFromFile(input_arg.getValue())); if (!org_mesh) + { return EXIT_FAILURE; + } INFO("Mesh read: %d nodes, %d elements.", org_mesh->getNumberOfNodes(), org_mesh->getNumberOfElements()); // revise the mesh diff --git a/Applications/Utils/MeshEdit/swapNodeCoordinateAxes.cpp b/Applications/Utils/MeshEdit/swapNodeCoordinateAxes.cpp index e19f5cdddefc66ff7d45154712459a42540ba9a2..3d1d145a82d94b8994a216d4e69bc9e17ac5a381 100644 --- a/Applications/Utils/MeshEdit/swapNodeCoordinateAxes.cpp +++ b/Applications/Utils/MeshEdit/swapNodeCoordinateAxes.cpp @@ -28,10 +28,14 @@ static void swapNodeCoordinateAxes(MeshLib::Mesh &mesh, std::array<int, 3> const double new_coords[3] = {}; for (MeshLib::Node* node : mesh.getNodes()) { - for (int i=0; i<3; i++) + for (int i = 0; i < 3; i++) + { new_coords[i] = (*node)[new_axes_indices[i]]; - for (int i=0; i<3; i++) + } + for (int i = 0; i < 3; i++) + { (*node)[i] = new_coords[i]; + } } } @@ -43,18 +47,27 @@ static bool parseNewOrder(std::string const& str_order, std::array<int, 3> &new_ return false; } - for (std::size_t i=0; i<new_axes_indices.size(); i++) + for (std::size_t i = 0; i < new_axes_indices.size(); i++) + { new_axes_indices[i] = -1; + } for (int i=0; i<3; i++) { if (str_order[i] == 'x') + { new_axes_indices[i] = 0; + } else if (str_order[i] == 'y') + { new_axes_indices[i] = 1; + } else if (str_order[i] == 'z') + { new_axes_indices[i] = 2; - else { + } + else + { ERR("Invalid argument for the new order. The given argument " "contains a character other than 'x', 'y', 'z'."); return false; @@ -102,12 +115,16 @@ int main(int argc, char *argv[]) const std::string str_order = new_order_arg.getValue(); std::array<int, 3> new_order = {{}}; if (!parseNewOrder(str_order, new_order)) + { return EXIT_FAILURE; + } std::unique_ptr<MeshLib::Mesh> mesh( MeshLib::IO::readMeshFromFile(input_arg.getValue())); if (!mesh) + { return EXIT_FAILURE; + } if (mesh->getDimension() == 3) { diff --git a/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp b/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp index 69e8f07c48b4972b20683ce127b2628a55f64402..d80629f48c6624b0ca114627ab02a62056fef0af 100644 --- a/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp +++ b/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp @@ -135,7 +135,9 @@ int main (int argc, char* argv[]) std::string polygon_name; ply_vec->getNameOfElement(plys[j], polygon_name); if (polygon_name.empty()) + { polygon_name = "Polygon-" + std::to_string(j); + } // create Polygon from Polyline GeoLib::Polygon const& polygon(*(plys[j])); // ids of mesh nodes on surface that are within the given polygon diff --git a/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp b/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp index 1491d7b224705bd5e8ee4f0c1aaac6571fc3cb35..3614095d5d0ea1901b6ff6339a39a4399556c029 100644 --- a/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp +++ b/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp @@ -126,7 +126,9 @@ int main (int argc, char* argv[]) // generate file names for output std::string path(out_base_fname.getValue()); if (path.empty()) + { path = BaseLib::dropFileExtension(mesh_in.getValue()); + } std::string const id_and_area_fname(path+".txt"); std::string const csv_fname(path+".csv"); diff --git a/Applications/Utils/ModelPreparation/ConvertVtkDataArrayToVtkDataArray.cpp b/Applications/Utils/ModelPreparation/ConvertVtkDataArrayToVtkDataArray.cpp index 1544ab65735e1164f270cdca1fa6511fd26463e5..1a2e6cf6560c728029a4f197a251edf695f2f5a9 100644 --- a/Applications/Utils/ModelPreparation/ConvertVtkDataArrayToVtkDataArray.cpp +++ b/Applications/Utils/ModelPreparation/ConvertVtkDataArrayToVtkDataArray.cpp @@ -33,15 +33,19 @@ std::pair<bool, std::string> castPropertyVectorToPropertyVector( auto const* const orig_pv = properties.getPropertyVector<T1>( property_vector_name_in, MeshLib::MeshItemType::Cell, 1); if (!orig_pv) + { return std::make_pair(false, "Original property vector '" + property_vector_name_in + "' not found."); + } auto* new_pv = properties.createNewPropertyVector<T2>( property_vector_name_out, MeshLib::MeshItemType::Cell, 1); if (!new_pv) + { return std::make_pair(false, "Could not create new property vector '" + property_vector_name_in + "' not found."); + } new_pv->resize(orig_pv->getNumberOfTuples()); for (std::size_t i(0); i < new_pv->getNumberOfTuples(); ++i) { @@ -129,21 +133,25 @@ int main(int argc, char* argv[]) if (mesh->getProperties().existsPropertyVector<float>( property_arg.getValue(), MeshLib::MeshItemType::Cell, 1)) + { std::tie(success, err_msg) = castPropertyVectorToPropertyVector<float, int>( mesh->getProperties(), property_arg.getValue(), new_property_arg.getValue()); + } } if (new_property_data_type_arg.getValue() == "double") { if (mesh->getProperties().existsPropertyVector<float>( property_arg.getValue(), MeshLib::MeshItemType::Cell, 1)) + { std::tie(success, err_msg) = castPropertyVectorToPropertyVector<float, double>( mesh->getProperties(), property_arg.getValue(), new_property_arg.getValue()); + } } if (!success) diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp index b620fecfb03f20b1abf6ab28c6bdc8591c617de0..08f68c1897f25722ae22271e49496e989aa925ed 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp +++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp @@ -381,7 +381,9 @@ bool copyPropertyVector(MeshLib::Properties const& original_properties, std::size_t const total_number_of_tuples) { if (!original_properties.existsPropertyVector<T>(name)) + { return false; + } auto const& pv = original_properties.getPropertyVector<T>(name); auto partitioned_pv = partitioned_properties.createNewPropertyVector<T>( @@ -708,7 +710,9 @@ bool writePropertyVectorBinary( std::ostream& out_val, std::ostream& out_meta) { if (!partitioned_properties.existsPropertyVector<T>(name)) + { return false; + } MeshLib::IO::PropertyVectorMetaData pvmd; pvmd.property_name = name; diff --git a/Applications/Utils/ModelPreparation/createNeumannBc.cpp b/Applications/Utils/ModelPreparation/createNeumannBc.cpp index e03f656a584417826a36e5de1d6bcf0846d714f0..4a35bc69cac305b213e4eef7a61c1ae44b9e95a2 100644 --- a/Applications/Utils/ModelPreparation/createNeumannBc.cpp +++ b/Applications/Utils/ModelPreparation/createNeumannBc.cpp @@ -147,7 +147,9 @@ int main(int argc, char* argv[]) } }(); if (!node_id_pv) + { return EXIT_FAILURE; + } std::vector<double> integrated_values = getSurfaceIntegratedValuesForNodes( *surface_mesh, property_in_arg.getValue()); @@ -176,7 +178,9 @@ int main(int argc, char* argv[]) std::ofstream result_out(result_file.getValue() + ".txt"); result_out.precision(std::numeric_limits<double>::digits10); for (auto const& p : direct_values) + { result_out << p.first << " " << p.second << "\n"; + } return EXIT_SUCCESS; } diff --git a/Applications/Utils/OGSFileConverter/CMakeLists.txt b/Applications/Utils/OGSFileConverter/CMakeLists.txt index 15ec84709ea3e051c2cfa803cdf1fba774f4a568..38bd1d1e12865fffd4a8345d9ee241f1d6125c5a 100644 --- a/Applications/Utils/OGSFileConverter/CMakeLists.txt +++ b/Applications/Utils/OGSFileConverter/CMakeLists.txt @@ -1,37 +1,31 @@ -set(SOURCES +add_library(OGSFileConverterLib + FileListDialog.h + OGSFileConverter.h FileListDialog.cpp OGSFileConverter.cpp ) - -include_directories( - # Qt generated file includes - ${CMAKE_CURRENT_BINARY_DIR} - - # Workaround for CMake 3.8 - ${CMAKE_CURRENT_BINARY_DIR}/OGSFileConverterLib_autogen/include +target_link_libraries(OGSFileConverterLib + PUBLIC ApplicationsFileIO MathLib QtBase ${VTK_LIBRARIES} + INTERFACE MeshLib ) -add_library(OGSFileConverterLib - ${SOURCES} - ${HEADERS} -) -target_link_libraries(OGSFileConverterLib - PUBLIC QtBase MathLib - INTERFACE MeshLib ApplicationsFileIO +target_include_directories(OGSFileConverterLib PUBLIC + ${CMAKE_CURRENT_BINARY_DIR}/OGSFileConverterLib_autogen/include) + +set_target_properties(OGSFileConverterLib PROPERTIES + AUTOMOC TRUE + AUTOUIC TRUE ) add_executable(OGSFileConverter main.cpp) target_link_libraries(OGSFileConverter - OGSFileConverterLib - ApplicationsFileIO + PUBLIC OGSFileConverterLib ApplicationsFileIO ) set_target_properties(OGSFileConverter OGSFileConverterLib PROPERTIES FOLDER "Utilities" - AUTOMOC ON - AUTOUIC ON ) if(OGS_USE_PCH) @@ -41,7 +35,5 @@ endif() #################### ### Installation ### #################### - install(TARGETS OGSFileConverter RUNTIME DESTINATION bin COMPONENT ogs_cli) set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} "OGSFileConverter" "File Converter") -set(CPACK_NSIS_MENU_LINKS ${CPACK_NSIS_MENU_LINKS} "bin/OGSFileConverter.exe" "File Converter" PARENT_SCOPE) diff --git a/Applications/Utils/PostProcessing/postLIE.cpp b/Applications/Utils/PostProcessing/postLIE.cpp index 0127f0e2f714d28832ef178cc964eb96dbf08312..01321a05898d1743c041ae8217a80c02485888f7 100644 --- a/Applications/Utils/PostProcessing/postLIE.cpp +++ b/Applications/Utils/PostProcessing/postLIE.cpp @@ -34,7 +34,9 @@ void postVTU(std::string const& int_vtu_filename, std::unique_ptr<MeshLib::Mesh const> mesh( MeshLib::IO::readMeshFromFile(int_vtu_filename)); if (mesh->isNonlinear()) + { mesh = MeshLib::convertToLinearMesh(*mesh, mesh->getName()); + } // post-process std::vector<MeshLib::Element*> vec_matrix_elements; @@ -76,7 +78,9 @@ void postPVD(std::string const& in_pvd_filename, for (auto& dataset : pt.get_child("VTKFile.Collection")) { if (dataset.first != "DataSet") + { continue; + } // get VTU file name auto const org_vtu_filename = @@ -85,7 +89,9 @@ void postPVD(std::string const& in_pvd_filename, BaseLib::extractBaseName(org_vtu_filename); auto org_vtu_dir = BaseLib::extractPath(org_vtu_filename); if (org_vtu_dir.empty()) + { org_vtu_dir = in_pvd_file_dir; + } auto const org_vtu_filepath = BaseLib::joinPaths(org_vtu_dir, org_vtu_filebasename); INFO("processing %s...", org_vtu_filepath.c_str()); @@ -133,12 +139,18 @@ int main(int argc, char* argv[]) auto const in_file_ext = BaseLib::getFileExtension(arg_in_file.getValue()); if (in_file_ext == "pvd") + { postPVD(arg_in_file.getValue(), arg_out_file.getValue()); + } else if (in_file_ext == "vtu") + { postVTU(arg_in_file.getValue(), arg_out_file.getValue()); + } else + { OGS_FATAL("The given file type (%s) is not supported.", in_file_ext.c_str()); + } return EXIT_SUCCESS; } diff --git a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp index e660ca3cfb052ba48bf05162c050fc0ed9aa4f55..f62dcdde5b0959091989c04266059a772a1b6a08 100644 --- a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp +++ b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp @@ -144,8 +144,10 @@ int main (int argc, char* argv[]) const unsigned dim = getDimension(eleType); bool dim_used[3] = {false}; - for (unsigned i=0; i<dim; i++) + for (unsigned i = 0; i < dim; i++) + { dim_used[i] = true; + } std::vector<TCLAP::ValueArg<double>*> vec_lengthArg = {&lengthXArg, &lengthYArg, &lengthZArg}; std::vector<TCLAP::ValueArg<unsigned>*> vec_ndivArg = {&nsubdivXArg, &nsubdivYArg, &nsubdivZArg}; diff --git a/BaseLib/Algorithm.h b/BaseLib/Algorithm.h index 1cd7ccb3242f047fe62c18b954a362286d0bf467..4a9471bda26afacdcc759bcf1906f645e8cc6efd 100644 --- a/BaseLib/Algorithm.h +++ b/BaseLib/Algorithm.h @@ -215,7 +215,9 @@ void uniquePushBack(Container& container, { if (std::find(container.begin(), container.end(), element) == container.end()) + { container.push_back(element); + } } template <typename Container> diff --git a/BaseLib/BuildInfo.h b/BaseLib/BuildInfo.h index 544ccc7a8c7f02724612221821e49adfb7faa33e..1eda014d1394911afca551e6ae5ba605a71a41ff 100644 --- a/BaseLib/BuildInfo.h +++ b/BaseLib/BuildInfo.h @@ -38,5 +38,5 @@ namespace BuildInfo extern BASELIB_EXPORT const std::string data_path; extern BASELIB_EXPORT const std::string data_binary_path; extern BASELIB_EXPORT const std::string tests_tmp_path; -} -} + } // namespace BuildInfo + } // namespace BaseLib diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 87ddab369adb363b933ea5b660af5425fdd7a8a4..9acdf51c07393bdcf350664932dd6092fcc08916 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -40,7 +40,9 @@ ConfigTree:: getConfigParameter(std::string const& param) const { if (auto p = getConfigParameterOptional<T>(param)) + { return *p; + } error("Key <" + param + "> has not been found"); } @@ -51,7 +53,9 @@ ConfigTree:: getConfigParameter(std::string const& param, T const& default_value) const { if (auto p = getConfigParameterOptional<T>(param)) + { return *p; + } return default_value; } @@ -69,7 +73,10 @@ template <typename T> boost::optional<T> ConfigTree::getConfigParameterOptionalImpl( std::string const& param, T*) const { - if (auto p = getConfigSubtreeOptional(param)) return p->getValue<T>(); + if (auto p = getConfigSubtreeOptional(param)) + { + return p->getValue<T>(); + } return boost::none; } @@ -84,7 +91,9 @@ boost::optional<std::vector<T>> ConfigTree::getConfigParameterOptionalImpl( std::vector<T> result; T value; while (sstr >> value) + { result.push_back(value); + } if (!sstr.eof()) // The stream is not read until the end, must be an // error. result contains number of read values. { @@ -185,7 +194,9 @@ ConfigTree:: getConfigAttribute(std::string const& attr) const { if (auto a = getConfigAttributeOptional<T>(attr)) + { return *a; + } error("Did not find XML attribute with name '" + attr + "'."); } @@ -195,7 +206,9 @@ T ConfigTree::getConfigAttribute(std::string const& attr, T const& default_value) const { if (auto a = getConfigAttributeOptional<T>(attr)) + { return *a; + } return default_value; } @@ -237,7 +250,10 @@ markVisited(std::string const& key, Attr const is_attr, if (!p.second) { // no insertion happened auto& v = p.first->second; if (v.type == type) { - if (!peek_only) ++v.count; + if (!peek_only) + { + ++v.count; + } } else { error("There already was an attempt to obtain key <" + key + "> with type '" + v.type.name() + "' (now: '" + type.name() + @@ -248,4 +264,4 @@ markVisited(std::string const& key, Attr const is_attr, return p.first->second; } -} +} // namespace BaseLib diff --git a/BaseLib/ConfigTree.cpp b/BaseLib/ConfigTree.cpp index 21196c27c8bef6c7cd628f563905c31c45e2856e..1cf8551998fc760bb65e83a691885653e2d7bb14 100644 --- a/BaseLib/ConfigTree.cpp +++ b/BaseLib/ConfigTree.cpp @@ -113,7 +113,9 @@ getConfigParameter(std::string const& root) const { auto ct = getConfigSubtree(root); if (ct.hasChildren()) + { error("Requested parameter <" + root + "> actually is a subtree."); + } return ct; } @@ -123,7 +125,9 @@ getConfigParameterOptional(std::string const& root) const { auto ct = getConfigSubtreeOptional(root); if (ct && ct->hasChildren()) + { error("Requested parameter <" + root + "> actually is a subtree."); + } return ct; } @@ -241,7 +245,9 @@ void ConfigTree::onwarning(const std::string& filename, const std::string& path, void ConfigTree::assertNoSwallowedErrors() { if (configtree_destructor_error_messages.empty()) + { return; + } ERR("ConfigTree: There have been errors when parsing the configuration " "file(s):"); @@ -257,7 +263,10 @@ std::string ConfigTree::shortString(const std::string &s) { const std::size_t maxlen = 100; - if (s.size() < maxlen) return s; + if (s.size() < maxlen) + { + return s; + } return s.substr(0, maxlen-3) + "..."; } @@ -287,7 +296,10 @@ joinPaths( const std::string &p1, const std::string &p2) const error("Second path to be joined is empty."); } - if (p1.empty()) return p2; + if (p1.empty()) + { + return p2; + } return p1 + pathseparator + p2; } @@ -313,7 +325,10 @@ void ConfigTree::checkUniqueAttr(const std::string &attr) const auto attr2 = attr; do { pos = attr2.find_first_of(":ABCDEFGHIJKLMNOPQRSTUVWXYZ", pos); - if (pos != attr.npos) attr2[pos] = 'a'; + if (pos != attr.npos) + { + attr2[pos] = 'a'; + } } while (pos != attr.npos); checkKeyname(attr2); @@ -353,10 +368,13 @@ ConfigTree::hasChildren() const { auto const& tree = *_tree; if (tree.begin() == tree.end()) - return false; // no children - if (tree.front().first == "<xmlattr>" - && (++tree.begin()) == tree.end()) - return false; // only attributes + { + return false; // no children + } + if (tree.front().first == "<xmlattr>" && (++tree.begin()) == tree.end()) + { + return false; // only attributes + } return true; } @@ -364,7 +382,10 @@ ConfigTree::hasChildren() const void ConfigTree::checkAndInvalidate() { - if (!_tree) return; + if (!_tree) + { + return; + } // Note: due to a limitation in boost::property_tree it is not possible // to discriminate between <tag></tag> and <tag/> in the input file. @@ -376,8 +397,10 @@ ConfigTree::checkAndInvalidate() // iterate over children for (auto const& p : *_tree) { - if (p.first != "<xmlattr>") // attributes are handled below + if (p.first != "<xmlattr>") + { // attributes are handled below markVisitedDecrement(Attr::TAG, p.first); + } } // iterate over attributes @@ -430,12 +453,18 @@ void checkAndInvalidate(ConfigTree &conf) void checkAndInvalidate(ConfigTree* const conf) { - if (conf) conf->checkAndInvalidate(); + if (conf) + { + conf->checkAndInvalidate(); + } } void checkAndInvalidate(std::unique_ptr<ConfigTree> const& conf) { - if (conf) conf->checkAndInvalidate(); + if (conf) + { + conf->checkAndInvalidate(); + } } -} +} // namespace BaseLib diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index cc50ba473227044524668b955c04ed5ceb798a88..e4cfe1825e38bab7529ae413dd4796dda2db002f 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -158,8 +158,10 @@ public: ConfigTree operator*() { auto st = SubtreeIterator::operator*(); if (st.hasChildren()) - _parent.error("The requested parameter <" + _tagname + ">" - " has child elements."); + { + _parent.error("The requested parameter <" + _tagname + + "> has child elements."); + } return st; } }; @@ -643,6 +645,6 @@ private: friend void checkAndInvalidate(std::unique_ptr<ConfigTree> const& conf); }; -} +} // namespace BaseLib #include "ConfigTree-impl.h" diff --git a/BaseLib/ConfigTreeUtil.cpp b/BaseLib/ConfigTreeUtil.cpp index 117c41453154c485286e13429ebe9d5c7b62e1ed..93f0a647a32ad7ff45c6f60c68aa89295b3a16af 100644 --- a/BaseLib/ConfigTreeUtil.cpp +++ b/BaseLib/ConfigTreeUtil.cpp @@ -75,4 +75,4 @@ makeConfigTree(const std::string& filepath, const bool be_ruthless, filepath.c_str()); } -} +} // namespace BaseLib diff --git a/BaseLib/ConfigTreeUtil.h b/BaseLib/ConfigTreeUtil.h index 1d5a187a3dc48fd50243794ecdcce49db70ac3f7..4bfec5085af625ec2365d6f7e8e52246c59cd8e8 100644 --- a/BaseLib/ConfigTreeUtil.h +++ b/BaseLib/ConfigTreeUtil.h @@ -87,4 +87,4 @@ ConfigTreeTopLevel makeConfigTree(std::string const& filepath, bool const be_ruthless, std::string const& toplevel_tag); -} +} // namespace BaseLib diff --git a/BaseLib/DateTools.cpp b/BaseLib/DateTools.cpp index 9d2bea60c6fed0d5abe6a6d8eb2c6a37f659f6f2..fcbf8ee1b74f067b716d5a8c60432fe8e1adf3a8 100644 --- a/BaseLib/DateTools.cpp +++ b/BaseLib/DateTools.cpp @@ -48,10 +48,14 @@ std::string int2date(int date) int d = date - (y * 10000) - (m * 100); std::stringstream ss; if (d < 10) + { ss << "0"; + } ss << d << "."; if (m < 10) + { ss << "0"; + } ss << m << "." << y; return ss.str(); } @@ -79,10 +83,14 @@ std::string date2string(double ddate) std::string day = std::to_string(d); if (d < 10) + { day = "0" + day; + } std::string month = std::to_string(m); if (m < 10) + { month = "0" + month; + } std::string s = std::to_string(y) + "-" + month + "-" + day; return s; } @@ -91,7 +99,9 @@ int strDate2int(const std::string &s) { std::string str(s); if (s.length() > 10) - str = s.substr(0,10); + { + str = s.substr(0, 10); + } std::size_t sep ( str.find('.',0) ); int d ( atoi(str.substr(0, sep).c_str()) ); std::size_t sep2 ( str.find('.', sep + 1) ); diff --git a/BaseLib/FileFinder.cpp b/BaseLib/FileFinder.cpp index d05ba3760aacb7a2f570ea39896c3442f23e8967..fc0fb6672c19b1310c5a2607792e6e8bf4f0463b 100644 --- a/BaseLib/FileFinder.cpp +++ b/BaseLib/FileFinder.cpp @@ -31,18 +31,26 @@ FileFinder::FileFinder(std::initializer_list<std::string> dirs) { addDirectory("."); for (auto const& dir : dirs) + { addDirectory(dir); + } } void FileFinder::addDirectory(std::string const& dir) { if (dir.empty()) + { return; + } if (dir[dir.size() - 1] != '/') + { _directories.emplace_back(dir + "/"); + } else + { _directories.push_back(dir); + } } std::string FileFinder::getPath(std::string const& filename) const diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index d710c88ff4fb2b299dec9386d1d4ca8b36d903fb..0dbf77f2fefe263ce721d85aa6a9c5a787bafa03 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -48,11 +48,15 @@ double swapEndianness(double const& v) } a {}, b {}; a.v = v; - for (unsigned short i = 0; i < sizeof(double)/2; i++) - b.c[i] = a.c[sizeof(double)/2 - i - 1]; + for (unsigned short i = 0; i < sizeof(double) / 2; i++) + { + b.c[i] = a.c[sizeof(double) / 2 - i - 1]; + } - for (unsigned short i = sizeof(double)/2; i < sizeof(double); i++) - b.c[i] = a.c[sizeof(double)+sizeof(double)/2 - i - 1]; + for (unsigned short i = sizeof(double) / 2; i < sizeof(double); i++) + { + b.c[i] = a.c[sizeof(double) + sizeof(double) / 2 - i - 1]; + } return b.v; } @@ -95,12 +99,16 @@ std::string dropFileExtension(std::string const& filename) // Look for dots in filename. auto const p = findLastDot(filename); if (p == std::string::npos) + { return filename; + } // Check position of the last path separator. auto const s = findLastPathSeparator(filename); if (s != std::string::npos && p < s) + { return filename; + } return filename.substr(0, p); } @@ -109,7 +117,9 @@ std::string extractBaseName(std::string const& pathname) { auto const p = findLastPathSeparator(pathname); if (p == std::string::npos) + { return pathname; + } return pathname.substr(p + 1); } @@ -124,7 +134,9 @@ std::string getFileExtension(const std::string &path) const std::string str = extractBaseName(path); auto const p = findLastDot(str); if (p == std::string::npos) + { return std::string(); + } return str.substr(p + 1); } @@ -146,12 +158,18 @@ std::string copyPathToFileName(const std::string &file_name, // check if file_name already contains a full path auto const pos = findLastPathSeparator(file_name); if (pos != std::string::npos) + { return file_name; + } if (source.empty()) + { return file_name; + } if (source.back() != pathSeparator) + { return BaseLib::extractPath(source + pathSeparator).append(file_name); + } return BaseLib::extractPath(source).append(file_name); } @@ -159,24 +177,32 @@ std::string extractPath(std::string const& pathname) { auto const pos = findLastPathSeparator(pathname); if (pos == std::string::npos) + { return ""; + } return pathname.substr(0, pos + 1); } std::string appendPathSeparator(std::string const& path) { - if(findLastPathSeparator(path) == path.length() - 1) + if (findLastPathSeparator(path) == path.length() - 1) + { return path; + } return path + pathSeparator; } std::string joinPaths(std::string const& pathA, std::string const& pathB) { if (pathA.empty()) + { return pathB; + } if (pathB.empty()) + { return pathA; + } if (pathB.front() == pathSeparator) { auto const tmpB = pathB.substr(1); diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h index 05d36edc15dc6b6d3318d14b1f85d5e37f29b964..c5613eedbbf3f789e46064cbc8cc25d5301d5f36 100644 --- a/BaseLib/FileTools.h +++ b/BaseLib/FileTools.h @@ -52,7 +52,9 @@ T swapEndianness(T const& v) a.v = v; for (unsigned short i = 0; i < sizeof(T); i++) + { b.c[i] = a.c[sizeof(T) - i - 1]; + } return b.v; } @@ -84,10 +86,14 @@ std::vector<T> readBinaryArray(std::string const& filename, std::size_t const n) result.reserve(n); for (std::size_t p = 0; in && !in.eof() && p < n; ++p) + { result.push_back(BaseLib::readBinaryValue<T>(in)); + } if (result.size() == n) + { return result; + } ERR("readBinaryArray(): Error while reading from file '%s'.", filename.c_str()); diff --git a/BaseLib/Functional.cpp b/BaseLib/Functional.cpp index 8162fa6e5877f6629faf8fc10889f79794fa0d88..73c1efa84600895e6035187c06345b80c7362efb 100644 --- a/BaseLib/Functional.cpp +++ b/BaseLib/Functional.cpp @@ -28,6 +28,6 @@ DEFINE_INDEXEDPLACEHOLDER_MEMBER(6, 7); DEFINE_INDEXEDPLACEHOLDER_MEMBER(7, 8); DEFINE_INDEXEDPLACEHOLDER_MEMBER(8, 9); DEFINE_INDEXEDPLACEHOLDER_MEMBER(9, 10); -} +} // namespace detail } // namespace BaseLib diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 3561cf267e8bf27251ddec9ad721075b4fafaad4..4a6159f1495101518e86a8b6e3705d9549185a9a 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -81,7 +81,9 @@ public: void update() { if (!_dirty) + { return; + } _bin_width = (_max - _min) / _nr_bins; @@ -120,7 +122,9 @@ public: const int n_stars = std::ceil(line_width * ((double)_histogram[bin] / count_max)); for (int star = 0; star < n_stars; star++) + { os << "*"; + } os << "\n"; } } @@ -147,7 +151,9 @@ public: double const bin_width (this->getBinWidth()); for (std::size_t k(0); k < n_bins; k++) - out << min+k*bin_width << " " << bin_cnts[k] << "\n"; + { + out << min + k * bin_width << " " << bin_cnts[k] << "\n"; + } out.close (); return 0; } @@ -165,7 +171,9 @@ protected: _dirty = true; if (computeHistogram) + { update(); + } } Data _data; diff --git a/BaseLib/IO/Writer.cpp b/BaseLib/IO/Writer.cpp index a68ebff1f3f6f43839a42fe4a40c714b81380676..5dac385a0a45b067a379f2110d49ebe648aba4a6 100644 --- a/BaseLib/IO/Writer.cpp +++ b/BaseLib/IO/Writer.cpp @@ -36,7 +36,9 @@ std::string Writer::writeToString() _out.clear(); if (this->write()) + { return _out.str(); + } return std::string(""); } diff --git a/BaseLib/IO/XmlIO/XMLInterface.cpp b/BaseLib/IO/XmlIO/XMLInterface.cpp index a2e011139f39ef152df34aca1ff9e3843849d6d7..126f2ee0e7a4be5cd57c62c89a25e6928efa82b2 100644 --- a/BaseLib/IO/XmlIO/XMLInterface.cpp +++ b/BaseLib/IO/XmlIO/XMLInterface.cpp @@ -24,4 +24,4 @@ XMLInterface::XMLInterface() : {} } -} +} // namespace BaseLib diff --git a/BaseLib/IO/XmlIO/XMLInterface.h b/BaseLib/IO/XmlIO/XMLInterface.h index 6d2b8bcc9b82a4a0333de973ef97a749b1c2fb44..7de12dd35ae31b098eb13dc176bbd1d0c6d34b9f 100644 --- a/BaseLib/IO/XmlIO/XMLInterface.h +++ b/BaseLib/IO/XmlIO/XMLInterface.h @@ -38,5 +38,5 @@ protected: std::string _exportName; }; -} -} +} // namespace IO +} // namespace BaseLib diff --git a/BaseLib/MemWatch.h b/BaseLib/MemWatch.h index a7e7341067e43f5682fd629fffc465d022a43409..4d11181a1cae12e9e77492ca888eb008f67a37ed 100644 --- a/BaseLib/MemWatch.h +++ b/BaseLib/MemWatch.h @@ -32,4 +32,4 @@ private: unsigned long _cmem_size = 0; }; -} +} // namespace BaseLib diff --git a/BaseLib/StringTools.cpp b/BaseLib/StringTools.cpp index a1e10e4a1ec141e1c0c99a7ef635accc1158a4e1..080fa99b2a8e62305d747583053c62db01787cef 100644 --- a/BaseLib/StringTools.cpp +++ b/BaseLib/StringTools.cpp @@ -40,8 +40,10 @@ std::list<std::string> splitString(const std::string &str, char delim) std::list<std::string> strList; std::stringstream ss(str); std::string item; - while(getline(ss, item, delim)) + while (getline(ss, item, delim)) + { strList.push_back(item); + } return strList; } @@ -60,11 +62,15 @@ void trim(std::string &str, char ch) { str.erase(pos + 1); pos = str.find_first_not_of(ch); - if(pos != std::string::npos) + if (pos != std::string::npos) + { str.erase(0, pos); + } } else + { str.erase(str.begin(), str.end()); + } } void simplify(std::string &str) diff --git a/BaseLib/Subdivision.cpp b/BaseLib/Subdivision.cpp index 58d1adb4d7f0cf40cc1ef7da158f2d4cf7df986a..e8655e9e64d325c4a37974eb53848af143818e8b 100644 --- a/BaseLib/Subdivision.cpp +++ b/BaseLib/Subdivision.cpp @@ -50,9 +50,13 @@ std::vector<double> GradualSubdivision::operator()() const if (vec_x.back() < _length) { double last_dx = vec_x[vec_x.size() - 1] - vec_x[vec_x.size() - 2]; if (_length - vec_x.back() < last_dx) + { vec_x[vec_x.size() - 1] = _length; + } else + { vec_x.push_back(_length); + } } return vec_x; } diff --git a/BaseLib/Subdivision.h b/BaseLib/Subdivision.h index 9751621097411a5a3e56f7577145fcd924824735..fc0a3552f3f577859b635ae980ac17323f2dd2f1 100644 --- a/BaseLib/Subdivision.h +++ b/BaseLib/Subdivision.h @@ -46,8 +46,10 @@ public: std::vector<double> x; x.reserve(_n_subdivision+1); const double dL = _length/static_cast<double>(_n_subdivision); - for (std::size_t i=0; i<_n_subdivision+1; i++) - x.push_back(i*dL); + for (std::size_t i = 0; i < _n_subdivision + 1; i++) + { + x.push_back(i * dL); + } return x; } @@ -112,4 +114,4 @@ private: const double _multiplier; }; -} // BaseLib +} // namespace BaseLib diff --git a/BaseLib/TCLAPCustomOutput.h b/BaseLib/TCLAPCustomOutput.h index b4c232976846b9ff7a8fc46966175155b163c255..3c3ef0034f4c2f3a7d56b4060bcc9c7c4e6782ee 100644 --- a/BaseLib/TCLAPCustomOutput.h +++ b/BaseLib/TCLAPCustomOutput.h @@ -97,8 +97,10 @@ inline void TCLAPCustomOutput::failure( TCLAP::CmdLineInterface& _cmd, << std::endl << " " << progName << " --help" << std::endl << std::endl; } - else - usage(_cmd); + else + { + usage(_cmd); + } throw TCLAP::ExitException(1); } @@ -118,22 +120,31 @@ TCLAPCustomOutput::_shortUsage( TCLAP::CmdLineInterface& _cmd, for ( int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ ) { s += " {"; - for ( TCLAP::ArgVectorIterator it = xorList[i].begin(); - it != xorList[i].end(); it++ ) + for (TCLAP::ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++) + { s += (*it)->shortID() + "|"; + } s[s.length()-1] = '}'; } // then the rest - for (auto it = argList.rbegin(); it != argList.rend(); ++it) // here modified - if ( !xorHandler.contains( (*it) ) ) - s += " " + (*it)->shortID(); + for (auto it = argList.rbegin(); it != argList.rend(); ++it) + { // here modified + if (!xorHandler.contains((*it))) + { + s += " " + (*it)->shortID(); + } + } // if the program name is too long, then adjust the second line offset int secondLineOffset = static_cast<int>(progName.length()) + 2; - if ( secondLineOffset > 75/2 ) - secondLineOffset = static_cast<int>(75/2); + if (secondLineOffset > 75 / 2) + { + secondLineOffset = static_cast<int>(75 / 2); + } spacePrint( os, s, 75, 3, secondLineOffset ); } @@ -157,20 +168,24 @@ TCLAPCustomOutput::_longUsage( TCLAP::CmdLineInterface& _cmd, this->spacePrint( os, (*it)->longID(), 75, 3, 3 ); spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); - if ( it+1 != xorList[i].end() ) + if (it + 1 != xorList[i].end()) + { spacePrint(os, "-- OR --", 75, 9, 0); + } } os << std::endl << std::endl; } // then the rest - for (auto it = argList.rbegin(); it != argList.rend(); it++) // here modified - if ( !xorHandler.contains( (*it) ) ) + for (auto it = argList.rbegin(); it != argList.rend(); it++) + { // here modified + if (!xorHandler.contains((*it))) { spacePrint( os, (*it)->longID(), 75, 3, 3 ); spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); os << std::endl; } + } os << std::endl; diff --git a/BaseLib/TemplateLogogFormatterSuppressedGCC-impl.h b/BaseLib/TemplateLogogFormatterSuppressedGCC-impl.h index 81f14f487a88260c4852a19c6ee7c088d4a62082..61ba7c48169d5cc92877d3d5d655f46e286f4923 100644 --- a/BaseLib/TemplateLogogFormatterSuppressedGCC-impl.h +++ b/BaseLib/TemplateLogogFormatterSuppressedGCC-impl.h @@ -76,8 +76,10 @@ TemplateLogogFormatterSuppressedGCC<T_SUPPPRESS_TOPIC_FLAG> m_sMessageBuffer.append( (LOGOG_CHAR)'\n' ); } - if ( target.GetNullTerminatesStrings() ) + if (target.GetNullTerminatesStrings()) + { m_sMessageBuffer.append((LOGOG_CHAR)'\0'); + } return m_sMessageBuffer; } diff --git a/BaseLib/TimeInterval.cpp b/BaseLib/TimeInterval.cpp index 9058d3f3a9cbdcb8c5b41a9e05558fcba50aa728..161f0585053bdfe76599c09a41fe2825e3bbba7c 100644 --- a/BaseLib/TimeInterval.cpp +++ b/BaseLib/TimeInterval.cpp @@ -33,4 +33,4 @@ std::unique_ptr<TimeInterval> createTimeInterval( return std::make_unique<BaseLib::TimeInterval>(start_time, end_time); } -} // end of namespace +} // namespace BaseLib diff --git a/BaseLib/TimeInterval.h b/BaseLib/TimeInterval.h index 8d2a68361f52e49112e310f6e3840f6800d1c8d3..c21fb7dda9d205a97fc3db527f7c21247204716d 100644 --- a/BaseLib/TimeInterval.h +++ b/BaseLib/TimeInterval.h @@ -47,4 +47,4 @@ private: std::unique_ptr<TimeInterval> createTimeInterval( BaseLib::ConfigTree const& config); -} // end of namespace +} // namespace BaseLib diff --git a/GeoLib/AABB.h b/GeoLib/AABB.h index 2ac4d543618740c3862683a4be2fbfa44de5807d..20380adbf9a254bf7f339bbf3662516e125c9679 100644 --- a/GeoLib/AABB.h +++ b/GeoLib/AABB.h @@ -130,19 +130,31 @@ public: bool containsPoint(T const & pnt, double eps) const { if (pnt[0] < _min_pnt[0] - eps || _max_pnt[0] + eps <= pnt[0]) + { return false; + } if (pnt[1] < _min_pnt[1] - eps || _max_pnt[1] + eps <= pnt[1]) + { return false; + } if (pnt[2] < _min_pnt[2] - eps || _max_pnt[2] + eps <= pnt[2]) + { return false; + } return true; } template <typename T> bool containsPointXY(T const & pnt) const { - if (pnt[0] < _min_pnt[0] || _max_pnt[0] <= pnt[0]) return false; - if (pnt[1] < _min_pnt[1] || _max_pnt[1] <= pnt[1]) return false; + if (pnt[0] < _min_pnt[0] || _max_pnt[0] <= pnt[0]) + { + return false; + } + if (pnt[1] < _min_pnt[1] || _max_pnt[1] <= pnt[1]) + { + return false; + } return true; } @@ -240,4 +252,4 @@ private: update(*pnt); } }; -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/AnalyticalGeometry-impl.h b/GeoLib/AnalyticalGeometry-impl.h index 025c10dcf80f9262c0c1491b3adfe65a8c94eea0..63ccc49095ed53d9adc56bbb5ea20b47a3d17fec 100644 --- a/GeoLib/AnalyticalGeometry-impl.h +++ b/GeoLib/AnalyticalGeometry-impl.h @@ -33,7 +33,9 @@ void getNewellPlane (InputIterator pnts_begin, InputIterator pnts_end, auto n_pnts(std::distance(pnts_begin, pnts_end)); assert(n_pnts > 2); if (n_pnts > 0) + { d = MathLib::scalarProduct(centroid, plane_normal) / n_pnts; + } } template <class T_POINT> @@ -154,14 +156,22 @@ void computeRotationMatrixToXY(MathLib::Vector3 const& n, rot_mat(1,0) = 0.0; rot_mat(1,1) = 0.0; if (n[1] > 0) + { rot_mat(1,2) = -1.0; + } else - rot_mat(1,2) = 1.0; + { + rot_mat(1, 2) = 1.0; + } rot_mat(2,0) = 0.0; if (n[1] > 0) + { rot_mat(2,1) = 1.0; + } else - rot_mat(2,1) = -1.0; + { + rot_mat(2, 1) = -1.0; + } rot_mat(2,2) = 0.0; return; } @@ -189,7 +199,9 @@ void rotatePoints( for (auto it=pnts_begin; it!=pnts_end; ++it) { tmp = rot_mat * (*it)->getCoords(); for (std::size_t j(0); j < 3; j++) + { (*(*it))[j] = tmp[j]; + } delete [] tmp; } } @@ -213,8 +225,10 @@ MathLib::DenseMatrix<double> rotatePointsToXY(InputIterator1 p_pnts_begin, computeRotationMatrixToXY(plane_normal, rot_mat); rotatePoints(rot_mat, r_pnts_begin, r_pnts_end); - for (auto it=r_pnts_begin; it!=r_pnts_end; ++it) - (*(*it))[2] = 0.0; // should be -= d but there are numerical errors + for (auto it = r_pnts_begin; it != r_pnts_end; ++it) + { + (*(*it))[2] = 0.0; // should be -= d but there are numerical errors + } return rot_mat; } diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 283a4a955b0304da03a3c7394df22c04db6e1adb..3da46a907d76d961ec753f41371182263f46ec33 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -50,7 +50,7 @@ double getOrientation2dFast(MathLib::Point3d const& a, const_cast<double*>(b.getCoords()), const_cast<double*>(c.getCoords())); } -} +} // namespace ExactPredicates namespace GeoLib { @@ -60,9 +60,13 @@ Orientation getOrientation(MathLib::Point3d const& p0, { double const orientation = ExactPredicates::getOrientation2d(p0, p1, p2); if (orientation > 0) + { return CCW; + } if (orientation < 0) + { return CW; + } return COLLINEAR; } @@ -73,9 +77,13 @@ Orientation getOrientationFast(MathLib::Point3d const& p0, double const orientation = ExactPredicates::getOrientation2dFast(p0, p1, p2); if (orientation > 0) + { return CCW; + } if (orientation < 0) + { return CW; + } return COLLINEAR; } @@ -85,33 +93,49 @@ bool parallel(MathLib::Vector3 v, MathLib::Vector3 w) // check degenerated cases if (v.getLength() < eps) + { return false; + } if (w.getLength() < eps) + { return false; + } v.normalize(); w.normalize(); bool parallel(true); - if (std::abs(v[0]-w[0]) > eps) + if (std::abs(v[0] - w[0]) > eps) + { parallel = false; - if (std::abs(v[1]-w[1]) > eps) + } + if (std::abs(v[1] - w[1]) > eps) + { parallel = false; - if (std::abs(v[2]-w[2]) > eps) + } + if (std::abs(v[2] - w[2]) > eps) + { parallel = false; + } if (! parallel) { parallel = true; // change sense of direction of v_normalised v *= -1.0; // check again - if (std::abs(v[0]-w[0]) > eps) + if (std::abs(v[0] - w[0]) > eps) + { parallel = false; - if (std::abs(v[1]-w[1]) > eps) + } + if (std::abs(v[1] - w[1]) > eps) + { parallel = false; - if (std::abs(v[2]-w[2]) > eps) + } + if (std::abs(v[2] - w[2]) > eps) + { parallel = false; + } } return parallel; @@ -127,7 +151,9 @@ bool lineSegmentIntersect(GeoLib::LineSegment const& s0, GeoLib::Point const& d{s1.getEndPoint()}; if (!isCoplanar(a, b, c, d)) + { return false; + } // handle special cases here to avoid computing intersection numerical if (MathLib::sqrDist(a, c) < std::numeric_limits<double>::epsilon() || @@ -297,8 +323,10 @@ void rotatePointsToXZ(std::vector<GeoLib::Point*> &pnts) rotatePoints(rot_mat, pnts); } - for (auto & pnt : pnts) - (*pnt)[1] = 0.0; // should be -= d but there are numerical errors + for (auto& pnt : pnts) + { + (*pnt)[1] = 0.0; // should be -= d but there are numerical errors + } } std::unique_ptr<GeoLib::Point> triangleLineIntersection( @@ -312,11 +340,20 @@ std::unique_ptr<GeoLib::Point> triangleLineIntersection( const MathLib::Vector3 pc(p, c); double u (MathLib::scalarTriple(pq, pc, pb)); - if (u<0) return nullptr; + if (u < 0) + { + return nullptr; + } double v (MathLib::scalarTriple(pq, pa, pc)); - if (v<0) return nullptr; + if (v < 0) + { + return nullptr; + } double w (MathLib::scalarTriple(pq, pb, pa)); - if (w<0) return nullptr; + if (w < 0) + { + return nullptr; + } const double denom (1.0/(u+v+w)); u*=denom; @@ -364,7 +401,9 @@ GeoLib::Polygon rotatePolygonToXY(GeoLib::Polygon const& polygon_in, // 1 copy all points auto* polygon_pnts(new std::vector<GeoLib::Point*>); for (std::size_t k(0); k < polygon_in.getNumberOfPoints(); k++) - polygon_pnts->push_back (new GeoLib::Point (*(polygon_in.getPoint(k)))); + { + polygon_pnts->push_back(new GeoLib::Point(*(polygon_in.getPoint(k)))); + } // 2 rotate points double d_polygon (0.0); @@ -381,7 +420,9 @@ GeoLib::Polygon rotatePolygonToXY(GeoLib::Polygon const& polygon_in, // 4 create new polygon GeoLib::Polyline rot_polyline(*polygon_pnts); for (std::size_t k(0); k < polygon_in.getNumberOfPoints(); k++) + { rot_polyline.addPoint(k); + } rot_polyline.addPoint(0); return GeoLib::Polygon(rot_polyline); } @@ -405,10 +446,14 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( // check: (cd) and (ab) are on the same line if (orient_abc == 0.0 && orient_abd == 0.0) { double const eps(std::numeric_limits<double>::epsilon()); - if (MathLib::sqrDist2d(a,c) < eps && MathLib::sqrDist2d(b,d) < eps) - return {{ a, b }}; - if (MathLib::sqrDist2d(a,d) < eps && MathLib::sqrDist2d(b,c) < eps) - return {{ a, b }}; + if (MathLib::sqrDist2d(a, c) < eps && MathLib::sqrDist2d(b, d) < eps) + { + return {{a, b}}; + } + if (MathLib::sqrDist2d(a, d) < eps && MathLib::sqrDist2d(b, c) < eps) + { + return {{a, b}}; + } // Since orient_ab and orient_abd vanish, a, b, c, d are on the same // line and for this reason it is enough to check the x-component. @@ -499,14 +544,18 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d( }; if (orient_abc == 0.0) { - if (isCollinearPointOntoLineSegment(a,b,c)) + if (isCollinearPointOntoLineSegment(a, b, c)) + { return {{c}}; + } return std::vector<MathLib::Point3d>(); } if (orient_abd == 0.0) { - if (isCollinearPointOntoLineSegment(a,b,d)) + if (isCollinearPointOntoLineSegment(a, b, d)) + { return {{d}}; + } return std::vector<MathLib::Point3d>(); } @@ -545,12 +594,14 @@ void sortSegments( double const eps(std::numeric_limits<double>::epsilon()); auto findNextSegment = [&eps]( - MathLib::Point3d const& seg_beg_pnt, - std::vector<GeoLib::LineSegment>& sub_segments, - std::vector<GeoLib::LineSegment>::iterator& sub_seg_it) - { + MathLib::Point3d const& seg_beg_pnt, + std::vector<GeoLib::LineSegment>& sub_segments, + std::vector<GeoLib::LineSegment>::iterator& + sub_seg_it) { if (sub_seg_it == sub_segments.end()) + { return; + } // find appropriate segment for the given segment begin point auto act_beg_seg_it = std::find_if( sub_seg_it, sub_segments.end(), @@ -560,16 +611,22 @@ void sortSegments( MathLib::sqrDist(seg_beg_pnt, seg.getEndPoint()) < eps; }); if (act_beg_seg_it == sub_segments.end()) + { return; + } // if necessary correct orientation of segment, i.e. swap beg and end if (MathLib::sqrDist(seg_beg_pnt, act_beg_seg_it->getEndPoint()) < MathLib::sqrDist(seg_beg_pnt, act_beg_seg_it->getBeginPoint())) + { std::swap(act_beg_seg_it->getBeginPoint(), act_beg_seg_it->getEndPoint()); + } assert(sub_seg_it != sub_segments.end()); // exchange segments within the container if (sub_seg_it != act_beg_seg_it) + { std::swap(*sub_seg_it, *act_beg_seg_it); + } }; // find start segment @@ -581,7 +638,9 @@ void sortSegments( MathLib::Point3d & new_seg_beg_pnt(seg_it->getEndPoint()); seg_it++; if (seg_it != sub_segments.end()) + { findNextSegment(new_seg_beg_pnt, sub_segments, seg_it); + } } } diff --git a/GeoLib/DuplicateGeometry.cpp b/GeoLib/DuplicateGeometry.cpp index d9eb3e3e8877b5a6359947c8fe60ed8bcdaece83..2b6ec49db82ad0da9945ba47809a93e48d4a7dac 100644 --- a/GeoLib/DuplicateGeometry.cpp +++ b/GeoLib/DuplicateGeometry.cpp @@ -69,11 +69,15 @@ std::unique_ptr<std::vector<GeoLib::Polyline*>> DuplicateGeometry::copyPolylines for (std::size_t i=0; i<n_plys; ++i) { if (polylines[i] == nullptr) + { continue; + } (*new_lines)[i] = new GeoLib::Polyline(*_geo_objects.getPointVec(_output_name)); std::size_t const nLinePnts (polylines[i]->getNumberOfPoints()); - for (std::size_t j=0; j<nLinePnts; ++j) + for (std::size_t j = 0; j < nLinePnts; ++j) + { (*new_lines)[i]->addPoint(polylines[i]->getPointID(j)); + } } return new_lines; } @@ -88,7 +92,9 @@ std::unique_ptr<std::vector<Surface*>> DuplicateGeometry::copySurfacesVector( for (std::size_t i=0; i<n_sfc; ++i) { if (surfaces[i] == nullptr) + { continue; + } (*new_surfaces)[i] = new GeoLib::Surface(*_geo_objects.getPointVec(_output_name)); std::size_t const n_tris (surfaces[i]->getNumberOfTriangles()); @@ -117,4 +123,4 @@ std::vector<GeoLib::Surface*>& DuplicateGeometry::getSurfaceVectorCopy() return const_cast<std::vector<GeoLib::Surface*>&>(*_geo_objects.getSurfaceVec(_output_name)); } -} +} // namespace GeoLib diff --git a/GeoLib/DuplicateGeometry.h b/GeoLib/DuplicateGeometry.h index 1a29866a6537f4d1b036bb3e93a97d3aa748f5bd..84aea52dbd316dc590710e7e28fa385d79e3ad30 100644 --- a/GeoLib/DuplicateGeometry.h +++ b/GeoLib/DuplicateGeometry.h @@ -63,4 +63,4 @@ private: }; // class -} // namespace +} // namespace GeoLib diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index 15562145f916fb84c4f1dc2d891404729a849b05..23809f0e63bf0d2cd46934a53ae87742c571daf3 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -27,13 +27,19 @@ GEOObjects::~GEOObjects() { // delete surfaces for (auto& surface : _sfc_vecs) + { delete surface; + } // delete polylines for (auto& polyline : _ply_vecs) + { delete polyline; + } // delete points for (auto& point : _pnt_vecs) + { delete point; + } } void GEOObjects::addPointVec(std::unique_ptr<std::vector<Point*>> points, @@ -58,7 +64,9 @@ const std::vector<Point*>* GEOObjects::getPointVec(const std::string &name) cons { std::size_t const idx = this->exists(name); if (idx != std::numeric_limits<std::size_t>::max()) + { return _pnt_vecs[idx]->getVector(); + } DBUG("GEOObjects::getPointVec() - No entry found with name '%s'.", name.c_str()); @@ -69,7 +77,9 @@ const PointVec* GEOObjects::getPointVecObj(const std::string &name) const { std::size_t const idx = this->exists(name); if (idx != std::numeric_limits<std::size_t>::max()) + { return _pnt_vecs[idx]; + } DBUG("GEOObjects::getPointVecObj() - No entry found with name '%s'.", name.c_str()); @@ -85,6 +95,7 @@ bool GEOObjects::removePointVec(std::string const& name) } for (auto it(_pnt_vecs.begin()); it != _pnt_vecs.end(); ++it) + { if ((*it)->getName() == name) { _callbacks->removePointVec(name); @@ -92,6 +103,7 @@ bool GEOObjects::removePointVec(std::string const& name) _pnt_vecs.erase(it); return true; } + } DBUG("GEOObjects::removePointVec() - No entry found with name '%s'.", name.c_str()); return false; @@ -136,11 +148,15 @@ void GEOObjects::addPolylineVec( it = lines->erase (it_erase); } else + { ++it; + } } if (lines->empty()) + { return; + } _ply_vecs.push_back( new PolylineVec(name, std::move(lines), std::move(ply_names))); @@ -154,8 +170,12 @@ bool GEOObjects::appendPolylineVec(const std::vector<Polyline*>& polylines, std::size_t idx (0); bool nfound (true); for (idx = 0; idx < _ply_vecs.size() && nfound; idx++) + { if (_ply_vecs[idx]->getName() == name) + { nfound = false; + } + } if (!nfound) { @@ -163,7 +183,9 @@ bool GEOObjects::appendPolylineVec(const std::vector<Polyline*>& polylines, std::size_t n_plys (polylines.size()); // append lines for (std::size_t k(0); k < n_plys; k++) - _ply_vecs[idx]->push_back (polylines[k]); + { + _ply_vecs[idx]->push_back(polylines[k]); + } _callbacks->appendPolylineVec(name); return true; } @@ -175,8 +197,12 @@ const std::vector<Polyline*>* GEOObjects::getPolylineVec(const std::string &name { std::size_t size (_ply_vecs.size()); for (std::size_t i = 0; i < size; i++) + { if (_ply_vecs[i]->getName() == name) + { return _ply_vecs[i]->getVector(); + } + } DBUG("GEOObjects::getPolylineVec() - No entry found with name '%s'.", name.c_str()); @@ -187,8 +213,12 @@ const PolylineVec* GEOObjects::getPolylineVecObj(const std::string &name) const { std::size_t size (_ply_vecs.size()); for (std::size_t i = 0; i < size; i++) + { if (_ply_vecs[i]->getName() == name) + { return _ply_vecs[i]; + } + } DBUG("GEOObjects::getPolylineVecObj() - No entry found with name '%s'.", name.c_str()); @@ -199,12 +229,14 @@ bool GEOObjects::removePolylineVec(std::string const& name) { _callbacks->removePolylineVec(name); for (auto it = _ply_vecs.begin(); it != _ply_vecs.end(); ++it) + { if ((*it)->getName() == name) { delete *it; _ply_vecs.erase(it); return true; } + } DBUG("GEOObjects::removePolylineVec() - No entry found with name '%s'.", name.c_str()); @@ -229,8 +261,12 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, std::size_t idx (0); bool nfound (true); for (idx = 0; idx < _sfc_vecs.size() && nfound; idx++) + { if (_sfc_vecs[idx]->getName() == name) + { nfound = false; + } + } if (!nfound) { @@ -238,7 +274,9 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, std::size_t n_sfcs (surfaces.size()); // append surfaces for (std::size_t k(0); k < n_sfcs; k++) - _sfc_vecs[idx]->push_back (surfaces[k]); + { + _sfc_vecs[idx]->push_back(surfaces[k]); + } _callbacks->appendSurfaceVec(name); return true; } @@ -247,7 +285,9 @@ bool GEOObjects::appendSurfaceVec(const std::vector<Surface*>& surfaces, // ctor, which needs write access to the surface vector. auto sfc = std::make_unique<std::vector<GeoLib::Surface*>>(); for (auto surface : surfaces) + { sfc->push_back(surface); + } addSurfaceVec(std::move(sfc), name); return false; } @@ -256,8 +296,12 @@ const std::vector<Surface*>* GEOObjects::getSurfaceVec(const std::string &name) { std::size_t size (_sfc_vecs.size()); for (std::size_t i = 0; i < size; i++) + { if (_sfc_vecs[i]->getName() == name) + { return _sfc_vecs[i]->getVector(); + } + } DBUG("GEOObjects::getSurfaceVec() - No entry found with name '%s'.", name.c_str()); return nullptr; @@ -267,12 +311,14 @@ bool GEOObjects::removeSurfaceVec(const std::string &name) { _callbacks->removeSurfaceVec(name); for (auto it(_sfc_vecs.begin()); it != _sfc_vecs.end(); ++it) + { if ((*it)->getName() == name) { delete *it; _sfc_vecs.erase (it); return true; } + } DBUG("GEOObjects::removeSurfaceVec() - No entry found with name '%s'.", name.c_str()); @@ -283,8 +329,12 @@ const SurfaceVec* GEOObjects::getSurfaceVecObj(const std::string &name) const { std::size_t size (_sfc_vecs.size()); for (std::size_t i = 0; i < size; i++) + { if (_sfc_vecs[i]->getName() == name) + { return _sfc_vecs[i]; + } + } DBUG("GEOObjects::getSurfaceVecObj() - No entry found with name '%s'.", name.c_str()); return nullptr; @@ -305,11 +355,17 @@ bool GEOObjects::isUniquePointVecName(std::string &name) // If the original name already exists we start to add numbers to name for // as long as it takes to make the name unique. if (count > 1) + { cpName = cpName + "-" + std::to_string(count); + } for (auto& point : _pnt_vecs) + { if (cpName == point->getName()) + { isUnique = false; + } + } } // At this point cpName is a unique name and isUnique is true. @@ -329,12 +385,16 @@ bool GEOObjects::isPntVecUsed (const std::string &name) const for (auto polyline : _ply_vecs) { if (polyline->getName() == name) + { return true; + } } for (auto surface : _sfc_vecs) { if (surface->getName() == name) + { return true; + } } return false; @@ -343,16 +403,24 @@ bool GEOObjects::isPntVecUsed (const std::string &name) const void GEOObjects::getStationVectorNames(std::vector<std::string>& names) const { for (auto point : _pnt_vecs) + { if (point->getType() == PointVec::PointType::STATION) + { names.push_back(point->getName()); + } + } } void GEOObjects::getGeometryNames (std::vector<std::string>& names) const { names.clear (); for (auto point : _pnt_vecs) + { if (point->getType() == PointVec::PointType::POINT) + { names.push_back(point->getName()); + } + } } const std::string GEOObjects::getElementNameByID(const std::string &geometry_name, GeoLib::GEOTYPE type, std::size_t id) const @@ -378,12 +446,16 @@ int GEOObjects::mergeGeometries (std::vector<std::string> const & geo_names, const std::size_t n_geo_names(geo_names.size()); if (n_geo_names < 2) + { return 2; + } std::vector<std::size_t> pnt_offsets(n_geo_names, 0); - if (! mergePoints(geo_names, merged_geo_name, pnt_offsets)) + if (!mergePoints(geo_names, merged_geo_name, pnt_offsets)) + { return 1; + } mergePolylines(geo_names, merged_geo_name, pnt_offsets); @@ -404,7 +476,9 @@ bool GEOObjects::mergePoints(std::vector<std::string> const & geo_names, for (std::size_t j(0); j < n_geo_names; ++j) { GeoLib::PointVec const*const pnt_vec(this->getPointVecObj(geo_names[j])); if (pnt_vec == nullptr) + { continue; + } const std::vector<GeoLib::Point*>* pnts(pnt_vec->getVector()); if (pnts == nullptr) { return false; @@ -635,25 +709,31 @@ const GeoLib::GeoObject* GEOObjects::getGeoObject( case GeoLib::GEOTYPE::POINT: { GeoLib::PointVec const* pnt_vec(getPointVecObj(geo_name)); if (pnt_vec) + { geo_obj = const_cast<GeoLib::GeoObject*>( - dynamic_cast<GeoLib::GeoObject const*>( - pnt_vec->getElementByName(geo_obj_name))); + dynamic_cast<GeoLib::GeoObject const*>( + pnt_vec->getElementByName(geo_obj_name))); + } break; } case GeoLib::GEOTYPE::POLYLINE: { GeoLib::PolylineVec const* ply_vec(getPolylineVecObj(geo_name)); if (ply_vec) + { geo_obj = const_cast<GeoLib::GeoObject*>( - dynamic_cast<GeoLib::GeoObject const*>( - ply_vec->getElementByName(geo_obj_name))); + dynamic_cast<GeoLib::GeoObject const*>( + ply_vec->getElementByName(geo_obj_name))); + } break; } case GeoLib::GEOTYPE::SURFACE: { GeoLib::SurfaceVec const* sfc_vec(getSurfaceVecObj(geo_name)); if (sfc_vec) + { geo_obj = const_cast<GeoLib::GeoObject*>( - dynamic_cast<GeoLib::GeoObject const*>( - sfc_vec->getElementByName(geo_obj_name))); + dynamic_cast<GeoLib::GeoObject const*>( + sfc_vec->getElementByName(geo_obj_name))); + } break; } default: @@ -677,11 +757,17 @@ GeoLib::GeoObject const* GEOObjects::getGeoObject( getGeoObject(geo_name, GeoLib::GEOTYPE::POINT, geo_obj_name) ); - if(!geo_obj) - geo_obj = getGeoObject(geo_name, GeoLib::GEOTYPE::POLYLINE, geo_obj_name); + if (!geo_obj) + { + geo_obj = + getGeoObject(geo_name, GeoLib::GEOTYPE::POLYLINE, geo_obj_name); + } - if(!geo_obj) - geo_obj = getGeoObject(geo_name, GeoLib::GEOTYPE::SURFACE, geo_obj_name); + if (!geo_obj) + { + geo_obj = + getGeoObject(geo_name, GeoLib::GEOTYPE::SURFACE, geo_obj_name); + } if (!geo_obj) { DBUG("GEOObjects::getGeoObject(): Could not find '%s' in geometry %s.", @@ -694,15 +780,20 @@ std::size_t GEOObjects::exists(const std::string &geometry_name) const { std::size_t const size (_pnt_vecs.size()); for (std::size_t i = 0; i < size; i++) + { if (_pnt_vecs[i]->getName() == geometry_name) + { return i; + } + } // HACK for enabling conversion of files without loading the associated geometry if (size > 0 && _pnt_vecs[0]->getName() == "conversionTestRun#1") + { return 1; + } return std::numeric_limits<std::size_t>::max(); } - -} // namespace +} // namespace GeoLib diff --git a/GeoLib/GEOObjects.h b/GeoLib/GEOObjects.h index a3a9779bc83df7aca5878208d99a7e50c05399db..89baa730d12f10d6ee1b1de7e3d27fbf92da3b04 100644 --- a/GeoLib/GEOObjects.h +++ b/GeoLib/GEOObjects.h @@ -380,4 +380,4 @@ private: void markUnusedPoints(std::string const& geo_name, std::vector<bool>& transfer_pnts) const; }; -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/IO/TINInterface.cpp b/GeoLib/IO/TINInterface.cpp index 125446e923625404af8b8b8f7452eab71136c64b..b92a59f30c64b1d8df30d20ef4efb84ff76b7d38 100644 --- a/GeoLib/IO/TINInterface.cpp +++ b/GeoLib/IO/TINInterface.cpp @@ -36,7 +36,9 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, if (!in) { WARN("readTIN(): could not open stream from %s.", fname.c_str()); if (errors) - errors->push_back ("readTINFile error opening stream from " + fname); + { + errors->push_back("readTINFile error opening stream from " + fname); + } return nullptr; } @@ -48,7 +50,9 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, { // allow empty lines if (line.empty()) + { continue; + } // parse line std::stringstream input(line); @@ -62,9 +66,13 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, if (!(input >> p0[0] >> p0[1] >> p0[2])) { ERR("Could not read coords of 1st point of triangle %d.", id); if (errors) - errors->push_back (std::string("readTIN error: ") + - std::string("Could not read coords of 1st point in triangle ") + + { + errors->push_back( + std::string("readTIN error: ") + + std::string( + "Could not read coords of 1st point in triangle ") + std::to_string(id)); + } in.close(); delete sfc; return nullptr; @@ -73,9 +81,13 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, if (!(input >> p1[0] >> p1[1] >> p1[2])) { ERR("Could not read coords of 2nd point of triangle %d.", id); if (errors) - errors->push_back (std::string("readTIN error: ") + - std::string("Could not read coords of 2nd point in triangle ") + + { + errors->push_back( + std::string("readTIN error: ") + + std::string( + "Could not read coords of 2nd point in triangle ") + std::to_string(id)); + } in.close(); delete sfc; return nullptr; @@ -84,9 +96,13 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, if (!(input >> p2[0] >> p2[1] >> p2[2])) { ERR("Could not read coords of 3rd point of triangle %d.", id); if (errors) - errors->push_back (std::string("readTIN error: ") + - std::string("Could not read coords of 3rd point in triangle ") + + { + errors->push_back( + std::string("readTIN error: ") + + std::string( + "Could not read coords of 3rd point in triangle ") + std::to_string(id)); + } in.close(); delete sfc; return nullptr; @@ -97,8 +113,11 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, if (MathLib::calcTriangleArea(p0, p1, p2) < d_eps) { ERR("readTIN: Triangle %d has zero area.", id); if (errors) - errors->push_back (std::string("readTIN: Triangle ") - + std::to_string(id) + std::string(" has zero area.")); + { + errors->push_back(std::string("readTIN: Triangle ") + + std::to_string(id) + + std::string(" has zero area.")); + } delete sfc; return nullptr; } @@ -121,7 +140,9 @@ GeoLib::Surface* TINInterface::readTIN(std::string const& fname, if (sfc->getNumberOfTriangles() == 0) { WARN("readTIN(): No triangle found.", fname.c_str()); if (errors) - errors->push_back ("readTIN error because of no triangle found"); + { + errors->push_back("readTIN error because of no triangle found"); + } delete sfc; return nullptr; } diff --git a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp index 48c45298b2a7feac21a3e1018fb1cb1f7658116e..5c40bacbf05898dba26566f4642b9bb9dabf1ae9 100644 --- a/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp +++ b/GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.cpp @@ -299,7 +299,9 @@ bool BoostXmlGmlInterface::write() pnt_tag.put("<xmlattr>.z", (*((*pnts)[k]))[2]); std::string const& point_name(pnt_vec->getItemNameByID(k)); if (!point_name.empty()) + { pnt_tag.put("<xmlattr>.name", point_name); + } } addPolylinesToPropertyTree(geometry_set); @@ -341,7 +343,9 @@ void BoostXmlGmlInterface::addSurfacesToPropertyTree( auto& surface_tag = surfaces_tag.add("surface", ""); surface_tag.put("<xmlattr>.id", i); if (!sfc_name.empty()) + { surface_tag.put("<xmlattr>.name", sfc_name); + } for (std::size_t j=0; j<surface->getNumberOfTriangles(); ++j) { auto& element_tag = surface_tag.add("element", ""); element_tag.put("<xmlattr>.p1", (*(*surface)[j])[0]); @@ -381,7 +385,9 @@ void BoostXmlGmlInterface::addPolylinesToPropertyTree( auto& polyline_tag = polylines_tag.add("polyline", ""); polyline_tag.put("<xmlattr>.id", i); if (!ply_name.empty()) + { polyline_tag.put("<xmlattr>.name", ply_name); + } for (std::size_t j=0; j<polyline->getNumberOfPoints(); ++j) { polyline_tag.add("pnt", polyline->getPointID(j)); } diff --git a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp index a9a3345fd849f8f4a88df035f016dd00852282f6..5b3e4cce983cb1a361af439f4b6b411522074b6d 100644 --- a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp +++ b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.cpp @@ -66,9 +66,13 @@ std::vector<GeoLib::Point*> *RapidStnInterface::readStationFile(const std::strin { std::string b(list_item->name()); if (b == "stations") + { RapidStnInterface::readStations(list_item, stations, fileName); + } if (b == "boreholes") + { RapidStnInterface::readStations(list_item, stations, fileName); + } } } @@ -144,18 +148,27 @@ void RapidStnInterface::readStations(const rapidxml::xml_node<>* station_root, s { double zVal(0.0); if (station_node->first_attribute("z")) + { zVal = strtod(station_node->first_attribute("z")->value(), nullptr); + } std::string station_name(""), sensor_data_file_name(""), bdate_str("0000-00-00"); double station_value(0.0), borehole_depth(0.0); if (station_node->first_node("name")) + { station_name = station_node->first_node("name")->value(); + } if (station_node->first_node("sensordata")) - sensor_data_file_name = station_node->first_node("sensordata")->value(); + { + sensor_data_file_name = + station_node->first_node("sensordata")->value(); + } if (station_node->first_node("value")) + { station_value = strtod(station_node->first_node("value")->value(), nullptr); + } /* add other station features here */ if (std::string(station_node->name()) == "station") @@ -169,16 +182,23 @@ void RapidStnInterface::readStations(const rapidxml::xml_node<>* station_root, s station_name); s->setStationValue(station_value); if (!sensor_data_file_name.empty()) - s->addSensorDataFromCSV(BaseLib::copyPathToFileName(sensor_data_file_name, file_name)); + { + s->addSensorDataFromCSV(BaseLib::copyPathToFileName( + sensor_data_file_name, file_name)); + } stations->push_back(s); } else if (std::string(station_node->name()) == "borehole") { if (station_node->first_node("bdepth")) + { borehole_depth = strtod( station_node->first_node("bdepth")->value(), nullptr); + } if (station_node->first_node("bdate")) + { bdate_str = station_node->first_node("bdate")->value(); + } /* add other borehole features here */ GeoLib::StationBorehole* s = @@ -194,7 +214,10 @@ void RapidStnInterface::readStations(const rapidxml::xml_node<>* station_root, s s->setStationValue(station_value); if (station_node->first_node("strat")) - RapidStnInterface::readStratigraphy(station_node->first_node("strat"), s); + { + RapidStnInterface::readStratigraphy( + station_node->first_node("strat"), s); + } stations->push_back(s); @@ -220,7 +243,9 @@ void RapidStnInterface::readStratigraphy( const rapidxml::xml_node<>* strat_root { std::string horizon_name("[NN]"); if (horizon_node->first_node("name")) + { horizon_name = horizon_node->first_node("name")->value(); + } /* add other horizon features here */ double depth( @@ -253,5 +278,5 @@ void RapidStnInterface::readStratigraphy( const rapidxml::xml_node<>* strat_root } } -} // IO -} // GeoLib +} // namespace IO +} // namespace GeoLib diff --git a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.h b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.h index 487ad84813fafd195b02b134ca07a920b409774e..ab3e4bbf0e67957323e84967a7a448dbbdd846d0 100644 --- a/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.h +++ b/GeoLib/IO/XmlIO/Rapid/RapidStnInterface.h @@ -48,5 +48,5 @@ private: static void readStratigraphy(const rapidxml::xml_node<>* strat_root, GeoLib::StationBorehole* borehole); }; -} // IO -} // GeoLib +} // namespace IO +} // namespace GeoLib diff --git a/GeoLib/LineSegment.cpp b/GeoLib/LineSegment.cpp index f9d6b4f1f9ce2d55d5ca4264ae6225947f530970..b8074cae5f902a819fb0cd3f65c3103d9320ac8b 100644 --- a/GeoLib/LineSegment.cpp +++ b/GeoLib/LineSegment.cpp @@ -101,4 +101,4 @@ bool operator==(LineSegment const& s0, LineSegment const& s1) (MathLib::sqrDist(s0.getBeginPoint(), s1.getEndPoint()) < tol && MathLib::sqrDist(s0.getEndPoint(), s1.getBeginPoint()) < tol); } -} +} // namespace GeoLib diff --git a/GeoLib/LineSegment.h b/GeoLib/LineSegment.h index 73b852aa3d967b3f879811940f156f76424ff818..38a1c465c4a1710969fa547c0e0a1fe5bdda9e6b 100644 --- a/GeoLib/LineSegment.h +++ b/GeoLib/LineSegment.h @@ -58,4 +58,4 @@ std::ostream& operator<<(std::ostream& os, /// of double. bool operator==(LineSegment const& s0, LineSegment const& s1); -} +} // namespace GeoLib diff --git a/GeoLib/MinimalBoundingSphere.cpp b/GeoLib/MinimalBoundingSphere.cpp index d473b2ac6dbeb65262b60e958f2752c42e749011..8f0ebc47611ec3871cefc263e91647aa554184cf 100644 --- a/GeoLib/MinimalBoundingSphere.cpp +++ b/GeoLib/MinimalBoundingSphere.cpp @@ -68,9 +68,13 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, { MinimalBoundingSphere two_pnts_sphere; if (a.getLength() > b.getLength()) + { two_pnts_sphere = MinimalBoundingSphere(p,r); + } else - two_pnts_sphere = MinimalBoundingSphere(p,q); + { + two_pnts_sphere = MinimalBoundingSphere(p, q); + } _radius = two_pnts_sphere.getRadius(); _center = two_pnts_sphere.getCenter(); } @@ -206,4 +210,4 @@ std::vector<MathLib::Point3d*>* MinimalBoundingSphere::getRandomSpherePoints(std return pnts; } -} +} // namespace GeoLib diff --git a/GeoLib/MinimalBoundingSphere.h b/GeoLib/MinimalBoundingSphere.h index b724582cb57b1b9a93bab5102349a470a464cb33..adb9b6e5836d4a97ca4a0b24e4d65660e489dc77 100644 --- a/GeoLib/MinimalBoundingSphere.h +++ b/GeoLib/MinimalBoundingSphere.h @@ -84,4 +84,4 @@ private: MathLib::Vector3 _center; }; -} // namespace +} // namespace GeoLib diff --git a/GeoLib/OctTree-impl.h b/GeoLib/OctTree-impl.h index 3c29d9dddcd31c5149484f1a5a80d2dedc39539c..eeeaf203b926acd13ae3ae5c4320b31df8372408 100644 --- a/GeoLib/OctTree-impl.h +++ b/GeoLib/OctTree-impl.h @@ -40,7 +40,9 @@ OctTree<POINT, MAX_POINTS>* OctTree<POINT, MAX_POINTS>::createOctTree(T ll, T ur } } if (eps == 0.0) + { eps = std::numeric_limits<double>::epsilon(); + } for (std::size_t k(0); k<3; ++k) { if (ur[k] - ll[k] > 0.0) { ur[k] += (ur[k] - ll[k]) * 1e-6; @@ -55,7 +57,9 @@ template <typename POINT, std::size_t MAX_POINTS> OctTree<POINT, MAX_POINTS>::~OctTree() { for (auto c : _children) + { delete c; + } } template <typename POINT, std::size_t MAX_POINTS> @@ -91,7 +95,9 @@ bool OctTree<POINT, MAX_POINTS>::addPoint(POINT * pnt, POINT *& ret_pnt) return true; } if (ret_pnt != nullptr) + { return false; + } } } @@ -112,17 +118,22 @@ void OctTree<POINT, MAX_POINTS>::getPointsInRange(T const& min, T const& max, std::vector<POINT*> &pnts) const { if (_ur[0] < min[0] || _ur[1] < min[1] || _ur[2] < min[2]) + { return; + } if (max[0] < _ll[0] || max[1] < _ll[1] || max[2] < _ll[2]) + { return; + } if (_is_leaf) { for (auto p : _pnts) { - if (min[0] <= (*p)[0] && (*p)[0] < max[0] - && min[1] <= (*p)[1] && (*p)[1] < max[1] - && min[2] <= (*p)[2] && (*p)[2] < max[2]) + if (min[0] <= (*p)[0] && (*p)[0] < max[0] && min[1] <= (*p)[1] && + (*p)[1] < max[1] && min[2] <= (*p)[2] && (*p)[2] < max[2]) + { pnts.push_back(p); + } } } else { for (std::size_t k(0); k<8; k++) { @@ -154,7 +165,9 @@ bool OctTree<POINT, MAX_POINTS>::addPoint_(POINT * pnt, POINT *& ret_pnt) return true; } if (ret_pnt != nullptr) + { return false; + } } } @@ -172,7 +185,9 @@ template <typename POINT, std::size_t MAX_POINTS> bool OctTree<POINT, MAX_POINTS>::addPointToChild(POINT * pnt) { if (isOutside(pnt)) + { return false; + } if (_pnts.size() < MAX_POINTS) { _pnts.push_back(pnt); @@ -245,7 +260,9 @@ void OctTree<POINT, MAX_POINTS>::splitNode(POINT * pnt) // add the passed point pnt to the childs at first for (std::size_t k(0); k < 8; k++) { if (_children[k]->addPointToChild(pnt)) + { break; + } } // distribute points to sub quadtrees @@ -264,9 +281,13 @@ template <typename POINT, std::size_t MAX_POINTS> bool OctTree<POINT, MAX_POINTS>::isOutside(POINT * pnt) const { if ((*pnt)[0] < _ll[0] || (*pnt)[1] < _ll[1] || (*pnt)[2] < _ll[2]) + { return true; + } if ((*pnt)[0] >= _ur[0] || (*pnt)[1] >= _ur[1] || (*pnt)[2] >= _ur[2]) + { return true; + } return false; } } // end namespace GeoLib diff --git a/GeoLib/Point.h b/GeoLib/Point.h index 1f29cb5f8047ac5b8e91f7be49882b13417bd32e..f8af4d5f3ad221b5ece622a37fd16c5a1fa93e95 100644 --- a/GeoLib/Point.h +++ b/GeoLib/Point.h @@ -60,4 +60,4 @@ protected: void setID(std::size_t id) { _id = id; } }; -} +} // namespace GeoLib diff --git a/GeoLib/PointVec.cpp b/GeoLib/PointVec.cpp index d5b69bb93337d9f4e7c19d84f8825951791ce139..4d7540ca4f65eea2e1aa0de7eb994b0ad5858ada 100644 --- a/GeoLib/PointVec.cpp +++ b/GeoLib/PointVec.cpp @@ -98,13 +98,17 @@ PointVec::PointVec( std::size_t cnt(0); for (cnt = 0; cnt < rm_pos.size() && _pnt_id_map[rm_pos[k]] > rm_pos[cnt];) + { cnt++; + } _pnt_id_map[rm_pos[k]] -= cnt; } // set value of the point id to the position of the point within _data_vec for (std::size_t k(0); k < _data_vec->size(); ++k) + { (*_data_vec)[k]->setID(k); + } if (number_of_all_input_pnts > _data_vec->size()) WARN("PointVec::PointVec(): there are %d double points.", @@ -116,7 +120,10 @@ PointVec::PointVec( // fetch the names from the name id map for (auto p : *_name_id_map) { - if (p.second >= _id_to_name_map.size()) continue; + if (p.second >= _id_to_name_map.size()) + { + continue; + } _id_to_name_map[p.second] = p.first; } } @@ -268,4 +275,4 @@ void PointVec::resetInternalDataStructures() } } -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/PointVec.h b/GeoLib/PointVec.h index a7b85ff0c4c594f188b2d463492fd91d8aa0e969..030cfddbf18c2c0a11b8651b93311a6d5e11e33d 100644 --- a/GeoLib/PointVec.h +++ b/GeoLib/PointVec.h @@ -157,4 +157,4 @@ private: double _rel_eps; std::unique_ptr<GeoLib::OctTree<GeoLib::Point, 16>> _oct_tree; }; -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index a0c3276a81965807edff8ea0cdee2fd6ea3de5d1..f9c326c24d42d5321678aef1a39b2cc8faee1a80 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -27,7 +27,9 @@ Polygon::Polygon(const Polyline &ply, bool init) : Polyline(ply), _aabb(ply.getPointsVec(), ply._ply_pnt_ids) { if (init) - initialise (); + { + initialise(); + } _simple_polygon_list.push_back(this); } @@ -49,9 +51,13 @@ Polygon::~Polygon() { // remove polygons from list for (auto& polygon : _simple_polygon_list) + { // the first entry of the list can be a pointer the object itself if (polygon != this) + { delete polygon; + } + } } bool Polygon::initialise () @@ -69,9 +75,11 @@ bool Polygon::isPntInPolygon (GeoLib::Point const & pnt) const MathLib::Point3d const& min_aabb_pnt(_aabb.getMinPoint()); MathLib::Point3d const& max_aabb_pnt(_aabb.getMaxPoint()); - if (pnt[0] < min_aabb_pnt[0] || max_aabb_pnt[0] < pnt[0] || pnt[1] < min_aabb_pnt[1] || - max_aabb_pnt[1] < pnt[1]) + if (pnt[0] < min_aabb_pnt[0] || max_aabb_pnt[0] < pnt[0] || + pnt[1] < min_aabb_pnt[1] || max_aabb_pnt[1] < pnt[1]) + { return false; + } std::size_t n_intersections (0); GeoLib::Point s; @@ -97,14 +105,18 @@ bool Polygon::isPntInPolygon (GeoLib::Point const & pnt) const } } if (n_intersections % 2 == 1) + { return true; + } } else { for (auto it(_simple_polygon_list.begin()++); it != _simple_polygon_list.end(); ++it) { - if ((*it)->isPntInPolygon (pnt)) + if ((*it)->isPntInPolygon(pnt)) + { return true; + } } return false; } @@ -176,12 +188,20 @@ bool Polygon::containsSegment(GeoLib::LineSegment const& segment) const } // Check if all sub segments are within the polygon. - if (!isPntInPolygon(GeoLib::Point(0.5*(a[0]+s[0][0]), 0.5*(a[1]+s[0][1]), 0.5*(a[2]+s[0][2])))) + if (!isPntInPolygon(GeoLib::Point(0.5 * (a[0] + s[0][0]), + 0.5 * (a[1] + s[0][1]), + 0.5 * (a[2] + s[0][2])))) + { return false; + } const std::size_t n_sub_segs(s.size()-1); for (std::size_t k(0); k<n_sub_segs; k++) { - if (!isPntInPolygon(GeoLib::Point(0.5*(s[k][0]+s[k+1][0]), 0.5*(s[k][1]+s[k+1][1]), 0.5*(s[k][2]+s[k+1][2])))) - return false; + if (!isPntInPolygon(GeoLib::Point(0.5 * (s[k][0] + s[k + 1][0]), + 0.5 * (s[k][1] + s[k + 1][1]), + 0.5 * (s[k][2] + s[k + 1][2])))) + { + return false; + } } return isPntInPolygon(GeoLib::Point(0.5 * (s[0][0] + b[0]), 0.5 * (s[0][1] + b[1]), @@ -258,7 +278,9 @@ void Polygon::computeListOfSimplePolygons () splitPolygonAtIntersection (_simple_polygon_list.begin()); for (auto& polygon : _simple_polygon_list) + { polygon->initialise(); + } } EdgeType Polygon::getEdgeType (std::size_t k, GeoLib::Point const & pnt) const @@ -269,7 +291,9 @@ EdgeType Polygon::getEdgeType (std::size_t k, GeoLib::Point const & pnt) const const GeoLib::Point & v (*(getPoint(k))); const GeoLib::Point & w (*(getPoint(k + 1))); if (v[1] < pnt[1] && pnt[1] <= w[1]) + { return EdgeType::CROSSING; + } return EdgeType::INESSENTIAL; } @@ -277,7 +301,9 @@ EdgeType Polygon::getEdgeType (std::size_t k, GeoLib::Point const & pnt) const const GeoLib::Point & v (*(getPoint(k))); const GeoLib::Point & w (*(getPoint(k + 1))); if (w[1] < pnt[1] && pnt[1] <= v[1]) + { return EdgeType::CROSSING; + } return EdgeType::INESSENTIAL; } @@ -297,26 +323,37 @@ void Polygon::ensureCCWOrientation () std::size_t n_pnts (this->getNumberOfPoints() - 1); std::vector<GeoLib::Point*> tmp_polygon_pnts; for (std::size_t k(0); k < n_pnts; k++) - tmp_polygon_pnts.push_back (new GeoLib::Point (*(this->getPoint(k)))); + { + tmp_polygon_pnts.push_back(new GeoLib::Point(*(this->getPoint(k)))); + } // rotate copied points into x-y-plane GeoLib::rotatePointsToXY(tmp_polygon_pnts); - for (auto & tmp_polygon_pnt : tmp_polygon_pnts) - (*tmp_polygon_pnt)[2] = 0.0; // should be -= d but there are numerical errors + for (auto& tmp_polygon_pnt : tmp_polygon_pnts) + { + (*tmp_polygon_pnt)[2] = + 0.0; // should be -= d but there are numerical errors + } // *** get the left most upper point std::size_t min_x_max_y_idx (0); // for orientation check for (std::size_t k(0); k < n_pnts; k++) + { if ((*(tmp_polygon_pnts[k]))[0] <= (*(tmp_polygon_pnts[min_x_max_y_idx]))[0]) { - if ((*(tmp_polygon_pnts[k]))[0] < (*(tmp_polygon_pnts[min_x_max_y_idx]))[0]) + if ((*(tmp_polygon_pnts[k]))[0] < + (*(tmp_polygon_pnts[min_x_max_y_idx]))[0]) + { min_x_max_y_idx = k; + } else if ((*(tmp_polygon_pnts[k]))[1] > (*(tmp_polygon_pnts[min_x_max_y_idx]))[1]) + { min_x_max_y_idx = k; - + } } + } // *** determine orientation GeoLib::Orientation orient; if (0 < min_x_max_y_idx && min_x_max_y_idx < n_pnts - 2) @@ -347,11 +384,15 @@ void Polygon::ensureCCWOrientation () std::size_t tmp_n_pnts (n_pnts); tmp_n_pnts++; // include last point of polygon (which is identical to the first) for (std::size_t k(0); k < tmp_n_pnts / 2; k++) - std::swap (_ply_pnt_ids[k], _ply_pnt_ids[tmp_n_pnts - 1 - k]); + { + std::swap(_ply_pnt_ids[k], _ply_pnt_ids[tmp_n_pnts - 1 - k]); + } } for (std::size_t k(0); k < n_pnts; k++) + { delete tmp_polygon_pnts[k]; + } } #if __GNUC__ <= 4 && (__GNUC_MINOR__ < 9) @@ -367,7 +408,9 @@ void Polygon::splitPolygonAtIntersection( GeoLib::Point intersection_pnt; if (!GeoLib::lineSegmentsIntersect(*polygon_it, seg_it0, seg_it1, intersection_pnt)) + { return; + } std::size_t idx0(seg_it0.getSegmentNumber()); std::size_t idx1(seg_it1.getSegmentNumber()); @@ -378,24 +421,34 @@ void Polygon::splitPolygonAtIntersection( // split Polygon if (idx0 > idx1) - std::swap (idx0, idx1); + { + std::swap(idx0, idx1); + } GeoLib::Polyline polyline0{(*polygon_it)->getPointsVec()}; for (std::size_t k(0); k <= idx0; k++) + { polyline0.addPoint((*polygon_it)->getPointID(k)); + } polyline0.addPoint(intersection_pnt_id); for (std::size_t k(idx1 + 1); k < (*polygon_it)->getNumberOfPoints(); k++) + { polyline0.addPoint((*polygon_it)->getPointID(k)); + } GeoLib::Polyline polyline1{(*polygon_it)->getPointsVec()}; polyline1.addPoint(intersection_pnt_id); for (std::size_t k(idx0 + 1); k <= idx1; k++) + { polyline1.addPoint((*polygon_it)->getPointID(k)); + } polyline1.addPoint(intersection_pnt_id); // remove the polygon except the first if (*polygon_it != this) + { delete *polygon_it; + } // erase polygon_it and add two new polylines auto polygon1_it = _simple_polygon_list.insert( _simple_polygon_list.erase(polygon_it), new GeoLib::Polygon(polyline1)); @@ -420,29 +473,41 @@ void Polygon::splitPolygonAtPoint (const std::list<GeoLib::Polygon*>::iterator& BaseLib::quicksort (id_vec, 0, n, perm); for (std::size_t k(0); k < n - 1; k++) + { if (id_vec[k] == id_vec[k + 1]) { idx0 = perm[k]; idx1 = perm[k + 1]; if (idx0 > idx1) - std::swap (idx0, idx1); + { + std::swap(idx0, idx1); + } // create two closed polylines GeoLib::Polyline polyline0{*(*polygon_it)}; for (std::size_t j(0); j <= idx0; j++) + { polyline0.addPoint((*polygon_it)->getPointID(j)); + } for (std::size_t j(idx1 + 1); - j < (*polygon_it)->getNumberOfPoints(); j++) + j < (*polygon_it)->getNumberOfPoints(); + j++) + { polyline0.addPoint((*polygon_it)->getPointID(j)); + } GeoLib::Polyline polyline1{*(*polygon_it)}; for (std::size_t j(idx0); j <= idx1; j++) + { polyline1.addPoint((*polygon_it)->getPointID(j)); + } // remove the polygon except the first if (*polygon_it != this) + { delete *polygon_it; + } // erase polygon_it and add two new polygons auto polygon1_it = _simple_polygon_list.insert( _simple_polygon_list.erase(polygon_it), new Polygon(polyline1)); @@ -454,6 +519,7 @@ void Polygon::splitPolygonAtPoint (const std::list<GeoLib::Polygon*>::iterator& return; } + } } GeoLib::Polygon* createPolygonFromCircle (GeoLib::Point const& middle_pnt, double radius, @@ -473,7 +539,9 @@ GeoLib::Polygon* createPolygonFromCircle (GeoLib::Point const& middle_pnt, doubl // create polygon GeoLib::Polygon* polygon (new GeoLib::Polygon (pnts, false)); for (std::size_t k(0); k < resolution; k++) - polygon->addPoint (k + off_set); + { + polygon->addPoint(k + off_set); + } polygon->addPoint (off_set); return polygon; @@ -482,7 +550,9 @@ GeoLib::Polygon* createPolygonFromCircle (GeoLib::Point const& middle_pnt, doubl bool operator==(Polygon const& lhs, Polygon const& rhs) { if (lhs.getNumberOfPoints() != rhs.getNumberOfPoints()) + { return false; + } const std::size_t n(lhs.getNumberOfPoints()); const std::size_t start_pnt(lhs.getPointID(0)); @@ -498,7 +568,10 @@ bool operator==(Polygon const& lhs, Polygon const& rhs) } // case: start point not found in second polygon - if (nfound) return false; + if (nfound) + { + return false; + } // *** determine direction // opposite direction diff --git a/GeoLib/PolygonWithSegmentMarker.cpp b/GeoLib/PolygonWithSegmentMarker.cpp index 0330436be45b0f16f6192cdc7352894bac10fcc9..cf253e5c43223a49caa49c93e7399f07752f199a 100644 --- a/GeoLib/PolygonWithSegmentMarker.cpp +++ b/GeoLib/PolygonWithSegmentMarker.cpp @@ -45,4 +45,4 @@ bool PolygonWithSegmentMarker::insertPoint(std::size_t pos, std::size_t pnt_id) return false; } -} // end GeoLib +} // namespace GeoLib diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index f2ec9c673d1581ad8c890f9b087e2ef812e69112..c85f32f5a8a9004488e769774bb70c9b3a131eaf 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -39,7 +39,9 @@ void Polyline::write(std::ostream &os) const { std::size_t size(_ply_pnt_ids.size()); for (std::size_t k(0); k < size; k++) + { os << *(_ply_pnts[_ply_pnt_ids[k]]) << "\n"; + } } bool Polyline::addPoint(std::size_t pnt_id) @@ -49,7 +51,9 @@ bool Polyline::addPoint(std::size_t pnt_id) // don't insert point if this would result in identical IDs for two adjacent points if (n_pnts > 0 && _ply_pnt_ids.back() == pnt_id) + { return false; + } _ply_pnt_ids.push_back(pnt_id); @@ -59,7 +63,9 @@ bool Polyline::addPoint(std::size_t pnt_id) *_ply_pnts[_ply_pnt_ids[n_pnts-1]], *_ply_pnts[pnt_id]))); double dist_until_now(0.0); if (n_pnts > 1) + { dist_until_now = _length[n_pnts - 1]; + } _length.push_back(dist_until_now + act_dist); } @@ -105,7 +111,9 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) _length.insert(_length.begin() + 1, act_dist); const std::size_t s(_length.size()); for (std::size_t k(2); k < s; k++) + { _length[k] += _length[1]; + } } else { if (pos == _ply_pnt_ids.size() - 1) { // insert at last position @@ -114,7 +122,9 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) *_ply_pnts[pnt_id]))); double dist_until_now (0.0); if (_ply_pnt_ids.size() > 2) + { dist_until_now = _length[_ply_pnt_ids.size() - 2]; + } _length.insert(_length.begin() + pos_dt, dist_until_now + act_dist); @@ -122,7 +132,9 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) // insert at arbitrary position within the vector double dist_until_now (0.0); if (pos > 1) + { dist_until_now = _length[pos - 1]; + } double len_seg0(std::sqrt(MathLib::sqrDist( *_ply_pnts[_ply_pnt_ids[pos - 1]], *_ply_pnts[pnt_id]))); @@ -136,7 +148,9 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) _length.insert(it1, _length[pos] + len_seg1); for (it1 = _length.begin() + pos_dt + 2; it1 != _length.end(); ++it1) + { *it1 += update_dist; + } } } } @@ -146,7 +160,9 @@ bool Polyline::insertPoint(std::size_t pos, std::size_t pnt_id) void Polyline::removePoint(std::size_t pos) { if (pos >= _ply_pnt_ids.size()) + { return; + } auto const pos_dt( static_cast<std::vector<std::size_t>::difference_type>(pos)); @@ -162,7 +178,9 @@ void Polyline::removePoint(std::size_t pos) if (pos == 0) { double seg_length(_length[0]); for (std::size_t k(0); k < n_ply_pnt_ids; k++) + { _length[k] = _length[k + 1] - seg_length; + } _length.pop_back(); } else { const double len_seg0(_length[pos] - _length[pos - 1]); @@ -173,7 +191,9 @@ void Polyline::removePoint(std::size_t pos) double seg_length_diff(len_new_seg - len_seg0 - len_seg1); for (std::size_t k(pos); k < n_ply_pnt_ids; k++) + { _length[k] += seg_length_diff; + } } } @@ -190,7 +210,9 @@ std::size_t Polyline::getNumberOfSegments() const bool Polyline::isClosed() const { if (_ply_pnt_ids.size() < 3) + { return false; + } return _ply_pnt_ids.front() == _ply_pnt_ids.back(); } @@ -199,7 +221,9 @@ bool Polyline::isCoplanar() const { std::size_t const n_points (_ply_pnt_ids.size()); if (n_points < 4) + { return true; + } GeoLib::Point const& p0 (*this->getPoint(0)); GeoLib::Point const& p1 (*this->getPoint(1)); @@ -273,7 +297,9 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & std::vector<Polyline*> local_ply_vec; for (std::size_t i = 1; i < nLines; i++) + { local_ply_vec.push_back(ply_vec[i]); + } while (!local_ply_vec.empty()) { @@ -291,11 +317,15 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & { auto* tmp = new Polyline((*it)->getPointsVec()); for (std::size_t k = 0; k < nPoints; k++) + { tmp->addPoint((*it)->getPointID(nPoints - k - 1)); + } std::size_t new_ply_size(new_ply->getNumberOfPoints()); for (std::size_t k = 1; k < new_ply_size; k++) + { tmp->addPoint(new_ply->getPointID(k)); + } delete new_ply; new_ply = tmp; ply_found = true; @@ -307,7 +337,9 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & auto* tmp = new Polyline(**it); std::size_t new_ply_size(new_ply->getNumberOfPoints()); for (std::size_t k = 1; k < new_ply_size; k++) + { tmp->addPoint(new_ply->getPointID(k)); + } delete new_ply; new_ply = tmp; ply_found = true; @@ -320,7 +352,9 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & (*it)->getPointID(0), prox)) { for (std::size_t k = 1; k < nPoints; k++) + { new_ply->addPoint((*it)->getPointID(k)); + } ply_found = true; } //else if (new_ply->getPointID(new_ply->getNumberOfPoints()-1) == (*it)->getPointID(nPoints-1)) @@ -331,7 +365,9 @@ Polyline* Polyline::constructPolylineFromSegments(const std::vector<Polyline*> & (*it)->getPointID(nPoints - 1), prox)) { for (std::size_t k = 1; k < nPoints; k++) + { new_ply->addPoint((*it)->getPointID(nPoints - k - 1)); + } ply_found = true; } if (ply_found) @@ -377,20 +413,31 @@ Location Polyline::getLocationOfPoint (std::size_t k, GeoLib::Point const & pnt) long double det_2x2 (a[0] * b[1] - a[1] * b[0]); if (det_2x2 > std::numeric_limits<double>::epsilon()) + { return Location::LEFT; + } if (std::numeric_limits<double>::epsilon() < std::abs(det_2x2)) + { return Location::RIGHT; + } if (a[0] * b[0] < 0.0 || a[1] * b[1] < 0.0) + { return Location::BEHIND; + } if (a[0] * a[0] + a[1] * a[1] < b[0] * b[0] + b[1] * b[1]) + { return Location::BEYOND; - if (MathLib::sqrDist (pnt, - *_ply_pnts[_ply_pnt_ids[k]]) < pow(std::numeric_limits<double>::epsilon(),2)) + } + if (MathLib::sqrDist(pnt, *_ply_pnts[_ply_pnt_ids[k]]) < + pow(std::numeric_limits<double>::epsilon(), 2)) + { return Location::SOURCE; - if (MathLib::sqrDist (pnt, - *_ply_pnts[_ply_pnt_ids[k + 1]]) < + } + if (MathLib::sqrDist(pnt, *_ply_pnts[_ply_pnt_ids[k + 1]]) < std::sqrt(std::numeric_limits<double>::epsilon())) + { return Location::DESTINATION; + } return Location::BETWEEN; } @@ -400,8 +447,11 @@ void Polyline::updatePointIDs(const std::vector<std::size_t> &pnt_ids) { if (pnt_ids[*it] != *it) { - if (it!=this->_ply_pnt_ids.begin() && (pnt_ids[*it] == pnt_ids[*(it-1)])) + if (it != this->_ply_pnt_ids.begin() && + (pnt_ids[*it] == pnt_ids[*(it - 1)])) + { it = this->_ply_pnt_ids.erase(it); + } else { *it = pnt_ids[*it]; @@ -409,7 +459,9 @@ void Polyline::updatePointIDs(const std::vector<std::size_t> &pnt_ids) } } else + { ++it; + } } } @@ -440,8 +492,10 @@ double Polyline::getDistanceAlongPolyline(const MathLib::Point3d& pnt, } } // end line segment loop - if (! found) + if (!found) + { dist = -1.0; + } return dist; } @@ -460,7 +514,9 @@ Polyline::SegmentIterator& Polyline::SegmentIterator::operator=( SegmentIterator const& rhs) { if (&rhs == this) + { return *this; + } _polyline = rhs._polyline; _segment_number = rhs._segment_number; @@ -510,7 +566,9 @@ Polyline::SegmentIterator& Polyline::SegmentIterator::operator+=( static_cast<std::vector<GeoLib::Point>::size_type>(n); } if (_segment_number > _polyline->getNumberOfSegments()) + { OGS_FATAL(""); + } return *this; } @@ -533,7 +591,9 @@ Polyline::SegmentIterator& Polyline::SegmentIterator::operator-=( static_cast<std::vector<GeoLib::Point>::size_type>(-n); } if (_segment_number > _polyline->getNumberOfSegments()) + { OGS_FATAL(""); + } return *this; } @@ -559,16 +619,22 @@ bool containsEdge (const Polyline& ply, std::size_t id0, std::size_t id1) return false; } if (id0 > id1) - std::swap (id0,id1); + { + std::swap(id0, id1); + } const std::size_t n (ply.getNumberOfPoints() - 1); for (std::size_t k(0); k < n; k++) { std::size_t ply_pnt0 (ply.getPointID (k)); std::size_t ply_pnt1 (ply.getPointID (k + 1)); if (ply_pnt0 > ply_pnt1) - std::swap (ply_pnt0, ply_pnt1); + { + std::swap(ply_pnt0, ply_pnt1); + } if (ply_pnt0 == id0 && ply_pnt1 == id1) + { return true; + } } return false; } @@ -576,12 +642,18 @@ bool containsEdge (const Polyline& ply, std::size_t id0, std::size_t id1) bool operator==(Polyline const& lhs, Polyline const& rhs) { if (lhs.getNumberOfPoints() != rhs.getNumberOfPoints()) + { return false; + } const std::size_t n(lhs.getNumberOfPoints()); for (std::size_t k(0); k < n; k++) + { if (lhs.getPointID(k) != rhs.getPointID(k)) + { return false; + } + } return true; } @@ -592,7 +664,9 @@ bool pointsAreIdentical(const std::vector<Point*> &pnt_vec, double prox) { if (i == j) + { return true; + } return MathLib::sqrDist(*pnt_vec[i], *pnt_vec[j]) < prox; } } // end namespace GeoLib diff --git a/GeoLib/Polyline.h b/GeoLib/Polyline.h index 1eb7b6908e6536808330faf8d83e309c7f11c69e..a37a258a61506c535098a0902733d0b110d05679 100644 --- a/GeoLib/Polyline.h +++ b/GeoLib/Polyline.h @@ -261,4 +261,4 @@ bool operator==(Polyline const& lhs, Polyline const& rhs); bool pointsAreIdentical(const std::vector<Point*> &pnt_vec, std::size_t i, std::size_t j, double prox); -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/PolylineVec.h b/GeoLib/PolylineVec.h index 683fe5ed62a929e576be05deba836219d7aa40df..7813bb24b1749ad5e09a22254e19c7ef05c8adf1 100644 --- a/GeoLib/PolylineVec.h +++ b/GeoLib/PolylineVec.h @@ -28,4 +28,4 @@ namespace GeoLib { using PolylineVec = TemplateVec<GeoLib::Polyline>; -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/PolylineWithSegmentMarker.cpp b/GeoLib/PolylineWithSegmentMarker.cpp index 83795209abbf8de15d0855feb3439cf59a51b5e9..3119acba8b56a0ebf3f4054bf1c5806806c9a4a7 100644 --- a/GeoLib/PolylineWithSegmentMarker.cpp +++ b/GeoLib/PolylineWithSegmentMarker.cpp @@ -49,4 +49,4 @@ bool PolylineWithSegmentMarker::insertPoint(std::size_t pos, std::size_t pnt_id) return false; } -} // end GeoLib +} // namespace GeoLib diff --git a/GeoLib/PolylineWithSegmentMarker.h b/GeoLib/PolylineWithSegmentMarker.h index 78cc3812cd786aa0e15f416c6c6228d4bc7f55d9..87b0cec951137f62fe1143a5cc10e96196dbeaa3 100644 --- a/GeoLib/PolylineWithSegmentMarker.h +++ b/GeoLib/PolylineWithSegmentMarker.h @@ -57,4 +57,4 @@ private: std::vector<bool> _marker; }; -} +} // namespace GeoLib diff --git a/GeoLib/QuadTree.h b/GeoLib/QuadTree.h index 6a7e49801d21743d6487a330a1a4ae2af73bff58..650e39748b17192f049e4b508a83859fe33d2384 100644 --- a/GeoLib/QuadTree.h +++ b/GeoLib/QuadTree.h @@ -61,12 +61,18 @@ public: // init children for (auto& child : _children) + { child = nullptr; + } if ((_ur[0] - _ll[0]) > (_ur[1] - _ll[1])) + { _ur[1] = _ll[1] + _ur[0] - _ll[0]; + } else + { _ur[0] = _ll[0] + _ur[1] - _ll[1]; + } DBUG("QuadTree(): lower left: (%f,%f,%f), upper right: (%f,%f,%f), depth: %d", _ll[0], _ll[1], _ll[2], _ur[0], _ur[1], _ur[2], _depth); } @@ -90,16 +96,30 @@ public: */ bool addPoint (POINT const* pnt) { - if ((*pnt)[0] < _ll[0]) return false; - if ((*pnt)[0] >= _ur[0]) return false; - if ((*pnt)[1] < _ll[1]) return false; - if ((*pnt)[1] >= _ur[1]) return false; + if ((*pnt)[0] < _ll[0]) + { + return false; + } + if ((*pnt)[0] >= _ur[0]) + { + return false; + } + if ((*pnt)[1] < _ll[1]) + { + return false; + } + if ((*pnt)[1] >= _ur[1]) + { + return false; + } if (!_is_leaf) { for (auto& child : _children) { if (child->addPoint(pnt)) + { return true; + } } return false; } @@ -111,15 +131,23 @@ public: const double v1((*(_pnts[k]))[1] - (*pnt)[1]); const double sqr_dist (v0*v0 + v1*v1); if (sqr_dist < std::numeric_limits<double>::epsilon()) + { pnt_in_quadtree = true; + } } if (!pnt_in_quadtree) + { _pnts.push_back (pnt); + } else + { return false; + } - if (_pnts.size () > _max_points_per_leaf) - splitNode (); + if (_pnts.size() > _max_points_per_leaf) + { + splitNode(); + } return true; } @@ -141,6 +169,7 @@ public: leaf_list.pop_front (); if (node->isLeaf()) + { if (needToRefine (node)) { node->splitNode (); @@ -152,32 +181,56 @@ public: // check if north neighbor has to be refined QuadTree<POINT>* north_neighbor (node->getNorthNeighbor()); if (north_neighbor != nullptr) - if (north_neighbor->getDepth() < node->getDepth ()) + { + if (north_neighbor->getDepth() < node->getDepth()) + { if (north_neighbor->isLeaf()) - leaf_list.push_back (north_neighbor); + { + leaf_list.push_back(north_neighbor); + } + } + } // check if west neighbor has to be refined QuadTree<POINT>* west_neighbor (node->getWestNeighbor()); if (west_neighbor != nullptr) - if (west_neighbor->getDepth() < node->getDepth ()) + { + if (west_neighbor->getDepth() < node->getDepth()) + { if (west_neighbor->isLeaf()) - leaf_list.push_back (west_neighbor); + { + leaf_list.push_back(west_neighbor); + } + } + } // check if south neighbor has to be refined QuadTree<POINT>* south_neighbor (node->getSouthNeighbor()); if (south_neighbor != nullptr) - if (south_neighbor->getDepth() < node->getDepth ()) + { + if (south_neighbor->getDepth() < node->getDepth()) + { if (south_neighbor->isLeaf()) - leaf_list.push_back (south_neighbor); + { + leaf_list.push_back(south_neighbor); + } + } + } // check if east neighbor has to be refined QuadTree<POINT>* east_neighbor (node->getEastNeighbor()); if (east_neighbor != nullptr) - if (east_neighbor->getDepth() < node->getDepth ()) + { + if (east_neighbor->getDepth() < node->getDepth()) + { if (east_neighbor->isLeaf()) - leaf_list.push_back (east_neighbor); - + { + leaf_list.push_back(east_neighbor); + } + } + } } + } } } @@ -188,10 +241,16 @@ public: void getLeafs (std::list<QuadTree<POINT>*>& leaf_list) { if (_is_leaf) + { leaf_list.push_back (this); + } else + { for (auto& child : _children) + { child->getLeafs(leaf_list); + } + } } const std::vector<POINT const*>& getPoints () const { return _pnts; } @@ -213,17 +272,27 @@ public: { if (pnt[0] <= 0.5 * (_ur[0] + _ll[0])) // WEST { - if (pnt[1] <= 0.5 * (_ur[1] + _ll[1])) // SOUTH + if (pnt[1] <= 0.5 * (_ur[1] + _ll[1])) + { // SOUTH _children[static_cast<int>(Quadrant::SW)]->getLeaf (pnt, ll, ur); - else // NORTH - _children[static_cast<int>(Quadrant::NW)]->getLeaf (pnt, ll, ur); + } + else + { // NORTH + _children[static_cast<int>(Quadrant::NW)]->getLeaf( + pnt, ll, ur); + } } else // EAST { - if (pnt[1] <= 0.5 * (_ur[1] + _ll[1])) // SOUTH + if (pnt[1] <= 0.5 * (_ur[1] + _ll[1])) + { // SOUTH _children[static_cast<int>(Quadrant::SE)]->getLeaf (pnt, ll, ur); - else // NORTH - _children[static_cast<int>(Quadrant::NE)]->getLeaf (pnt, ll, ur); + } + else + { // NORTH + _children[static_cast<int>(Quadrant::NE)]->getLeaf( + pnt, ll, ur); + } } } } @@ -246,7 +315,9 @@ public: void getMaxDepth (std::size_t &max_depth) const { if (max_depth < _depth) + { max_depth = _depth; + } for (auto& child : _children) { @@ -273,94 +344,145 @@ private: bool isChild (QuadTree<POINT> const* const tree, Quadrant quadrant) const { - if (_children[static_cast<int>(quadrant)] == tree) return true; + if (_children[static_cast<int>(quadrant)] == tree) + { + return true; + } return false; } QuadTree<POINT>* getNorthNeighbor () const { - if (this->_father == nullptr) // root of QuadTree + if (this->_father == nullptr) + { // root of QuadTree return nullptr; + } - if (this->_father->isChild (this, Quadrant::SW)) - return this->_father->getChild (Quadrant::NW); - if (this->_father->isChild (this, Quadrant::SE)) - return this->_father->getChild (Quadrant::NE); + if (this->_father->isChild(this, Quadrant::SW)) + { + return this->_father->getChild(Quadrant::NW); + } + if (this->_father->isChild(this, Quadrant::SE)) + { + return this->_father->getChild(Quadrant::NE); + } QuadTree<POINT>* north_neighbor (this->_father->getNorthNeighbor ()); if (north_neighbor == nullptr) + { return nullptr; + } if (north_neighbor->isLeaf()) + { return north_neighbor; + } - if (this->_father->isChild (this, Quadrant::NW)) - return north_neighbor->getChild (Quadrant::SW); + if (this->_father->isChild(this, Quadrant::NW)) + { + return north_neighbor->getChild(Quadrant::SW); + } return north_neighbor->getChild(Quadrant::SE); } QuadTree<POINT>* getSouthNeighbor () const { - if (this->_father == nullptr) // root of QuadTree + if (this->_father == nullptr) + { // root of QuadTree return nullptr; + } - if (this->_father->isChild (this, Quadrant::NW)) - return this->_father->getChild (Quadrant::SW); - if (this->_father->isChild (this, Quadrant::NE)) - return this->_father->getChild (Quadrant::SE); + if (this->_father->isChild(this, Quadrant::NW)) + { + return this->_father->getChild(Quadrant::SW); + } + if (this->_father->isChild(this, Quadrant::NE)) + { + return this->_father->getChild(Quadrant::SE); + } QuadTree<POINT>* south_neighbor (this->_father->getSouthNeighbor ()); if (south_neighbor == nullptr) + { return nullptr; + } if (south_neighbor->isLeaf()) + { return south_neighbor; + } - if (this->_father->isChild (this, Quadrant::SW)) - return south_neighbor->getChild (Quadrant::NW); + if (this->_father->isChild(this, Quadrant::SW)) + { + return south_neighbor->getChild(Quadrant::NW); + } return south_neighbor->getChild(Quadrant::NE); } QuadTree<POINT>* getEastNeighbor () const { - if (this->_father == nullptr) // root of QuadTree + if (this->_father == nullptr) + { // root of QuadTree return nullptr; + } - if (this->_father->isChild (this, Quadrant::NW)) - return this->_father->getChild (Quadrant::NE); - if (this->_father->isChild (this, Quadrant::SW)) - return this->_father->getChild (Quadrant::SE); + if (this->_father->isChild(this, Quadrant::NW)) + { + return this->_father->getChild(Quadrant::NE); + } + if (this->_father->isChild(this, Quadrant::SW)) + { + return this->_father->getChild(Quadrant::SE); + } QuadTree<POINT>* east_neighbor (this->_father->getEastNeighbor ()); if (east_neighbor == nullptr) + { return nullptr; + } if (east_neighbor->isLeaf()) + { return east_neighbor; + } - if (this->_father->isChild (this, Quadrant::SE)) - return east_neighbor->getChild (Quadrant::SW); + if (this->_father->isChild(this, Quadrant::SE)) + { + return east_neighbor->getChild(Quadrant::SW); + } return east_neighbor->getChild(Quadrant::NW); } QuadTree<POINT>* getWestNeighbor () const { - if (this->_father == nullptr) // root of QuadTree + if (this->_father == nullptr) + { // root of QuadTree return nullptr; + } - if (this->_father->isChild (this, Quadrant::NE)) - return this->_father->getChild (Quadrant::NW); - if (this->_father->isChild (this, Quadrant::SE)) - return this->_father->getChild (Quadrant::SW); + if (this->_father->isChild(this, Quadrant::NE)) + { + return this->_father->getChild(Quadrant::NW); + } + if (this->_father->isChild(this, Quadrant::SE)) + { + return this->_father->getChild(Quadrant::SW); + } QuadTree<POINT>* west_neighbor (this->_father->getWestNeighbor ()); if (west_neighbor == nullptr) + { return nullptr; + } if (west_neighbor->isLeaf()) + { return west_neighbor; + } - if (this->_father->isChild (this, Quadrant::SW)) - return west_neighbor->getChild (Quadrant::SE); + if (this->_father->isChild(this, Quadrant::SW)) + { + return west_neighbor->getChild(Quadrant::SE); + } return west_neighbor->getChild(Quadrant::NE); } @@ -388,7 +510,9 @@ private: { // init children for (auto& child : _children) + { child = nullptr; + } } void splitNode () @@ -417,8 +541,12 @@ private: for (std::size_t j(0); j < _pnts.size(); j++) { bool nfound(true); for (std::size_t k(0); k < 4 && nfound; k++) - if (_children[k]->addPoint(_pnts[j])) nfound = false; - + { + if (_children[k]->addPoint(_pnts[j])) + { + nfound = false; + } + } } _pnts.clear(); _is_leaf = false; @@ -430,52 +558,76 @@ private: if (north_neighbor != nullptr) { if (north_neighbor->getDepth() == node->getDepth()) + { if (!north_neighbor->isLeaf ()) { if (!(north_neighbor->getChild(Quadrant::SW))->isLeaf()) + { return true; + } if (!(north_neighbor->getChild(Quadrant::SE))->isLeaf()) + { return true; + } } + } } QuadTree<POINT>* west_neighbor (node->getWestNeighbor ()); if (west_neighbor != nullptr) { if (west_neighbor->getDepth() == node->getDepth()) + { if (!west_neighbor->isLeaf ()) { if (!(west_neighbor->getChild(Quadrant::SE))->isLeaf()) + { return true; + } if (!(west_neighbor->getChild(Quadrant::NE))->isLeaf()) + { return true; + } } + } } QuadTree<POINT>* south_neighbor (node->getSouthNeighbor ()); if (south_neighbor != nullptr) { if (south_neighbor->getDepth() == node->getDepth()) + { if (!south_neighbor->isLeaf()) { if (!(south_neighbor->getChild(Quadrant::NE))->isLeaf()) + { return true; + } if (!(south_neighbor->getChild(Quadrant::NW))->isLeaf()) + { return true; + } } + } } QuadTree<POINT>* east_neighbor (node->getEastNeighbor ()); if (east_neighbor != nullptr) { if (east_neighbor->getDepth() == node->getDepth()) + { if (!east_neighbor->isLeaf ()) { if (!(east_neighbor->getChild(Quadrant::NW))->isLeaf()) + { return true; + } if (!(east_neighbor->getChild(Quadrant::SW))->isLeaf()) + { return true; + } } + } } return false; } @@ -505,4 +657,4 @@ private: */ const std::size_t _max_points_per_leaf; }; -} +} // namespace GeoLib diff --git a/GeoLib/Raster.cpp b/GeoLib/Raster.cpp index a30a7f9afaadfcc9af6ef4e297641438482c34e1..04d06c1b9d68c4553cae724bd96560333f80528a 100644 --- a/GeoLib/Raster.cpp +++ b/GeoLib/Raster.cpp @@ -142,15 +142,18 @@ double Raster::interpolateValueAtPoint(MathLib::Point3d const& pnt) const { // check if neighbour pixel is still on the raster, otherwise substitute // a no data value. This also allows the cast to unsigned type. - if ( (xIdx + x_nb[j]) < 0 || - (yIdx + y_nb[j]) < 0 || - (xIdx + x_nb[j]) > (_header.n_cols-1) || - (yIdx + y_nb[j]) > (_header.n_rows-1) ) + if ((xIdx + x_nb[j]) < 0 || (yIdx + y_nb[j]) < 0 || + (xIdx + x_nb[j]) > (_header.n_cols - 1) || + (yIdx + y_nb[j]) > (_header.n_rows - 1)) + { pix_val[j] = _header.no_data; + } else - pix_val[j] = _raster_data[ - static_cast<std::size_t>(yIdx + y_nb[j]) * _header.n_cols + - static_cast<std::size_t>(xIdx + x_nb[j])]; + { + pix_val[j] = _raster_data[static_cast<std::size_t>(yIdx + y_nb[j]) * + _header.n_cols + + static_cast<std::size_t>(xIdx + x_nb[j])]; + } // remove no data values if (std::fabs(pix_val[j] - _header.no_data) < std::numeric_limits<double>::epsilon()) @@ -163,8 +166,10 @@ double Raster::interpolateValueAtPoint(MathLib::Point3d const& pnt) const // adjust weights if necessary if (no_data_count > 0) { - if (no_data_count == 4) // if there is absolutely no data just use the default value + if (no_data_count == 4) + { // if there is absolutely no data just use the default value return _header.no_data; + } const double norm = 1.0 / (weight[0]+weight[1]+weight[2]+weight[3]); std::for_each(weight.begin(), weight.end(), [&norm](double &val){val*=norm;}); diff --git a/GeoLib/Raster.h b/GeoLib/Raster.h index 9d461c3afe052b84567081442f38be1d8b888ee6..5bda05f0937ffc06e3b25d061e998fd1e6121886 100644 --- a/GeoLib/Raster.h +++ b/GeoLib/Raster.h @@ -108,4 +108,4 @@ private: double* _raster_data; }; -} +} // namespace GeoLib diff --git a/GeoLib/SensorData.cpp b/GeoLib/SensorData.cpp index 4961fac8faa6ee664737cf1e3f124fe0caca04f8..39fb1894248ab5cef7345c97049a600877d71bad 100644 --- a/GeoLib/SensorData.cpp +++ b/GeoLib/SensorData.cpp @@ -46,7 +46,9 @@ SensorData::SensorData(std::size_t first_timestep, std::size_t last_timestep, st SensorData::~SensorData() { for (std::vector<float>* vec : _data_vecs) + { delete vec; + } } @@ -79,7 +81,9 @@ const std::vector<float>* SensorData::getTimeSeries(SensorDataType time_series_n for (std::size_t i=0; i<_vec_names.size(); i++) { if (time_series_name == _vec_names[i]) + { return _data_vecs[i]; + } } ERR("Error in SensorData::getTimeSeries() - Time series '%d' not found.", time_series_name); @@ -91,7 +95,9 @@ std::string SensorData::getDataUnit(SensorDataType time_series_name) const for (std::size_t i=0; i<_vec_names.size(); i++) { if (time_series_name == _vec_names[i]) + { return _data_unit_string[i]; + } } ERR("Error in SensorData::getDataUnit() - Time series '%d' not found.", time_series_name); @@ -116,8 +122,10 @@ int SensorData::readDataFromFile(const std::string &file_name) std::list<std::string>::const_iterator it (fields.begin()); std::size_t nFields = fields.size(); - if (nFields<2) + if (nFields < 2) + { return 0; + } std::size_t nDataArrays(nFields-1); @@ -141,12 +149,16 @@ int SensorData::readDataFromFile(const std::string &file_name) std::size_t current_time_step = (pos == std::string::npos) ? atoi((it++)->c_str()) : BaseLib::strDate2int(*it++); this->_time_steps.push_back(current_time_step); - for (std::size_t i=0; i<nDataArrays; i++) + for (std::size_t i = 0; i < nDataArrays; i++) + { this->_data_vecs[i]->push_back( static_cast<float>(strtod((it++)->c_str(), nullptr))); + } } else + { return 0; + } } in.close(); @@ -159,11 +171,18 @@ int SensorData::readDataFromFile(const std::string &file_name) std::string SensorData::convertSensorDataType2String(SensorDataType t) { - if (SensorDataType::EVAPORATION == t) return "Evaporation"; + if (SensorDataType::EVAPORATION == t) + { + return "Evaporation"; + } if (SensorDataType::PRECIPITATION == t) + { return "Precipitation"; + } if (SensorDataType::TEMPERATURE == t) + { return "Temperature"; + } // pls leave this as last choice return "Unknown"; } @@ -171,11 +190,17 @@ std::string SensorData::convertSensorDataType2String(SensorDataType t) SensorDataType SensorData::convertString2SensorDataType(const std::string &s) { if (s == "Evaporation" || s == "EVAPORATION") + { return SensorDataType::EVAPORATION; + } if (s == "Precipitation" || s == "PRECIPITATION") + { return SensorDataType::PRECIPITATION; + } if (s == "Temperature" || s == "TEMPERATURE") + { return SensorDataType::TEMPERATURE; + } return SensorDataType::OTHER; } diff --git a/GeoLib/SimplePolygonTree.h b/GeoLib/SimplePolygonTree.h index 6847716ee40db2d713637430283c8e352a445f34..893416e599e271f325092a2c959c3945174d6cf5 100644 --- a/GeoLib/SimplePolygonTree.h +++ b/GeoLib/SimplePolygonTree.h @@ -95,7 +95,9 @@ void createPolygonTrees (std::list<POLYGONTREETYPE*>& list_of_simple_polygon_hie ++it1; // skip test if it1 points to the end after increment if (it1 == list_of_simple_polygon_hierarchies.end()) + { break; + } } if ((*it0)->isPolygonInside(*it1)) { (*it0)->insertSimplePolygonTree(*it1); diff --git a/GeoLib/Station.cpp b/GeoLib/Station.cpp index 4b8bff29f4e3a3f8ff9609f050a3d34fe86b1d45..ecd98fd41b894a0b81d07c8fb40bd7ee83ed094a 100644 --- a/GeoLib/Station.cpp +++ b/GeoLib/Station.cpp @@ -61,7 +61,10 @@ Station* Station::createStation(const std::string & line) (*station)[0] = std::strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), nullptr); (*station)[1] = std::strtod((BaseLib::replaceString(",", ".", *(++it))).c_str(), nullptr); if (++it != fields.end()) - (*station)[2] = std::strtod((BaseLib::replaceString(",", ".", *it)).c_str(), nullptr); + { + (*station)[2] = std::strtod( + (BaseLib::replaceString(",", ".", *it)).c_str(), nullptr); + } } else { @@ -88,5 +91,4 @@ bool isStation(GeoLib::Point const* pnt) return bh != nullptr; } -} // namespace - +} // namespace GeoLib diff --git a/GeoLib/Station.h b/GeoLib/Station.h index 00ae4aa0bcfd346a90e4933dffaa897cdcf3048d..1f50b59723ebf1d33e03145ed47d0f6b4ac5dfa0 100644 --- a/GeoLib/Station.h +++ b/GeoLib/Station.h @@ -104,4 +104,4 @@ private: }; bool isStation(GeoLib::Point const* pnt); -} // namespace +} // namespace GeoLib diff --git a/GeoLib/StationBorehole.cpp b/GeoLib/StationBorehole.cpp index 89b80ed3e750f27e40f308a390269c18c2fe8618..ceb00bb4d93b36efd1df093fcea19d587ccb0ee1 100644 --- a/GeoLib/StationBorehole.cpp +++ b/GeoLib/StationBorehole.cpp @@ -45,15 +45,21 @@ StationBorehole::~StationBorehole(void) // deletes profile vector of borehole, starting at layer 1 // the first point is NOT deleted as it points to the station object itself for (std::size_t k(1); k < _profilePntVec.size(); k++) + { delete _profilePntVec[k]; + } } int StationBorehole::find(const std::string &str) { std::size_t size = _soilName.size(); for (std::size_t i = 0; i < size; i++) + { if (_soilName[i].find(str) == 0) + { return 1; + } + } return 0; } @@ -87,7 +93,9 @@ int StationBorehole::addStratigraphy(const std::string &path, StationBorehole* b { std::size_t size = data.size(); for (std::size_t i = 0; i < size; i++) + { addLayer(data[i], borehole); + } // check if a layer is missing // size = borehole->_soilName.size(); @@ -106,7 +114,9 @@ int StationBorehole::addStratigraphy(const std::string &path, StationBorehole* b // } } else + { borehole->addSoilLayer(borehole->getDepth(), "depth"); + } return 1; } @@ -176,8 +186,12 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin { name = static_cast<StationBorehole*>((*boreholes)[it])->_name; if (fields.front() != name) + { if (it < boreholes->size() - 1) + { it++; + } + } fields.pop_front(); //the method just assumes that layers are read in correct order @@ -198,7 +212,9 @@ int StationBorehole::addStratigraphies(const std::string &path, std::vector<Poin } } else + { createSurrogateStratigraphies(boreholes); + } return 1; } @@ -221,7 +237,9 @@ StationBorehole* StationBorehole::createStation(const std::string &line) borehole->_depth = strtod(BaseLib::replaceString(",", ".", fields.front()).c_str(), nullptr); fields.pop_front(); if (fields.empty()) + { borehole->_date = 0; + } else { borehole->_date = BaseLib::strDate2int(fields.front()); @@ -251,7 +269,9 @@ StationBorehole* StationBorehole::createStation(const std::string &name, (*station)[2] = z; station->_depth = depth; if (date != "0000-00-00") - station->_date = BaseLib::xmlDate2int(date); + { + station->_date = BaseLib::xmlDate2int(date); + } return station; } @@ -283,7 +303,9 @@ void StationBorehole::addSoilLayer ( double thickness, const std::string &soil_n // KR - Bode if (_profilePntVec.empty()) - addSoilLayer ((*this)[0], (*this)[1], (*this)[2], ""); + { + addSoilLayer((*this)[0], (*this)[1], (*this)[2], ""); + } std::size_t idx (_profilePntVec.size()); double x((*_profilePntVec[idx - 1])[0]); @@ -304,4 +326,4 @@ bool isBorehole(GeoLib::Point const* pnt) return bh != nullptr; } -} // namespace +} // namespace GeoLib diff --git a/GeoLib/StationBorehole.h b/GeoLib/StationBorehole.h index 4b9a657024d03b4471d1a5a439df7ecebcaa5303..e8861b01f6cfd7aabc5a7ee27f4c23590bbcbc18 100644 --- a/GeoLib/StationBorehole.h +++ b/GeoLib/StationBorehole.h @@ -117,4 +117,4 @@ private: bool isBorehole(GeoLib::Point const* pnt); -} // namespace +} // namespace GeoLib diff --git a/GeoLib/Surface.cpp b/GeoLib/Surface.cpp index 97fc8c2491efe9ea395c189d06e19128ed641d35..83e1ed6bcab91a4f901e06b4bc96efbe96723ea1 100644 --- a/GeoLib/Surface.cpp +++ b/GeoLib/Surface.cpp @@ -48,8 +48,10 @@ Surface::Surface(Surface const& src) Surface::~Surface() { - for (auto & _sfc_triangle : _sfc_triangles) + for (auto& _sfc_triangle : _sfc_triangles) + { delete _sfc_triangle; + } } void Surface::addTriangle(std::size_t pnt_a, @@ -61,7 +63,9 @@ void Surface::addTriangle(std::size_t pnt_a, // Check if two points of the triangle have identical IDs if (pnt_a == pnt_b || pnt_a == pnt_c || pnt_b == pnt_c) + { return; + } // Adding a new triangle invalides the surface grid. _surface_grid.reset(); @@ -122,4 +126,4 @@ const Triangle* Surface::findTriangle(MathLib::Point3d const& pnt) const return nullptr; } -} // end namespace +} // namespace GeoLib diff --git a/GeoLib/Surface.h b/GeoLib/Surface.h index 8971f480cc130377c84aa4a94cf67ff6e488b807..048e2d059f1b9a81b54e00d54891587d57aec3a7 100644 --- a/GeoLib/Surface.h +++ b/GeoLib/Surface.h @@ -99,4 +99,4 @@ protected: /// called and a valid surface grid is not existing. mutable std::unique_ptr<SurfaceGrid> _surface_grid; }; -} +} // namespace GeoLib diff --git a/GeoLib/SurfaceGrid.cpp b/GeoLib/SurfaceGrid.cpp index 8bf219b1f4a46b1734465b504010e5add5bcdcb9..00849d4013042f353c0809cc7745039f544e9c8c 100644 --- a/GeoLib/SurfaceGrid.cpp +++ b/GeoLib/SurfaceGrid.cpp @@ -64,9 +64,13 @@ SurfaceGrid::SurfaceGrid(Surface const*const sfc) : const std::size_t n_tris_per_cell(5); std::bitset<3> dim; // all bits are set to zero. - for (std::size_t k(0); k<3; ++k) + for (std::size_t k(0); k < 3; ++k) + { if (std::abs(delta[k]) >= std::numeric_limits<double>::epsilon()) + { dim[k] = true; + } + } // *** condition: n_tris / n_cells < n_tris_per_cell // where n_cells = _n_steps[0] * _n_steps[1] * _n_steps[2] @@ -137,15 +141,21 @@ bool SurfaceGrid::sortTriangleInGridCells(Triangle const*const triangle) boost::optional<std::array<std::size_t, 3> const> c_p0( getGridCellCoordinates(*(triangle->getPoint(0)))); if (!c_p0) + { return false; + } boost::optional<std::array<std::size_t, 3> const> c_p1( getGridCellCoordinates(*(triangle->getPoint(1)))); if (!c_p1) + { return false; + } boost::optional<std::array<std::size_t, 3> const> c_p2( getGridCellCoordinates(*(triangle->getPoint(2)))); if (!c_p2) + { return false; + } // determine interval in grid (grid cells the triangle will be inserted) std::size_t const i_min(std::min(std::min((*c_p0)[0], (*c_p1)[0]), (*c_p2)[0])); diff --git a/GeoLib/TemplateVec.h b/GeoLib/TemplateVec.h index 158be41006ac05e94b8eea291bd7b4259b3ade2a..2894f75358dd8398987de7b5d7d79f9b2a048e00 100644 --- a/GeoLib/TemplateVec.h +++ b/GeoLib/TemplateVec.h @@ -69,7 +69,9 @@ public: } if (!_name_id_map) + { _name_id_map = std::make_unique<NameIdMap>(); + } } /** @@ -77,7 +79,10 @@ public: */ virtual ~TemplateVec () { - for (std::size_t k(0); k < size(); k++) delete (*_data_vec)[k]; + for (std::size_t k(0); k < size(); k++) + { + delete (*_data_vec)[k]; + } } /** sets the name of the vector of geometric objects @@ -130,7 +135,9 @@ public: std::size_t id; bool ret (getElementIDByName (name, id)); if (ret) + { return (*_data_vec)[id]; + } return nullptr; } @@ -172,8 +179,12 @@ public: bool getNameOfElement (const T* data, std::string& name) const { for (std::size_t k(0); k < _data_vec->size(); k++) + { if ((*_data_vec)[k] == data) - return getNameOfElementByID (k, name); + { + return getNameOfElementByID(k, name); + } + } return false; } @@ -183,7 +194,9 @@ public: { _data_vec->push_back (data_element); if (!name || name->empty()) + { return; + } std::map<std::string, std::size_t>::const_iterator it( _name_id_map->find(*name) @@ -204,7 +217,9 @@ public: // Erase id if found in map. auto it = findFirstElementByID(id); if (it != _name_id_map->end()) + { _name_id_map->erase(it); + } if (!name.empty()) { //insert new or revised name diff --git a/Jenkinsfile b/Jenkinsfile index e6715cedc283207761bf0a1d90a25c784e0e7b8b..44bbf10b8c83e85c845d6da9bb3c921b85df7328 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,7 @@ @Library('jenkins-pipeline@1.0.19') _ def stage_required = [build: false, data: false, full: false, docker: false] +def build_shared = 'ON' pipeline { agent none @@ -11,6 +12,16 @@ pipeline { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '10')) timeout(time: 6, unit: 'HOURS') } + parameters { + booleanParam(name: 'docker_conan', defaultValue: true) + booleanParam(name: 'docker_conan_debug', defaultValue: true) + booleanParam(name: 'docker_conan_gui', defaultValue: true) + booleanParam(name: 'envinf1_serial', defaultValue: true) + booleanParam(name: 'envinf1_parallel', defaultValue: true) + booleanParam(name: 'win', defaultValue: true) + booleanParam(name: 'mac', defaultValue: true) + booleanParam(name: 'clang_analyzer', defaultValue: true) + } stages { // *************************** Git Check ********************************** stage('Git Check') { @@ -23,6 +34,9 @@ pipeline { // ********* Check changesets for conditional stage execution ********** script { + if (env.JOB_NAME == 'ufz/ogs/master') { + build_shared = 'OFF' + } if (currentBuild.number == 1) { stage_required.full = true return true @@ -74,7 +88,7 @@ pipeline { stage('Docker-Conan') { when { beforeAgent true - expression { return stage_required.build || stage_required.full } + expression { return params.docker_conan && (stage_required.build || stage_required.full) } } agent { dockerfile { @@ -93,6 +107,7 @@ pipeline { sh 'git submodule sync' configure { cmakeOptions = + "-DBUILD_SHARED_LIBS=${build_shared} " + '-DOGS_CPU_ARCHITECTURE=generic ' + '-DOGS_USE_PYTHON=ON ' + '-DOGS_BUILD_UTILS=ON ' + @@ -142,7 +157,7 @@ pipeline { stage('Docker-Conan-GUI') { when { beforeAgent true - expression { return stage_required.build || stage_required.full } + expression { return params.docker_conan_gui && (stage_required.build || stage_required.full) } } agent { dockerfile { @@ -159,6 +174,7 @@ pipeline { sh 'git submodule sync' configure { cmakeOptions = + "-DBUILD_SHARED_LIBS=${build_shared} " + '-DOGS_CPU_ARCHITECTURE=generic ' + '-DOGS_USE_PYTHON=ON ' + '-DOGS_USE_PCH=OFF ' + // see #1992 @@ -188,7 +204,7 @@ pipeline { stage('Docker-Conan-Debug') { when { beforeAgent true - expression { return stage_required.build || stage_required.full } + expression { return params.docker_conan_debug && (stage_required.build || stage_required.full) } } agent { dockerfile { @@ -204,6 +220,7 @@ pipeline { sh 'git submodule sync' configure { cmakeOptions = + "-DBUILD_SHARED_LIBS=${build_shared} " + '-DOGS_CPU_ARCHITECTURE=generic ' + '-DOGS_COVERAGE=ON ' config = 'Debug' @@ -311,7 +328,7 @@ pipeline { stage('Win') { when { beforeAgent true - expression { return stage_required.build || stage_required.full } + expression { return params.win && (stage_required.build || stage_required.full) } } agent {label 'win && conan' } environment { @@ -327,6 +344,7 @@ pipeline { // CLI + GUI configure { cmakeOptions = + "-DBUILD_SHARED_LIBS=OFF " + '-DOGS_DOWNLOAD_ADDITIONAL_CONTENT=ON ' + '-DOGS_USE_PYTHON=ON ' + '-DOGS_BUILD_GUI=ON ' + @@ -363,7 +381,7 @@ pipeline { stage('Mac') { when { beforeAgent true - expression { return stage_required.build || stage_required.full } + expression { return params.mac && (stage_required.build || stage_required.full) } } agent { label "mac"} environment { @@ -374,6 +392,7 @@ pipeline { sh 'git submodule sync' configure { cmakeOptions = + "-DBUILD_SHARED_LIBS=${build_shared} " + '-DOGS_CPU_ARCHITECTURE=core2 ' + '-DOGS_DOWNLOAD_ADDITIONAL_CONTENT=ON ' + '-DOGS_BUILD_GUI=ON ' + @@ -405,6 +424,43 @@ pipeline { } } } + // ************************* Clang-Analyzer ********************************* + stage('Clang-Analyzer') { + when { + beforeAgent true + expression { return params.clang_analyzer && (stage_required.build || stage_required.full) } + } + agent { + dockerfile { + filename 'Dockerfile.clang.full' + dir 'scripts/docker' + label 'docker' + args '-v /home/jenkins/cache/ccache:/opt/ccache -v /home/jenkins/cache/conan/.conan:/opt/conan/.conan' + additionalBuildArgs '--pull' + } + } + steps { + script { + sh 'git submodule sync' + sh 'find $CONAN_USER_HOME -name "system_reqs.txt" -exec rm {} \\;' + configure { + cmakeOptions = + "-DBUILD_SHARED_LIBS=${build_shared} " + + '-DBUILD_TESTING=OFF ' + + '-DCMAKE_CXX_CLANG_TIDY=clang-tidy-7 ' + } + build { log = 'build.log' } + } + } + post { + always { + recordIssues enabledForFailure: true, filters: [ + excludeFile('.*\\.conan.*')], + tools: [clangTidy(name: 'Clang-Tidy', pattern: 'build/build.log')], + qualityGates: [[threshold: 513, type: 'TOTAL', unstable: true]] + } + } + } } // end parallel } // end stage Build stage('Master') { @@ -474,7 +530,7 @@ pipeline { filename 'Dockerfile.clang.full' dir 'scripts/docker' label 'docker' - args '-v /home/jenkins/cache:/home/jenkins/cache -v /home/jenkins/cache/conan/.conan:/home/jenkins/.conan' + args '-v /home/jenkins/cache/ccache:/opt/ccache -v /home/jenkins/cache/conan/.conan:/opt/conan/.conan' additionalBuildArgs '--pull' } } @@ -484,17 +540,12 @@ pipeline { sh 'find $CONAN_USER_HOME -name "system_reqs.txt" -exec rm {} \\;' configure { cmakeOptions = + "-DBUILD_SHARED_LIBS=${build_shared} " + '"-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=include-what-you-use;-Xiwyu;--mapping_file=../scripts/jenkins/iwyu-mappings.imp" ' + - '-DCMAKE_LINK_WHAT_YOU_USE=ON ' + - '"-DCMAKE_CXX_CPPCHECK=cppcheck;--std=c++11;--language=c++;--suppress=syntaxError;--suppress=preprocessorErrorDirective:*/ThirdParty/*;--suppress=preprocessorErrorDirective:*conan*/package/*" ' + - '-DCMAKE_CXX_CLANG_TIDY=clang-tidy-3.9 ' + '-DCMAKE_LINK_WHAT_YOU_USE=ON ' config = 'Release' } - try { - build { target = 'check-header' } - build { } - } - catch (Exception e) { } + build { target = 'check-header' } } } } @@ -580,7 +631,7 @@ pipeline { filename 'Dockerfile.clang.minimal' dir 'scripts/docker' label 'docker' - args '-v /home/jenkins/cache:/home/jenkins/cache -v /home/jenkins/cache/conan/.conan:/home/jenkins/.conan' + args '-v /home/jenkins/cache/ccache:/opt/ccache -v /home/jenkins/cache/conan/.conan:/opt/conan/.conan' additionalBuildArgs '--pull' } } diff --git a/MaterialLib/Adsorption/Adsorption.cpp b/MaterialLib/Adsorption/Adsorption.cpp index 92ab5b76792a64c4104f435e808c30c0d9f93382..315c4c2c5c283b0f02289deb095af80daccdddb5 100644 --- a/MaterialLib/Adsorption/Adsorption.cpp +++ b/MaterialLib/Adsorption/Adsorption.cpp @@ -49,16 +49,20 @@ double AdsorptionReaction::getEvaporationEnthalpy(double T_Ads) // in kJ/kg if (T_Ads <= 10.){ const double c[] = {2.50052e3,-2.1068,-3.57500e-1,1.905843e-1,-5.11041e-2,7.52511e-3,-6.14313e-4,2.59674e-5,-4.421e-7}; double hv = 0.; - for (size_t i=0; i< sizeof(c)/sizeof(c[0]);i++) - hv += c[i] * pow(T_Ads,i); + for (size_t i = 0; i < sizeof(c) / sizeof(c[0]); i++) + { + hv += c[i] * pow(T_Ads, i); + } return hv; } if (T_Ads <= 300.) { const double c[] = {2.50043e3,-2.35209,1.91685e-4,-1.94824e-5,2.89539e-7,-3.51199e-9,2.06926e-11,-6.4067e-14,8.518e-17,1.558e-20,-1.122e-22}; double hv = 0.; - for (size_t i=0; i< sizeof(c)/sizeof(c[0]);i++) - hv += c[i] * pow(T_Ads,i); + for (size_t i = 0; i < sizeof(c) / sizeof(c[0]); i++) + { + hv += c[i] * pow(T_Ads, i); + } return hv; } const double c[] = {2.99866e3, -3.1837e-3, -1.566964e1, @@ -73,8 +77,10 @@ double AdsorptionReaction::getSpecificHeatCapacity(const double T_Ads) { const double c[] = {4.224,-3.716e-3,9.351e-5,-7.1786e-7,-9.1266e-9,2.69247e-10,-2.773104e-12,1.553177e-14,-4.982795e-17,8.578e-20,-6.12423e-23}; double cp = 0.; - for (unsigned i=0; i< sizeof(c)/sizeof(c[0]);i++) - cp += c[i] * pow(T_Ads,i); + for (unsigned i = 0; i < sizeof(c) / sizeof(c[0]); i++) + { + cp += c[i] * pow(T_Ads, i); + } return cp; // kJ/(kg*K) } @@ -103,7 +109,10 @@ double AdsorptionReaction::getReactionRate(const double p_Ads, const double T_Ad { const double A = getPotential(p_Ads, T_Ads, M_Ads); double C_eq = getAdsorbateDensity(T_Ads) * characteristicCurve(A); - if (C_eq < 0.0) C_eq = 0.0; + if (C_eq < 0.0) + { + C_eq = 0.0; + } return k_rate * (C_eq - loading); // scaled with mass fraction // this the rate in terms of loading! @@ -184,6 +193,4 @@ double AdsorptionReaction::getEquilibriumLoading( return getAdsorbateDensity(T_Ads) * characteristicCurve(A); } - - -} // namespace Ads +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/Adsorption.h b/MaterialLib/Adsorption/Adsorption.h index 8eb7bb92129990843c4c3af3348823f9fdab04b9..ae7b05a4025fa35e5e49e65c67d4dfeb37df33ed 100644 --- a/MaterialLib/Adsorption/Adsorption.h +++ b/MaterialLib/Adsorption/Adsorption.h @@ -82,4 +82,4 @@ inline double dCurvePolyfrac(const double* coeffs, const double x) return (du*v - u*dv) / v / v; } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/Density100MPa.cpp b/MaterialLib/Adsorption/Density100MPa.cpp index 88e24c4904909af5de16a5a51008fc348b7128a4..89400b43883660eafb7b187eee8f66adc452ceea 100644 --- a/MaterialLib/Adsorption/Density100MPa.cpp +++ b/MaterialLib/Adsorption/Density100MPa.cpp @@ -24,7 +24,7 @@ const double c[] = { -9.919599580166727e-11 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -60,4 +60,4 @@ double Density100MPa::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/Density100MPa.h b/MaterialLib/Adsorption/Density100MPa.h index d100d341cd6c0f28106ceba0930e109df928b250..e13fe9a87016e80cbc10160047714de4e79cb41b 100644 --- a/MaterialLib/Adsorption/Density100MPa.h +++ b/MaterialLib/Adsorption/Density100MPa.h @@ -23,4 +23,4 @@ public: double dCharacteristicCurve(const double A) const override; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityConst.cpp b/MaterialLib/Adsorption/DensityConst.cpp index 736c9f435afce3244530f15c7b5aad1ddb01dfdc..c1f48961e46055d0a4f294c2fd34c13e7d0dc265 100644 --- a/MaterialLib/Adsorption/DensityConst.cpp +++ b/MaterialLib/Adsorption/DensityConst.cpp @@ -25,7 +25,7 @@ const double c[] = { -1.0668790477629686e-10 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -57,4 +57,4 @@ double DensityConst::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityConst.h b/MaterialLib/Adsorption/DensityConst.h index 172fd663ea50be54b436c712420092eaf788c7d8..4aa41e4ae7a14ba5f3445bb339dfe659e326a110 100644 --- a/MaterialLib/Adsorption/DensityConst.h +++ b/MaterialLib/Adsorption/DensityConst.h @@ -23,4 +23,4 @@ public: double dCharacteristicCurve(const double A) const override; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityCook.cpp b/MaterialLib/Adsorption/DensityCook.cpp index 301e524e8cb70987fca9f14b6cb93c454637f22a..35a12dabe0a86bce69898d380e28a6dc1a166b89 100644 --- a/MaterialLib/Adsorption/DensityCook.cpp +++ b/MaterialLib/Adsorption/DensityCook.cpp @@ -24,7 +24,7 @@ const double c[] = { -1.037977321231462e-10 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -56,4 +56,4 @@ double DensityCook::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityCook.h b/MaterialLib/Adsorption/DensityCook.h index ad6ab60034f5266b83b87be06a7a5e3de64ff567..fa90f2a1127161e0964e01c7363623a9451a79bc 100644 --- a/MaterialLib/Adsorption/DensityCook.h +++ b/MaterialLib/Adsorption/DensityCook.h @@ -54,4 +54,4 @@ inline double alphaTWaterDean(const double T_Ads) return aT_100 / (1. - aT_100 * (Tcel - 100.)); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityDubinin.cpp b/MaterialLib/Adsorption/DensityDubinin.cpp index f7731dda7705a95980b9ce2364b509383037a5e9..054915c7cf969f26aeb539421e6f8155b55472b2 100644 --- a/MaterialLib/Adsorption/DensityDubinin.cpp +++ b/MaterialLib/Adsorption/DensityDubinin.cpp @@ -27,7 +27,7 @@ const double c[] = { -1.0477401124006098e-10 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -91,4 +91,4 @@ double DensityDubinin::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityDubinin.h b/MaterialLib/Adsorption/DensityDubinin.h index ac9516140d5ee3e25b4985c5cf98a7f6cc1a6d2b..fd026c01213851edce55bd912be9df742cc1bc7e 100644 --- a/MaterialLib/Adsorption/DensityDubinin.h +++ b/MaterialLib/Adsorption/DensityDubinin.h @@ -23,4 +23,4 @@ public: double dCharacteristicCurve(const double A) const override; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityHauer.cpp b/MaterialLib/Adsorption/DensityHauer.cpp index 38daaa957a53cc95569751cbe8aee7b9088a8755..c6f5b17f72034b263d4ad6f383749cd7f17e69c5 100644 --- a/MaterialLib/Adsorption/DensityHauer.cpp +++ b/MaterialLib/Adsorption/DensityHauer.cpp @@ -24,7 +24,7 @@ const double c[] = { -1.0300151379421499e-10 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -60,4 +60,4 @@ double DensityHauer::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityHauer.h b/MaterialLib/Adsorption/DensityHauer.h index 7c49be66ecc380104d3dd135ca136f95863ca4b0..ce034699ab63bfa6586c9ea4b4873bb6121fcae6 100644 --- a/MaterialLib/Adsorption/DensityHauer.h +++ b/MaterialLib/Adsorption/DensityHauer.h @@ -32,4 +32,4 @@ inline double rhoWaterHauer(const double T_Ads) return rho0 * (1. - alpha0 * (T_Ads-T0)); // in kg/m^3 } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityLegacy.cpp b/MaterialLib/Adsorption/DensityLegacy.cpp index 76468d5af3a387d89ff2a5e0a07b9decc8b863ea..9eda437d24eadd5d335ba97470bc0eff7a9fe8fa 100644 --- a/MaterialLib/Adsorption/DensityLegacy.cpp +++ b/MaterialLib/Adsorption/DensityLegacy.cpp @@ -22,7 +22,7 @@ const double c[] = { 0.34102920966608297, -7.610441241719489e-11 }; -} +} // namespace namespace Adsorption { @@ -61,4 +61,4 @@ double DensityLegacy::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityLegacy.h b/MaterialLib/Adsorption/DensityLegacy.h index d434ecb86fba4fa7dc42ef6de598c6bbd37216c0..888933157e92713f0dbccdfe5bb9f34cba92aece 100644 --- a/MaterialLib/Adsorption/DensityLegacy.h +++ b/MaterialLib/Adsorption/DensityLegacy.h @@ -23,4 +23,4 @@ public: double dCharacteristicCurve(const double A) const override; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityMette.cpp b/MaterialLib/Adsorption/DensityMette.cpp index b60ee6f0f2c2cce79117a13c0f269e0c9516406e..d0f96151ced82c6686643da6b0c5771333790cee 100644 --- a/MaterialLib/Adsorption/DensityMette.cpp +++ b/MaterialLib/Adsorption/DensityMette.cpp @@ -23,7 +23,7 @@ const double c[] = { 6.854673678427112e-10, /* a5 */ -1.0197050219481966e-10 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -63,4 +63,4 @@ double DensityMette::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityMette.h b/MaterialLib/Adsorption/DensityMette.h index f83da39eb7ffb812145ba77641313344df5a8f1e..a0e43b1435def8601639ffb39709217eb77b6dd3 100644 --- a/MaterialLib/Adsorption/DensityMette.h +++ b/MaterialLib/Adsorption/DensityMette.h @@ -23,4 +23,4 @@ public: double dCharacteristicCurve(const double A) const override; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityNunez.cpp b/MaterialLib/Adsorption/DensityNunez.cpp index 12df1282920ccee931dfadb8b47ee1f261e97838..cd3bafb6a3c3ad346675a969bf87d68eb5f0415f 100644 --- a/MaterialLib/Adsorption/DensityNunez.cpp +++ b/MaterialLib/Adsorption/DensityNunez.cpp @@ -24,7 +24,7 @@ const double c[] = { -1.0345385018952998e-10 /* a6 */ }; -} +} // namespace namespace Adsorption { @@ -71,4 +71,4 @@ double DensityNunez::dCharacteristicCurve(const double A) const return dCurvePolyfrac(c, A); } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/DensityNunez.h b/MaterialLib/Adsorption/DensityNunez.h index c3726c1a9337159548d5d362d5b3638e5952a525..2c6c571841715e40a3a3cebf11427cd8e10d0473 100644 --- a/MaterialLib/Adsorption/DensityNunez.h +++ b/MaterialLib/Adsorption/DensityNunez.h @@ -23,4 +23,4 @@ public: double dCharacteristicCurve(const double A) const override; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/Reaction.cpp b/MaterialLib/Adsorption/Reaction.cpp index 9544834ce8793e6b407bdc23ce5b84859f9d6309..a91172ed102658dc32765808ad5db933d4f58a60 100644 --- a/MaterialLib/Adsorption/Reaction.cpp +++ b/MaterialLib/Adsorption/Reaction.cpp @@ -38,27 +38,49 @@ newInstance(BaseLib::ConfigTree const& conf) auto const type = conf.getConfigParameter<std::string>("type"); if (type == "Z13XBF") + { return std::make_unique<DensityLegacy>(); + } if (type == "Z13XBF_100MPa") + { return std::make_unique<Density100MPa>(); + } if (type == "Z13XBF_Const") + { return std::make_unique<DensityConst>(); + } if (type == "Z13XBF_Cook") + { return std::make_unique<DensityCook>(); + } if (type == "Z13XBF_Dubinin") + { return std::make_unique<DensityDubinin>(); + } if (type == "Z13XBF_Hauer") + { return std::make_unique<DensityHauer>(); + } if (type == "Z13XBF_Mette") + { return std::make_unique<DensityMette>(); + } if (type == "Z13XBF_Nunez") + { return std::make_unique<DensityNunez>(); + } if (type == "Inert") + { return std::make_unique<ReactionInert>(); + } if (type == "Sinusoidal") + { return std::make_unique<ReactionSinusoidal>(conf); + } if (type == "CaOH2") + { return std::make_unique<ReactionCaOH2>(conf); + } OGS_FATAL("Unknown reactive system: %s.", type.c_str()); diff --git a/MaterialLib/Adsorption/Reaction.h b/MaterialLib/Adsorption/Reaction.h index 0011b734a876717a4384b55efaf1307a1c8d8727..a220d3cda18ac30cee1239b21ef2f5b7d7f72cfa 100644 --- a/MaterialLib/Adsorption/Reaction.h +++ b/MaterialLib/Adsorption/Reaction.h @@ -33,4 +33,4 @@ public: virtual ~Reaction() = default; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/ReactionCaOH2.cpp b/MaterialLib/Adsorption/ReactionCaOH2.cpp index 17af5d07793f3caf2b3124097b8d8559b9d3bbc7..94f7f99e0b022d34d3705848171145fda5ed0997 100644 --- a/MaterialLib/Adsorption/ReactionCaOH2.cpp +++ b/MaterialLib/Adsorption/ReactionCaOH2.cpp @@ -109,11 +109,18 @@ double ReactionCaOH2::CaHydration() dXdt = -1.0*(1.0-X_H) * (T_s - T_eq) / T_eq * 0.2 * conversion_rate::x_react; #else //this is from Schaube if (_X_H == _tol_u || _rho_s == rho_up) + { dXdt = 0.0; - else if ( (_T_eq-_T_s) >= 50.0) + } + else if ((_T_eq - _T_s) >= 50.0) + { dXdt = 13945.0 * exp(-89486.0/R/_T_s) * std::pow(_p_r_g/_p_eq - 1.0,0.83) * 3.0 * (_X_D) * std::pow(-1.0*log(_X_D),0.666); + } else - dXdt = 1.0004e-34 * exp(5.3332e4/_T_s) * std::pow(_p_r_g, 6.0) * (_X_D); + { + dXdt = 1.0004e-34 * exp(5.3332e4 / _T_s) * std::pow(_p_r_g, 6.0) * + (_X_D); + } #endif } else // dehydration @@ -123,14 +130,22 @@ double ReactionCaOH2::CaHydration() dXdt = -1.0* (1.0-X_D) * (T_s - T_eq) / T_eq * 0.05; #else if (_X_D == _tol_u || _rho_s == rho_low) + { dXdt = 0.0; + } else if (_X_D < 0.2) + { dXdt = -1.9425e12 * exp( -1.8788e5/R/_T_s ) * std::pow(1.0-_p_r_g/_p_eq,3.0)*(_X_H); + } else - dXdt = -8.9588e9 * exp( -1.6262e5/R/_T_s ) * std::pow(1.0-_p_r_g/_p_eq,3.0)*2.0 * std::pow(_X_H, 0.5); + { + dXdt = -8.9588e9 * exp(-1.6262e5 / R / _T_s) * + std::pow(1.0 - _p_r_g / _p_eq, 3.0) * 2.0 * + std::pow(_X_H, 0.5); + } #endif } return dXdt; } -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/ReactionCaOH2.h b/MaterialLib/Adsorption/ReactionCaOH2.h index aa1aea2b13a02e6bf4e4db02bd73e82dd81725ce..645c00c0a626f1e4118ca003b193946178628d71 100644 --- a/MaterialLib/Adsorption/ReactionCaOH2.h +++ b/MaterialLib/Adsorption/ReactionCaOH2.h @@ -84,4 +84,4 @@ public: static MATERIALLIB_EXPORT const double rho_up; //! upper density limit }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/ReactionInert.h b/MaterialLib/Adsorption/ReactionInert.h index fe2dc76080388f2e9d4b6e035665e9ad338f1001..2eaa2e9ccf22118dbf9701cd596d864d1754f0a0 100644 --- a/MaterialLib/Adsorption/ReactionInert.h +++ b/MaterialLib/Adsorption/ReactionInert.h @@ -32,4 +32,4 @@ public: } }; -} +} // namespace Adsorption diff --git a/MaterialLib/Adsorption/ReactionSinusoidal.h b/MaterialLib/Adsorption/ReactionSinusoidal.h index 4dc5b0dd5c2c847f012b2c3fe0677593a4d02c2e..e34864c6de6645cba805987ac5fd9a880e54ed00 100644 --- a/MaterialLib/Adsorption/ReactionSinusoidal.h +++ b/MaterialLib/Adsorption/ReactionSinusoidal.h @@ -44,4 +44,4 @@ private: double _enthalpy; }; -} +} // namespace Adsorption diff --git a/MaterialLib/Fluid/ConstantFluidProperty.h b/MaterialLib/Fluid/ConstantFluidProperty.h index 11afa7eef0b0d6374bf5e15aac163e30510a6850..87327aa5e5d6e25daafa94e2a0e894142b031e72 100644 --- a/MaterialLib/Fluid/ConstantFluidProperty.h +++ b/MaterialLib/Fluid/ConstantFluidProperty.h @@ -54,5 +54,5 @@ private: const double _value; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp index 959921e750d31b75b59b6d13f3e41940de7b2789..b603f09f306ac638161e1234b3f5a058aec41600 100644 --- a/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp +++ b/MaterialLib/Fluid/Density/CreateFluidDensityModel.cpp @@ -139,13 +139,21 @@ std::unique_ptr<FluidProperty> createFluidDensityModel( config.getConfigParameter<double>("value")); } if (type == "LiquidDensity") + { return createLiquidDensity(config); + } if (type == "TemperatureDependent") + { return createLinearTemperatureDependentDensity(config); + } if (type == "ConcentrationDependent") + { return createLinearConcentrationDependentDensity(config); + } if (type == "ConcentrationAndPressureDependent") + { return createLinearConcentrationAndPressureDependentDensity(config); + } if (type == "IdealGasLaw") { //! \ogs_file_param{material__fluid__density__type} @@ -167,5 +175,5 @@ std::unique_ptr<FluidProperty> createFluidDensityModel( type.data()); } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Density/IdealGasLaw.h b/MaterialLib/Fluid/Density/IdealGasLaw.h index e39cf29ef7fd5ebc71729a81c38f11e5d1d2fd9c..5e6b29e5b06069f397c06a99b59b8740bf128726 100644 --- a/MaterialLib/Fluid/Density/IdealGasLaw.h +++ b/MaterialLib/Fluid/Density/IdealGasLaw.h @@ -87,5 +87,5 @@ private: return _molar_mass / (PhysicalConstant::IdealGasConstant * T); } }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Density/LinearConcentrationAndPressureDependentDensity.h b/MaterialLib/Fluid/Density/LinearConcentrationAndPressureDependentDensity.h index 4145a47385e390e08afe78562ff0d93fba47530a..963be12861fd91fd9527279fe11c36b76e8ee59e 100644 --- a/MaterialLib/Fluid/Density/LinearConcentrationAndPressureDependentDensity.h +++ b/MaterialLib/Fluid/Density/LinearConcentrationAndPressureDependentDensity.h @@ -88,7 +88,7 @@ public: return _reference_density * _fluid_density_concentration_difference_ratio; } - else if (var == PropertyVariableType::p) + if (var == PropertyVariableType::p) { return _reference_density * _fluid_density_pressure_difference_ratio; diff --git a/MaterialLib/Fluid/Density/LinearConcentrationDependentDensity.h b/MaterialLib/Fluid/Density/LinearConcentrationDependentDensity.h index 8dd7693e8f9d3f26edf7b700c8e63d79a57151a7..1943e202d09527c6da90f2133cea22837e4a46f1 100644 --- a/MaterialLib/Fluid/Density/LinearConcentrationDependentDensity.h +++ b/MaterialLib/Fluid/Density/LinearConcentrationDependentDensity.h @@ -72,7 +72,9 @@ public: { (void)var_vals; if (var != PropertyVariableType::C) + { return 0.0; + } return _reference_density * _fluid_density_difference_ratio; } @@ -82,5 +84,5 @@ private: const double _fluid_density_difference_ratio; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Density/LinearTemperatureDependentDensity.h b/MaterialLib/Fluid/Density/LinearTemperatureDependentDensity.h index dd0cc41b983d9d165b62a4238fbd62dc82047bfe..b92bfa40a2bd4c9fab91f7e681161e1fc7a30e45 100644 --- a/MaterialLib/Fluid/Density/LinearTemperatureDependentDensity.h +++ b/MaterialLib/Fluid/Density/LinearTemperatureDependentDensity.h @@ -62,7 +62,9 @@ public: { (void)var_vals; if (var != PropertyVariableType::T) + { return 0.0; + } return -_rho0 * _beta; } @@ -72,5 +74,5 @@ private: const double _beta; ///< Parameter. }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Density/LiquidDensity.h b/MaterialLib/Fluid/Density/LiquidDensity.h index bc106fc3a3d42e40e816d50664abab1e7408a619..7b8395f33a41595375d8988dd6bfd77e1a13587c 100644 --- a/MaterialLib/Fluid/Density/LiquidDensity.h +++ b/MaterialLib/Fluid/Density/LiquidDensity.h @@ -138,5 +138,5 @@ private: } }; -} // end of namespace -} // end of namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Density/WaterDensityIAPWSIF97Region1.h b/MaterialLib/Fluid/Density/WaterDensityIAPWSIF97Region1.h index 7d1d4a65510653edf0354bd49f7ae51c9084c996..badae46d99fc943eda8fdb9fb17446871f2435ed 100644 --- a/MaterialLib/Fluid/Density/WaterDensityIAPWSIF97Region1.h +++ b/MaterialLib/Fluid/Density/WaterDensityIAPWSIF97Region1.h @@ -90,5 +90,5 @@ private: const double _sR = 461.526; }; -} // end of namespace -} // end of namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp index 8c511f53ce665f08b9f6f0b3480d9eb117ac5e1c..8a364d28a49863d10bf7b2b46e4a47207a758d5d 100644 --- a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp +++ b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp @@ -76,12 +76,14 @@ std::unique_ptr<FluidProperties> createFluidProperties( if (is_mu_density_dependent || is_cp_density_dependent || is_KT_density_dependent) + { return std::make_unique< MaterialLib::Fluid::FluidPropertiesWithDensityDependentModels>( std::move(liquid_density), std::move(viscosity), std::move(specific_heat_capacity), std::move(thermal_conductivity), is_mu_density_dependent, is_cp_density_dependent, is_KT_density_dependent); + } return std::make_unique< MaterialLib::Fluid::PrimaryVariableDependentFluidProperties>( @@ -89,5 +91,5 @@ std::unique_ptr<FluidProperties> createFluidProperties( std::move(specific_heat_capacity), std::move(thermal_conductivity)); } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h index ba5f018957495fc9e67fb651ea4f00407159725a..4ffc5026d47915a43b32860c10b8d8459879a975 100644 --- a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h +++ b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h @@ -29,4 +29,4 @@ class FluidProperties; std::unique_ptr<FluidProperties> createFluidProperties( BaseLib::ConfigTree const& config); } // end namespace -} // end namespace +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperties/FluidProperties.h b/MaterialLib/Fluid/FluidProperties/FluidProperties.h index b70f8c13460ad819e4d7a86b047962541bf414e1..87c03eaac6fe4720ab593c76000c152b209dab64 100644 --- a/MaterialLib/Fluid/FluidProperties/FluidProperties.h +++ b/MaterialLib/Fluid/FluidProperties/FluidProperties.h @@ -94,5 +94,5 @@ protected: _property_models; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp b/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp index 7fd1c30aef9b1bcf8a3e4214da12e01739f0e253..2a0a8167b6739d6caba5f1e21a06dd69e788a89d 100644 --- a/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp +++ b/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.cpp @@ -123,5 +123,5 @@ double FluidPropertiesWithDensityDependentModels::compute_df_drho_drho_dp( drho_dp; } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.h b/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.h index a4b41be650e0d50f3510c12bbfb02c5cd4c1b7d7..cf11057e72d51404ab479d61d51ad732e07a8d4a 100644 --- a/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.h +++ b/MaterialLib/Fluid/FluidProperties/FluidPropertiesWithDensityDependentModels.h @@ -77,5 +77,5 @@ private: std::array<bool, FluidPropertyTypeNumber> _is_density_dependent; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperties/PrimaryVariableDependentFluidProperties.h b/MaterialLib/Fluid/FluidProperties/PrimaryVariableDependentFluidProperties.h index 030bb6dd344a0d2ccba46a6c81bab8f1c0ab1cb4..488730350808733081e3584be67059eec5c6b8f8 100644 --- a/MaterialLib/Fluid/FluidProperties/PrimaryVariableDependentFluidProperties.h +++ b/MaterialLib/Fluid/FluidProperties/PrimaryVariableDependentFluidProperties.h @@ -71,5 +71,5 @@ public: } }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/FluidProperty.h b/MaterialLib/Fluid/FluidProperty.h index 68fec1a75439cc94dfe3500d5f8fb844a251e475..e56c4d452521adbef9cc8a28030eb909762c82b6 100644 --- a/MaterialLib/Fluid/FluidProperty.h +++ b/MaterialLib/Fluid/FluidProperty.h @@ -45,5 +45,5 @@ public: const PropertyVariableType /* var */) const = 0; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.cpp b/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.cpp index 359bec651746ba91dacca593813b7bbdd1500270..756350c58d32a99ea734699d543ed30956c11ea7 100644 --- a/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.cpp +++ b/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.cpp @@ -119,5 +119,5 @@ double DimensionLessGibbsFreeEnergyRegion1::get_dgamma_dtau_dpi( return val; } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.h b/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.h index 53bcc1754cac90cd2a49e3f93419bdc5914bd03a..9dd50f20febd9cf6866d723be55fb4265ad6d69c 100644 --- a/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.h +++ b/MaterialLib/Fluid/GibbsFreeEnergy/DimensionLessGibbsFreeEnergyRegion1.h @@ -94,5 +94,5 @@ public: double get_dgamma_dtau_dpi(const double tau, const double pi) const; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/PropertyVariableType.h b/MaterialLib/Fluid/PropertyVariableType.h index 9b8d50fe4ce001417785b44e91697ce8d1d25136..28d430c71f72ec83ad1e2d7d384e3796d88a1c4e 100644 --- a/MaterialLib/Fluid/PropertyVariableType.h +++ b/MaterialLib/Fluid/PropertyVariableType.h @@ -29,5 +29,5 @@ enum class PropertyVariableType const unsigned PropertyVariableNumber = static_cast<unsigned>(PropertyVariableType::number_of_variables); -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp index 28087cb95c6bbb2967fbf13e04cde7aad69547ba..18f901d8526186e328a5c00bd30034e037c37d05 100644 --- a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp +++ b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.cpp @@ -30,9 +30,11 @@ std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel( auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") + { return std::make_unique<ConstantFluidProperty>( //! \ogs_file_param{material__fluid__specific_heat_capacity__Constant__value} config.getConfigParameter<double>("value")); + } // TODO: add more models OGS_FATAL( @@ -41,5 +43,5 @@ std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel( type.data()); } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h index 048a6217e390549feb87ed4eadb8cb8e3053fe81..b037290f98657bbde5279f6a9a317c7520605323 100644 --- a/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h +++ b/MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h @@ -33,5 +33,5 @@ class FluidProperty; std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel( BaseLib::ConfigTree const& config); -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp index 985dca5fdaf109a9ec6719276beb21eea532593b..8b1a64b87c93f8755f4f96fee2959c0e07272ec7 100644 --- a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp +++ b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.cpp @@ -30,9 +30,11 @@ std::unique_ptr<FluidProperty> createFluidThermalConductivityModel( auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") + { return std::make_unique<ConstantFluidProperty>( //! \ogs_file_param{material__fluid__thermal_conductivity__Constant__value} config.getConfigParameter<double>("value")); + } // TODO: add more models OGS_FATAL( @@ -41,5 +43,5 @@ std::unique_ptr<FluidProperty> createFluidThermalConductivityModel( type.data()); } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h index 2139422a3bf800f80ff3f0720422c8701f297f25..742248ba3c40300a372940454cb990878dbadf5f 100644 --- a/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h +++ b/MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h @@ -33,5 +33,5 @@ class FluidProperty; std::unique_ptr<FluidProperty> createFluidThermalConductivityModel( BaseLib::ConfigTree const& config); -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp index cfa855b347a6f186a787b7e6d7c0578d48c5b73b..36f56e451d23c09942f5bd869572c395776b1448 100644 --- a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp +++ b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.cpp @@ -86,9 +86,13 @@ std::unique_ptr<FluidProperty> createViscosityModel( config.getConfigParameter<double>("value")); } if (type == "LinearPressure") + { return createLinearPressureDependentViscosity(config); + } if (type == "TemperatureDependent") + { return createTemperatureDependentViscosity(config); + } if (type == "Vogels") { //! \ogs_file_param{material__fluid__viscosity__type} @@ -146,5 +150,5 @@ std::unique_ptr<FluidProperty> createViscosityModel( type.data()); } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.h b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.h index 4b9cc72c3218255489b50bf4bc0049dbb6a6b1e4..878f524ae368553807bfa06ffe43251ff7051587 100644 --- a/MaterialLib/Fluid/Viscosity/CreateViscosityModel.h +++ b/MaterialLib/Fluid/Viscosity/CreateViscosityModel.h @@ -29,4 +29,4 @@ std::unique_ptr<FluidProperty> createViscosityModel( BaseLib::ConfigTree const& config); } // end namespace -} // end namespace +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/LinearPressureDependentViscosity.h b/MaterialLib/Fluid/Viscosity/LinearPressureDependentViscosity.h index eedeefefc1241852687f145dbdb06de234187d5a..7481c2aceccd5ff59406d69df8b88c28086d7ff7 100644 --- a/MaterialLib/Fluid/Viscosity/LinearPressureDependentViscosity.h +++ b/MaterialLib/Fluid/Viscosity/LinearPressureDependentViscosity.h @@ -82,5 +82,5 @@ private: const double _gamma; ///< Parameter. }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/TemperatureDependentViscosity.h b/MaterialLib/Fluid/Viscosity/TemperatureDependentViscosity.h index 48386f10dc0e0eeb802fe130da0417b14236445e..1ee3564dcba2c1e3a0f48dafc7042bd607a2653e 100644 --- a/MaterialLib/Fluid/Viscosity/TemperatureDependentViscosity.h +++ b/MaterialLib/Fluid/Viscosity/TemperatureDependentViscosity.h @@ -91,5 +91,5 @@ private: const double _temperature_v; ///< Reference temperature 2. }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h b/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h index 0bf51cf16d6a4999a8ba9ae9537e826848da48a7..b2c1ba88574a1d8eac7fabba2f1e4c1ca6bd8e26 100644 --- a/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h +++ b/MaterialLib/Fluid/Viscosity/VogelsLiquidDynamicViscosity.h @@ -110,5 +110,5 @@ struct VogelsViscosityConstantsCH4 const double C = 969.306; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp index 6dfe681c5cfff24edc1acde60a85d5ae370dc9f0..21bd160a2d0da9df08ffeb01c9b8763486c8ce2c 100644 --- a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp +++ b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.cpp @@ -195,5 +195,5 @@ double computedBarMu_dbarRho(const double barT, double bar_rho) (mu1_factor + bar_rho * dmu1_factor_dbar_rho); } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.h b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.h index 950007cb960c4d51002e636c656904549a887343..80e7175fa790f70b7767105954ee5815cc3ed328 100644 --- a/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.h +++ b/MaterialLib/Fluid/Viscosity/WaterViscosityIAPWS.h @@ -82,5 +82,5 @@ private: // Coefficients Hi and Hij are given in two static arrays in the cpp file. }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.cpp b/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.cpp index 0c53db4408f89bb0785a6970ed70a1d6c6546bc9..d330cd104a093f3f2ac4a230bb7e11dc9d67bf0e 100644 --- a/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.cpp +++ b/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.cpp @@ -83,5 +83,5 @@ double WaterVaporProperties::getWaterVaporEnthalpySimple(const double temperatur h_wg; } -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.h b/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.h index fed0898b0d63d19a2f47d3f44d38bb177302504f..a43baa58492cf0fa0e9c2cf2a9828067f3c9bc3e 100644 --- a/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.h +++ b/MaterialLib/Fluid/WaterVaporProperties/WaterVaporProperties.h @@ -62,5 +62,5 @@ private: const double& _air_mol_mass = PhysicalConstant::MolarMass::Air; }; -} // end namespace -} // end namespace +} // namespace Fluid +} // namespace MaterialLib diff --git a/MaterialLib/FractureModels/CohesiveZoneModeI.cpp b/MaterialLib/FractureModels/CohesiveZoneModeI.cpp index 48838487b3642cd28db6e2e07970c8fbb2bfc667..efb029d3794858bb8864e7f2ea563fea18483851 100644 --- a/MaterialLib/FractureModels/CohesiveZoneModeI.cpp +++ b/MaterialLib/FractureModels/CohesiveZoneModeI.cpp @@ -73,7 +73,9 @@ void CohesiveZoneModeI<DisplacementDim>::computeConstitutiveRelation( const int index_ns = DisplacementDim - 1; double const w_n = w[index_ns]; for (int i = 0; i < index_ns; i++) + { C(i, i) = mp.Ks; + } sigma.noalias() = C * w; diff --git a/MaterialLib/FractureModels/LinearElasticIsotropic.cpp b/MaterialLib/FractureModels/LinearElasticIsotropic.cpp index 21448e43b38f885a24bcf0ca8a0f4cf8d4168fc9..dbc3b4339900a79b0b3488a4c9176e04d8491220 100644 --- a/MaterialLib/FractureModels/LinearElasticIsotropic.cpp +++ b/MaterialLib/FractureModels/LinearElasticIsotropic.cpp @@ -40,7 +40,9 @@ void LinearElasticIsotropic<DisplacementDim>::computeConstitutiveRelation( const int index_ns = DisplacementDim - 1; C.setZero(); for (int i = 0; i < index_ns; i++) + { C(i, i) = _mp.shear_stiffness(t, x)[0]; + } sigma.noalias() = C * w; diff --git a/MaterialLib/FractureModels/LogPenalty.h b/MaterialLib/FractureModels/LogPenalty.h index 5d6ac5c53cec1ce65e60f36b7e084ddd1ca67285..ebe06de8698184df2dd9be787beb69362558d6d3 100644 --- a/MaterialLib/FractureModels/LogPenalty.h +++ b/MaterialLib/FractureModels/LogPenalty.h @@ -25,7 +25,9 @@ inline double logPenaltyDerivative(double const aperture0, double const aperture_cutoff) { if (aperture >= aperture0) + { return 1; + } // Logarithmic penalty if (aperture > aperture_cutoff) @@ -49,7 +51,9 @@ inline double logPenalty(double const aperture0, double const aperture_cutoff) { if (aperture >= aperture0) + { return 1; + } // Logarithmic penalty if (aperture > aperture_cutoff) diff --git a/MaterialLib/FractureModels/MohrCoulomb.cpp b/MaterialLib/FractureModels/MohrCoulomb.cpp index 6d569b05f58e10ce54d5c7f5ed60d3d3ee6803f5..1e86063670c244cf1c86f4ecdd38cb567790b3b6 100644 --- a/MaterialLib/FractureModels/MohrCoulomb.cpp +++ b/MaterialLib/FractureModels/MohrCoulomb.cpp @@ -43,7 +43,7 @@ struct MaterialPropertyValues } }; -} // no namespace +} // namespace template <int DisplacementDim> void MohrCoulomb<DisplacementDim>::computeConstitutiveRelation( @@ -78,7 +78,9 @@ void MohrCoulomb<DisplacementDim>::computeConstitutiveRelation( { // Elastic tangent stiffness Ke = Eigen::MatrixXd::Zero(DisplacementDim, DisplacementDim); for (int i = 0; i < index_ns; i++) + { Ke(i, i) = mat.Ks; + } Ke(index_ns, index_ns) = mat.Kn * @@ -89,7 +91,9 @@ void MohrCoulomb<DisplacementDim>::computeConstitutiveRelation( { // Elastic tangent stiffness at w_prev Ke_prev = Eigen::MatrixXd::Zero(DisplacementDim, DisplacementDim); for (int i = 0; i < index_ns; i++) + { Ke_prev(i, i) = mat.Ks; + } Ke_prev(index_ns, index_ns) = mat.Kn * logPenaltyDerivative( diff --git a/MaterialLib/MPL/CreateComponent.cpp b/MaterialLib/MPL/CreateComponent.cpp index 1364eb9c45ca0415b21d5f732d44026d0fc2ef23..c042afe9501e1cfb84e99cd2f939c508bcbe4f6d 100644 --- a/MaterialLib/MPL/CreateComponent.cpp +++ b/MaterialLib/MPL/CreateComponent.cpp @@ -59,7 +59,7 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent( return std::make_unique<Component>(component_name, std::move(properties)); } -} +} // namespace namespace MaterialPropertyLib { diff --git a/MaterialLib/MPL/CreatePhase.cpp b/MaterialLib/MPL/CreatePhase.cpp index 8423aef48119571a0f193053888e7eda99e31c28..800de257b90905abf3542d6c72b60d4954a3b555 100644 --- a/MaterialLib/MPL/CreatePhase.cpp +++ b/MaterialLib/MPL/CreatePhase.cpp @@ -75,7 +75,7 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase( return std::make_unique<Phase>( std::move(phase_type), std::move(components), std::move(properties)); } -} +} // namespace namespace MaterialPropertyLib { diff --git a/MaterialLib/MPL/Properties/LinearProperty.h b/MaterialLib/MPL/Properties/LinearProperty.h index 7ba5ebe49d31bbdc12f8aea2ebb46b7ba0e6bce6..61727a702d8af81c84dde3b6771edbfa7090d693 100644 --- a/MaterialLib/MPL/Properties/LinearProperty.h +++ b/MaterialLib/MPL/Properties/LinearProperty.h @@ -50,4 +50,4 @@ public: private: IndependentVariable const _independent_variable; }; -} +} // namespace MaterialPropertyLib diff --git a/MaterialLib/PorousMedium/CreatePorousMediaProperties.cpp b/MaterialLib/PorousMedium/CreatePorousMediaProperties.cpp index 1aaabb81533c49c46635e5b63010aad91adf91f3..27651ac36925715d1d97326ef93bbd9bb6c92eb4 100644 --- a/MaterialLib/PorousMedium/CreatePorousMediaProperties.cpp +++ b/MaterialLib/PorousMedium/CreatePorousMediaProperties.cpp @@ -83,12 +83,14 @@ PorousMediaProperties createPorousMediaProperties( : *std::max_element(begin(*material_ids), end(*material_ids)); if (max_material_id > static_cast<int>(mat_ids.size() - 1)) + { OGS_FATAL( "The maximum value of MaterialIDs in mesh is %d. As the " "given number of porous media definitions in the project " "file is %d, the maximum value of MaterialIDs in mesh must be %d " "(index starts with zero).", max_material_id, mat_ids.size(), max_material_id - 1); + } if (max_material_id < static_cast<int>(mat_ids.size() - 1)) WARN( @@ -98,14 +100,16 @@ PorousMediaProperties createPorousMediaProperties( mat_ids.size(), max_material_id - 1); if (mat_ids.back() != static_cast<int>(mat_ids.size()) - 1) + { OGS_FATAL( "The ids in the porous media definitions in the project file have " "to be sequential, starting with the id zero."); + } return PorousMediaProperties{std::move(porosity_models), std::move(intrinsic_permeability_models), std::move(storage_models), material_ids}; } -} // namespace ComponentTransport -} // namespace ProcessLib +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Permeability/Permeability.h b/MaterialLib/PorousMedium/Permeability/Permeability.h index b577bc64766b2951b85a82ecbe98ecd3a99b98a6..4716f0135d2ef1c3c41b79283064a5ffa8937c6b 100644 --- a/MaterialLib/PorousMedium/Permeability/Permeability.h +++ b/MaterialLib/PorousMedium/Permeability/Permeability.h @@ -77,5 +77,5 @@ private: mutable Eigen::MatrixXd _intrinsic_permeability_tensor; }; -} // end of namespace -} // end of namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.cpp b/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.cpp index 75226449378f20a1787a6b7e446544982e2ef7b3..a8a510efa8bd6cb533357bfb899d66b822a3d1f4 100644 --- a/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.cpp +++ b/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.cpp @@ -59,5 +59,5 @@ std::unique_ptr<Permeability> createPermeabilityModel( type.data()); } -} // end of namespace -} // end of namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.h b/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.h index c51bd827b8c87690c40da248e0f488331e69d782..0237ebea93b4228b2a118477c10f6f7e7c0a6510 100644 --- a/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.h +++ b/MaterialLib/PorousMedium/Permeability/createPermeabilityModel.h @@ -35,5 +35,5 @@ std::unique_ptr<Permeability> createPermeabilityModel( BaseLib::ConfigTree const& config, std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters); -} // end of namespace -} // end of namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Porosity/Porosity.h b/MaterialLib/PorousMedium/Porosity/Porosity.h index b6a8ce93f623f370c870fc42c6dc1be0228e7b80..a4cca87dc1f838f09246c30ad62b0083e93ed268 100644 --- a/MaterialLib/PorousMedium/Porosity/Porosity.h +++ b/MaterialLib/PorousMedium/Porosity/Porosity.h @@ -51,5 +51,5 @@ private: ProcessLib::Parameter<double> const& _parameter; }; -} // end of namespace -} // end of namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp b/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp index 4fb36d2b127f8b041884d7c6d8c8c9a81ac87dbf..de4cd5b11e81a627d87827746b0f203938ebe25a 100644 --- a/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp +++ b/MaterialLib/PorousMedium/Porosity/createPorosityModel.cpp @@ -44,5 +44,5 @@ std::unique_ptr<Porosity> createPorosityModel(BaseLib::ConfigTree const& config, type.data()); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Porosity/createPorosityModel.h b/MaterialLib/PorousMedium/Porosity/createPorosityModel.h index 6c0444e8cfdcd1786842885765d7147072281af0..bdfb5602239a601481e20214379e2a8c70e3c9a3 100644 --- a/MaterialLib/PorousMedium/Porosity/createPorosityModel.h +++ b/MaterialLib/PorousMedium/Porosity/createPorosityModel.h @@ -35,5 +35,5 @@ std::unique_ptr<Porosity> createPorosityModel( BaseLib::ConfigTree const& config, std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters); -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/PorousMediaProperties.cpp b/MaterialLib/PorousMedium/PorousMediaProperties.cpp index fb03d81bf4f9bf6bd716ddd79ce0415301f7fe40..6c05d86e96b544a94849b2736c4eae43d4ed7217 100644 --- a/MaterialLib/PorousMedium/PorousMediaProperties.cpp +++ b/MaterialLib/PorousMedium/PorousMediaProperties.cpp @@ -40,5 +40,5 @@ PorousMediaProperties::getSpecificStorage( { return *_specific_storage_models[getMaterialID(pos)]; } -} -} +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/PorousMediaProperties.h b/MaterialLib/PorousMedium/PorousMediaProperties.h index dc07be9200c74f6673341b08872f1e4f9ec67185..cc5965c6e8b8fff6c0debf4576e237cb8d6a43f2 100644 --- a/MaterialLib/PorousMedium/PorousMediaProperties.h +++ b/MaterialLib/PorousMedium/PorousMediaProperties.h @@ -68,5 +68,5 @@ private: MeshLib::PropertyVector<int> const* const _material_ids; }; -} -} +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Storage/ConstantStorage.h b/MaterialLib/PorousMedium/Storage/ConstantStorage.h index bab1ee765111ef57c3c35de188c6dd49ff3cee87..b1dd4a89da1eb4d9e59a7f39f1615268852aa44e 100644 --- a/MaterialLib/PorousMedium/Storage/ConstantStorage.h +++ b/MaterialLib/PorousMedium/Storage/ConstantStorage.h @@ -40,5 +40,5 @@ private: const double _value; }; -} // end of namespace -} // end of namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Storage/Storage.h b/MaterialLib/PorousMedium/Storage/Storage.h index b80c7554b31a0fd79ee54e54651f093cb06d2e21..67ab489b15e6d1af06915ae3716fa4fda8833838 100644 --- a/MaterialLib/PorousMedium/Storage/Storage.h +++ b/MaterialLib/PorousMedium/Storage/Storage.h @@ -32,5 +32,5 @@ public: virtual double getValue(const double variable) const = 0; }; -} // end of namespace -} // end of namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Storage/createStorageModel.cpp b/MaterialLib/PorousMedium/Storage/createStorageModel.cpp index ef826f05bbf9f4de6a515e27e44e8ae1d4587978..6cdaa9ed3d10706941af77df915e52171338d685 100644 --- a/MaterialLib/PorousMedium/Storage/createStorageModel.cpp +++ b/MaterialLib/PorousMedium/Storage/createStorageModel.cpp @@ -28,13 +28,15 @@ std::unique_ptr<Storage> createStorageModel(BaseLib::ConfigTree const& config) auto const type = config.getConfigParameter<std::string>("type"); if (type == "Constant") + { return std::make_unique<ConstantStorage>( //! \ogs_file_param{material__porous_medium__storage__Constant__value} config.getConfigParameter<double>("value")); + } OGS_FATAL("The storage type %s is unavailable.\n", type.data(), "The available type is Constant."); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/Storage/createStorageModel.h b/MaterialLib/PorousMedium/Storage/createStorageModel.h index 29c3b8c301a2f164e947a49284962e65d6478e69..827f96c69993878e6e60992c209a8fd9b9ad4655 100644 --- a/MaterialLib/PorousMedium/Storage/createStorageModel.h +++ b/MaterialLib/PorousMedium/Storage/createStorageModel.h @@ -30,4 +30,4 @@ class Storage; std::unique_ptr<Storage> createStorageModel(BaseLib::ConfigTree const& config); } // end namespace -} // end namespace +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.cpp index 2645f5bedd0dd5cb368a454c32d47a8d343b5acb..c89cbd318c559952c1a35df24bac741740f407d0 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.cpp @@ -53,5 +53,5 @@ double BrooksCoreyCapillaryPressureSaturation::getdPcdS( return (_pb * val) / (_m * (_saturation_r - S)); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.h b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.h index b4b5f0442b01a992d2fdfcc5dae67e2b4d663828..63e2d4ef5521b31fc9ac692f5c0eb78e8107d75a 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/BrooksCoreyCapillaryPressureSaturation.h @@ -87,5 +87,5 @@ private: const double _m; ///< Exponent m, m>1. }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturation.h b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturation.h index 2a28ab6e0ce8ffc3e7af1e0f6a76026096cd968b..1c3037c72542af0711b7e51f0ea363c21e2156ed 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturation.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturation.h @@ -69,5 +69,5 @@ protected: const double _minor_offset = std::numeric_limits<double>::epsilon(); }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h index b9929793fb64f09e168f5b04d46c94e864e9fb96..7362a2b4e423fd02c9a7f10163141815e7868be5 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CapillaryPressureSaturationCurve.h @@ -81,5 +81,5 @@ private: std::unique_ptr<MathLib::PiecewiseLinearMonotonicCurve> _curve_data; }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp index 0822e55c1e461e6bfb4de11f744d2071ae48c47a..88b2ed1804964fb862f4fbcf308c7aafacd1e3d1 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.cpp @@ -163,5 +163,5 @@ std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel( type.data()); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.h b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.h index 340d6a5a961d5b0d619209c624f7688c3b128250..a69597503bcd343ccb8ce91c00094ca0aca0099c 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/CreateCapillaryPressureModel.h @@ -29,4 +29,4 @@ class CapillaryPressureSaturation; std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel( BaseLib::ConfigTree const& config); } -} // end namespace +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp index d29857c1f9bdce5cfd69c808a5681afc084bf656..e337aaf1f5432e66b4d7cee6bb9b8877819035f3 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.cpp @@ -77,9 +77,13 @@ double VanGenuchtenCapillaryPressureSaturation::getdPcdS( return -getdPcdSvGBar(1 - _saturation_r); } if (saturation < _saturation_r) + { return 0; + } if (saturation > _saturation_max) + { return 0; + } const double S = MathLib::limitValueInInterval(saturation, _saturation_r + _minor_offset, @@ -100,9 +104,13 @@ double VanGenuchtenCapillaryPressureSaturation::getd2PcdS2( "pressure relation is not implemented."); } if (saturation < _saturation_r) + { return 0; + } if (saturation > _saturation_max) + { return 0; + } const double S = MathLib::limitValueInInterval(saturation, _saturation_r + _minor_offset, @@ -158,5 +166,5 @@ double VanGenuchtenCapillaryPressureSaturation::getdPcdSvG( std::pow(S_le, (-1 / _m)) / S_le; } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.h b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.h index da948f38caa2ba88af03ff2e4fec391d2da80ee3..a4310c96b0a318cd5df3c94ef49c69723fd0d348 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/CapillaryPressure/VanGenuchtenCapillaryPressureSaturation.h @@ -114,5 +114,5 @@ private: double getdPcdSvG(const double Sg) const; }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp index 0c1d6d4a257d4a3b4ed84b23448759905ac6efb1..4aff51cf35bf713c41b5b9b876020a512dc3a726 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.cpp @@ -209,5 +209,5 @@ std::unique_ptr<RelativePermeability> createRelativePermeabilityModel( type.data()); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.h index fdf30e87f695522bf270c956f3436429de90f987..8cef856c1b614f0906bbd0b975f1d818b37d892c 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/CreateRelativePermeabilityModel.h @@ -29,4 +29,4 @@ class RelativePermeability; std::unique_ptr<RelativePermeability> createRelativePermeabilityModel( BaseLib::ConfigTree const& config); } -} // end namespace +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.cpp index 2e00900fea23520e8fe0a8a0f834c9ad48e33edd..1f713447f74def7441f22260e6d6f8971c85d41d 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.cpp @@ -47,5 +47,5 @@ double NonWettingPhaseBrooksCoreyOilGas::getdValue( (_saturation_max - _saturation_r); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.h index 92c1046ea05c612f9692b044f2f474e6303c94c2..3b495bbec784a465b930d3ddcea535d4a5bce17e 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseBrooksCoreyOilGas.h @@ -68,5 +68,5 @@ private: const double _krel_min; ///< Minimum relative permeability }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.cpp index 77d65ce200d32e673912fcb52fea515a5ac6754f..d14cd7aebab7bbb557a3fac4fefd2a2a0ed3ae34 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.cpp @@ -46,5 +46,5 @@ double NonWettingPhaseVanGenuchten::getdValue(const double saturation_w) const std::pow(Se, (1. - _m) / _m)) / (_saturation_max - _saturation_r); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.h index 66fa666a1c761a5b9c4211697ed909d0f908566f..87420a4c10f5821ac4a2e540c199525eb9fd657e 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/NonWettingPhaseVanGenuchten.h @@ -72,5 +72,5 @@ private: const double _krel_min; ///< Minimum relative permeability }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeability.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeability.h index 6d80afc09be23d5f904f773b2fe333045d46f80b..7ba94a9810d33628fb568658270c3041e1822496 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeability.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeability.h @@ -51,5 +51,5 @@ protected: const double _saturation_max; ///< Maximum saturation. }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h index f4a3727a2383d864f4118c45de33a23d234db3e4..d4676428ef43584cb2f439d8fd958c100a972cc5 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/RelativePermeabilityCurve.h @@ -63,5 +63,5 @@ public: private: std::unique_ptr<MathLib::PiecewiseLinearInterpolation> _curve_data; }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.cpp index 4ccebdb24cd082f5f672b6d2b907b39f1a30d5c4..be11d6922851411be5e1200afec80fd12d4dca7f 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.cpp @@ -39,5 +39,5 @@ double WettingPhaseBrooksCoreyOilGas::getdValue(const double saturation) const return ((3.0 + 2.0 / _m) * std::pow(Se, 2.0 + 2.0 / _m)) / (_saturation_max - _saturation_r); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.h index de81cc669ddc4c0cc541a21a07138778e608b644..4fb7003dee3971065c6c04fe8805223f8d16f56a 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseBrooksCoreyOilGas.h @@ -64,5 +64,5 @@ private: const double _krel_min; ///< Minimum relative permeability }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.cpp b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.cpp index 8ee6e83e781e632f1925407b474ae75ea11e8853..aafcb00532b6ddc2d2c72962075019c56fea2d71 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.cpp +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.cpp @@ -48,5 +48,5 @@ double WettingPhaseVanGenuchten::getdValue(const double saturation) const (_saturation_max - _saturation_r); } -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.h b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.h index ef27881417a74f12ee8bcccc6fdcd6ed513bad5d..ee47217360ad0be47a043363bae97bbd7d931316 100644 --- a/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.h +++ b/MaterialLib/PorousMedium/UnsaturatedProperty/RelativePermeability/WettingPhaseVanGenuchten.h @@ -67,5 +67,5 @@ private: const double _krel_min; ///< Minimum relative permeability }; -} // end namespace -} // end namespace +} // namespace PorousMedium +} // namespace MaterialLib diff --git a/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp b/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp index cf24b3b0d03392ce3f95c6727ce97275b62eb0f7..5eed2b314b2418ee3642c847feb25f72e2892333 100644 --- a/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp +++ b/MaterialLib/SolidModels/CreateConstitutiveRelation.cpp @@ -119,5 +119,5 @@ template std::map<int, std::unique_ptr<MaterialLib::Solids::MechanicsBase<3>>> createConstitutiveRelations<3>( std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, BaseLib::ConfigTree const& config); -} -} +} // namespace Solids +} // namespace MaterialLib diff --git a/MaterialLib/SolidModels/CreateConstitutiveRelation.h b/MaterialLib/SolidModels/CreateConstitutiveRelation.h index 5031039142533acc280bf17d623eef7e97ac8b4f..9136a944b84dc804ba6b8421a273168db8ef436e 100644 --- a/MaterialLib/SolidModels/CreateConstitutiveRelation.h +++ b/MaterialLib/SolidModels/CreateConstitutiveRelation.h @@ -50,5 +50,5 @@ extern template std::map<int, createConstitutiveRelations<3>( std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, BaseLib::ConfigTree const& config); -} -} +} // namespace Solids +} // namespace MaterialLib diff --git a/MaterialLib/SolidModels/CreateCreepBGRa.h b/MaterialLib/SolidModels/CreateCreepBGRa.h index f5adefbc8306d05e0f78c2006247cd2ddbc9b816..23b4c770c82ab14ec704edb42babcc81875dddc1 100644 --- a/MaterialLib/SolidModels/CreateCreepBGRa.h +++ b/MaterialLib/SolidModels/CreateCreepBGRa.h @@ -48,6 +48,6 @@ extern template std::unique_ptr<MaterialLib::Solids::MechanicsBase<3>> createCreepBGRa<3>( std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters, BaseLib::ConfigTree const& config); -} -} -} +} // namespace Creep +} // namespace Solids +} // namespace MaterialLib diff --git a/MaterialLib/SolidModels/CreateNewtonRaphsonSolverParameters.cpp b/MaterialLib/SolidModels/CreateNewtonRaphsonSolverParameters.cpp index 6b5cab0d1aa28a7a6e6879c5d3758eeb89eb35c2..72f83be098f4c4b22aa4c52b96dda890b55140f4 100644 --- a/MaterialLib/SolidModels/CreateNewtonRaphsonSolverParameters.cpp +++ b/MaterialLib/SolidModels/CreateNewtonRaphsonSolverParameters.cpp @@ -40,4 +40,4 @@ NumLib::NewtonRaphsonSolverParameters createNewtonRaphsonSolverParameters( return {maximum_iterations, error_tolerance}; } -} +} // namespace MaterialLib diff --git a/MaterialLib/SolidModels/CreepBGRa.cpp b/MaterialLib/SolidModels/CreepBGRa.cpp index 94c7f5e99eb3f297501313277b0686e963d8cd4b..0c58a8469f5277ed0d964b4ca526a83b214a192e 100644 --- a/MaterialLib/SolidModels/CreepBGRa.cpp +++ b/MaterialLib/SolidModels/CreepBGRa.cpp @@ -118,7 +118,9 @@ CreepBGRa<DisplacementDim>::integrateStress( auto const success_iterations = newton_solver.solve(jacobian); if (!success_iterations) + { return {}; + } // If *success_iterations>0, tangentStiffness = J_(sigma)^{-1}C // where J_(sigma) is the Jacobian of the last local Newton-Raphson diff --git a/MaterialLib/SolidModels/Ehlers.cpp b/MaterialLib/SolidModels/Ehlers.cpp index cba52ae5e120838c3a441a1a571f87811e9b88bc..efece2a3756a84a2403c6c99087dff88f68e7d87 100644 --- a/MaterialLib/SolidModels/Ehlers.cpp +++ b/MaterialLib/SolidModels/Ehlers.cpp @@ -629,14 +629,18 @@ SolidEhlers<DisplacementDim>::integrateStress( auto const success_iterations = newton_solver.solve(jacobian); if (!success_iterations) + { return {}; + } // If the Newton loop didn't run, the linear solver will not be // initialized. // This happens usually for the first iteration of the first // timestep. if (*success_iterations == 0) + { linear_solver.compute(jacobian); + } std::tie(sigma, state.eps_p, std::ignore) = splitSolutionVector<ResidualVectorType, KelvinVector>(solution); diff --git a/MaterialLib/SolidModels/Ehlers.h b/MaterialLib/SolidModels/Ehlers.h index a8ee5d325fa6348115fc15a6f66e2665837a9983..3734d0fb2831f3c2962f06745ecdc08366c17ecd 100644 --- a/MaterialLib/SolidModels/Ehlers.h +++ b/MaterialLib/SolidModels/Ehlers.h @@ -44,11 +44,17 @@ enum class TangentType inline TangentType makeTangentType(std::string const& s) { if (s == "Elastic") + { return TangentType::Elastic; + } if (s == "PlasticDamageSecant") + { return TangentType::PlasticDamageSecant; + } if (s == "Plastic") + { return TangentType::Plastic; + } OGS_FATAL("Not valid string '%s' to create a tangent type from.", s.c_str()); } diff --git a/MaterialLib/SolidModels/Lubby2.cpp b/MaterialLib/SolidModels/Lubby2.cpp index bcfe915b72759be211d81755de8703a62c29010a..f804c9d8da1d6a23bc4826e5043aba5a8521b07a 100644 --- a/MaterialLib/SolidModels/Lubby2.cpp +++ b/MaterialLib/SolidModels/Lubby2.cpp @@ -165,13 +165,17 @@ Lubby2<DisplacementDim>::integrateStress( auto const success_iterations = newton_solver.solve(K_loc); if (!success_iterations) + { return {}; + } // If the Newton loop didn't run, the linear solver will not be // initialized. // This happens usually for the first iteration of the first timestep. if (*success_iterations == 0) + { linear_solver.compute(K_loc); + } } KelvinMatrix C = diff --git a/MaterialLib/SolidModels/Lubby2.h b/MaterialLib/SolidModels/Lubby2.h index cc7c527e93ee2d6f3825ae24ef25c48caf907baf..58a0ebe58321c1a9786529bd21d761afd9279c26 100644 --- a/MaterialLib/SolidModels/Lubby2.h +++ b/MaterialLib/SolidModels/Lubby2.h @@ -98,7 +98,7 @@ struct LocalLubby2Properties double etaK; double etaM; }; -} +} // namespace detail template <int DisplacementDim> class Lubby2 final : public MechanicsBase<DisplacementDim> diff --git a/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp b/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp index 3d77bc224abb45ad829bad9af8697fef79a9e393..891ff1653ddf8fbf9a582c9f4f2c7c93118c9406 100644 --- a/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp +++ b/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.cpp @@ -140,5 +140,5 @@ createTwoPhaseFlowMaterialProperties( std::move(fluid_config)); } -} // end namespace -} // end namespace +} // namespace TwoPhaseFlowWithPP +} // namespace MaterialLib diff --git a/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.h b/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.h index a61e3ac218a559ba2d8afbf8747b351f80b84bea..021ac92e594c1c6d03d1388e2bb4479e77720bda 100644 --- a/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.h +++ b/MaterialLib/TwoPhaseModels/CreateTwoPhaseFlowMaterialProperties.h @@ -35,4 +35,4 @@ createTwoPhaseFlowMaterialProperties( std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters); } // end namespace -} // end namespace +} // namespace MaterialLib diff --git a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp index 97e68662b165583ddc96b3f20e3467534a3e3a52..b7a71d1922954c9eb4cb6f807bbc3583120509f3 100644 --- a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp +++ b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.cpp @@ -166,9 +166,13 @@ double TwoPhaseFlowWithPPMaterialProperties::getNonwetRelativePermeability( const double /*p*/, const double /*T*/, const double saturation) const { if (saturation < 0.) + { return 1.0; + } if (saturation > 1) + { return 0.0; + } return boost::math::pow<3>(1 - saturation); } @@ -177,10 +181,14 @@ double TwoPhaseFlowWithPPMaterialProperties::getWetRelativePermeability( const double /*p*/, const double /*T*/, const double saturation) const { if (saturation < 0) + { return 0.0; + } if (saturation > 1) + { return 1.0; + } return boost::math::pow<3>(saturation); } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace MaterialLib diff --git a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.h b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.h index 4156a649fa7b2286c7e291ceefa2f5e5d6e16b24..4adb66bad51f2f10424b5ad3687742aa72e76596 100644 --- a/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.h +++ b/MaterialLib/TwoPhaseModels/TwoPhaseFlowWithPPMaterialProperties.h @@ -138,5 +138,5 @@ private: _relative_permeability_models; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace MaterialLib diff --git a/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h b/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h index cd81af627cd1dd58ff1536acd29b3d037b7a43bb..8213360c91d734b7e93526071dad455d84a80a3f 100644 --- a/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h +++ b/MathLib/Curve/CreatePiecewiseLinearCurve-impl.h @@ -40,4 +40,4 @@ std::unique_ptr<CurveType> createPiecewiseLinearCurve( } return std::make_unique<CurveType>(std::move(x), std::move(y)); } -} +} // namespace MathLib diff --git a/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp b/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp index 48d829367ab620adbcc57e70e0c7d085c318f706..d669e6e491185f9f2e749476cd05dd245688b92e 100644 --- a/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp +++ b/MathLib/Curve/PiecewiseLinearMonotonicCurve.cpp @@ -35,7 +35,9 @@ bool PiecewiseLinearMonotonicCurve::isStrongMonotonic() const const double gradient0 = getDerivative(_supp_pnts[0]); if (std::fabs(gradient0) < std::numeric_limits<double>::min()) + { return false; + } return std::none_of(_supp_pnts.begin(), _supp_pnts.end(), [&](const double p) { @@ -93,4 +95,4 @@ double PiecewiseLinearMonotonicCurve::getInverseVariable(const double y) const return m * (y - yi) + xi; } -} // namespace +} // namespace MathLib diff --git a/MathLib/Curve/PiecewiseLinearMonotonicCurve.h b/MathLib/Curve/PiecewiseLinearMonotonicCurve.h index 283a0b84c603939c778cfd536b394225a68fd0c1..2b2d76a0e6f248e452827c25452e90f7800fc5f1 100644 --- a/MathLib/Curve/PiecewiseLinearMonotonicCurve.h +++ b/MathLib/Curve/PiecewiseLinearMonotonicCurve.h @@ -44,4 +44,4 @@ private: */ bool isStrongMonotonic() const; }; -} // namespace +} // namespace MathLib diff --git a/MathLib/GeometricBasics.cpp b/MathLib/GeometricBasics.cpp index 6b53384973de7b1c4a11a357eff53c39c9550760..94cdeffa879e73883b22cffc0c91705d8d997b2a 100644 --- a/MathLib/GeometricBasics.cpp +++ b/MathLib/GeometricBasics.cpp @@ -61,16 +61,22 @@ bool isPointInTetrahedron(MathLib::Point3d const& p, MathLib::Point3d const& a, bool const d0_sign (d0>0); // if p is on the same side of bcd as a double const d1 (MathLib::orientation3d(d, p, b, c)); - if (!(d0_sign == (d1>=0) || std::abs(d1) < eps)) + if (!(d0_sign == (d1 >= 0) || std::abs(d1) < eps)) + { return false; + } // if p is on the same side of acd as b double const d2 (MathLib::orientation3d(d, a, p, c)); - if (!(d0_sign == (d2>=0) || std::abs(d2) < eps)) + if (!(d0_sign == (d2 >= 0) || std::abs(d2) < eps)) + { return false; + } // if p is on the same side of abd as c double const d3 (MathLib::orientation3d(d, a, b, p)); - if (!(d0_sign == (d3>=0) || std::abs(d3) < eps)) + if (!(d0_sign == (d3 >= 0) || std::abs(d3) < eps)) + { return false; + } // if p is on the same side of abc as d double const d4 (MathLib::orientation3d(p, a, b, c)); return d0_sign == (d4 >= 0) || std::abs(d4) < eps; @@ -133,7 +139,9 @@ bool gaussPointInTriangle(MathLib::Point3d const& q, {a[0] + y[0] * v[0] + y[1] * w[0], a[1] + y[0] * v[1] + y[1] * w[1], a[2] + y[0] * v[2] + y[1] * w[2]}}); if (MathLib::sqrDist(q, q_projected) <= eps_pnt_out_of_plane) + { return true; + } } return false; @@ -147,7 +155,9 @@ bool barycentricPointInTriangle(MathLib::Point3d const& p, double eps_pnt_out_of_tri) { if (std::abs(MathLib::orientation3d(p, a, b, c)) > eps_pnt_out_of_plane) + { return false; + } MathLib::Vector3 const pa(p, a); MathLib::Vector3 const pb(p, b); @@ -156,10 +166,14 @@ bool barycentricPointInTriangle(MathLib::Point3d const& p, double const alpha((MathLib::crossProduct(pb, pc).getLength()) / area_x_2); if (alpha < -eps_pnt_out_of_tri || alpha > 1 + eps_pnt_out_of_tri) + { return false; + } double const beta((MathLib::crossProduct(pc, pa).getLength()) / area_x_2); if (beta < -eps_pnt_out_of_tri || beta > 1 + eps_pnt_out_of_tri) + { return false; + } double const gamma(1 - alpha - beta); return !(gamma < -eps_pnt_out_of_tri || gamma > 1 + eps_pnt_out_of_tri); } @@ -196,7 +210,9 @@ bool dividedByPlane(const MathLib::Point3d& a, const MathLib::Point3d& b, (b[x] - a[x]) * (d[y] - a[y]) - (b[y] - a[y]) * (d[x] - a[x]); if ((abc > 0 && abd < 0) || (abc < 0 && abd > 0)) + { return true; + } } return false; } diff --git a/MathLib/Integration/GaussLegendrePyramid.cpp b/MathLib/Integration/GaussLegendrePyramid.cpp index 07556c3748d7ac03d90a1d45ee18fc871a6d6e51..ce2f4b448f7f3ee7ba352d57717265a67b0e6807 100644 --- a/MathLib/Integration/GaussLegendrePyramid.cpp +++ b/MathLib/Integration/GaussLegendrePyramid.cpp @@ -57,4 +57,4 @@ double const GaussLegendrePyramid<3>::W[13] = { 0.419515737191525950 }; -} +} // namespace MathLib diff --git a/MathLib/Integration/GaussLegendrePyramid.h b/MathLib/Integration/GaussLegendrePyramid.h index 217fdd6ac0bea0b76b33093f373c49d689ff3fdb..e417c84bdfc39a20e7d862c37ee40c7880a63598 100644 --- a/MathLib/Integration/GaussLegendrePyramid.h +++ b/MathLib/Integration/GaussLegendrePyramid.h @@ -51,4 +51,4 @@ const std::array<std::array<double, 3>, GaussLegendrePyramid<1>::NPoints> template <> double const GaussLegendrePyramid<1>::W[1]; #endif -} +} // namespace MathLib diff --git a/MathLib/Integration/GaussLegendreTet.cpp b/MathLib/Integration/GaussLegendreTet.cpp index 24fdbbb9817c9a0e3a5db488eef32f9d0d5d1ff6..a1d751d85403a645e793f7305533bf897fe1eb8a 100644 --- a/MathLib/Integration/GaussLegendreTet.cpp +++ b/MathLib/Integration/GaussLegendreTet.cpp @@ -63,4 +63,4 @@ static const double r = 0.0425460207770812 / 6.; double const GaussLegendreTet<3>::W[GaussLegendreTet<3>::NPoints] = { p, p, p, p, q, q, q, q, r, r, r, r, r, r}; -} +} // namespace MathLib diff --git a/MathLib/Integration/GaussLegendreTet.h b/MathLib/Integration/GaussLegendreTet.h index 51249dcf5da24a7a65073c33ce7a35e1bbe53496..a30a8f7002e6ca6815e59938142a531f49700c37 100644 --- a/MathLib/Integration/GaussLegendreTet.h +++ b/MathLib/Integration/GaussLegendreTet.h @@ -51,4 +51,4 @@ const std::array<std::array<double, 3>, GaussLegendreTet<1>::NPoints> template <> double const GaussLegendreTet<1>::W[1]; #endif -} +} // namespace MathLib diff --git a/MathLib/Integration/GaussLegendreTri.cpp b/MathLib/Integration/GaussLegendreTri.cpp index 9485205909333453ac4f2a1032d440dde04933dd..eb2bcef70b0acfefb4e2bedc806de1761e52227b 100644 --- a/MathLib/Integration/GaussLegendreTri.cpp +++ b/MathLib/Integration/GaussLegendreTri.cpp @@ -26,4 +26,4 @@ double const GaussLegendreTri<2>::W[3] = {1./3., 1./3., 1./3.}; const std::array<std::array<double, 2>, GaussLegendreTri<3>::NPoints> GaussLegendreTri<3>::X = {{{{1./3., 1./3.}}, {{1./5., 3./5.}}, {{1./5., 1./5.}}, {{3./5., 1./5.}}}}; double const GaussLegendreTri<3>::W[4] = {-27./48., 25./48., 25./48., 25./48.}; -} +} // namespace MathLib diff --git a/MathLib/Integration/GaussLegendreTri.h b/MathLib/Integration/GaussLegendreTri.h index c2018a715cefce379e8c9e8cf2f053891ac39b85..0a47bccdc87fcb4274f92f58309e1bafc3665f74 100644 --- a/MathLib/Integration/GaussLegendreTri.h +++ b/MathLib/Integration/GaussLegendreTri.h @@ -56,4 +56,4 @@ const std::array<std::array<double, 2>, GaussLegendreTri<1>::NPoints> template <> double const GaussLegendreTri<1>::W[1]; #endif -} +} // namespace MathLib diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index 1b34ae676063b234db6a95cd123781c9ce789522..c89daa348245a7b96130b6c162d53112a3e3ecd8 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp @@ -131,4 +131,4 @@ double PiecewiseLinearInterpolation::getSupportMin() const assert(!_supp_pnts.empty()); return _supp_pnts.front(); } -} // end MathLib +} // namespace MathLib diff --git a/MathLib/KelvinVector.cpp b/MathLib/KelvinVector.cpp index 4f2131aa2f2d811cf6950e5761a1f85708036b93..49fba2c3897ebf7e27d2829b7380b735b1448f02 100644 --- a/MathLib/KelvinVector.cpp +++ b/MathLib/KelvinVector.cpp @@ -169,7 +169,7 @@ kelvinVectorToSymmetricTensor(Eigen::Matrix<double, { return kelvinVectorToSymmetricTensor<4>(v); } - else if (v.size() == 6) + if (v.size() == 6) { return kelvinVectorToSymmetricTensor<6>(v); } diff --git a/MathLib/LinAlg/Dense/DenseMatrix-impl.h b/MathLib/LinAlg/Dense/DenseMatrix-impl.h index ce34f55bc785294c747c3a005933df6739aea193..0c899ee21cc9328e7b22bddf0681caf609d74197 100644 --- a/MathLib/LinAlg/Dense/DenseMatrix-impl.h +++ b/MathLib/LinAlg/Dense/DenseMatrix-impl.h @@ -28,7 +28,9 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::DenseMatrix(IDX_TYPE rows, IDX_TYPE cols, { const IDX_TYPE n(_n_rows * _n_cols); for (IDX_TYPE k(0); k < n; k++) + { _data[k] = initial_value; + } } template<typename FP_TYPE, typename IDX_TYPE> @@ -60,7 +62,9 @@ DenseMatrix<FP_TYPE, IDX_TYPE>& DenseMatrix<FP_TYPE, IDX_TYPE>::operator=(DenseMatrix<FP_TYPE, IDX_TYPE> const& rhs) { if (this == &rhs) + { return *this; + } if (_n_rows != rhs.getNumberOfRows() || _n_cols != rhs.getNumberOfColumns()) { std::string msg("DenseMatrix::operator=(DenseMatrix const& rhs), Dimension mismatch, "); @@ -169,7 +173,9 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::operator+(const DenseMatrix<FP_TYPE, IDX_TYPE>& { // make sure the two matrices have the same dimension. if (_n_rows != mat.getNumberOfRows() || _n_cols != mat.getNumberOfColumns()) + { throw std::range_error("DenseMatrix::operator+, illegal matrix size!"); + } DenseMatrix<FP_TYPE, IDX_TYPE>* y(new DenseMatrix<FP_TYPE, IDX_TYPE>(_n_rows, _n_cols)); for (IDX_TYPE i = 0; i < _n_rows; i++) { @@ -187,7 +193,9 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::operator-(const DenseMatrix<FP_TYPE, IDX_TYPE>& { // make sure the two matrices have the same dimension. if (_n_rows != mat.getNumberOfRows() || _n_cols != mat.getNumberOfColumns()) + { throw std::range_error("DenseMatrix::operator-, illegal matrix size!"); + } DenseMatrix<FP_TYPE, IDX_TYPE>* y(new DenseMatrix<FP_TYPE, IDX_TYPE>(_n_rows, _n_cols)); for (IDX_TYPE i = 0; i < _n_rows; i++) { @@ -205,8 +213,11 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::operator*(const DenseMatrix<FP_TYPE, IDX_TYPE>& { // make sure the two matrices have the same dimension. if (_n_cols != mat.getNumberOfRows()) + { throw std::range_error( - "DenseMatrix::operator*, number of rows and cols should be the same!"); + "DenseMatrix::operator*, number of rows and cols should be the " + "same!"); + } IDX_TYPE y_cols(mat.getNumberOfColumns()); DenseMatrix<FP_TYPE, IDX_TYPE>* y( @@ -215,7 +226,9 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::operator*(const DenseMatrix<FP_TYPE, IDX_TYPE>& for (IDX_TYPE i = 0; i < _n_rows; i++) { for (IDX_TYPE j = 0; j < y_cols; j++) { for (IDX_TYPE k = 0; k < _n_cols; k++) + { (*y)(i, j) += _data[address(i, k)] * mat(k, j); + } } } @@ -242,8 +255,12 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::transposeInPlace() { if (_n_rows==_n_cols) { // square matrix for (IDX_TYPE i = 0; i < _n_rows; i++) - for (IDX_TYPE j = i+1; j < _n_cols; j++) + { + for (IDX_TYPE j = i + 1; j < _n_cols; j++) + { std::swap(_data[address(i, j)], _data[address(j, i)]); + } + } } else { // non-square matrix const DenseMatrix<FP_TYPE, IDX_TYPE> org(*this); std::swap(_n_rows, _n_cols); @@ -263,9 +280,15 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::getSubMatrix( IDX_TYPE e_row, IDX_TYPE e_col) const { if (b_row >= e_row | b_col >= e_col) - throw std::range_error("DenseMatrix::getSubMatrix() illegal sub matrix"); + { + throw std::range_error( + "DenseMatrix::getSubMatrix() illegal sub matrix"); + } if (e_row > _n_rows | e_col > _n_cols) - throw std::range_error("DenseMatrix::getSubMatrix() illegal sub matrix"); + { + throw std::range_error( + "DenseMatrix::getSubMatrix() illegal sub matrix"); + } DenseMatrix<FP_TYPE, IDX_TYPE>* y( new DenseMatrix<FP_TYPE, IDX_TYPE>(e_row - b_row, e_col - b_col)); @@ -282,8 +305,11 @@ void DenseMatrix<FP_TYPE, IDX_TYPE>::setSubMatrix(IDX_TYPE b_row, IDX_TYPE b_col, const DenseMatrix<FP_TYPE, IDX_TYPE>& sub_mat) { - if (b_row + sub_mat.getNumberOfRows() > _n_rows | b_col + sub_mat.getNumberOfColumns() > _n_cols) + if (b_row + sub_mat.getNumberOfRows() > _n_rows | + b_col + sub_mat.getNumberOfColumns() > _n_cols) + { throw std::range_error("DenseMatrix::setSubMatrix() sub matrix to big"); + } for (IDX_TYPE i = 0; i < sub_mat.getNumberOfRows(); i++) { for (IDX_TYPE j = 0; j < sub_mat.getNumberOfColumns(); j++) { @@ -328,8 +354,10 @@ DenseMatrix<FP_TYPE, IDX_TYPE>::setIdentity() { (*this) = 0.0; const IDX_TYPE n_square_rows = std::min(_n_rows, _n_cols); - for (IDX_TYPE i=0; i<n_square_rows; i++) - _data[address(i,i)] = 1.0; + for (IDX_TYPE i = 0; i < n_square_rows; i++) + { + _data[address(i, i)] = 1.0; + } } template <typename FP_TYPE, typename IDX_TYPE> @@ -339,8 +367,12 @@ sqrFrobNrm (const DenseMatrix<FP_TYPE, IDX_TYPE> &mat) FP_TYPE nrm(static_cast<FP_TYPE>(0)); IDX_TYPE i, j; for (j = 0; j < mat.getNumberOfColumns(); j++) + { for (i = 0; i < mat.getNumberOfRows(); i++) + { nrm += mat(i, j) * mat(i, j); + } + } return nrm; } diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp index 935f47656e384c579d098844c447371f2581182e..bf204a4aa81fa23bff1df59a83091ab69c2455f9 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.cpp @@ -56,7 +56,10 @@ public: { INFO("-> solve with %s", EigenOption::getSolverName(opt.solver_type).c_str()); - if (!A.isCompressed()) A.makeCompressed(); + if (!A.isCompressed()) + { + A.makeCompressed(); + } _solver.compute(A); if(_solver.info()!=Eigen::Success) { @@ -91,7 +94,9 @@ public: _solver.setMaxIterations(opt.max_iterations); if (!A.isCompressed()) + { A.makeCompressed(); + } _solver.compute(A); if(_solver.info()!=Eigen::Success) { @@ -171,7 +176,7 @@ std::unique_ptr<EigenLinearSolverBase> createIterativeSolver( } } -} // details +} // namespace details EigenLinearSolver::EigenLinearSolver( const std::string& /*solver_name*/, @@ -180,7 +185,9 @@ EigenLinearSolver::EigenLinearSolver( using Matrix = EigenMatrix::RawMatrixType; if (option) + { setOption(*option); + } // TODO for my taste it is much too unobvious that the default solver type // currently is SparseLU. @@ -222,7 +229,9 @@ void EigenLinearSolver::setOption(BaseLib::ConfigTree const& option) //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen} auto const ptSolver = option.getConfigSubtreeOptional("eigen"); if (!ptSolver) + { return; + } if (auto solver_type = //! \ogs_file_param{prj__linear_solvers__linear_solver__eigen__solver_type} @@ -277,7 +286,9 @@ bool EigenLinearSolver::solve(EigenMatrix &A, EigenVector& b, EigenVector &x) x.getRawVector(), _option); #ifdef USE_EIGEN_UNSUPPORTED if (scal) + { x.getRawVector() = scal->RightScaling().cwiseProduct(x.getRawVector()); + } #endif INFO("------------------------------------------------------------------"); @@ -285,4 +296,4 @@ bool EigenLinearSolver::solve(EigenMatrix &A, EigenVector& b, EigenVector &x) return success; } -} //MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenLinearSolver.h b/MathLib/LinAlg/Eigen/EigenLinearSolver.h index 65aaee9879ad514e096cfa5493720688d89db3a3..834b37dcc8afdd4aa2d08c5d315fcdf7b36c6d2e 100644 --- a/MathLib/LinAlg/Eigen/EigenLinearSolver.h +++ b/MathLib/LinAlg/Eigen/EigenLinearSolver.h @@ -60,4 +60,4 @@ protected: std::unique_ptr<EigenLinearSolverBase> _solver; }; -} // MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenMapTools.h b/MathLib/LinAlg/Eigen/EigenMapTools.h index af82b6fdd4ce837fddca8896d4f80fc5f51ebccd..b4efa62f24c37402d4095fdc7c471e6dee6e3ee5 100644 --- a/MathLib/LinAlg/Eigen/EigenMapTools.h +++ b/MathLib/LinAlg/Eigen/EigenMapTools.h @@ -209,4 +209,4 @@ inline Eigen::Map<Eigen::VectorXd> toVector( return {data.data(), static_cast<Eigen::VectorXd::Index>(data.size())}; } -} // MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenMatrix.h b/MathLib/LinAlg/Eigen/EigenMatrix.h index e0ce42ce580d04cc85ae2692b99abb8552186049..2144299a35c225b3ddcc589041bdc00f7c8b505d 100644 --- a/MathLib/LinAlg/Eigen/EigenMatrix.h +++ b/MathLib/LinAlg/Eigen/EigenMatrix.h @@ -65,8 +65,10 @@ public: void setZero() { auto const N = _mat.nonZeros(); - for (auto i = decltype(N){0}; i<N; i++) + for (auto i = decltype(N){0}; i < N; i++) + { _mat.valuePtr()[i] = 0; + } // don't use _mat.setZero(). it makes a matrix uncompressed } @@ -151,15 +153,21 @@ public: { std::ofstream of(filename); if (of) + { write(of); + } } /// printout this matrix for debugging void write(std::ostream &os) const { - for (int k=0; k<_mat.outerSize(); ++k) - for (RawMatrixType::InnerIterator it(_mat,k); it; ++it) - os << it.row() << " " << it.col() << ": " << it.value() << "\n"; + for (int k = 0; k < _mat.outerSize(); ++k) + { + for (RawMatrixType::InnerIterator it(_mat, k); it; ++it) + { + os << it.row() << " " << it.col() << ": " << it.value() << "\n"; + } + } os << std::endl; } diff --git a/MathLib/LinAlg/Eigen/EigenOption.cpp b/MathLib/LinAlg/Eigen/EigenOption.cpp index 47a8c46c81f7824ef9c33e81a32d0775cf7d3481..00ae5c414756fd0801d8e527958571d6011ddfa9 100644 --- a/MathLib/LinAlg/Eigen/EigenOption.cpp +++ b/MathLib/LinAlg/Eigen/EigenOption.cpp @@ -27,15 +27,25 @@ EigenOption::EigenOption() EigenOption::SolverType EigenOption::getSolverType(const std::string &solver_name) { if (solver_name == "CG") + { return SolverType::CG; + } if (solver_name == "BiCGSTAB") + { return SolverType::BiCGSTAB; + } if (solver_name == "SparseLU") + { return SolverType::SparseLU; + } if (solver_name == "PardisoLU") + { return SolverType::PardisoLU; + } if (solver_name == "GMRES") + { return SolverType::GMRES; + } OGS_FATAL("Unknown Eigen solver type `%s'", solver_name.c_str()); } @@ -43,11 +53,17 @@ EigenOption::SolverType EigenOption::getSolverType(const std::string &solver_nam EigenOption::PreconType EigenOption::getPreconType(const std::string &precon_name) { if (precon_name == "NONE") + { return PreconType::NONE; + } if (precon_name == "DIAGONAL") + { return PreconType::DIAGONAL; + } if (precon_name == "ILUT") + { return PreconType::ILUT; + } OGS_FATAL("Unknown Eigen preconditioner type `%s'", precon_name.c_str()); } @@ -82,4 +98,4 @@ std::string EigenOption::getPreconName(PreconType const precon_type) return "Invalid"; } -} //MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenOption.h b/MathLib/LinAlg/Eigen/EigenOption.h index f3cf3974676f0bbf6a6ddca9036dbb3ead92d2d4..aab3884ad51fee646392ef9f8be6d64d80a43d58 100644 --- a/MathLib/LinAlg/Eigen/EigenOption.h +++ b/MathLib/LinAlg/Eigen/EigenOption.h @@ -79,4 +79,4 @@ struct EigenOption final }; -} +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenTools.cpp b/MathLib/LinAlg/Eigen/EigenTools.cpp index dd60c3efda75523ac3c8d8f263932af64bea143e..43ef0d91068aaee108cb7d8969c482a5175c2594 100644 --- a/MathLib/LinAlg/Eigen/EigenTools.cpp +++ b/MathLib/LinAlg/Eigen/EigenTools.cpp @@ -29,9 +29,14 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, // A(k, j) = 0. // set row to zero for (auto row_id : vec_knownX_id) + { for (SpMat::InnerIterator it(A,row_id); it; ++it) { - if (it.col() != decltype(it.col())(row_id)) it.valueRef() = 0.0; + if (it.col() != decltype(it.col())(row_id)) + { + it.valueRef() = 0.0; + } } + } SpMat AT = A.transpose(); @@ -44,7 +49,10 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, // set column to zero, subtract from rhs for (SpMat::InnerIterator it(AT, row_id); it; ++it) { - if (it.col() == row_id) continue; + if (it.col() == row_id) + { + continue; + } b[it.col()] -= it.value()*x; it.valueRef() = 0.0; @@ -62,7 +70,4 @@ void applyKnownSolution(EigenMatrix &A_, EigenVector &b_, EigenVector &/*x*/, A = AT.transpose(); } -} // MathLib - - - +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenTools.h b/MathLib/LinAlg/Eigen/EigenTools.h index 198d78559a4742464df47070352e530f843a1209..85194e70eb64048288d44bb2ce364ffb1b2388c3 100644 --- a/MathLib/LinAlg/Eigen/EigenTools.h +++ b/MathLib/LinAlg/Eigen/EigenTools.h @@ -44,4 +44,4 @@ void applyKnownSolution(Eigen::MatrixXd &A, Eigen::VectorXd &b, Eigen::VectorXd OGS_FATAL("Method not implemented."); // TODO implement } -} // MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/Eigen/EigenVector.h b/MathLib/LinAlg/Eigen/EigenVector.h index 065c60bbd4be8e77125d31945477f26d84c2822a..906592a6cb1c8e0ea2a6d22b9eb84473ba67aeff 100644 --- a/MathLib/LinAlg/Eigen/EigenVector.h +++ b/MathLib/LinAlg/Eigen/EigenVector.h @@ -121,4 +121,4 @@ private: RawVectorType _vec; }; -} // MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/LinAlg.h b/MathLib/LinAlg/LinAlg.h index 129374da08607c1af669f04fe16c847933987b9a..cb777773b592c9c525a60f97e220ef86b3bd48b5 100644 --- a/MathLib/LinAlg/LinAlg.h +++ b/MathLib/LinAlg/LinAlg.h @@ -129,8 +129,8 @@ void matMultAdd(Matrix const& A, Vector const& v1, Vector const& v2, Vector& v3) v3 = v2 + A*v1; } -}} // namespaces - +} // namespace LinAlg +} // namespace MathLib // Global PETScMatrix/PETScVector ////////////////////////////////////////// #ifdef USE_PETSC diff --git a/MathLib/LinAlg/LinAlgEnums.cpp b/MathLib/LinAlg/LinAlgEnums.cpp index 08d59424a531d06b453eb8fe08312cb0a742e063..848a9a9faaf6f2b3a99e346c49e9bcf82a0cf5ac 100644 --- a/MathLib/LinAlg/LinAlgEnums.cpp +++ b/MathLib/LinAlg/LinAlgEnums.cpp @@ -27,9 +27,18 @@ std::string convertVecNormTypeToString(VecNormType normType) VecNormType convertStringToVecNormType(const std::string &str) { - if (str == "NORM1") return VecNormType::NORM1; - if (str == "NORM2") return VecNormType::NORM2; - if (str == "INFINITY_N") return VecNormType::INFINITY_N; + if (str == "NORM1") + { + return VecNormType::NORM1; + } + if (str == "NORM2") + { + return VecNormType::NORM2; + } + if (str == "INFINITY_N") + { + return VecNormType::INFINITY_N; + } return VecNormType::INVALID; } diff --git a/MathLib/LinAlg/LinearSolverOptions.cpp b/MathLib/LinAlg/LinearSolverOptions.cpp index e15dd3357d4c530a1eeae88e2c1e1dd9cc02f2f8..fc1e1b9a6341680b066f90d28a9113a9f112536f 100644 --- a/MathLib/LinAlg/LinearSolverOptions.cpp +++ b/MathLib/LinAlg/LinearSolverOptions.cpp @@ -18,8 +18,11 @@ ignoreOtherLinearSolvers(const BaseLib::ConfigTree &config, const std::string &solver_name) { for (auto const& s : known_linear_solvers) { - if (s!=solver_name) config.ignoreConfigParameter(s); + if (s != solver_name) + { + config.ignoreConfigParameter(s); + } } } -} +} // namespace MathLib diff --git a/MathLib/LinAlg/LinearSolverOptions.h b/MathLib/LinAlg/LinearSolverOptions.h index 27e0b50ea781c1b1c796b015f5bffe9994da8a16..75557a0ba1edc14561c6ae14dfd59d610882d3b5 100644 --- a/MathLib/LinAlg/LinearSolverOptions.h +++ b/MathLib/LinAlg/LinearSolverOptions.h @@ -35,4 +35,4 @@ namespace MathLib void ignoreOtherLinearSolvers(BaseLib::ConfigTree const& config, std::string const& solver_name); -} +} // namespace MathLib diff --git a/MathLib/LinAlg/MatrixVectorTraits.cpp b/MathLib/LinAlg/MatrixVectorTraits.cpp index a3501d72d64e4f5661a7c45d8fd7cb55253ee409..fd11aef995189fbe0b7d762d37a914e3fb62d8b8 100644 --- a/MathLib/LinAlg/MatrixVectorTraits.cpp +++ b/MathLib/LinAlg/MatrixVectorTraits.cpp @@ -110,7 +110,9 @@ newInstance(MatrixSpecifications const& spec) auto A = std::make_unique<EigenMatrix>(spec.nrows); if (spec.sparsity_pattern) + { setMatrixSparsity(*A, *spec.sparsity_pattern); + } return A; } diff --git a/MathLib/LinAlg/RowColumnIndices.h b/MathLib/LinAlg/RowColumnIndices.h index 0fdb3ebe5b30dc85812801642601794970c897ab..7141ee25cead7974f6fbd0c74cbbf26c6d9c8092 100644 --- a/MathLib/LinAlg/RowColumnIndices.h +++ b/MathLib/LinAlg/RowColumnIndices.h @@ -26,4 +26,4 @@ struct RowColumnIndices LineIndex const& columns; }; -} // MathLib +} // namespace MathLib diff --git a/MathLib/LinAlg/SetMatrixSparsity.h b/MathLib/LinAlg/SetMatrixSparsity.h index 23d4376dac4c9cdc5ac0cf71aceaeb6da51a3ddd..3013e9d1c2aad3074a160c092f5c575e75cef070 100644 --- a/MathLib/LinAlg/SetMatrixSparsity.h +++ b/MathLib/LinAlg/SetMatrixSparsity.h @@ -31,7 +31,7 @@ void setMatrixSparsity(MATRIX& matrix, SPARSITY_PATTERN const& sparsity_pattern) set_sparsity(matrix, sparsity_pattern); } -} // MathLib +} // namespace MathLib #ifdef USE_LIS #include "Lis/LisMatrix.h" diff --git a/MathLib/LinAlg/UnifiedMatrixSetters.cpp b/MathLib/LinAlg/UnifiedMatrixSetters.cpp index 0ba7ed525b5f9ee3dcce99dacac3f187b731e5c8..4b0211d35b83c37aa3ec9238b3610f0c0247ae70 100644 --- a/MathLib/LinAlg/UnifiedMatrixSetters.cpp +++ b/MathLib/LinAlg/UnifiedMatrixSetters.cpp @@ -113,7 +113,9 @@ void setVector(EigenVector& v_, assert((std::size_t)v.size() == values.size()); auto it = values.begin(); for (std::size_t i = 0; i < values.size(); ++i) + { v[i] = *(it++); + } } void setVector(EigenVector& v, MatrixVectorTraits<EigenVector>::Index const index, diff --git a/MathLib/LinearFunction.h b/MathLib/LinearFunction.h index d004c1bff0df1a6d1927964265f6a67382941cef..47285852720eab7ae8a0abd0f6a5eadf7fba70ae 100644 --- a/MathLib/LinearFunction.h +++ b/MathLib/LinearFunction.h @@ -55,4 +55,4 @@ private: const std::array<T_TYPE, N_VARS+1> _coefficients; }; -} // MathLib +} // namespace MathLib diff --git a/MathLib/MathTools.cpp b/MathLib/MathTools.cpp index f648c8d0ddf4a3fdec91045f6f2b398cbd46daa2..c8e5061fdf8e33a44ea39084b895c02e5c544aac 100644 --- a/MathLib/MathTools.cpp +++ b/MathLib/MathTools.cpp @@ -27,7 +27,9 @@ double calcProjPntToLineAndDists(const double p[3], const double a[3], // compute projected point double proj_pnt[3]; for (std::size_t k(0); k < 3; k++) + { proj_pnt[k] = a[k] + lambda * v[k]; + } d0 = std::sqrt (sqrDist (proj_pnt, a)); @@ -43,6 +45,4 @@ double getAngle (const double p0[3], const double p1[3], const double p2[3]) return std::acos (scalarProduct<double,3> (v0,v1) / (std::sqrt(scalarProduct<double,3>(v0,v0)) * sqrt(scalarProduct<double,3>(v1,v1)))); } - - -} // namespace +} // namespace MathLib diff --git a/MathLib/MathTools.h b/MathLib/MathTools.h index 0be695079ff0d240eed8bf0cd037354413be2671..1ca850028a0e6d7e600d55ea09eb6a01bd38266a 100644 --- a/MathLib/MathTools.h +++ b/MathLib/MathTools.h @@ -31,7 +31,9 @@ T scalarProduct(T const * const v0, T const * const v1) #pragma omp parallel for reduction (+:res) for (int k = 1; k < N; k++) + { res += v0[k] * v1[k]; + } return res; } @@ -40,7 +42,9 @@ double scalarProduct<double,3>(double const * const v0, double const * const v1) { double res (v0[0] * v1[0]); for (std::size_t k(1); k < 3; k++) + { res += v0[k] * v1[k]; + } return res; } @@ -51,7 +55,9 @@ inline T scalarProduct(T const* const v0, T const* const v1, int const n) #pragma omp parallel for reduction (+:res) for (int k = 1; k < n; k++) + { res += v0[k] * v1[k]; + } return res; } @@ -100,9 +106,13 @@ template<typename Type> Type limitValueInInterval(const Type variable, const Type upper_bound) { if (variable < lower_bound) + { return lower_bound; + } if (variable > upper_bound) + { return upper_bound; + } return variable; } -} // namespace +} // namespace MathLib diff --git a/MathLib/Nonlinear/Root1D.h b/MathLib/Nonlinear/Root1D.h index 728cb75a7fee515aefa6928c6c4c08ee54f6ab6f..0040226d61b3cfef132630638ef1dbb99a07279d 100644 --- a/MathLib/Nonlinear/Root1D.h +++ b/MathLib/Nonlinear/Root1D.h @@ -38,8 +38,7 @@ inline bool almost_zero(double a) return std::abs(a) <= std::numeric_limits<double>::epsilon(); } -} - +} // namespace detail //! Use the regula falsi method to find the root of some scalar function of one //! variable. @@ -72,7 +71,10 @@ public: { for (unsigned i=0; i<num_steps; ++i) { - if (_a == _b) return; + if (_a == _b) + { + return; + } const double s = (_fb - _fa)/(_b - _a); const double c = _a - _fa/s; @@ -98,7 +100,10 @@ public: //! Returns the current estimate of the root. double getResult() const { - if (_a == _b) return _a; + if (_a == _b) + { + return _a; + } const double s = (_fb - _fa)/(_b - _a); const double c = _a - _fa/s; @@ -159,6 +164,6 @@ struct AndersonBjorck } }; -} +} // namespace Nonlinear } // namespace MathLib diff --git a/MathLib/Point3dWithID.h b/MathLib/Point3dWithID.h index ffd5e01999775af762f9dc005a3ee9ad0420e15a..87f8fe8a99eb3da226bb7dddd84a8a496d977291 100644 --- a/MathLib/Point3dWithID.h +++ b/MathLib/Point3dWithID.h @@ -66,4 +66,4 @@ protected: std::size_t _id; }; -} +} // namespace MathLib diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index f07e06ffa4bca9fb3434c124b08c1c20c0d4b283..7b084776d03d97312ef2a07d6944878d9af4eae2 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -80,20 +80,28 @@ public: TemplateVector3& operator+=(TemplateVector3 const& v) { - for (std::size_t i(0); i < 3; i++) this->_x[i] += v[i]; + for (std::size_t i(0); i < 3; i++) + { + this->_x[i] += v[i]; + } return *this; } TemplateVector3& operator-=(const TemplateVector3 & pV) { - for (std::size_t i(0); i < 3; i++) this->_x[i] -= pV[i]; + for (std::size_t i(0); i < 3; i++) + { + this->_x[i] -= pV[i]; + } return *this; } TemplateVector3& operator*=(double s) { for (std::size_t i(0); i < 3; i++) + { this->_x[i] *= s; + } return *this; } @@ -104,14 +112,18 @@ public: { const double s(1/getLength()); for (std::size_t i(0); i < 3; i++) + { this->_x[i] *= s; + } } /// Returns a normalized version of this vector TemplateVector3<double> getNormalizedVector() const { if (getSqrLength() == 0) - return TemplateVector3<double>(0,0,0); + { + return TemplateVector3<double>(0, 0, 0); + } TemplateVector3<double> norm_vec (this->_x[0], this->_x[1], this->_x[2]); norm_vec.normalize(); return norm_vec; @@ -191,4 +203,4 @@ using Vector3 = TemplateVector3<double>; double scalarTriple(MathLib::Vector3 const& u, MathLib::Vector3 const& v, MathLib::Vector3 const& w); -} +} // namespace MathLib diff --git a/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp b/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp index 324caa7a5afa5a72068a225f1de18a5549a93138..7b71d284beac49dc1268aa4c528d4e6425c7dedc 100644 --- a/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp +++ b/MeshGeoToolsLib/AppendLinesAlongPolyline.cpp @@ -93,5 +93,4 @@ std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines( return new_mesh; } -} // MeshGeoToolsLib - +} // namespace MeshGeoToolsLib diff --git a/MeshGeoToolsLib/AppendLinesAlongPolyline.h b/MeshGeoToolsLib/AppendLinesAlongPolyline.h index 569a60e444443f874fa29863aea62510d631c00f..43ca120eae76cfd415f258d377a443d8065e253b 100644 --- a/MeshGeoToolsLib/AppendLinesAlongPolyline.h +++ b/MeshGeoToolsLib/AppendLinesAlongPolyline.h @@ -40,4 +40,4 @@ namespace MeshGeoToolsLib */ std::unique_ptr<MeshLib::Mesh> appendLinesAlongPolylines( const MeshLib::Mesh& mesh, const GeoLib::PolylineVec& ply_vec); -} +} // namespace MeshGeoToolsLib diff --git a/MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp b/MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp index 28d0c716a4d6e56f6013df08ada6fe6e773f01d0..b6f693d4bb0319758c70d0a26010f91433fd727c 100644 --- a/MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp +++ b/MeshGeoToolsLib/BoundaryElementsAlongPolyline.cpp @@ -40,10 +40,14 @@ BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline( auto* e = _mesh.getElement(ele_id); // skip line elements if (e->getDimension() == 1) + { continue; + } // skip internal elements if (!e->isBoundaryElement()) + { continue; + } // find edges on the polyline for (unsigned i=0; i<e->getNumberOfEdges(); i++) { auto* edge = e->getEdge(i); @@ -56,7 +60,9 @@ BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline( *edge, ply, edge_node_distances_along_ply, node_ids_on_poly); if (edge != new_edge) + { delete edge; + } _boundary_elements.push_back(new_edge); } else { delete edge; @@ -86,7 +92,9 @@ BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline( BoundaryElementsAlongPolyline::~BoundaryElementsAlongPolyline() { for (auto p : _boundary_elements) + { delete p; + } } bool BoundaryElementsAlongPolyline::includesAllEdgeNodeIDs(const std::vector<std::size_t> &vec_node_ids, const MeshLib::Element &edge, std::vector<std::size_t> &edge_node_distances) const @@ -95,9 +103,13 @@ bool BoundaryElementsAlongPolyline::includesAllEdgeNodeIDs(const std::vector<std for (; j<edge.getNumberOfBaseNodes(); j++) { auto itr = std::find(vec_node_ids.begin(), vec_node_ids.end(), edge.getNodeIndex(j)); if (itr != vec_node_ids.end()) + { edge_node_distances.push_back(std::distance(vec_node_ids.begin(), itr)); + } else + { break; + } } return (j==edge.getNumberOfBaseNodes()); } @@ -127,7 +139,10 @@ MeshLib::Element* BoundaryElementsAlongPolyline::modifyEdgeNodeOrdering( new_nodes[2] = const_cast<MeshLib::Node*>(e->getNode(2)); } else - OGS_FATAL("Not implemented for element type %s", typeid(edge).name()); + { + OGS_FATAL("Not implemented for element type %s", + typeid(edge).name()); + } return edge.clone(new_nodes, edge.getID()); } diff --git a/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp b/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp index 28738f42b30e3b527ef273eae91e73818d298901..8f65f65cc05e5703c49f493a1b4a9101380d862a 100644 --- a/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp +++ b/MeshGeoToolsLib/BoundaryElementsAtPoint.cpp @@ -26,16 +26,20 @@ BoundaryElementsAtPoint::BoundaryElementsAtPoint( { auto const node_ids = mshNodeSearcher.getMeshNodeIDs(_point); if (node_ids.empty()) + { OGS_FATAL( "BoundaryElementsAtPoint: the mesh node searcher was unable to " "locate the point (%f, %f, %f) in the mesh.", _point[0], _point[1], _point[2]); + } if (node_ids.size() > 1) + { OGS_FATAL( "BoundaryElementsAtPoint: the mesh node searcher found %d points " "near the requested point (%f, %f, %f) in the mesh, while exactly " "one is expected.", node_ids.size(), _point[0], _point[1], _point[2]); + } std::array<MeshLib::Node*, 1> const nodes = {{ const_cast<MeshLib::Node*>(_mesh.getNode(node_ids[0]))}}; @@ -46,6 +50,8 @@ BoundaryElementsAtPoint::BoundaryElementsAtPoint( BoundaryElementsAtPoint::~BoundaryElementsAtPoint() { for (auto p : _boundary_elements) + { delete p; + } } -} // MeshGeoToolsLib +} // namespace MeshGeoToolsLib diff --git a/MeshGeoToolsLib/BoundaryElementsOnSurface.cpp b/MeshGeoToolsLib/BoundaryElementsOnSurface.cpp index bc5e83d5b74414bd694d3655b6f4045dcd442ffe..35101d38f873c9072c4e41fc5e9de3abe11c3da6 100644 --- a/MeshGeoToolsLib/BoundaryElementsOnSurface.cpp +++ b/MeshGeoToolsLib/BoundaryElementsOnSurface.cpp @@ -34,17 +34,24 @@ BoundaryElementsOnSurface::BoundaryElementsOnSurface( auto* e = _mesh.getElement(ele_id); // skip internal elements if (!e->isBoundaryElement()) + { continue; + } // find faces on surface for (unsigned i=0; i<e->getNumberOfFaces(); i++) { auto* face = e->getFace(i); // check std::size_t cnt_match = 0; for (std::size_t j=0; j<face->getNumberOfBaseNodes(); j++) { - if (std::find(node_ids_on_sfc.begin(), node_ids_on_sfc.end(), face->getNodeIndex(j)) != node_ids_on_sfc.end()) + if (std::find(node_ids_on_sfc.begin(), node_ids_on_sfc.end(), + face->getNodeIndex(j)) != node_ids_on_sfc.end()) + { cnt_match++; + } else + { break; + } } // update the list if (cnt_match==face->getNumberOfBaseNodes()) @@ -52,7 +59,9 @@ BoundaryElementsOnSurface::BoundaryElementsOnSurface( _boundary_elements.push_back(const_cast<MeshLib::Element*>(face)); } else + { delete face; + } } } } @@ -60,7 +69,9 @@ BoundaryElementsOnSurface::BoundaryElementsOnSurface( BoundaryElementsOnSurface::~BoundaryElementsOnSurface() { for (auto p : _boundary_elements) + { delete p; + } } } // end namespace MeshGeoToolsLib diff --git a/MeshGeoToolsLib/BoundaryElementsSearcher.cpp b/MeshGeoToolsLib/BoundaryElementsSearcher.cpp index 0237dd85da82e860c812fb3086e60db1851e080a..58d7f133bd84710a613da3bbed8cd65eaf8708dc 100644 --- a/MeshGeoToolsLib/BoundaryElementsSearcher.cpp +++ b/MeshGeoToolsLib/BoundaryElementsSearcher.cpp @@ -33,11 +33,17 @@ BoundaryElementsSearcher::BoundaryElementsSearcher( BoundaryElementsSearcher::~BoundaryElementsSearcher() { for (auto p : _boundary_elements_at_point) + { delete p; + } for (auto p : _boundary_elements_along_polylines) + { delete p; + } for (auto p : _boundary_elements_along_surfaces) + { delete p; + } } std::vector<MeshLib::Element*> const& BoundaryElementsSearcher::getBoundaryElements(GeoLib::GeoObject const& geoObj) @@ -65,7 +71,9 @@ BoundaryElementsSearcher::getBoundaryElementsAtPoint(GeoLib::Point const& point) for (auto const& boundaryElements : _boundary_elements_at_point) { if (boundaryElements->getPoint() == point) + { return boundaryElements->getBoundaryElements(); + } } // create new boundary elements at points. diff --git a/MeshGeoToolsLib/GeoMapper.cpp b/MeshGeoToolsLib/GeoMapper.cpp index 8881fcb06e8c1246cd28ef2f51700d448649ab13..21ebfc6da48969869f5bbd8185d227ff5bd39287 100644 --- a/MeshGeoToolsLib/GeoMapper.cpp +++ b/MeshGeoToolsLib/GeoMapper.cpp @@ -76,10 +76,14 @@ void GeoMapper::mapOnMesh(MeshLib::Mesh const*const mesh) // the variable _surface_mesh is reused below, so first the existing // _surface_mesh has to be cleaned up if (_surface_mesh) + { delete _surface_mesh; + } - if (mesh->getDimension()<3) + if (mesh->getDimension() < 3) + { _surface_mesh = new MeshLib::Mesh(*mesh); + } else { const MathLib::Vector3 dir(0,0,-1); @@ -139,7 +143,9 @@ void GeoMapper::mapStationData(std::vector<GeoLib::Point*> const& points) : getDemElevation(*pnt); if (!GeoLib::isBorehole(pnt)) + { continue; + } auto const& layers = static_cast<GeoLib::StationBorehole*>(pnt)->getProfile(); for (auto * layer_pnt : layers) { (*layer_pnt)[2] = (*layer_pnt)[2] + offset; @@ -168,9 +174,13 @@ void GeoMapper::mapPointDataToMeshSurface(std::vector<GeoLib::Point*> const& pnt // projected onto the y-x plane GeoLib::Point &p(*pnt); if (p[0] < aabb.getMinPoint()[0] || aabb.getMaxPoint()[0] < p[0]) + { continue; + } if (p[1] < aabb.getMinPoint()[1] || aabb.getMaxPoint()[1] < p[1]) + { continue; + } p[2] = getMeshElevation(p[0], p[1], min_val, max_val); } @@ -179,8 +189,11 @@ void GeoMapper::mapPointDataToMeshSurface(std::vector<GeoLib::Point*> const& pnt float GeoMapper::getDemElevation(GeoLib::Point const& pnt) const { double const elevation (_raster->getValueAtPoint(pnt)); - if (std::abs(elevation-_raster->getHeader().no_data) < std::numeric_limits<double>::epsilon()) + if (std::abs(elevation - _raster->getHeader().no_data) < + std::numeric_limits<double>::epsilon()) + { return 0.0; + } return static_cast<float>(elevation); } @@ -197,20 +210,26 @@ double GeoMapper::getMeshElevation( { if (intersection == nullptr && element->getGeomType() != MeshLib::MeshElemType::LINE) + { intersection = GeoLib::triangleLineIntersection( *element->getNode(0), *element->getNode(1), *element->getNode(2), GeoLib::Point(x, y, max_val), GeoLib::Point(x, y, min_val)); + } if (intersection == nullptr && element->getGeomType() == MeshLib::MeshElemType::QUAD) + { intersection = GeoLib::triangleLineIntersection( *element->getNode(0), *element->getNode(2), *element->getNode(3), GeoLib::Point(x, y, max_val), GeoLib::Point(x, y, min_val)); + } } if (intersection) + { return (*intersection)[2]; + } // if something goes wrong, simply take the elevation of the nearest mesh node return (*(_surface_mesh->getNode(pnt->getID())))[2]; } @@ -267,7 +286,9 @@ static std::vector<MathLib::Point3d> computeElementSegmentIntersections( std::vector<MathLib::Point3d> const intersections( GeoLib::lineSegmentIntersect2d(segment, elem_segment)); for (auto const& p : intersections) + { element_intersections.push_back(std::move(p)); + } } return element_intersections; } @@ -283,9 +304,10 @@ static std::vector<GeoLib::LineSegment> createSubSegmentsForElement( std::stringstream out; out << "element with id " << elem->getID() << " and seg " << " intersecting at more than two edges\n"; - for (std::size_t k(0); k<intersections.size(); ++k) - out << k << " " << intersections[k] - << "\n"; + for (std::size_t k(0); k < intersections.size(); ++k) + { + out << k << " " << intersections[k] << "\n"; + } out << "Could not map segment on element. Aborting.\n"; OGS_FATAL("%s", out.str().c_str()); } @@ -297,9 +319,11 @@ static std::vector<GeoLib::LineSegment> createSubSegmentsForElement( // added. if (MathLib::sqrDist(beg_pnt, intersections[0]) > std::numeric_limits<double>::epsilon()) + { sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0}, new GeoLib::Point{intersections[0], 0}, true); + } } if (intersections.size() == 1 && elem == end_elem) @@ -309,8 +333,10 @@ static std::vector<GeoLib::LineSegment> createSubSegmentsForElement( // added. if (MathLib::sqrDist(end_pnt, intersections[0]) > std::numeric_limits<double>::epsilon()) + { sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0}, new GeoLib::Point{end_pnt, 0}, true); + } } if (intersections.size() == 1 && (elem != beg_elem && elem != end_elem)) @@ -344,7 +370,9 @@ static std::vector<GeoLib::LineSegment> mapLineSegment( std::vector<MathLib::Point3d> element_intersections( computeElementSegmentIntersections(*elem, segment)); if (element_intersections.empty()) + { continue; + } BaseLib::makeVectorUnique(element_intersections); @@ -470,11 +498,15 @@ static void insertSubSegments( auto const begin_id(points.push_back( new GeoLib::Point(segment.getBeginPoint(), points.size()))); if (ply.insertPoint(j + new_pnts_cnt + 1, begin_id)) + { new_pnts_cnt++; + } auto const end_id(points.push_back( new GeoLib::Point(segment.getEndPoint(), points.size()))); if (ply.insertPoint(j + new_pnts_cnt + 1, end_id)) + { new_pnts_cnt++; + } } segment_it += new_pnts_cnt; } @@ -496,7 +528,9 @@ static void mapPolylineOnSurfaceMesh( if (elem) { if (!snapPointToElementNode(p, *elem, 1e-3)) + { mapPointOnSurfaceElement(*elem, p); + } } return elem; }; @@ -527,7 +561,9 @@ static void mapPolylineOnSurfaceMesh( *segment_it, candidate_elements, beg_elem, end_elem)); if (sub_segments.empty()) + { continue; + } // The case sub_segment.size() == 1 is already handled above. @@ -542,7 +578,9 @@ void GeoMapper::advancedMapOnMesh(MeshLib::Mesh const& mesh) { // 1. extract surface if (_surface_mesh) + { delete _surface_mesh; + } if (mesh.getDimension()<3) { _surface_mesh = new MeshLib::Mesh(mesh); } else { diff --git a/MeshGeoToolsLib/HeuristicSearchLength.cpp b/MeshGeoToolsLib/HeuristicSearchLength.cpp index d629706a57e75b26fab0b89df4c73586fc268c72..ae9e5a221dfa04f7a60900e91f4265230f9c29ac 100644 --- a/MeshGeoToolsLib/HeuristicSearchLength.cpp +++ b/MeshGeoToolsLib/HeuristicSearchLength.cpp @@ -59,10 +59,14 @@ HeuristicSearchLength::HeuristicSearchLength(MeshLib::Mesh const& mesh, LengthTy _search_length = mean/2; if (variance > 0) { - if (variance < mean*mean/4) + if (variance < mean * mean / 4) + { _search_length -= std::sqrt(variance); + } else + { _search_length = std::numeric_limits<double>::epsilon(); + } } DBUG( diff --git a/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h b/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h index ff78efe45158ba539f7b0794292a4869a2bd2840..b5ed5f882fa802ce23020cfeb2f9fcad1fc31a5a 100644 --- a/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h +++ b/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h @@ -33,7 +33,9 @@ std::vector<bool> markNodesOutSideOfPolygon( // 1 copy all mesh nodes to GeoLib::Points std::vector<GeoLib::Point*> rotated_nodes; for (auto node : nodes) + { rotated_nodes.push_back(new GeoLib::Point(*node, node->getID())); + } // 2 rotate the Points MathLib::DenseMatrix<double> rot_mat(3,3); GeoLib::computeRotationMatrixToXY(normal, rot_mat); @@ -51,16 +53,20 @@ std::vector<bool> markNodesOutSideOfPolygon( } } - for (auto & rotated_node : rotated_nodes) + for (auto& rotated_node : rotated_nodes) + { delete rotated_node; + } std::vector<GeoLib::Point*> & rot_polygon_pnts( const_cast<std::vector<GeoLib::Point*> &>( rot_polygon.getPointsVec() ) ); - for (auto & rot_polygon_pnt : rot_polygon_pnts) + for (auto& rot_polygon_pnt : rot_polygon_pnts) + { delete rot_polygon_pnt; + } return outside; } diff --git a/MeshGeoToolsLib/MeshEditing/ResetMeshElementProperty.h b/MeshGeoToolsLib/MeshEditing/ResetMeshElementProperty.h index cd0108fe87d2b75ba177597935112e74ee805dd5..9d8e36723ff4f37dac165d3d6fbcebe10ef63493 100644 --- a/MeshGeoToolsLib/MeshEditing/ResetMeshElementProperty.h +++ b/MeshGeoToolsLib/MeshEditing/ResetMeshElementProperty.h @@ -84,4 +84,4 @@ void resetMeshElementProperty(MeshLib::Mesh& mesh, } } -} // end namespace +} // namespace MeshGeoToolsLib diff --git a/MeshGeoToolsLib/MeshNodeSearcher.cpp b/MeshGeoToolsLib/MeshNodeSearcher.cpp index a1cd2e97e6b091e6795d730f3b9ccd730ae68724..561779b63faa1ebeef4de56d406ed2867253a0e5 100644 --- a/MeshGeoToolsLib/MeshNodeSearcher.cpp +++ b/MeshGeoToolsLib/MeshNodeSearcher.cpp @@ -47,11 +47,17 @@ MeshNodeSearcher::MeshNodeSearcher( MeshNodeSearcher::~MeshNodeSearcher() { for (auto pointer : _mesh_nodes_on_points) + { delete pointer; + } for (auto pointer : _mesh_nodes_along_polylines) + { delete pointer; + } for (auto pointer : _mesh_nodes_along_surfaces) + { delete pointer; + } } std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs( @@ -191,8 +197,10 @@ MeshNodeSearcher const& MeshNodeSearcher::getMeshNodeSearcher( std::unique_ptr<MeshGeoToolsLib::SearchLength>&& search_length_algorithm) { std::size_t const mesh_id = mesh.getID(); - if (_mesh_node_searchers.size() < mesh_id+1) - _mesh_node_searchers.resize(mesh_id+1); + if (_mesh_node_searchers.size() < mesh_id + 1) + { + _mesh_node_searchers.resize(mesh_id + 1); + } if (_mesh_node_searchers[mesh_id]) { diff --git a/MeshGeoToolsLib/MeshNodesAlongSurface.cpp b/MeshGeoToolsLib/MeshNodesAlongSurface.cpp index 23f3e5a4a8f04776c07f412e11a785bb2e22ab29..7d5ca05b4c425688533673b009535e658d5931f1 100644 --- a/MeshGeoToolsLib/MeshNodesAlongSurface.cpp +++ b/MeshGeoToolsLib/MeshNodesAlongSurface.cpp @@ -36,7 +36,9 @@ MeshNodesAlongSurface::MeshNodesAlongSurface(MeshLib::Mesh const& mesh, for (std::size_t i = 0; i < n_nodes; i++) { auto* node = mesh_nodes[i]; if (!sfc.isPntInBoundingVolume(*node, epsilon_radius)) + { continue; + } if (sfc.isPntInSfc(*node, epsilon_radius)) { _msh_node_ids.push_back(node->getID()); } diff --git a/MeshGeoToolsLib/MeshNodesOnPoint.cpp b/MeshGeoToolsLib/MeshNodesOnPoint.cpp index f8f56b5bfebaf7ed4c18adbc9d80f2c505fb8c3a..b530f08ad18cf1861b0181078cb9be027e177f43 100644 --- a/MeshGeoToolsLib/MeshNodesOnPoint.cpp +++ b/MeshGeoToolsLib/MeshNodesOnPoint.cpp @@ -20,11 +20,18 @@ MeshNodesOnPoint::MeshNodesOnPoint( { std::vector<std::size_t> vec_ids(mesh_grid.getPointsInEpsilonEnvironment(pnt, epsilon_radius)); if (search_all_nodes == SearchAllNodes::Yes) + { _msh_node_ids = vec_ids; - else { + } + else + { for (auto id : vec_ids) + { if (mesh.isBaseNode(id)) + { _msh_node_ids.push_back(id); + } + } } } diff --git a/MeshLib/CoordinateSystem.cpp b/MeshLib/CoordinateSystem.cpp index 5747dfa8c085607fd5f0d63ee26c36a842e048b6..bd0d8e04d7a68bab211e8cfce060b34f43457185 100644 --- a/MeshLib/CoordinateSystem.cpp +++ b/MeshLib/CoordinateSystem.cpp @@ -21,12 +21,18 @@ CoordinateSystem::CoordinateSystem(const Element &ele) if (bboxCoordSys.getDimension() >= ele.getDimension()) { _type = bboxCoordSys.getType(); } else { // e.g. zero volume elements - if (ele.getDimension()>=1) + if (ele.getDimension() >= 1) + { _type = CoordinateSystemType::X; - if (ele.getDimension()>=2) + } + if (ele.getDimension() >= 2) + { _type |= CoordinateSystemType::Y; - if (ele.getDimension()==3) + } + if (ele.getDimension() == 3) + { _type |= CoordinateSystemType::Z; + } } } @@ -40,13 +46,19 @@ unsigned char CoordinateSystem::getCoordinateSystem(const GeoLib::AABB &bbox) co // Therefore, the difference between the particular coordinates of the // points is modified by the unit in the last place towards zero. if (std::nexttoward(std::abs(pt_diff[0]), 0.0) > .0) + { coords |= CoordinateSystemType::X; + } if (std::nexttoward(std::abs(pt_diff[1]), 0.0) > .0) + { coords |= CoordinateSystemType::Y; + } if (std::nexttoward(std::abs(pt_diff[2]), 0.0) > .0) + { coords |= CoordinateSystemType::Z; + } return coords; } -} // end +} // namespace MeshLib diff --git a/MeshLib/CoordinateSystem.h b/MeshLib/CoordinateSystem.h index 289c500f702fd1a03c409f0db80c2b29ece65e25..e02e4f3767999130e9ef37fe13efe0c045e1519d 100644 --- a/MeshLib/CoordinateSystem.h +++ b/MeshLib/CoordinateSystem.h @@ -76,4 +76,4 @@ private: unsigned char _type; }; -} // MeshLib +} // namespace MeshLib diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp index 7044317130bf9532a4ff25a93ddc607c4afd5950..a0241ba4b54a5557d5d0c757949221a25d0c12bb 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.cpp +++ b/MeshLib/ElementCoordinatesMappingLocal.cpp @@ -26,7 +26,9 @@ void rotateToLocal(const MeshLib::RotationMatrix& matR2local, std::vector<MathLib::Point3d>& points) { for (auto& p : points) + { p = matR2local * p; + } } /// get a rotation matrix to the global coordinates @@ -44,9 +46,13 @@ void getRotationMatrixToGlobal(const unsigned element_dimension, MathLib::Vector3 xx(points[0], points[1]); xx.normalize(); if (global_dim == 2) + { GeoLib::compute2DRotationMatrixToX(xx, matR); + } else + { GeoLib::compute3DRotationMatrixToX(xx, matR); + } matR.transposeInPlace(); } else if (global_dim == 3 && element_dimension == 2) @@ -72,8 +78,10 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal( { assert(e.getDimension() <= global_dim); _points.reserve(e.getNumberOfNodes()); - for(unsigned i = 0; i < e.getNumberOfNodes(); i++) + for (unsigned i = 0; i < e.getNumberOfNodes(); i++) + { _points.emplace_back(*(e.getNode(i))); + } auto const element_dim = e.getDimension(); @@ -87,4 +95,4 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal( detail::rotateToLocal(_matR2global.transpose(), _points); } -} // MeshLib +} // namespace MeshLib diff --git a/MeshLib/ElementCoordinatesMappingLocal.h b/MeshLib/ElementCoordinatesMappingLocal.h index 3416396b8f3f39762a63f6da901e3a9109aacba5..24aab080d9ebf9a3f2e4e6ce821cecc12852ad80 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.h +++ b/MeshLib/ElementCoordinatesMappingLocal.h @@ -52,4 +52,4 @@ private: RotationMatrix _matR2global; }; -} +} // namespace MeshLib diff --git a/MeshLib/ElementStatus.cpp b/MeshLib/ElementStatus.cpp index 2933c1216db95fe10d7afe356efbcec19425a211..29bdff5e67e7b4c40ed63d2ac465add2a413a3b7 100644 --- a/MeshLib/ElementStatus.cpp +++ b/MeshLib/ElementStatus.cpp @@ -27,7 +27,9 @@ ElementStatus::ElementStatus(Mesh const* const mesh, bool hasAnyInactive) { const std::vector<MeshLib::Node*>& nodes(_mesh->getNodes()); for (auto node : nodes) + { _active_nodes.push_back(node->getNumberOfElements()); + } } ElementStatus::ElementStatus(Mesh const* const mesh, @@ -49,15 +51,25 @@ ElementStatus::ElementStatus(Mesh const* const mesh, _vec_active_eles.reserve(getNumberOfActiveElements()); const std::size_t nElems (_mesh->getNumberOfElements()); - for (std::size_t i=0; i<nElems; ++i) + for (std::size_t i = 0; i < nElems; ++i) + { if (_element_status[i]) - _vec_active_eles.push_back(const_cast<MeshLib::Element*>(_mesh->getElement(i))); + { + _vec_active_eles.push_back( + const_cast<MeshLib::Element*>(_mesh->getElement(i))); + } + } _vec_active_nodes.reserve(this->getNumberOfActiveNodes()); const std::size_t nNodes (_mesh->getNumberOfNodes()); - for (std::size_t i=0; i<nNodes; ++i) - if (_active_nodes[i]>0) - _vec_active_nodes.push_back(const_cast<MeshLib::Node*>(_mesh->getNode(i))); + for (std::size_t i = 0; i < nNodes; ++i) + { + if (_active_nodes[i] > 0) + { + _vec_active_nodes.push_back( + const_cast<MeshLib::Node*>(_mesh->getNode(i))); + } + } DBUG( "Deactivated %d materials and resulting active %d nodes and %d " @@ -70,7 +82,9 @@ ElementStatus::ElementStatus(Mesh const* const mesh, std::vector<MeshLib::Element*> const& ElementStatus::getActiveElements() const { if (_hasAnyInactive) + { return _vec_active_eles; + } return _mesh->getElements(); } @@ -78,7 +92,9 @@ std::vector<MeshLib::Element*> const& ElementStatus::getActiveElements() const std::vector<MeshLib::Node*> const& ElementStatus::getActiveNodes() const { if (_hasAnyInactive) + { return _vec_active_nodes; + } return _mesh->getNodes(); } @@ -91,9 +107,13 @@ std::vector<MeshLib::Element*> ElementStatus::getActiveElementsAtNode(std::size_ for (auto elem : _mesh->getNode(node_id)->getElements()) { if (active_elements.size() == nActiveElements) + { return active_elements; + } if (_element_status[elem->getID()]) + { active_elements.push_back(elem); + } } return active_elements; } @@ -132,4 +152,4 @@ bool ElementStatus::isActiveNode(MeshLib::Node const* node) const return _active_nodes[node->getID()]>0; } -} +} // namespace MeshLib diff --git a/MeshLib/ElementStatus.h b/MeshLib/ElementStatus.h index 16d0ca03bac171ad8f15560a66baae55f73081c7..d03007cd6a2d86503879547e50c18804108c40e7 100644 --- a/MeshLib/ElementStatus.h +++ b/MeshLib/ElementStatus.h @@ -71,4 +71,4 @@ protected: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/CellRule.cpp b/MeshLib/Elements/CellRule.cpp index d87b278410f2d7641c841eff34c608d5e72fc074..3407bcdadd0bad7786820e71594f3283b8888ac5 100644 --- a/MeshLib/Elements/CellRule.cpp +++ b/MeshLib/Elements/CellRule.cpp @@ -32,9 +32,11 @@ bool CellRule::testElementNodeOrder(const Element* e) const double s = MathLib::scalarProduct(FaceRule::getSurfaceNormal(face), cx); delete face; if (s >= 0) + { return false; + } } return true; } -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/CellRule.h b/MeshLib/Elements/CellRule.h index 106ea8f5b259a601ddc259132d6f662b1b788ed8..3f3f3f1673adeea894174b43c9e52db65d8908f4 100644 --- a/MeshLib/Elements/CellRule.h +++ b/MeshLib/Elements/CellRule.h @@ -31,4 +31,4 @@ public: static bool testElementNodeOrder(const Element* /*e*/); }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/EdgeReturn.cpp b/MeshLib/Elements/EdgeReturn.cpp index aa1fa698d8494b934cf0f9edff9c25af32610da9..af522280d5bb754eee22527fc015c78b46a619f6 100644 --- a/MeshLib/Elements/EdgeReturn.cpp +++ b/MeshLib/Elements/EdgeReturn.cpp @@ -45,5 +45,4 @@ const Element* QuadraticEdgeReturn::getEdge(const Element* e, unsigned i) return nullptr; } -} // end MeshLib - +} // namespace MeshLib diff --git a/MeshLib/Elements/EdgeReturn.h b/MeshLib/Elements/EdgeReturn.h index e647750710a18df125fc4310c685ce2a6193356b..794fbfe854b55deb7e9ebec0cf2be00d13c443c3 100644 --- a/MeshLib/Elements/EdgeReturn.h +++ b/MeshLib/Elements/EdgeReturn.h @@ -41,4 +41,4 @@ public: static const Element* getEdge(const Element* e, unsigned i); }; -} // end MeshLib +} // namespace MeshLib diff --git a/MeshLib/Elements/EdgeRule.h b/MeshLib/Elements/EdgeRule.h index 601d49c0fc966ce32fd1e553a5c72e959787291a..deea3585230daeb339c3f4e48e3c1531388bc42a 100644 --- a/MeshLib/Elements/EdgeRule.h +++ b/MeshLib/Elements/EdgeRule.h @@ -37,4 +37,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/Element.cpp b/MeshLib/Elements/Element.cpp index 5c9061bee495f3d4a2228e3856a99d59bdb80ec7..214fef1d6af9abb6bdd5c34c5a6c2298e1e6aa91 100644 --- a/MeshLib/Elements/Element.cpp +++ b/MeshLib/Elements/Element.cpp @@ -38,20 +38,24 @@ Element::~Element() void Element::setNeighbor(Element* neighbor, unsigned const face_id) { if (neighbor == this) + { return; + } this->_neighbors[face_id] = neighbor; } boost::optional<unsigned> Element::addNeighbor(Element* e) { - if (e == this || - e == nullptr || - e->getDimension() != this->getDimension()) + if (e == this || e == nullptr || e->getDimension() != this->getDimension()) + { return boost::optional<unsigned>(); + } if (this->hasNeighbor(e)) + { return boost::optional<unsigned>(); + } Node* face_nodes[3]; const unsigned nNodes (this->getNumberOfBaseNodes()); @@ -59,8 +63,10 @@ boost::optional<unsigned> Element::addNeighbor(Element* e) const Node* const* e_nodes = e->getNodes(); unsigned count(0); const unsigned dim (this->getDimension()); - for (unsigned i(0); i<nNodes; i++) - for (unsigned j(0); j<eNodes; j++) + for (unsigned i(0); i < nNodes; i++) + { + for (unsigned j(0); j < eNodes; j++) + { if (_nodes[i] == e_nodes[j]) { face_nodes[count] = _nodes[i]; @@ -71,6 +77,8 @@ boost::optional<unsigned> Element::addNeighbor(Element* e) return boost::optional<unsigned>(e->identifyFace(face_nodes)); } } + } + } return boost::optional<unsigned>(); } @@ -135,9 +143,13 @@ const Element* Element::getNeighbor(unsigned i) const unsigned Element::getNodeIDinElement(const MeshLib::Node* node) const { const unsigned nNodes (this->getNumberOfNodes()); - for (unsigned i(0); i<nNodes; i++) + for (unsigned i(0); i < nNodes; i++) + { if (node == _nodes[i]) + { return i; + } + } return std::numeric_limits<unsigned>::max(); } @@ -176,9 +188,13 @@ std::size_t Element::getNodeIndex(unsigned i) const bool Element::hasNeighbor(Element* elem) const { unsigned nNeighbors (this->getNumberOfNeighbors()); - for (unsigned i=0; i<nNeighbors; i++) - if (this->_neighbors[i]==elem) + for (unsigned i = 0; i < nNeighbors; i++) + { + if (this->_neighbors[i] == elem) + { return true; + } + } return false; } @@ -239,4 +255,4 @@ bool isPointInElementXY(MathLib::Point3d const& p, Element const& e) MeshLib::MeshElemType2String(e.getGeomType()).c_str()); return false; } -} +} // namespace MeshLib diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index e6ffd9b6b432744b582e82171231fc9641c32a65..f9a5c02f39ca21ff06cd603faa277dee77d377a2 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -230,4 +230,4 @@ protected: /// @return true if the \f$p' \in e'\f$ and false if \f$p' \notin e'\f$ bool isPointInElementXY(MathLib::Point3d const& p, Element const& e); -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/ElementErrorCode.h b/MeshLib/Elements/ElementErrorCode.h index 33d64dceea321c3cd02a5e29859ccc9ba0c40166..d3839ceebe203ba855cd17f1abd2ae0148dae88e 100644 --- a/MeshLib/Elements/ElementErrorCode.h +++ b/MeshLib/Elements/ElementErrorCode.h @@ -47,13 +47,21 @@ public: static std::string toString(const ElementErrorFlag e) { if (e == ElementErrorFlag::ZeroVolume) + { return "zero volume"; + } if (e == ElementErrorFlag::NonCoplanar) + { return "non coplanar nodes"; + } if (e == ElementErrorFlag::NonConvex) + { return "non-convex geometry"; + } if (e == ElementErrorFlag::NodeOrder) + { return "wrong node order"; + } return "nonspecified error"; } diff --git a/MeshLib/Elements/FaceRule.cpp b/MeshLib/Elements/FaceRule.cpp index 4b4e7073a25bd6dca0bf3b9179feb4996e470c8f..169f4020a427f5ac3e7383ca4b4e27659a0e7bb2 100644 --- a/MeshLib/Elements/FaceRule.cpp +++ b/MeshLib/Elements/FaceRule.cpp @@ -39,5 +39,4 @@ MathLib::Vector3 FaceRule::getSurfaceNormal(const Element* e) return MathLib::crossProduct(u, v); } -} /* namespace */ - +} // namespace MeshLib diff --git a/MeshLib/Elements/FaceRule.h b/MeshLib/Elements/FaceRule.h index 3f3e9477a73179dca21e3dc1825c0a9d650e687c..ee1d42768c07c1c468abf7e607f4ead2baef2372 100644 --- a/MeshLib/Elements/FaceRule.h +++ b/MeshLib/Elements/FaceRule.h @@ -44,4 +44,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/HexRule20.cpp b/MeshLib/Elements/HexRule20.cpp index fff23b23ed1e90f07561348de2665b4acc7a4037..186d083d0699dbdd732d78531a6a58c1dcc8f2fa 100644 --- a/MeshLib/Elements/HexRule20.cpp +++ b/MeshLib/Elements/HexRule20.cpp @@ -48,8 +48,10 @@ const Element* HexRule20::getFace(const Element* e, unsigned i) if (i < n_faces) { std::array<Node*, 8> nodes; - for (unsigned j=0; j<8; j++) + for (unsigned j = 0; j < 8; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } return new Quad8(nodes, e->getID()); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); diff --git a/MeshLib/Elements/HexRule20.h b/MeshLib/Elements/HexRule20.h index e9e47efa1daa7e9dc1828a782006207042ea0d00..7e8b89fc041438c2ae0a6d6cb796e9c0f6baadb6 100644 --- a/MeshLib/Elements/HexRule20.h +++ b/MeshLib/Elements/HexRule20.h @@ -65,4 +65,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/HexRule8.cpp b/MeshLib/Elements/HexRule8.cpp index 80f082d4599d9a3f05ea74434b014eef379058fa..3ca24117f89a285ce4b4920d2b798abd4e306bd8 100644 --- a/MeshLib/Elements/HexRule8.cpp +++ b/MeshLib/Elements/HexRule8.cpp @@ -52,8 +52,10 @@ const Element* HexRule8::getFace(const Element* e, unsigned i) if (i < n_faces) { std::array<Node*, 4> nodes; - for (unsigned j=0; j<4; j++) + for (unsigned j = 0; j < 4; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } return new Quad(nodes, e->getID()); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); @@ -93,12 +95,20 @@ unsigned HexRule8::identifyFace(Node const* const* _nodes, Node* nodes[3]) for (unsigned i=0; i<6; i++) { unsigned flag(0); - for (unsigned j=0; j<4; j++) - for (unsigned k=0; k<3; k++) + for (unsigned j = 0; j < 4; j++) + { + for (unsigned k = 0; k < 3; k++) + { if (_nodes[face_nodes[i][j]] == nodes[k]) + { flag++; - if (flag==3) + } + } + } + if (flag == 3) + { return i; + } } return std::numeric_limits<unsigned>::max(); } @@ -111,7 +121,9 @@ ElementErrorCode HexRule8::validate(const Element* e) for (unsigned i=0; i<6; ++i) { if (error_code.all()) + { break; + } const MeshLib::Element* quad (e->getFace(i)); error_code |= quad->validate(); diff --git a/MeshLib/Elements/HexRule8.h b/MeshLib/Elements/HexRule8.h index 5bc4b57bb613039bc323047c0d66272830700558..ebf9de650b24903ebb3cc926a49ba0981e5a5df3 100644 --- a/MeshLib/Elements/HexRule8.h +++ b/MeshLib/Elements/HexRule8.h @@ -98,4 +98,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/LineRule2.cpp b/MeshLib/Elements/LineRule2.cpp index b07f735d9d4fee501ec5ffc9087ad724c2393d29..bce51c7847a933ec8bc6dfb4d87186d501d88ba3 100644 --- a/MeshLib/Elements/LineRule2.cpp +++ b/MeshLib/Elements/LineRule2.cpp @@ -39,9 +39,13 @@ bool LineRule2::isPntInElement(Node const* const* nodes, unsigned LineRule2::identifyFace(Node const* const* _nodes, Node* nodes[1]) { if (nodes[0] == _nodes[0]) + { return 0; + } if (nodes[0] == _nodes[1]) + { return 1; + } return std::numeric_limits<unsigned>::max(); } diff --git a/MeshLib/Elements/LineRule2.h b/MeshLib/Elements/LineRule2.h index 44037e34c0a4ea8424395abaa62dc7a258fd4d98..d5576eaf76b1b2bb91272f355c42e8690fb151ff 100644 --- a/MeshLib/Elements/LineRule2.h +++ b/MeshLib/Elements/LineRule2.h @@ -67,4 +67,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/LineRule3.h b/MeshLib/Elements/LineRule3.h index 02b8f2a88852845e575d1f5a2180082ea2868ca2..0e961526d29b6d1fad6fd7cefe3b0f2724c1780e 100644 --- a/MeshLib/Elements/LineRule3.h +++ b/MeshLib/Elements/LineRule3.h @@ -37,4 +37,4 @@ public: using EdgeReturn = MeshLib::QuadraticEdgeReturn; }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/MapBulkElementPoint.cpp b/MeshLib/Elements/MapBulkElementPoint.cpp index edb024cf742860ca53591d6e2bc0e8074b89ca05..d487f3e50685370860c6d9d4fddce9f25c701e16 100644 --- a/MeshLib/Elements/MapBulkElementPoint.cpp +++ b/MeshLib/Elements/MapBulkElementPoint.cpp @@ -128,4 +128,4 @@ MathLib::Point3d getBulkElementPoint(MeshLib::Mesh const& /*mesh*/, { return MathLib::ORIGIN; } -} // end namespace ProcessLib +} // namespace MeshLib diff --git a/MeshLib/Elements/MapBulkElementPoint.h b/MeshLib/Elements/MapBulkElementPoint.h index 7ef88153aa2633b2185aee40fb44be52677b3e09..73bb897200b6bd489d7a9625360018342a9fc06c 100644 --- a/MeshLib/Elements/MapBulkElementPoint.h +++ b/MeshLib/Elements/MapBulkElementPoint.h @@ -63,4 +63,4 @@ MathLib::Point3d getBulkElementPoint(MeshLib::Mesh const& mesh, std::size_t bulk_element_id, std::size_t bulk_face_id, MathLib::WeightedPoint3D const& wp); -} // end namespace ProcessLib +} // namespace MeshLib diff --git a/MeshLib/Elements/PointRule1.cpp b/MeshLib/Elements/PointRule1.cpp index 2d99977118dabf0c5a3041372fa317b05ea2ad5c..9b150994edfd2a7b877460ca19dedb1f2be839d2 100644 --- a/MeshLib/Elements/PointRule1.cpp +++ b/MeshLib/Elements/PointRule1.cpp @@ -34,7 +34,9 @@ bool PointRule1::isPntInElement(Node const* const* nodes, unsigned PointRule1::identifyFace(Node const* const* _nodes, Node* nodes[1]) { if (nodes[0] == _nodes[0]) + { return 0; + } return std::numeric_limits<unsigned>::max(); } diff --git a/MeshLib/Elements/PointRule1.h b/MeshLib/Elements/PointRule1.h index b92a6b0bc746fbd7e2cb7dd45ecbd47e7551bd62..6f4713efcc13c89f45b12dfadf87d0ae2a2738d3 100644 --- a/MeshLib/Elements/PointRule1.h +++ b/MeshLib/Elements/PointRule1.h @@ -60,4 +60,4 @@ public: /// Calculates the length of a line static double computeVolume(Node const* const* _nodes); }; -} +} // namespace MeshLib diff --git a/MeshLib/Elements/PrismRule15.cpp b/MeshLib/Elements/PrismRule15.cpp index b5f595ce86244ec9b231d2eb5d27aefecc2bfedb..abf33926aaa1fc3ff8bfd269cee883399298be3b 100644 --- a/MeshLib/Elements/PrismRule15.cpp +++ b/MeshLib/Elements/PrismRule15.cpp @@ -47,11 +47,15 @@ const Element* PrismRule15::getFace(const Element* e, unsigned i) { unsigned nFaceNodes(PrismRule15::n_face_nodes[i]); auto** nodes = new Node*[nFaceNodes]; - for (unsigned j=0; j<nFaceNodes; j++) + for (unsigned j = 0; j < nFaceNodes; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } if (i == 0 || i == 4) + { return new Tri6(nodes, e->getID()); + } return new Quad8(nodes); } diff --git a/MeshLib/Elements/PrismRule15.h b/MeshLib/Elements/PrismRule15.h index b570c683d467dc59bc3703f500537c1c49c4f427..22569761d3a62e7b2a0827e9716e056eea7fd187 100644 --- a/MeshLib/Elements/PrismRule15.h +++ b/MeshLib/Elements/PrismRule15.h @@ -66,4 +66,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/PrismRule6.cpp b/MeshLib/Elements/PrismRule6.cpp index 0e958401dccee5cfb39d16c8ddd55b0108bb36ca..e6ed02e3657e8af64934ba50826fa6951504dcb2 100644 --- a/MeshLib/Elements/PrismRule6.cpp +++ b/MeshLib/Elements/PrismRule6.cpp @@ -49,11 +49,15 @@ const Element* PrismRule6::getFace(const Element* e, unsigned i) { unsigned nFaceNodes(PrismRule6::n_face_nodes[i]); auto** nodes = new Node*[nFaceNodes]; - for (unsigned j=0; j<nFaceNodes; j++) + for (unsigned j = 0; j < nFaceNodes; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } if (i == 0 || i == 4) + { return new Tri(nodes, e->getID()); + } return new Quad(nodes); } @@ -85,12 +89,21 @@ unsigned PrismRule6::identifyFace(Node const* const* _nodes, Node* nodes[3]) for (unsigned i=0; i<5; i++) { unsigned flag(0); - for (unsigned j=0; j<4; j++) - for (unsigned k=0; k<3; k++) - if (face_nodes[i][j] != 99 && _nodes[face_nodes[i][j]] == nodes[k]) + for (unsigned j = 0; j < 4; j++) + { + for (unsigned k = 0; k < 3; k++) + { + if (face_nodes[i][j] != 99 && + _nodes[face_nodes[i][j]] == nodes[k]) + { flag++; - if (flag==3) + } + } + } + if (flag == 3) + { return i; + } } return std::numeric_limits<unsigned>::max(); } @@ -104,9 +117,13 @@ ElementErrorCode PrismRule6::validate(const Element* e) { const auto* quad(dynamic_cast<const MeshLib::Quad*>(e->getFace(i))); if (quad) + { error_code |= quad->validate(); + } else + { error_code.set(ElementErrorFlag::NodeOrder); + } delete quad; } error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder(); diff --git a/MeshLib/Elements/PrismRule6.h b/MeshLib/Elements/PrismRule6.h index f9452b300011aac795c8e341c9deee020e1b7b3e..5e93fa003f4dc93dc8b81e45133174f129dcc34b 100644 --- a/MeshLib/Elements/PrismRule6.h +++ b/MeshLib/Elements/PrismRule6.h @@ -99,4 +99,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/PyramidRule13.cpp b/MeshLib/Elements/PyramidRule13.cpp index ab4765f931eee17bb1ac63b814e8c0aa5953a003..d3a8390bf65d997f3b9397cff06f4a8b4442ed06 100644 --- a/MeshLib/Elements/PyramidRule13.cpp +++ b/MeshLib/Elements/PyramidRule13.cpp @@ -46,11 +46,15 @@ const Element* PyramidRule13::getFace(const Element* e, unsigned i) { unsigned nFaceNodes(PyramidRule13::n_face_nodes[i]); auto** nodes = new Node*[nFaceNodes]; - for (unsigned j=0; j<nFaceNodes; j++) + for (unsigned j = 0; j < nFaceNodes; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } if (i < 4) + { return new Tri6(nodes, e->getID()); + } return new Quad8(nodes, e->getID()); } diff --git a/MeshLib/Elements/PyramidRule13.h b/MeshLib/Elements/PyramidRule13.h index 62ca80115900f2b1548bdf59fcae855650f64166..dffea470b058abc53eb138e53a7dc512c828ad6a 100644 --- a/MeshLib/Elements/PyramidRule13.h +++ b/MeshLib/Elements/PyramidRule13.h @@ -65,4 +65,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/PyramidRule5.cpp b/MeshLib/Elements/PyramidRule5.cpp index 5f6c2b9992fa378c059a8bb406a3deb8c5488da6..292cc7a4a9c3d60ceeffd75f14a8f1fc826f11ee 100644 --- a/MeshLib/Elements/PyramidRule5.cpp +++ b/MeshLib/Elements/PyramidRule5.cpp @@ -48,11 +48,15 @@ const Element* PyramidRule5::getFace(const Element* e, unsigned i) { unsigned nFaceNodes(PyramidRule5::n_face_nodes[i]); auto** nodes = new Node*[nFaceNodes]; - for (unsigned j=0; j<nFaceNodes; j++) + for (unsigned j = 0; j < nFaceNodes; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } if (i < 4) + { return new Tri(nodes, e->getID()); + } return new Quad(nodes, e->getID()); } @@ -81,12 +85,21 @@ unsigned PyramidRule5::identifyFace(Node const* const* _nodes, Node* nodes[3]) for (unsigned i=0; i<5; i++) { unsigned flag(0); - for (unsigned j=0; j<4; j++) - for (unsigned k=0; k<3; k++) - if (face_nodes[i][j] != 99 && _nodes[face_nodes[i][j]] == nodes[k]) + for (unsigned j = 0; j < 4; j++) + { + for (unsigned k = 0; k < 3; k++) + { + if (face_nodes[i][j] != 99 && + _nodes[face_nodes[i][j]] == nodes[k]) + { flag++; - if (flag==3) + } + } + } + if (flag == 3) + { return i; + } } return std::numeric_limits<unsigned>::max(); } @@ -103,7 +116,9 @@ ElementErrorCode PyramidRule5::validate(const Element* e) error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder(); } else + { error_code.set(ElementErrorFlag::NodeOrder); + } delete base; return error_code; diff --git a/MeshLib/Elements/PyramidRule5.h b/MeshLib/Elements/PyramidRule5.h index f89a6e31223d873c4e396acd9caced4c621fa26a..bdf2c0f941208718113c8e437785e0ada0d9857a 100644 --- a/MeshLib/Elements/PyramidRule5.h +++ b/MeshLib/Elements/PyramidRule5.h @@ -98,4 +98,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/QuadRule4.cpp b/MeshLib/Elements/QuadRule4.cpp index 5b3202b3f9b2d7edf52196a064ae7fbcf23ea989..5bc4e82e39e8af77536e62d0f0678d59369048ec 100644 --- a/MeshLib/Elements/QuadRule4.cpp +++ b/MeshLib/Elements/QuadRule4.cpp @@ -45,12 +45,20 @@ unsigned QuadRule4::identifyFace(Node const* const* _nodes, Node* nodes[3]) for (unsigned i=0; i<4; i++) { unsigned flag(0); - for (unsigned j=0; j<2; j++) - for (unsigned k=0; k<2; k++) + for (unsigned j = 0; j < 2; j++) + { + for (unsigned k = 0; k < 2; k++) + { if (_nodes[edge_nodes[i][j]] == nodes[k]) + { flag++; - if (flag==2) + } + } + } + if (flag == 2) + { return i; + } } return std::numeric_limits<unsigned>::max(); } @@ -65,11 +73,13 @@ ElementErrorCode QuadRule4::validate(const Element* e) // for collapsed quads (i.e. reduced to a line) this test might result // "false" as all four points are actually located on a line. if (!error_code[ElementErrorFlag::ZeroVolume]) + { error_code[ElementErrorFlag::NonConvex] = (!(MathLib::dividedByPlane( *_nodes[0], *_nodes[2], *_nodes[1], *_nodes[3]) && MathLib::dividedByPlane( *_nodes[1], *_nodes[3], *_nodes[0], *_nodes[2]))); + } error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder(); return error_code; } diff --git a/MeshLib/Elements/QuadRule4.h b/MeshLib/Elements/QuadRule4.h index 324d89cb6c854cdbcdaee04f8c080e9b364fb5f7..8a78c7a62ab8e0a6bfd21b912ca8c65958c36cc9 100644 --- a/MeshLib/Elements/QuadRule4.h +++ b/MeshLib/Elements/QuadRule4.h @@ -80,4 +80,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/QuadRule8.h b/MeshLib/Elements/QuadRule8.h index 54e125e344f550f387b21865e41b6f833da84f7a..ce7f906198c626b92de33bfd0d9b5c8ca752fa35 100644 --- a/MeshLib/Elements/QuadRule8.h +++ b/MeshLib/Elements/QuadRule8.h @@ -49,4 +49,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/QuadRule9.h b/MeshLib/Elements/QuadRule9.h index cf04c23cc5aaf0906b831c52fea086348653832d..ebb77c291222309f8da233ff6abe1b079b2736f4 100644 --- a/MeshLib/Elements/QuadRule9.h +++ b/MeshLib/Elements/QuadRule9.h @@ -41,4 +41,4 @@ public: static const CellType cell_type = CellType::QUAD9; }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/TemplateElement-impl.h b/MeshLib/Elements/TemplateElement-impl.h index a461bdea23b28721335be6e707ecaaab6cc68cd8..72114bb14f1717e078f570ff1fde505ff72e32d9 100644 --- a/MeshLib/Elements/TemplateElement-impl.h +++ b/MeshLib/Elements/TemplateElement-impl.h @@ -38,11 +38,15 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(const TemplateElement &e) : Element(e.getID()) { this->_nodes = new Node*[n_all_nodes]; - for (unsigned i=0; i<n_all_nodes; i++) + for (unsigned i = 0; i < n_all_nodes; i++) + { this->_nodes[i] = e._nodes[i]; + } this->_neighbors = new Element*[getNumberOfNeighbors()]; - for (unsigned i=0; i<getNumberOfNeighbors(); i++) + for (unsigned i = 0; i < getNumberOfNeighbors(); i++) + { this->_neighbors[i] = e._neighbors[i]; + } this->_content = e.getContent(); } @@ -53,9 +57,14 @@ namespace detail template<unsigned N> bool isEdge(unsigned const (&edge_nodes)[N], unsigned idx1, unsigned idx2) { - - if (edge_nodes[0]==idx1 && edge_nodes[1]==idx2) return true; - if (edge_nodes[1]==idx1 && edge_nodes[0]==idx2) return true; + if (edge_nodes[0] == idx1 && edge_nodes[1] == idx2) + { + return true; + } + if (edge_nodes[1] == idx1 && edge_nodes[0] == idx2) + { + return true; + } return false; } @@ -74,11 +83,12 @@ bool TemplateElement<ELEMENT_RULE>::isEdge(unsigned idx1, unsigned idx2) const { for (unsigned i(0); i<getNumberOfEdges(); i++) { - if (detail::isEdge(ELEMENT_RULE::edge_nodes[i], idx1, idx2)) return true; + if (detail::isEdge(ELEMENT_RULE::edge_nodes[i], idx1, idx2)) + { + return true; + } } return false; } - -} // MeshLib - +} // namespace MeshLib diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index f69de977b48a28a98fabc05455d8cbd0f300608e..ef7d53d33f8404747ea330e12247f175371b3c50 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -142,8 +142,10 @@ public: inline Node* getEdgeNode(unsigned edge_id, unsigned node_id) const override { if (getNumberOfEdges() > 0) + { return const_cast<Node*>( this->_nodes[ELEMENT_RULE::edge_nodes[edge_id][node_id]]); + } return nullptr; } @@ -159,6 +161,6 @@ public: }; -} // MeshLib +} // namespace MeshLib #include "TemplateElement-impl.h" diff --git a/MeshLib/Elements/TetRule10.cpp b/MeshLib/Elements/TetRule10.cpp index be50ad3bb0341beb1d06c56d5d664ebfef842e5e..cb67eeda4b118a3ec34ca0b341a6db4bc97eb1a4 100644 --- a/MeshLib/Elements/TetRule10.cpp +++ b/MeshLib/Elements/TetRule10.cpp @@ -42,8 +42,10 @@ const Element* TetRule10::getFace(const Element* e, unsigned i) if (i<n_faces) { std::array<Node*,6> nodes; - for (unsigned j=0; j<6; j++) + for (unsigned j = 0; j < 6; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } return new Tri6(nodes, e->getID()); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); diff --git a/MeshLib/Elements/TetRule10.h b/MeshLib/Elements/TetRule10.h index 6fad37db15f75dd20e27f033f3bd7c1737fdadb7..47cb951e1d3a4168f56643969ac5deb576a03c27 100644 --- a/MeshLib/Elements/TetRule10.h +++ b/MeshLib/Elements/TetRule10.h @@ -60,4 +60,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/TetRule4.cpp b/MeshLib/Elements/TetRule4.cpp index 694dbb78d5b09a5c09d3718806c2116b0f2a73d7..dbac2ef6eebaebc5b7896e5632bb90702174349e 100644 --- a/MeshLib/Elements/TetRule4.cpp +++ b/MeshLib/Elements/TetRule4.cpp @@ -44,8 +44,10 @@ const Element* TetRule4::getFace(const Element* e, unsigned i) if (i<n_faces) { std::array<Node*,3> nodes; - for (unsigned j=0; j<3; j++) + for (unsigned j = 0; j < 3; j++) + { nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j])); + } return new Tri(nodes, e->getID()); } ERR("Error in MeshLib::Element::getFace() - Index %d does not exist.", i); @@ -69,12 +71,20 @@ unsigned TetRule4::identifyFace(Node const* const* _nodes, Node* nodes[3]) for (unsigned i=0; i<4; i++) { unsigned flag(0); - for (unsigned j=0; j<3; j++) - for (unsigned k=0; k<3; k++) + for (unsigned j = 0; j < 3; j++) + { + for (unsigned k = 0; k < 3; k++) + { if (_nodes[face_nodes[i][j]] == nodes[k]) + { flag++; - if (flag==3) + } + } + } + if (flag == 3) + { return i; + } } return std::numeric_limits<unsigned>::max(); } diff --git a/MeshLib/Elements/TetRule4.h b/MeshLib/Elements/TetRule4.h index f44241b1a8effa94caf77c0de6ced3a2c212b6cd..76ac9ac5930eedc03df275885900219b537b79ac 100644 --- a/MeshLib/Elements/TetRule4.h +++ b/MeshLib/Elements/TetRule4.h @@ -93,4 +93,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/TriRule3.cpp b/MeshLib/Elements/TriRule3.cpp index 0b836b16c5cb39b5081bde401536eca383d66b4f..605bafc4a8d5539ae9d9251e2266f9a049329c28 100644 --- a/MeshLib/Elements/TriRule3.cpp +++ b/MeshLib/Elements/TriRule3.cpp @@ -41,12 +41,20 @@ unsigned TriRule3::identifyFace(Node const* const* _nodes, Node* nodes[3]) for (unsigned i=0; i<3; i++) { unsigned flag(0); - for (unsigned j=0; j<2; j++) - for (unsigned k=0; k<2; k++) + for (unsigned j = 0; j < 2; j++) + { + for (unsigned k = 0; k < 2; k++) + { if (_nodes[edge_nodes[i][j]] == nodes[k]) + { flag++; - if (flag==2) + } + } + } + if (flag == 2) + { return i; + } } return std::numeric_limits<unsigned>::max(); } diff --git a/MeshLib/Elements/TriRule3.h b/MeshLib/Elements/TriRule3.h index 7e7e1e86f780cda639a5501728e42c8f0fc7a7cb..67178beb3acb9d4da378fcf7e9da93b44d0686b1 100644 --- a/MeshLib/Elements/TriRule3.h +++ b/MeshLib/Elements/TriRule3.h @@ -81,4 +81,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/TriRule6.h b/MeshLib/Elements/TriRule6.h index a64fafed359388369fd711d0c22d37eadf0f163c..6323752aeb956e9ea6351c00c974b3677969c43d 100644 --- a/MeshLib/Elements/TriRule6.h +++ b/MeshLib/Elements/TriRule6.h @@ -52,4 +52,4 @@ public: }; /* class */ -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/Elements/VertexRule.h b/MeshLib/Elements/VertexRule.h index b1a23173508a8252ffed2e9cbcb4e3cb695e3ddb..a8bc192db635eb438fa5c0663b1aad84a8df65fd 100644 --- a/MeshLib/Elements/VertexRule.h +++ b/MeshLib/Elements/VertexRule.h @@ -38,4 +38,4 @@ public: }; -} +} // namespace MeshLib diff --git a/MeshLib/IO/Legacy/MeshIO.cpp b/MeshLib/IO/Legacy/MeshIO.cpp index 9eab42dfd8d74604faf045a3720b602fdc08ef8d..a238f0a422ab1782d62a03909068a7aa2d22d09c 100644 --- a/MeshLib/IO/Legacy/MeshIO.cpp +++ b/MeshLib/IO/Legacy/MeshIO.cpp @@ -69,7 +69,9 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) // check keywords if (line_string.find("#STOP") != std::string::npos) + { break; + } if (line_string.find("$NODES") != std::string::npos) { double x, y, z, double_dummy; @@ -87,7 +89,9 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) nodes.push_back(node); iss >> s; if (s.find("$AREA") != std::string::npos) + { iss >> double_dummy; + } } } else if (line_string.find("$ELEMENTS") != std::string::npos) @@ -121,7 +125,9 @@ MeshLib::Mesh* MeshIO::loadMeshFromFile(const std::string& file_name) { ERR ("MeshIO::loadMeshFromFile() - File did not contain element information."); for (auto& node : nodes) + { delete node; + } return nullptr; } @@ -156,7 +162,9 @@ std::size_t MeshIO::readMaterialID(std::istream & in) const { unsigned index, material_id; if (!(in >> index >> material_id)) + { return std::numeric_limits<std::size_t>::max(); + } return material_id; } @@ -168,7 +176,9 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, do { if (!(in >> elem_type_str)) + { return nullptr; + } elem_type = MeshLib::String2MeshElemType(elem_type_str); } while (elem_type == MeshLib::MeshElemType::INVALID); @@ -179,72 +189,114 @@ MeshLib::Element* MeshIO::readElement(std::istream& in, { case MeshLib::MeshElemType::LINE: { for (int i = 0; i < 2; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } // edge_nodes array will be deleted from Line object auto** edge_nodes = new MeshLib::Node*[2]; for (unsigned k(0); k < 2; ++k) + { edge_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Line(edge_nodes); break; } case MeshLib::MeshElemType::TRIANGLE: { for (int i = 0; i < 3; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } auto** tri_nodes = new MeshLib::Node*[3]; for (unsigned k(0); k < 3; ++k) + { tri_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Tri(tri_nodes); break; } case MeshLib::MeshElemType::QUAD: { for (int i = 0; i < 4; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } auto** quad_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k < 4; ++k) + { quad_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Quad(quad_nodes); break; } case MeshLib::MeshElemType::TETRAHEDRON: { for (int i = 0; i < 4; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } auto** tet_nodes = new MeshLib::Node*[4]; for (unsigned k(0); k < 4; ++k) + { tet_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Tet(tet_nodes); break; } case MeshLib::MeshElemType::HEXAHEDRON: { for (int i = 0; i < 8; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } auto** hex_nodes = new MeshLib::Node*[8]; for (unsigned k(0); k < 8; ++k) + { hex_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Hex(hex_nodes); break; } case MeshLib::MeshElemType::PYRAMID: { for (int i = 0; i < 5; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } auto** pyramid_nodes = new MeshLib::Node*[5]; for (unsigned k(0); k < 5; ++k) + { pyramid_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Pyramid(pyramid_nodes); break; } case MeshLib::MeshElemType::PRISM: { for (int i = 0; i < 6; ++i) + { if (!(in >> idx[i])) + { return nullptr; + } + } auto** prism_nodes = new MeshLib::Node*[6]; for (unsigned k(0); k < 6; ++k) + { prism_nodes[k] = nodes[idx[k]]; + } elem = new MeshLib::Prism(prism_nodes); break; } @@ -309,14 +361,20 @@ void MeshIO::writeElements( out << ele_vector_size << "\n"; for (std::size_t i(0); i < ele_vector_size; ++i) { out << i << " "; - if (! material_ids) + if (!material_ids) + { out << "0 "; + } else + { out << (*material_ids)[i] << " "; + } out << this->ElemType2StringOutput(ele_vec[i]->getGeomType()) << " "; unsigned nElemNodes (ele_vec[i]->getNumberOfBaseNodes()); - for(std::size_t j = 0; j < nElemNodes; ++j) + for (std::size_t j = 0; j < nElemNodes; ++j) + { out << ele_vec[i]->getNode(j)->getID() << " "; + } out << "\n"; } } @@ -324,22 +382,36 @@ void MeshIO::writeElements( std::string MeshIO::ElemType2StringOutput(const MeshLib::MeshElemType t) const { if (t == MeshLib::MeshElemType::LINE) + { return "line"; + } if (t == MeshLib::MeshElemType::QUAD) + { return "quad"; + } if (t == MeshLib::MeshElemType::HEXAHEDRON) + { return "hex"; + } if (t == MeshLib::MeshElemType::TRIANGLE) + { return "tri"; + } if (t == MeshLib::MeshElemType::TETRAHEDRON) + { return "tet"; + } if (t == MeshLib::MeshElemType::PRISM) + { return "pris"; + } if (t == MeshLib::MeshElemType::PYRAMID) + { return "pyra"; + } return "none"; } } // end namespace Legacy } // end namespace IO -} // end namespace MeshLin +} // namespace MeshLib diff --git a/MeshLib/IO/MPI_IO/PropertyVectorMetaData.h b/MeshLib/IO/MPI_IO/PropertyVectorMetaData.h index b9e1e5321a0ed5b5fd2e204477cb3d746dcb7a88..301a79334255d9278c1076a60478c6d7c7871b97 100644 --- a/MeshLib/IO/MPI_IO/PropertyVectorMetaData.h +++ b/MeshLib/IO/MPI_IO/PropertyVectorMetaData.h @@ -84,12 +84,16 @@ inline boost::optional<PropertyVectorMetaData> readPropertyVectorMetaData( // read the size of the name of the PropertyVector std::string::size_type s = 0; if (!is.read(reinterpret_cast<char*>(&s), sizeof(std::string::size_type))) + { return boost::optional<PropertyVectorMetaData>(); + } PropertyVectorMetaData pvmd; char *dummy = new char[s]; if (!is.read(dummy, s)) + { return boost::none; + } pvmd.property_name = std::string(dummy, s); delete [] dummy; @@ -132,13 +136,16 @@ inline boost::optional<PropertyVectorPartitionMetaData> readPropertyVectorPartitionMetaData(std::istream& is) { PropertyVectorPartitionMetaData pvpmd; - if (!is.read(reinterpret_cast<char*>(&pvpmd.offset), - sizeof(unsigned long))) + if (!is.read(reinterpret_cast<char*>(&pvpmd.offset), sizeof(unsigned long))) + { return boost::optional<PropertyVectorPartitionMetaData>(); + } if (!is.read(reinterpret_cast<char*>(&pvpmd.number_of_tuples), sizeof(unsigned long))) + { return boost::optional<PropertyVectorPartitionMetaData>(); + } return boost::optional<PropertyVectorPartitionMetaData>(pvpmd); } -} -} +} // namespace IO +} // namespace MeshLib diff --git a/MeshLib/IO/VtkIO/PVDFile.cpp b/MeshLib/IO/VtkIO/PVDFile.cpp index 49c4da0659ef6d5b19a199bbc1234ed89c9ab60e..897b157fb39ee103ce88d65fe55bb2990b3214e2 100644 --- a/MeshLib/IO/VtkIO/PVDFile.cpp +++ b/MeshLib/IO/VtkIO/PVDFile.cpp @@ -37,10 +37,13 @@ void PVDFile::addVTUFile(const std::string &vtu_fname, double timestep) " <Collection>\n"; for (auto const& pair : _datasets) - fh << " <DataSet timestep=\"" << pair.first << "\" group=\"\" part=\"0\" file=\"" << pair.second << "\"/>\n"; + { + fh << " <DataSet timestep=\"" << pair.first + << "\" group=\"\" part=\"0\" file=\"" << pair.second << "\"/>\n"; + } fh << " </Collection>\n</VTKFile>\n"; } -} // IO -} // MeshLib +} // namespace IO +} // namespace MeshLib diff --git a/MeshLib/IO/readMeshFromFile.cpp b/MeshLib/IO/readMeshFromFile.cpp index eeccf095ff6dd63d0239ceb08b74954e7e309995..fdd4d70eec53c5434782ee34d5182f57ba2689a8 100644 --- a/MeshLib/IO/readMeshFromFile.cpp +++ b/MeshLib/IO/readMeshFromFile.cpp @@ -76,7 +76,9 @@ MeshLib::Mesh* readMeshFromFileSerial(const std::string &file_name) } if (BaseLib::hasFileExtension("vtu", file_name)) + { return MeshLib::IO::VtuInterface::readVTUFile(file_name); + } ERR("readMeshFromFile(): Unknown mesh file format in file %s.", file_name.c_str()); return nullptr; diff --git a/MeshLib/Location.h b/MeshLib/Location.h index b73b4ffe385bcdf78a7e3bc926cf5e722a390487..83b6a8fff6d93e7ea8a6268899bb01438f915a97 100644 --- a/MeshLib/Location.h +++ b/MeshLib/Location.h @@ -50,8 +50,14 @@ struct Location inline bool operator<(const Location& left, const Location& right) { - if (left.mesh_id != right.mesh_id) return left.mesh_id < right.mesh_id; - if (left.item_type != right.item_type) return left.item_type < right.item_type; + if (left.mesh_id != right.mesh_id) + { + return left.mesh_id < right.mesh_id; + } + if (left.item_type != right.item_type) + { + return left.item_type < right.item_type; + } return left.item_id < right.item_id; } diff --git a/MeshLib/Mesh.cpp b/MeshLib/Mesh.cpp index de759c6875662db438e6d402a21d28f3ba194fce..3c8ec24b80f8c3a7c984a291f33c61582613acb1 100644 --- a/MeshLib/Mesh.cpp +++ b/MeshLib/Mesh.cpp @@ -55,7 +55,9 @@ Mesh::Mesh(std::string name, recalculateMaxBaseNodeId(); } if ((_n_base_nodes == 0 && hasNonlinearElement()) || isNonlinear()) + { this->checkNonlinearNodeIDs(); + } this->setDimension(); this->setElementsConnectedToNodes(); //this->setNodesConnectedByEdges(); @@ -75,8 +77,10 @@ Mesh::Mesh(const Mesh &mesh) { const std::vector<Node*>& nodes (mesh.getNodes()); const std::size_t nNodes (nodes.size()); - for (unsigned i=0; i<nNodes; ++i) + for (unsigned i = 0; i < nNodes; ++i) + { _nodes[i] = new Node(*nodes[i]); + } const std::vector<Element*>& elements (mesh.getElements()); const std::size_t nElements (elements.size()); @@ -84,11 +88,16 @@ Mesh::Mesh(const Mesh &mesh) { const std::size_t nElemNodes = elements[i]->getNumberOfNodes(); _elements[i] = elements[i]->clone(); - for (unsigned j=0; j<nElemNodes; ++j) + for (unsigned j = 0; j < nElemNodes; ++j) + { _elements[i]->_nodes[j] = _nodes[elements[i]->getNode(j)->getID()]; + } } - if (_mesh_dimension==0) this->setDimension(); + if (_mesh_dimension == 0) + { + this->setDimension(); + } this->setElementsConnectedToNodes(); //this->setNodesConnectedByEdges(); //this->setNodesConnectedByElements(); @@ -98,12 +107,16 @@ Mesh::Mesh(const Mesh &mesh) Mesh::~Mesh() { const std::size_t nElements (_elements.size()); - for (std::size_t i=0; i<nElements; ++i) + for (std::size_t i = 0; i < nElements; ++i) + { delete _elements[i]; + } const std::size_t nNodes (_nodes.size()); - for (std::size_t i=0; i<nNodes; ++i) + for (std::size_t i = 0; i < nNodes; ++i) + { delete _nodes[i]; + } } void Mesh::addNode(Node* node) @@ -117,8 +130,10 @@ void Mesh::addElement(Element* elem) // add element information to nodes unsigned nNodes (elem->getNumberOfNodes()); - for (unsigned i=0; i<nNodes; ++i) + for (unsigned i = 0; i < nNodes; ++i) + { elem->_nodes[i]->addElement(elem); + } } void Mesh::resetNodeIDs() @@ -146,16 +161,22 @@ void Mesh::recalculateMaxBaseNodeId() void Mesh::resetElementIDs() { const std::size_t nElements (this->_elements.size()); - for (unsigned i=0; i<nElements; ++i) + for (unsigned i = 0; i < nElements; ++i) + { _elements[i]->setID(i); + } } void Mesh::setDimension() { const std::size_t nElements (_elements.size()); - for (unsigned i=0; i<nElements; ++i) + for (unsigned i = 0; i < nElements; ++i) + { if (_elements[i]->getDimension() > _mesh_dimension) + { _mesh_dimension = _elements[i]->getDimension(); + } + } } void Mesh::setElementsConnectedToNodes() @@ -163,16 +184,22 @@ void Mesh::setElementsConnectedToNodes() for (auto& element : _elements) { const unsigned nNodes(element->getNumberOfNodes()); - for (unsigned j=0; j<nNodes; ++j) + for (unsigned j = 0; j < nNodes; ++j) + { element->_nodes[j]->addElement(element); + } } } void Mesh::resetElementsConnectedToNodes() { for (auto& node : _nodes) + { if (node) + { node->clearElements(); + } + } this->setElementsConnectedToNodes(); } @@ -239,15 +266,24 @@ void Mesh::setNodesConnectedByEdges() MeshLib::Node const* node_k = conn_ele->getNode(k); bool is_in_vector (false); const std::size_t nConnNodes (conn_set.size()); - for (unsigned l(0); l<nConnNodes; ++l) + for (unsigned l(0); l < nConnNodes; ++l) + { if (node_k == conn_set[l]) + { is_in_vector = true; - if (is_in_vector) continue; + } + } + if (is_in_vector) + { + continue; + } if (conn_ele->getNumberOfBaseNodes() == conn_ele->getNumberOfNodes()) { if (conn_ele->isEdge(idx, k)) + { conn_set.push_back(const_cast<MeshLib::Node*>(node_k)); + } } else { @@ -259,13 +295,22 @@ void Mesh::setNodesConnectedByEdges() { auto edge_node = edge->getNode(m); if (edge_node == node || edge_node == node_k) + { match++; + } } if (match != 2) + { continue; + } conn_set.push_back(const_cast<MeshLib::Node*>(node_k)); - for (unsigned m=edge->getNumberOfBaseNodes(); m<edge->getNumberOfNodes(); m++) - conn_set.push_back(const_cast<MeshLib::Node*>(edge->getNode(m))); + for (unsigned m = edge->getNumberOfBaseNodes(); + m < edge->getNumberOfNodes(); + m++) + { + conn_set.push_back( + const_cast<MeshLib::Node*>(edge->getNode(m))); + } break; } } @@ -293,7 +338,9 @@ void Mesh::setNodesConnectedByElements() Node* const* const single_elem_nodes = element->getNodes(); std::size_t const nnodes = element->getNumberOfNodes(); for (std::size_t n = 0; n < nnodes; n++) + { adjacent_nodes.push_back(single_elem_nodes[n]); + } } // Make nodes unique and sorted by their ids. @@ -314,7 +361,9 @@ void Mesh::checkNonlinearNodeIDs() const for (unsigned i=e->getNumberOfBaseNodes(); i<e->getNumberOfNodes(); i++) { if (e->getNodeIndex(i) >= getNumberOfBaseNodes()) + { continue; + } WARN( "Found a nonlinear node whose ID (%d) is smaller than the " @@ -346,7 +395,9 @@ void scaleMeshPropertyVector(MeshLib::Mesh & mesh, } for (auto& v : *mesh.getProperties().getPropertyVector<double>(property_name)) + { v *= factor; + } } PropertyVector<int> const* materialIDs(Mesh const& mesh) @@ -421,4 +472,4 @@ std::unique_ptr<MeshLib::Mesh> createMeshFromElementSelection( return mesh; } -} +} // namespace MeshLib diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index 7f9e8c77bf290b2ea617fe1ecf6b6b0d89f1cdc3..44d0059239ed2f5cec76dcc62a56f4278830e7b2 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -212,18 +212,26 @@ void addPropertyToMesh(MeshLib::Mesh& mesh, std::string const& name, std::vector<T> const& values) { if (item_type == MeshLib::MeshItemType::Node) + { if (mesh.getNumberOfNodes() != values.size() / number_of_components) + { OGS_FATAL( "Error number of nodes (%u) does not match the number of " "tuples (%u).", mesh.getNumberOfNodes(), values.size() / number_of_components); + } + } if (item_type == MeshLib::MeshItemType::Cell) + { if (mesh.getNumberOfElements() != values.size() / number_of_components) + { OGS_FATAL( "Error number of elements (%u) does not match the number of " "tuples (%u).", mesh.getNumberOfElements(), values.size() / number_of_components); + } + } auto* const property = mesh.getProperties().createNewPropertyVector<T>( name, item_type, number_of_components); @@ -246,8 +254,10 @@ PropertyVector<T>* getOrCreateMeshProperty(Mesh& mesh, int const number_of_components) { if (property_name.empty()) + { OGS_FATAL( "Trying to get or to create a mesh property with empty name."); + } auto numberOfMeshItems = [&mesh, &item_type]() -> std::size_t { switch (item_type) @@ -303,4 +313,4 @@ PropertyVector<int> const* materialIDs(Mesh const& mesh); std::unique_ptr<MeshLib::Mesh> createMeshFromElementSelection( std::string mesh_name, std::vector<MeshLib::Element*> const& elements); -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/MeshEditing/AddLayerToMesh.cpp b/MeshLib/MeshEditing/AddLayerToMesh.cpp index 5b80d7e719f0692c158e22812b36d4ce76fa51a4..c36313f87676da5702911f0a6fd0c1acea6614bb 100644 --- a/MeshLib/MeshEditing/AddLayerToMesh.cpp +++ b/MeshLib/MeshEditing/AddLayerToMesh.cpp @@ -50,7 +50,9 @@ MeshLib::Element* extrudeElement(std::vector<MeshLib::Node*> const& subsfc_nodes std::map<std::size_t, std::size_t> const& subsfc_sfc_id_map) { if (sfc_elem.getDimension() > 2) + { return nullptr; + } const unsigned nElemNodes(sfc_elem.getNumberOfBaseNodes()); auto new_nodes = std::unique_ptr<MeshLib::Node* []> { @@ -67,11 +69,17 @@ MeshLib::Element* extrudeElement(std::vector<MeshLib::Node*> const& subsfc_nodes } if (sfc_elem.getGeomType() == MeshLib::MeshElemType::LINE) + { return new MeshLib::Quad(new_nodes.release()); + } if (sfc_elem.getGeomType() == MeshLib::MeshElemType::TRIANGLE) + { return new MeshLib::Prism(new_nodes.release()); + } if (sfc_elem.getGeomType() == MeshLib::MeshElemType::QUAD) + { return new MeshLib::Hex(new_nodes.release()); + } return nullptr; } @@ -103,9 +111,12 @@ MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness, std::string const prop_name("bulk_node_ids"); if (mesh.getDimension() == 3) + { sfc_mesh.reset(MeshLib::MeshSurfaceExtraction::getMeshSurface( mesh, dir, angle, prop_name)); - else { + } + else + { sfc_mesh = (on_top) ? std::make_unique<MeshLib::Mesh>(mesh) : std::unique_ptr<MeshLib::Mesh>( MeshLib::createFlippedMesh(mesh)); @@ -159,9 +170,11 @@ MeshLib::Mesh* addLayerToMesh(MeshLib::Mesh const& mesh, double thickness, // *** insert new layer elements into subsfc_mesh std::vector<MeshLib::Element*> const& sfc_elements(sfc_mesh->getElements()); std::size_t const n_sfc_elements(sfc_elements.size()); - for (std::size_t k(0); k<n_sfc_elements; ++k) + for (std::size_t k(0); k < n_sfc_elements; ++k) + { subsfc_elements.push_back(extrudeElement( subsfc_nodes, *sfc_elements[k], *node_id_pv, subsfc_sfc_id_map)); + } auto new_mesh = new MeshLib::Mesh(name, subsfc_nodes, subsfc_elements); diff --git a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp index a1106a992c1a178c2abcf0eab0219209347ea074..06cc122804a5646865ec1f301d4e15f460eba604 100644 --- a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp +++ b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp @@ -35,8 +35,11 @@ T_ELEMENT* createLinearElement(MeshLib::Element const* e, { auto const n_base_nodes = T_ELEMENT::n_base_nodes; auto** nodes = new MeshLib::Node*[n_base_nodes]; - for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) - nodes[i] = const_cast<MeshLib::Node*>(vec_new_nodes[e->getNode(i)->getID()]); + for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++) + { + nodes[i] = + const_cast<MeshLib::Node*>(vec_new_nodes[e->getNode(i)->getID()]); + } return new T_ELEMENT(nodes); } @@ -93,10 +96,14 @@ std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(MeshLib::Mesh const& org_mesh for (auto name : src_properties.getPropertyVectorNames()) { if (!src_properties.existsPropertyVector<double>(name)) + { continue; + } auto const* src_prop = src_properties.getPropertyVector<double>(name); if (src_prop->getMeshItemType() != MeshLib::MeshItemType::Node) + { continue; + } auto const n_src_comp = src_prop->getNumberOfComponents(); auto new_prop = @@ -108,7 +115,10 @@ std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(MeshLib::Mesh const& org_mesh for (unsigned i=0; i<org_mesh.getNumberOfBaseNodes(); i++) { for (int j = 0; j < n_src_comp; j++) - (*new_prop)[i*n_src_comp+j] = (*src_prop)[i*n_src_comp+j]; + { + (*new_prop)[i * n_src_comp + j] = + (*src_prop)[i * n_src_comp + j]; + } } } diff --git a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp index eb8a3e8ebc9999f702af049b597efbdb217b74c3..6039697280f9cc8b093a2579068b059a72f5e530 100644 --- a/MeshLib/MeshEditing/DuplicateMeshComponents.cpp +++ b/MeshLib/MeshEditing/DuplicateMeshComponents.cpp @@ -26,7 +26,10 @@ std::vector<MeshLib::Node*> copyNodeVector(const std::vector<MeshLib::Node*> &no std::vector<MeshLib::Node*> new_nodes; new_nodes.reserve(nNodes); for (std::size_t k = 0; k < nNodes; ++k) - new_nodes.push_back(new MeshLib::Node(nodes[k]->getCoords(), new_nodes.size())); + { + new_nodes.push_back( + new MeshLib::Node(nodes[k]->getCoords(), new_nodes.size())); + } return new_nodes; } @@ -36,26 +39,42 @@ std::vector<MeshLib::Element*> copyElementVector(const std::vector<MeshLib::Elem std::vector<MeshLib::Element*> new_elements; new_elements.reserve(nElements); for (std::size_t k = 0; k < nElements; ++k) + { new_elements.push_back(copyElement(elements[k], nodes)); + } return new_elements; } MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes) { if (element->getGeomType() == MeshElemType::LINE) + { return copyElement<MeshLib::Line>(element, nodes); + } if (element->getGeomType() == MeshElemType::TRIANGLE) + { return copyElement<MeshLib::Tri>(element, nodes); + } if (element->getGeomType() == MeshElemType::QUAD) + { return copyElement<MeshLib::Quad>(element, nodes); + } if (element->getGeomType() == MeshElemType::TETRAHEDRON) + { return copyElement<MeshLib::Tet>(element, nodes); + } if (element->getGeomType() == MeshElemType::HEXAHEDRON) + { return copyElement<MeshLib::Hex>(element, nodes); + } if (element->getGeomType() == MeshElemType::PYRAMID) + { return copyElement<MeshLib::Pyramid>(element, nodes); + } if (element->getGeomType() == MeshElemType::PRISM) + { return copyElement<MeshLib::Prism>(element, nodes); + } ERR ("Error: Unknown element type."); return nullptr; @@ -65,8 +84,10 @@ template <typename E> MeshLib::Element* copyElement(MeshLib::Element const*const element, const std::vector<MeshLib::Node*> &nodes) { auto** new_nodes = new MeshLib::Node*[element->getNumberOfNodes()]; - for (unsigned i=0; i<element->getNumberOfNodes(); ++i) + for (unsigned i = 0; i < element->getNumberOfNodes(); ++i) + { new_nodes[i] = nodes[element->getNode(i)->getID()]; + } return new E(new_nodes); } diff --git a/MeshLib/MeshEditing/ElementValueModification.cpp b/MeshLib/MeshEditing/ElementValueModification.cpp index 20bcd5cb2f2b44716abc20ec90a95b34574ad37a..14e81677322fb83ac0a76ff24e3f88ec99868102 100644 --- a/MeshLib/MeshEditing/ElementValueModification.cpp +++ b/MeshLib/MeshEditing/ElementValueModification.cpp @@ -62,7 +62,9 @@ bool ElementValueModification::replace(MeshLib::Mesh &mesh, for (std::size_t i = 0; i < n_property_tuples; ++i) { if ((*property_value_vec)[i] == old_value) + { (*property_value_vec)[i] = new_value; + } } return true; @@ -94,12 +96,16 @@ std::size_t ElementValueModification::condense(MeshLib::Mesh &mesh) std::vector<int> reverse_mapping(value_mapping.back() + 1, 0); std::size_t const nValues(value_mapping.size()); for (std::size_t i = 0; i < nValues; ++i) + { reverse_mapping[value_mapping[i]] = i; + } std::size_t const n_property_values(property_value_vector->size()); for (std::size_t i = 0; i < n_property_values; ++i) + { (*property_value_vector)[i] = reverse_mapping[(*property_value_vector)[i]]; + } return nValues; } @@ -123,7 +129,9 @@ std::size_t ElementValueModification::setByElementType(MeshLib::Mesh &mesh, Mesh for (std::size_t k(0); k < elements.size(); k++) { if (elements[k]->getGeomType() != ele_type) + { continue; + } (*property_value_vector)[k] = new_value; cnt++; } diff --git a/MeshLib/MeshEditing/FlipElements.cpp b/MeshLib/MeshEditing/FlipElements.cpp index 38b03b229231eab7b0c6f671b7c3e83afbaac63b..ef3f62359cc8f19c3c71f8ab48395eefc937edc8 100644 --- a/MeshLib/MeshEditing/FlipElements.cpp +++ b/MeshLib/MeshEditing/FlipElements.cpp @@ -22,20 +22,28 @@ std::unique_ptr<MeshLib::Element> createFlippedElement( MeshLib::Element const& elem, std::vector<MeshLib::Node*> const& nodes) { if (elem.getDimension() > 2) + { return nullptr; + } unsigned const n_nodes(elem.getNumberOfNodes()); auto elem_nodes = std::make_unique<MeshLib::Node* []>(n_nodes); for (unsigned i = 0; i < n_nodes; ++i) + { elem_nodes[i] = nodes[elem.getNode(i)->getID()]; + } std::swap(elem_nodes[0], elem_nodes[1]); if (elem.getGeomType() == MeshElemType::LINE) + { return std::make_unique<MeshLib::Line>(elem_nodes.release(), elem.getID()); + } if (elem.getGeomType() == MeshElemType::TRIANGLE) + { return std::make_unique<MeshLib::Tri>(elem_nodes.release(), elem.getID()); + } if (elem.getGeomType() == MeshElemType::QUAD) { std::swap(elem_nodes[2], elem_nodes[3]); @@ -48,7 +56,9 @@ std::unique_ptr<MeshLib::Element> createFlippedElement( std::unique_ptr<MeshLib::Mesh> createFlippedMesh(MeshLib::Mesh const& mesh) { if (mesh.getDimension() > 2) + { return nullptr; + } std::vector<MeshLib::Node*> new_nodes (MeshLib::copyNodeVector(mesh.getNodes())); std::vector<MeshLib::Element*> const& elems (mesh.getElements()); @@ -56,8 +66,11 @@ std::unique_ptr<MeshLib::Mesh> createFlippedMesh(MeshLib::Mesh const& mesh) std::size_t n_elems (mesh.getNumberOfElements()); new_elems.reserve(n_elems); - for (std::size_t i=0; i<n_elems; ++i) - new_elems.push_back(createFlippedElement(*elems[i], new_nodes).release()); + for (std::size_t i = 0; i < n_elems; ++i) + { + new_elems.push_back( + createFlippedElement(*elems[i], new_nodes).release()); + } return std::make_unique<MeshLib::Mesh>("FlippedElementMesh", new_nodes, new_elems, mesh.getProperties()); diff --git a/MeshLib/MeshEditing/FlipElements.h b/MeshLib/MeshEditing/FlipElements.h index 0fe3c7374a71abd8b3e60aabc44ab3f5034c381f..8229b036cf1dd1e72dd5d070343c2ea097488156 100644 --- a/MeshLib/MeshEditing/FlipElements.h +++ b/MeshLib/MeshEditing/FlipElements.h @@ -37,4 +37,4 @@ std::unique_ptr<MeshLib::Element> createFlippedElement(MeshLib::Element const& e */ std::unique_ptr<MeshLib::Mesh> createFlippedMesh(MeshLib::Mesh const& mesh); -} +} // namespace MeshLib diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp index 2967602299de38ca0733322fadd7be9fc28780f8..4f8c3fb5fd9f38fc023b1bb920c250fda53edf46 100644 --- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp +++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp @@ -74,7 +74,9 @@ bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh& dest_mesh) const } } if (dest_properties->size() != dest_mesh.getNumberOfElements()) + { dest_properties->resize(dest_mesh.getNumberOfElements()); + } interpolatePropertiesForMesh(dest_mesh, *dest_properties); @@ -102,7 +104,9 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh( { MeshLib::Element& dest_element(*dest_elements[k]); if (dest_element.getGeomType() == MeshElemType::LINE) + { continue; + } // compute axis aligned bounding box around the current element const GeoLib::AABB elem_aabb( @@ -132,10 +136,12 @@ void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh( } if (cnt == 0) + { OGS_FATAL( "Mesh2MeshInterpolation: Could not find values in source mesh " "for the element %d.", k); + } dest_properties[k] = average_value / cnt; } } diff --git a/MeshLib/MeshEditing/MeshRevision.cpp b/MeshLib/MeshEditing/MeshRevision.cpp index cf31521da71082738e9d1186ac0227a3f8be93d7..6a7fbbe704389ed14ebdb4f986e544a0c288e062 100644 --- a/MeshLib/MeshEditing/MeshRevision.cpp +++ b/MeshLib/MeshEditing/MeshRevision.cpp @@ -49,8 +49,12 @@ unsigned MeshRevision::getNumberOfCollapsableNodes(double eps) const std::size_t nNodes(id_map.size()); unsigned count(0); for (std::size_t i = 0; i < nNodes; ++i) + { if (i != id_map[i]) + { count++; + } + } return count; } @@ -58,7 +62,9 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, double eps, unsigned min_elem_dim) { if (this->_mesh.getNumberOfElements() == 0) + { return nullptr; + } // original data std::vector<MeshLib::Element*> const& elements(this->_mesh.getElements()); @@ -96,14 +102,18 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, return nullptr; } if (material_vec) + { new_material_vec->insert(new_material_vec->end(), n_new_elements, (*material_vec)[k]); + } } else { new_elements.push_back(MeshLib::copyElement(elem, new_nodes)); // copy material values if (material_vec) + { new_material_vec->push_back((*material_vec)[k]); + } } } else if (n_unique_nodes < elem->getNumberOfBaseNodes() && n_unique_nodes>1) { @@ -111,7 +121,9 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, elem, n_unique_nodes, new_nodes, new_elements, min_elem_dim) ); if (!material_vec) + { continue; + } new_material_vec->insert(new_material_vec->end(), n_new_elements, (*material_vec)[k]); } else @@ -120,8 +132,10 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, this->resetNodeIDs(); if (!new_elements.empty()) - return new MeshLib::Mesh( - new_mesh_name, new_nodes, new_elements, new_properties); + { + return new MeshLib::Mesh(new_mesh_name, new_nodes, new_elements, + new_properties); + } this->cleanUp(new_nodes, new_elements); return nullptr; @@ -130,7 +144,9 @@ MeshLib::Mesh* MeshRevision::simplifyMesh(const std::string &new_mesh_name, MeshLib::Mesh* MeshRevision::subdivideMesh(const std::string &new_mesh_name) const { if (this->_mesh.getNumberOfElements() == 0) + { return nullptr; + } // original data std::vector<MeshLib::Element*> const& elements(this->_mesh.getElements()); @@ -163,20 +179,26 @@ MeshLib::Mesh* MeshRevision::subdivideMesh(const std::string &new_mesh_name) con } // copy material values if (!material_vec) + { continue; + } new_material_vec->insert(new_material_vec->end(), n_new_elements, (*material_vec)[k]); } else { new_elements.push_back(MeshLib::copyElement(elem, new_nodes)); // copy material values if (material_vec) + { new_material_vec->push_back((*material_vec)[k]); + } } } if (!new_elements.empty()) - return new MeshLib::Mesh( - new_mesh_name, new_nodes, new_elements, new_properties); + { + return new MeshLib::Mesh(new_mesh_name, new_nodes, new_elements, + new_properties); + } this->cleanUp(new_nodes, new_elements); return nullptr; @@ -197,7 +219,9 @@ std::vector<std::size_t> MeshRevision::collapseNodeIndices(double eps) const { MeshLib::Node const*const node(nodes[k]); if (node->getID() != k) + { continue; + } std::vector<std::vector<MeshLib::Node*> const*> node_vectors( grid.getPntVecsOfGridCellsIntersectingCube(*node, half_eps)); @@ -211,16 +235,23 @@ std::vector<std::size_t> MeshRevision::collapseNodeIndices(double eps) const MeshLib::Node const*const test_node(cell_vector[j]); // are node indices already identical (i.e. nodes will be collapsed) if (id_map[node->getID()] == id_map[test_node->getID()]) + { continue; + } // if test_node has already been collapsed to another node x, ignore it // (if the current node would need to be collapsed with x it would already have happened when x was tested) if (test_node->getID() != id_map[test_node->getID()]) + { continue; + } // calc distance - if (MathLib::sqrDist(node->getCoords(), test_node->getCoords()) < sqr_eps) + if (MathLib::sqrDist(node->getCoords(), + test_node->getCoords()) < sqr_eps) + { id_map[test_node->getID()] = node->getID(); + } } } } @@ -244,7 +275,9 @@ std::vector<MeshLib::Node*> MeshRevision::constructNewNodesArray(const std::vect } // the other nodes are not copied and get the index of the nodes they will have been collapsed with else + { nodes[k]->setID(nodes[id_map[k]]->getID()); + } } return new_nodes; } @@ -255,12 +288,16 @@ unsigned MeshRevision::getNumberOfUniqueNodes(MeshLib::Element const*const eleme unsigned count(nNodes); for (unsigned i = 0; i < nNodes - 1; ++i) + { for (unsigned j = i + 1; j < nNodes; ++j) + { if (element->getNode(i)->getID() == element->getNode(j)->getID()) { count--; break; } + } + } return count; } @@ -269,7 +306,9 @@ void MeshRevision::resetNodeIDs() const std::size_t nNodes(this->_mesh.getNumberOfNodes()); const std::vector<MeshLib::Node*> &nodes(_mesh.getNodes()); for (std::size_t i = 0; i < nNodes; ++i) + { nodes[i]->setID(i); + } } std::size_t MeshRevision::subdivideElement( @@ -278,13 +317,21 @@ std::size_t MeshRevision::subdivideElement( std::vector<MeshLib::Element*> & elements) const { if (element->getGeomType() == MeshElemType::QUAD) + { return this->subdivideQuad(element, nodes, elements); + } if (element->getGeomType() == MeshElemType::HEXAHEDRON) + { return this->subdivideHex(element, nodes, elements); + } if (element->getGeomType() == MeshElemType::PYRAMID) + { return this->subdividePyramid(element, nodes, elements); + } if (element->getGeomType() == MeshElemType::PRISM) + { return this->subdividePrism(element, nodes, elements); + } return 0; } @@ -306,9 +353,13 @@ std::size_t MeshRevision::reduceElement(MeshLib::Element const*const element, (element->getGeomType() == MeshElemType::TETRAHEDRON)) { if (n_unique_nodes == 3 && min_elem_dim < 3) + { elements.push_back (this->constructTri(element, nodes)); + } else if (min_elem_dim == 1) - elements.push_back (this->constructLine(element, nodes)); + { + elements.push_back(this->constructLine(element, nodes)); + } return 1; } if (element->getGeomType() == MeshElemType::HEXAHEDRON) @@ -434,8 +485,10 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, if (n_unique_nodes == 7) { // reduce to prism + pyramid - for (unsigned i=0; i<7; ++i) - for (unsigned j=i+1; j<8; ++j) + for (unsigned i = 0; i < 7; ++i) + { + for (unsigned j = i + 1; j < 8; ++j) + { if (org_elem->getNode(i)->getID() == org_elem->getNode(j)->getID()) { const std::array<unsigned,4> base_nodes (this->lutHexCuttingQuadNodes(i,j)); @@ -447,7 +500,10 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, pyr_nodes[4] = nodes[org_elem->getNode(i)->getID()]; new_elements.push_back (new MeshLib::Pyramid(pyr_nodes)); - if (i<4 && j>=4) std::swap(i,j); + if (i < 4 && j >= 4) + { + std::swap(i, j); + } auto** prism_nodes = new MeshLib::Node*[6]; prism_nodes[0] = nodes[org_elem->getNode(base_nodes[0])->getID()]; prism_nodes[1] = nodes[org_elem->getNode(base_nodes[3])->getID()]; @@ -458,6 +514,8 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, new_elements.push_back (new MeshLib::Prism(prism_nodes)); return 2; } + } + } } else if (n_unique_nodes == 6) { @@ -494,12 +552,16 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, delete face; } // reduce to four tets -> divide into 2 prisms such that each has one collapsed node - for (unsigned i=0; i<7; ++i) - for (unsigned j=i+1; j<8; ++j) + for (unsigned i = 0; i < 7; ++i) + { + for (unsigned j = i + 1; j < 8; ++j) + { if (org_elem->getNode(i)->getID() == org_elem->getNode(j)->getID()) { - for (unsigned k=i; k<7; ++k) - for (unsigned l=k+1; l<8; ++l) + for (unsigned k = i; k < 7; ++k) + { + for (unsigned l = k + 1; l < 8; ++l) + { if (!(i==k && j==l) && org_elem->isEdge(i,j) && org_elem->isEdge(k,l) && org_elem->getNode(k)->getID() == org_elem->getNode(l)->getID()) { @@ -534,7 +596,11 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, delete prism2; return nNewElements; } + } + } } + } + } } else if (n_unique_nodes == 5) { @@ -555,7 +621,9 @@ unsigned MeshRevision::reduceHex(MeshLib::Element const*const org_elem, new_elements.push_back(new MeshLib::Tet(tet1_nodes)); } else + { new_elements.push_back(tet1); + } auto** tet2_nodes = new MeshLib::Node*[4]; tet2_nodes[0] = (tet_changed) ? nodes[first_four_nodes[0]] : nodes[first_four_nodes[1]]; @@ -597,12 +665,18 @@ void MeshRevision::reducePyramid(MeshLib::Element const*const org_elem, { MeshLib::Element* elem (this->constructFourNodeElement(org_elem, nodes, min_elem_dim)); if (elem) - new_elements.push_back (elem); + { + new_elements.push_back(elem); + } } else if (n_unique_nodes == 3 && min_elem_dim < 3) + { new_elements.push_back (this->constructTri(org_elem, nodes)); + } else if (n_unique_nodes == 2 && min_elem_dim == 1) - new_elements.push_back (this->constructLine(org_elem, nodes)); + { + new_elements.push_back(this->constructLine(org_elem, nodes)); + } return; } @@ -631,8 +705,10 @@ unsigned MeshRevision::reducePrism(MeshLib::Element const*const org_elem, // pyramid, otherwise it will be two tets if (n_unique_nodes == 5) { - for (unsigned i=0; i<5; ++i) - for (unsigned j=i+1; j<6; ++j) + for (unsigned i = 0; i < 5; ++i) + { + for (unsigned j = i + 1; j < 6; ++j) + { if (i!=j && org_elem->getNode(i)->getID() == org_elem->getNode(j)->getID()) { // non triangle edge collapsed @@ -669,17 +745,25 @@ unsigned MeshRevision::reducePrism(MeshLib::Element const*const org_elem, addTetrahedron(l_offset, k_offset, i, k); return 2; } + } + } } else if (n_unique_nodes == 4) { MeshLib::Element* elem (this->constructFourNodeElement(org_elem, nodes, min_elem_dim)); if (elem) - new_elements.push_back (elem); + { + new_elements.push_back(elem); + } } else if (n_unique_nodes == 3 && min_elem_dim < 3) + { new_elements.push_back (this->constructTri(org_elem, nodes)); + } else if (n_unique_nodes == 2 && min_elem_dim == 1) - new_elements.push_back (this->constructLine(org_elem, nodes)); + { + new_elements.push_back(this->constructLine(org_elem, nodes)); + } return 1; } @@ -723,7 +807,10 @@ MeshLib::Element* MeshRevision::constructTri(MeshLib::Element const*const elemen break; } } - if (tri_nodes[2]) break; + if (tri_nodes[2]) + { + break; + } } } assert(tri_nodes[2] != nullptr); @@ -740,8 +827,10 @@ MeshLib::Element* MeshRevision::constructFourNodeElement( new_nodes[count++] = nodes[element->getNode(0)->getID()]; for (unsigned i=1; i<element->getNumberOfBaseNodes(); ++i) { - if (count>3) + if (count > 3) + { break; + } bool unique_node (true); for (unsigned j=0; j<i; ++j) { @@ -752,7 +841,9 @@ MeshLib::Element* MeshRevision::constructFourNodeElement( } } if (unique_node) - new_nodes[count++] = nodes[element->getNode(i)->getID()];; + { + new_nodes[count++] = nodes[element->getNode(i)->getID()]; + }; } // test if quad or tet @@ -764,7 +855,9 @@ MeshLib::Element* MeshRevision::constructFourNodeElement( for (unsigned i=1; i<3; ++i) { if (elem->validate().none()) + { return elem; + } // change node order if not convex MeshLib::Node* tmp = new_nodes[i + 1]; @@ -774,7 +867,9 @@ MeshLib::Element* MeshRevision::constructFourNodeElement( return elem; } if (!isQuad) + { return new MeshLib::Tet(new_nodes); + } // is quad but min elem dim == 3 return nullptr; } @@ -786,11 +881,17 @@ unsigned MeshRevision::findPyramidTopNode(MeshLib::Element const& element, for (std::size_t i=0; i<nNodes; ++i) { bool top_node=true; - for (unsigned j=0; j<4; ++j) + for (unsigned j = 0; j < 4; ++j) + { if (element.getNode(i)->getID() == base_node_ids[j]) - top_node=false; + { + top_node = false; + } + } if (top_node) + { return i; + } } return std::numeric_limits<unsigned>::max(); // should never be reached if called correctly } @@ -852,27 +953,43 @@ const std::pair<unsigned, unsigned> MeshRevision::lutHexBackNodes( unsigned MeshRevision::lutPrismThirdNode(unsigned id1, unsigned id2) const { if ((id1 == 0 && id2 == 1) || (id1 == 1 && id2 == 2)) + { return 2; + } if ((id1 == 1 && id2 == 2) || (id1 == 2 && id2 == 1)) + { return 0; + } if ((id1 == 0 && id2 == 2) || (id1 == 2 && id2 == 0)) + { return 1; + } if ((id1 == 3 && id2 == 4) || (id1 == 4 && id2 == 3)) + { return 5; + } if ((id1 == 4 && id2 == 5) || (id1 == 5 && id2 == 4)) + { return 3; + } if ((id1 == 3 && id2 == 5) || (id1 == 5 && id2 == 3)) + { return 4; + } return std::numeric_limits<unsigned>::max(); } void MeshRevision::cleanUp(std::vector<MeshLib::Node*> &new_nodes, std::vector<MeshLib::Element*> &new_elements) const { for (auto& new_element : new_elements) + { delete new_element; + } for (auto& new_node : new_nodes) + { delete new_node; + } } } // end namespace MeshLib diff --git a/MeshLib/MeshEditing/MeshRevision.h b/MeshLib/MeshEditing/MeshRevision.h index ef961829dda1a9fbf1221d151d51229f3b95ce50..adcaa308d6536b3b632ae8cf47293b62c172c8a3 100644 --- a/MeshLib/MeshEditing/MeshRevision.h +++ b/MeshLib/MeshEditing/MeshRevision.h @@ -190,4 +190,4 @@ private: static const std::array<unsigned,8> _hex_diametral_nodes; }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshEditing/RemoveMeshComponents.cpp b/MeshLib/MeshEditing/RemoveMeshComponents.cpp index 6b5aa7b6bc49c6377d51a0346e9ac90001a11ce2..8432fe2248fa0409214cba541d8f7fb7bdc72696 100644 --- a/MeshLib/MeshEditing/RemoveMeshComponents.cpp +++ b/MeshLib/MeshEditing/RemoveMeshComponents.cpp @@ -28,18 +28,26 @@ std::vector<MeshLib::Element*> excludeElementCopy( std::vector<MeshLib::Element*> vec_dest_eles(vec_src_eles.size()-vec_removed.size()); unsigned cnt (0); - for (std::size_t i=0; i<vec_removed[0]; ++i) + for (std::size_t i = 0; i < vec_removed[0]; ++i) + { vec_dest_eles[cnt++] = vec_src_eles[i]; - for (std::size_t i=1; i<vec_removed.size(); ++i) - for (std::size_t j=vec_removed[i-1]+1; j<vec_removed[i]; ++j) + } + for (std::size_t i = 1; i < vec_removed.size(); ++i) + { + for (std::size_t j = vec_removed[i - 1] + 1; j < vec_removed[i]; ++j) + { vec_dest_eles[cnt++] = vec_src_eles[j]; - for (std::size_t i=vec_removed.back()+1; i<vec_src_eles.size(); ++i) + } + } + for (std::size_t i = vec_removed.back() + 1; i < vec_src_eles.size(); ++i) + { vec_dest_eles[cnt++] = vec_src_eles[i]; + } return vec_dest_eles; } -} // details +} // namespace details MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, const std::vector<std::size_t> &removed_element_ids, const std::string &new_mesh_name) { @@ -88,7 +96,9 @@ MeshLib::Mesh* removeElements(const MeshLib::Mesh& mesh, const std::vector<std:: MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::size_t> &del_nodes_idx, const std::string &new_mesh_name) { if (del_nodes_idx.empty()) + { return nullptr; + } // copy node and element objects std::vector<MeshLib::Node*> new_nodes = MeshLib::copyNodeVector(mesh.getNodes()); @@ -108,14 +118,19 @@ MeshLib::Mesh* removeNodes(const MeshLib::Mesh &mesh, const std::vector<std::siz // check unused nodes due to element deletion std::vector<bool> node_delete_flag(new_nodes.size(), true); for (auto e : new_elems) { - for (unsigned i=0; i<e->getNumberOfNodes(); i++) + for (unsigned i = 0; i < e->getNumberOfNodes(); i++) + { node_delete_flag[e->getNodeIndex(i)] = false; + } } // delete unused nodes for (std::size_t i=0; i<new_nodes.size(); i++) { - if (!node_delete_flag[i]) continue; + if (!node_delete_flag[i]) + { + continue; + } delete new_nodes[i]; new_nodes[i] = nullptr; } diff --git a/MeshLib/MeshEnums.cpp b/MeshLib/MeshEnums.cpp index eaeae99bb360db13c5ccb05959474d6c4166a959..0f7ddefbaa6edb3c95a8de6a28d2e4adea90bb5d 100644 --- a/MeshLib/MeshEnums.cpp +++ b/MeshLib/MeshEnums.cpp @@ -19,63 +19,111 @@ namespace MeshLib { const std::string MeshElemType2String(const MeshElemType t) { if (t == MeshElemType::POINT) + { return "Point"; + } if (t == MeshElemType::LINE) + { return "Line"; + } if (t == MeshElemType::QUAD) + { return "Quad"; + } if (t == MeshElemType::HEXAHEDRON) + { return "Hexahedron"; + } if (t == MeshElemType::TRIANGLE) + { return "Triangle"; + } if (t == MeshElemType::TETRAHEDRON) + { return "Tetrahedron"; + } if (t == MeshElemType::PRISM) + { return "Prism"; + } if (t == MeshElemType::PYRAMID) + { return "Pyramid"; + } return "none"; } const std::string MeshElemType2StringShort(const MeshElemType t) { if (t == MeshElemType::POINT) + { return "point"; + } if (t == MeshElemType::LINE) + { return "line"; + } if (t == MeshElemType::QUAD) + { return "quad"; + } if (t == MeshElemType::HEXAHEDRON) + { return "hex"; + } if (t == MeshElemType::TRIANGLE) + { return "tri"; + } if (t == MeshElemType::TETRAHEDRON) + { return "tet"; + } if (t == MeshElemType::PRISM) + { return "pris"; + } if (t == MeshElemType::PYRAMID) + { return "pyra"; + } return "none"; } MeshElemType String2MeshElemType(const std::string &s) { if (s == "point" || s == "Point") + { return MeshElemType::POINT; + } if (s == "line" || s == "Line") + { return MeshElemType::LINE; + } if (s == "quad" || s == "Quadrilateral") + { return MeshElemType::QUAD; + } if (s == "hex" || s == "Hexahedron") + { return MeshElemType::HEXAHEDRON; + } if (s == "tri" || s == "Triangle") + { return MeshElemType::TRIANGLE; + } if (s == "tet" || s == "Tetrahedron") + { return MeshElemType::TETRAHEDRON; + } if (s == "pris" || s == "Prism") + { return MeshElemType::PRISM; + } if (s == "pyra" || s == "Pyramid") + { return MeshElemType::PYRAMID; + } return MeshElemType::INVALID; } @@ -97,7 +145,9 @@ std::vector<std::string> getMeshElemTypeStringsShort() { std::vector<std::string> vec; for (MeshElemType eleType : getMeshElemTypes()) + { vec.push_back(MeshElemType2StringShort(eleType)); + } return vec; } @@ -133,16 +183,26 @@ const std::string CellType2String(const CellType t) const std::string MeshQualityType2String(const MeshQualityType t) { if (t == MeshQualityType::ELEMENTSIZE) + { return "ElementSize"; + } if (t == MeshQualityType::EDGERATIO) + { return "EdgeRatio"; + } if (t == MeshQualityType::EQUIANGLESKEW) + { return "EquiAngleSkew"; + } if (t == MeshQualityType::RADIUSEDGERATIO) + { return "RadiusEdgeRatio"; + } if (t == MeshQualityType::SIZEDIFFERENCE) + { return "SizeDifference"; + } return "none"; } -} +} // namespace MeshLib diff --git a/MeshLib/MeshEnums.h b/MeshLib/MeshEnums.h index 03b341ce6cadefebd8295b8bf7afd9d120d1ab58..20f48c0cbd229f8059349e5bc6faa1bc8159f037 100644 --- a/MeshLib/MeshEnums.h +++ b/MeshLib/MeshEnums.h @@ -106,4 +106,4 @@ const std::string CellType2String(const CellType t); const std::string MeshQualityType2String(const MeshQualityType t); -} +} // namespace MeshLib diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp index 16c563cb0486d7dab9697d07799758358d21c531..2e9a038571a8667505980f851fae364f8564a9b2 100644 --- a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp @@ -41,7 +41,9 @@ bool LayeredMeshGenerator::createLayers( double noDataReplacementValue) { if (mesh.getDimension() != 2) + { return false; + } bool result = createRasterLayers(mesh, rasters, minimum_thickness, noDataReplacementValue); std::for_each(rasters.begin(), rasters.end(), [](GeoLib::Raster const*const raster){ delete raster; }); @@ -52,7 +54,9 @@ std::unique_ptr<MeshLib::Mesh> LayeredMeshGenerator::getMesh(std::string const& mesh_name) const { if (_nodes.empty() || _elements.empty()) + { return nullptr; + } MeshLib::Properties properties; if (_materials.size() == _elements.size()) @@ -95,7 +99,9 @@ MeshLib::Node* LayeredMeshGenerator::getNewLayerNode(MeshLib::Node const& dem_no if ((std::abs(elevation - raster.getHeader().no_data) < std::numeric_limits<double>::epsilon()) || (elevation - last_layer_node[2] < _minimum_thickness)) + { return new MeshLib::Node(last_layer_node); + } return new MeshLib::Node(dem_node[0], dem_node[1], elevation, new_node_id); } diff --git a/MeshLib/MeshGenerators/LayeredVolume.cpp b/MeshLib/MeshGenerators/LayeredVolume.cpp index 48d766a7cec85ffeb5180ad6994cf6f36a51f8e1..633d49b1c01d9ee5e2f3589c58976b603943825b 100644 --- a/MeshLib/MeshGenerators/LayeredVolume.cpp +++ b/MeshLib/MeshGenerators/LayeredVolume.cpp @@ -33,27 +33,37 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh, double noDataReplacementValue) { if (mesh.getDimension() != 2) + { return false; + } _elevation_epsilon = calcEpsilon(*rasters[0], *rasters.back()); if (_elevation_epsilon <= 0) + { return false; + } // remove line elements, only tri + quad remain MeshLib::ElementSearch ex(mesh); ex.searchByElementType(MeshLib::MeshElemType::LINE); std::unique_ptr<MeshLib::Mesh> top( removeElements(mesh, ex.getSearchedElementIDs(), "MeshLayer")); - if (top==nullptr) + if (top == nullptr) + { top = std::make_unique<MeshLib::Mesh>(mesh); + } if (!MeshLib::MeshLayerMapper::layerMapping( *top, *rasters.back(), noDataReplacementValue)) + { return false; + } std::unique_ptr<MeshLib::Mesh> bottom(new MeshLib::Mesh(*top)); if (!MeshLib::MeshLayerMapper::layerMapping(*bottom, *rasters[0], 0)) + { return false; + } this->_minimum_thickness = minimum_thickness; _nodes = MeshLib::copyNodeVector(bottom->getNodes()); @@ -67,8 +77,10 @@ bool LayeredVolume::createRasterLayers(const MeshLib::Mesh &mesh, // map each layer and attach to subsurface mesh const std::size_t nRasters (rasters.size()); - for (std::size_t i=1; i<nRasters; ++i) + for (std::size_t i = 1; i < nRasters; ++i) + { this->addLayerToMesh(*top, i, *rasters[i]); + } // close boundaries between layers this->addLayerBoundaries(*top, nRasters); @@ -84,8 +96,13 @@ void LayeredVolume::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned layer const std::size_t node_id_offset (_nodes.size()); const std::size_t last_layer_node_offset (node_id_offset-nNodes); - for (std::size_t i=0; i<nNodes; ++i) - _nodes.push_back(getNewLayerNode(*nodes[i], *_nodes[last_layer_node_offset + i], raster, _nodes.size())); + for (std::size_t i = 0; i < nNodes; ++i) + { + _nodes.push_back(getNewLayerNode(*nodes[i], + *_nodes[last_layer_node_offset + i], + raster, + _nodes.size())); + } const std::vector<MeshLib::Element*> &layer_elements (dem_mesh.getElements()); for (MeshLib::Element* elem : layer_elements) @@ -118,8 +135,10 @@ void LayeredVolume::addLayerBoundaries(const MeshLib::Mesh &layer, std::size_t n for (MeshLib::Element* elem : layer_elements) { const std::size_t nElemNodes (elem->getNumberOfBaseNodes()); - for (unsigned i=0; i<nElemNodes; ++i) + for (unsigned i = 0; i < nElemNodes; ++i) + { if (elem->getNeighbor(i) == nullptr) + { for (unsigned j=0; j<nLayerBoundaries; ++j) { const std::size_t offset (j*nNodes); @@ -141,6 +160,8 @@ void LayeredVolume::addLayerBoundaries(const MeshLib::Mesh &layer, std::size_t n _materials.push_back(nLayers+j); } } + } + } } } @@ -157,12 +178,14 @@ void LayeredVolume::removeCongruentElements(std::size_t nLayers, std::size_t nEl unsigned count(0); const std::size_t nElemNodes (low->getNumberOfBaseNodes()); - for (std::size_t k=0; k<nElemNodes; ++k) + for (std::size_t k = 0; k < nElemNodes; ++k) + { if (high->getNodeIndex(k) == low->getNodeIndex(k)) { low->setNode(k, _nodes[high->getNodeIndex(k)]); count++; } + } if (count == nElemNodes) { diff --git a/MeshLib/MeshGenerators/MeshGenerator.cpp b/MeshLib/MeshGenerators/MeshGenerator.cpp index d70e2e033a94bb7435d975390caa1377469467e2..b9e307f6184a5c5cbe099f3ef32c63476a28d2c0 100644 --- a/MeshLib/MeshGenerators/MeshGenerator.cpp +++ b/MeshLib/MeshGenerators/MeshGenerator.cpp @@ -53,8 +53,10 @@ std::vector<MeshLib::Node*> MeshGenerator::generateRegularNodes( std::vector<const std::vector<double>*> vec_xyz_coords; vec_xyz_coords.push_back(&vec_x_coords); std::vector<double> dummy(1,0.0); - for (unsigned i=vec_xyz_coords.size()-1; i<3u; i++) + for (unsigned i = vec_xyz_coords.size() - 1; i < 3u; i++) + { vec_xyz_coords.push_back(&dummy); + } return generateRegularNodes(vec_xyz_coords, origin); } @@ -67,8 +69,10 @@ std::vector<MeshLib::Node*> MeshGenerator::generateRegularNodes( vec_xyz_coords.push_back(&vec_x_coords); vec_xyz_coords.push_back(&vec_y_coords); std::vector<double> dummy(1,0.0); - for (unsigned i=vec_xyz_coords.size()-1; i<3u; i++) + for (unsigned i = vec_xyz_coords.size() - 1; i < 3u; i++) + { vec_xyz_coords.push_back(&dummy); + } return generateRegularNodes(vec_xyz_coords, origin); } @@ -454,8 +458,10 @@ Mesh* MeshGenerator::generateRegularPrismMesh( std::unique_ptr<MeshLib::Mesh> mesh ( generateRegularTriMesh(n_x_cells, n_y_cells, cell_size_x, cell_size_y, origin, mesh_name)); std::size_t const n_tris (mesh->getNumberOfElements()); - for (std::size_t i=0; i<n_z_cells; ++i) + for (std::size_t i = 0; i < n_z_cells; ++i) + { mesh.reset(MeshLib::addTopLayerToMesh(*mesh, cell_size_z, mesh_name)); + } std::vector<std::size_t> elem_ids (n_tris); std::iota(elem_ids.begin(), elem_ids.end(), 0); return MeshLib::removeElements(*mesh, elem_ids, mesh_name); @@ -636,4 +642,4 @@ MeshGenerator::createSurfaceMesh(std::string const& mesh_name, return new MeshLib::Mesh(mesh_name, nodes, sfc_eles); } -} +} // namespace MeshLib diff --git a/MeshLib/MeshGenerators/MeshGenerator.h b/MeshLib/MeshGenerators/MeshGenerator.h index 3a34a39a74d1b3e807c9e883cf8938ef818eb464..514aa4664fd8111f464ff9e56ecc0baecb773b90 100644 --- a/MeshLib/MeshGenerators/MeshGenerator.h +++ b/MeshLib/MeshGenerators/MeshGenerator.h @@ -505,5 +505,5 @@ createSurfaceMesh(std::string const& mesh_name, std::array<std::size_t, 2> const& n_steps, const std::function<double(double,double)>& f); -} //MeshGenerator -} //MeshLib +} // namespace MeshGenerator +} // namespace MeshLib diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.cpp b/MeshLib/MeshGenerators/MeshLayerMapper.cpp index 11ce03cd14ae1376ba26c2fcca7c802745d9b7d1..84ce5900ad10268106d8b7cf2b98fdb7c051a3df 100644 --- a/MeshLib/MeshGenerators/MeshLayerMapper.cpp +++ b/MeshLib/MeshGenerators/MeshLayerMapper.cpp @@ -35,11 +35,16 @@ namespace MeshLib MeshLib::Mesh* MeshLayerMapper::createStaticLayers(MeshLib::Mesh const& mesh, std::vector<float> const& layer_thickness_vector, std::string const& mesh_name) { std::vector<float> thickness; - for (std::size_t i=0; i<layer_thickness_vector.size(); ++i) + for (std::size_t i = 0; i < layer_thickness_vector.size(); ++i) + { if (layer_thickness_vector[i] > std::numeric_limits<float>::epsilon()) + { thickness.push_back(layer_thickness_vector[i]); + } else - WARN ("Ignoring layer %d with thickness %f.", i, layer_thickness_vector[i]); + WARN("Ignoring layer %d with thickness %f.", i, + layer_thickness_vector[i]); + } const std::size_t nLayers(thickness.size()); if (nLayers < 1 || mesh.getDimension() != 2) @@ -75,14 +80,19 @@ MeshLib::Mesh* MeshLayerMapper::createStaticLayers(MeshLib::Mesh const& mesh, st { // add nodes for new layer unsigned node_offset (nNodes * layer_id); - if (layer_id > 0) z_offset += thickness[layer_id-1]; + if (layer_id > 0) + { + z_offset += thickness[layer_id - 1]; + } std::transform(nodes.cbegin(), nodes.cend(), new_nodes.begin() + node_offset, [&z_offset](MeshLib::Node* node){ return new MeshLib::Node((*node)[0], (*node)[1], (*node)[2]-z_offset); }); // starting with 2nd layer create prism or hex elements connecting the last layer with the current one if (layer_id == 0) + { continue; + } node_offset -= nNodes; const unsigned mat_id (nLayers - layer_id); @@ -90,8 +100,10 @@ MeshLib::Mesh* MeshLayerMapper::createStaticLayers(MeshLib::Mesh const& mesh, st for (unsigned i = 0; i < nOrgElems; ++i) { const MeshLib::Element* sfc_elem( elems[i] ); - if (sfc_elem->getDimension() < 2) // ignore line-elements + if (sfc_elem->getDimension() < 2) + { // ignore line-elements continue; + } const unsigned nElemNodes(sfc_elem->getNumberOfBaseNodes()); auto** e_nodes = new MeshLib::Node*[2 * nElemNodes]; @@ -137,7 +149,9 @@ bool MeshLayerMapper::createRasterLayers( auto top = std::make_unique<MeshLib::Mesh>(mesh); if (!layerMapping(*top, *rasters.back(), noDataReplacementValue)) + { return false; + } auto bottom = std::make_unique<MeshLib::Mesh>(mesh); if (!layerMapping(*bottom, *rasters[0], 0)) @@ -159,11 +173,15 @@ bool MeshLayerMapper::createRasterLayers( // add bottom layer std::vector<MeshLib::Node*> const& nodes = bottom->getNodes(); for (MeshLib::Node* node : nodes) + { _nodes.push_back(new MeshLib::Node(*node)); + } // add the other layers - for (std::size_t i=0; i<nLayers-1; ++i) - addLayerToMesh(*top, i, *rasters[i+1]); + for (std::size_t i = 0; i < nLayers - 1; ++i) + { + addLayerToMesh(*top, i, *rasters[i + 1]); + } return true; } @@ -182,8 +200,12 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay int const last_layer_node_offset = layer_id * nNodes; // add nodes for new layer - for (std::size_t i=0; i<nNodes; ++i) - _nodes.push_back(getNewLayerNode(*nodes[i], *_nodes[last_layer_node_offset + i], raster, _nodes.size())); + for (std::size_t i = 0; i < nNodes; ++i) + { + _nodes.push_back(getNewLayerNode(*nodes[i], + *_nodes[last_layer_node_offset + i], + raster, _nodes.size())); + } std::vector<MeshLib::Element*> const& elems = dem_mesh.getElements(); std::size_t const nElems (dem_mesh.getNumberOfElements()); @@ -192,17 +214,24 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay { MeshLib::Element* elem (elems[i]); if (elem->getGeomType() != MeshLib::MeshElemType::TRIANGLE) + { continue; + } unsigned node_counter(3), missing_idx(0); std::array<MeshLib::Node*, 6> new_elem_nodes; for (unsigned j=0; j<3; ++j) { new_elem_nodes[j] = _nodes[_nodes[last_layer_node_offset + elem->getNodeIndex(j)]->getID()]; new_elem_nodes[node_counter] = (_nodes[last_layer_node_offset + elem->getNodeIndex(j) + nNodes]); - if (new_elem_nodes[j]->getID() != new_elem_nodes[node_counter]->getID()) + if (new_elem_nodes[j]->getID() != + new_elem_nodes[node_counter]->getID()) + { node_counter++; + } else + { missing_idx = j; + } } switch (node_counter) @@ -261,8 +290,11 @@ bool MeshLayerMapper::layerMapping(MeshLib::Mesh &new_mesh, GeoLib::Raster const } double elevation (raster.interpolateValueAtPoint(*nodes[i])); - if (std::abs(elevation - header.no_data) < std::numeric_limits<double>::epsilon()) + if (std::abs(elevation - header.no_data) < + std::numeric_limits<double>::epsilon()) + { elevation = noDataReplacementValue; + } nodes[i]->updateCoordinates((*nodes[i])[0], (*nodes[i])[1], elevation); } @@ -279,7 +311,9 @@ bool MeshLayerMapper::mapToStaticValue(MeshLib::Mesh &mesh, double value) std::vector<MeshLib::Node*> const& nodes (mesh.getNodes()); for (MeshLib::Node* node : nodes) + { node->updateCoordinates((*node)[0], (*node)[1], value); + } return true; } diff --git a/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp b/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp index 23c3eb7257889346b181f69be8d8a42398dbac09..3a740e6538c7c25c5582d36f25caa9e2c7e8a181 100644 --- a/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/QuadraticMeshGenerator.cpp @@ -31,7 +31,9 @@ std::unique_ptr<QuadraticElement> convertLinearToQuadratic( // Copy base nodes of element to the quadratic element new nodes'. std::array<MeshLib::Node*, n_all_nodes> nodes; for (int i = 0; i < n_base_nodes; i++) + { nodes[i] = const_cast<MeshLib::Node*>(e.getNode(i)); + } // For each edge create a middle node. int const number_of_edges = e.getNumberOfEdges(); diff --git a/MeshLib/MeshGenerators/RasterToMesh.cpp b/MeshLib/MeshGenerators/RasterToMesh.cpp index 05f83caca4e10db38229304c7a8ed625499ed401..661f190936838f96dcfe514a4959d7195a7d9c4d 100644 --- a/MeshLib/MeshGenerators/RasterToMesh.cpp +++ b/MeshLib/MeshGenerators/RasterToMesh.cpp @@ -89,11 +89,15 @@ MeshLib::Mesh* RasterToMesh::convert( double* colour = pixelData->GetTuple(idx + j); bool const visible = (nTuple == 2 || nTuple == 4) ? (colour[nTuple - 1] != 0) : true; if (!visible) + { pix[idx + j] = header.no_data; + } else - pix[idx + j] = (nTuple < 3) ? - colour[0] : // grey (+ alpha) - (0.3 * colour[0] + 0.6 * colour[1] + 0.1 * colour[2]); // rgb(a) + { + pix[idx + j] = (nTuple < 3) ? colour[0] : // grey (+ alpha) + (0.3 * colour[0] + 0.6 * colour[1] + + 0.1 * colour[2]); // rgb(a) + } } } } @@ -137,20 +141,25 @@ MeshLib::Mesh* RasterToMesh::convert( header.origin[1] - (header.cell_size / 2.0), header.origin[2]}}); std::unique_ptr<MeshLib::Mesh> mesh (nullptr); if (elem_type == MeshElemType::TRIANGLE) + { mesh.reset( MeshLib::MeshGenerator::generateRegularTriMesh(header.n_cols, header.n_rows, header.cell_size, mesh_origin, "RasterDataMesh")); + } else if (elem_type == MeshElemType::QUAD) + { mesh.reset( MeshLib::MeshGenerator::generateRegularQuadMesh(header.n_cols, header.n_rows, header.cell_size, mesh_origin, "RasterDataMesh")); + } else if (elem_type == MeshElemType::PRISM) + { mesh.reset( MeshLib::MeshGenerator::generateRegularPrismMesh(header.n_cols, header.n_rows, @@ -158,7 +167,9 @@ MeshLib::Mesh* RasterToMesh::convert( header.cell_size, mesh_origin, "RasterDataMesh")); + } else if (elem_type == MeshElemType::HEXAHEDRON) + { mesh.reset( MeshLib::MeshGenerator::generateRegularHexMesh(header.n_cols, header.n_rows, @@ -166,6 +177,7 @@ MeshLib::Mesh* RasterToMesh::convert( header.cell_size, mesh_origin, "RasterDataMesh")); + } MeshLib::Mesh* new_mesh(nullptr); std::vector<std::size_t> elements_to_remove; @@ -189,14 +201,19 @@ MeshLib::Mesh* RasterToMesh::convert( { elements_to_remove.push_back(m * (idx + j)); if (double_idx) + { elements_to_remove.push_back(m * (idx + j) + 1); + } continue; } for (std::size_t n = 0; n < n_nodes; ++n) { (*(nodes[elems[m * (idx + j)]->getNodeIndex(n)]))[2] = val; if (double_idx) - (*(nodes[elems[m * (idx + j) + 1]->getNodeIndex(n)]))[2] = val; + { + (*(nodes[elems[m * (idx + j) + 1]->getNodeIndex( + n)]))[2] = val; + } } } } @@ -223,12 +240,18 @@ MeshLib::Mesh* RasterToMesh::convert( elements_to_remove = ex.getSearchedElementIDs(); } if (!elements_to_remove.empty()) + { new_mesh = MeshLib::removeElements(*mesh, elements_to_remove, mesh->getName()); + } else + { new_mesh = mesh.release(); + } if (intensity_type == UseIntensityAs::NONE) + { new_mesh->getProperties().removePropertyVector(array_name); + } return new_mesh; } diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.cpp b/MeshLib/MeshGenerators/VtkMeshConverter.cpp index 9c26daec86d6b6d8def084ad1760d087d365c867..7def6a68af62f01a7f2a1ed3736da10c6ab978c7 100644 --- a/MeshLib/MeshGenerators/VtkMeshConverter.cpp +++ b/MeshLib/MeshGenerators/VtkMeshConverter.cpp @@ -48,7 +48,9 @@ MeshLib::Element* createElementWithSameNodeOrder( { auto** ele_nodes = new MeshLib::Node*[T_ELEMENT::n_all_nodes]; for (unsigned k(0); k < T_ELEMENT::n_all_nodes; k++) + { ele_nodes[k] = nodes[node_ids->GetId(k)]; + } return new T_ELEMENT(ele_nodes, element_id); } } // namespace detail @@ -57,7 +59,9 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid( vtkUnstructuredGrid* grid, std::string const& mesh_name) { if (!grid) + { return nullptr; + } // set mesh nodes const std::size_t nNodes = grid->GetPoints()->GetNumberOfPoints(); @@ -210,12 +214,16 @@ MeshLib::Mesh* VtkMeshConverter::convertUnstructuredGrid( prism_nodes[i + 3] = nodes[node_ids->GetId(i)]; } for (unsigned i = 0; i < 3; ++i) + { prism_nodes[6 + i] = nodes[node_ids->GetId(8 - i)]; + } prism_nodes[9] = nodes[node_ids->GetId(12)]; prism_nodes[10] = nodes[node_ids->GetId(14)]; prism_nodes[11] = nodes[node_ids->GetId(13)]; for (unsigned i = 0; i < 3; ++i) + { prism_nodes[12 + i] = nodes[node_ids->GetId(11 - i)]; + } elem = new MeshLib::Prism15(prism_nodes, i); break; } @@ -242,26 +250,32 @@ void VtkMeshConverter::convertScalarArrays(vtkUnstructuredGrid& grid, auto const n_point_arrays = static_cast<unsigned>(point_data->GetNumberOfArrays()); for (unsigned i = 0; i < n_point_arrays; ++i) + { convertArray(*point_data->GetArray(i), mesh.getProperties(), MeshLib::MeshItemType::Node); + } vtkCellData* cell_data = grid.GetCellData(); auto const n_cell_arrays = static_cast<unsigned>(cell_data->GetNumberOfArrays()); for (unsigned i = 0; i < n_cell_arrays; ++i) + { convertArray(*cell_data->GetArray(i), mesh.getProperties(), MeshLib::MeshItemType::Cell); + } vtkFieldData* field_data = grid.GetFieldData(); auto const n_field_arrays = static_cast<unsigned>(field_data->GetNumberOfArrays()); for (unsigned i = 0; i < n_field_arrays; ++i) + { convertArray( *vtkDataArray::SafeDownCast(field_data->GetAbstractArray(i)), mesh.getProperties(), MeshLib::MeshItemType::IntegrationPoint); + } } void VtkMeshConverter::convertArray(vtkDataArray& array, @@ -316,10 +330,14 @@ void VtkMeshConverter::convertArray(vtkDataArray& array, { // MaterialIDs are assumed to be integers if (std::strncmp(array.GetName(), "MaterialIDs", 11) == 0) + { VtkMeshConverter::convertTypedArray<int>(array, properties, type); + } else - VtkMeshConverter::convertTypedArray<unsigned>( - array, properties, type); + { + VtkMeshConverter::convertTypedArray<unsigned>(array, properties, + type); + } return; } diff --git a/MeshLib/MeshGenerators/VtkMeshConverter.h b/MeshLib/MeshGenerators/VtkMeshConverter.h index 8c75411ec8b7b41ff85876660bce2f6b2e87566f..f5a00aaa0c18e9c215557e693f867ef9d1c3b401 100644 --- a/MeshLib/MeshGenerators/VtkMeshConverter.h +++ b/MeshLib/MeshGenerators/VtkMeshConverter.h @@ -76,6 +76,7 @@ private: MeshElemType elem_type) { for (std::size_t i = 0; i < imgHeight; i++) + { for (std::size_t j = 0; j < imgWidth; j++) { if (!pix_vis[i * imgWidth + j]) @@ -89,6 +90,7 @@ private: else if (elem_type == MeshElemType::QUAD) prop_vec.push_back(val); } + } } static void convertArray(vtkDataArray& array, diff --git a/MeshLib/MeshInformation.cpp b/MeshLib/MeshInformation.cpp index 89f53706ad57a22889e32a2016bdf84df72005b7..57b1f31ec6b13f946c03e1cbcf927572d67f3f93 100644 --- a/MeshLib/MeshInformation.cpp +++ b/MeshLib/MeshInformation.cpp @@ -31,15 +31,36 @@ const std::array<unsigned, 7> MeshInformation::getNumberOfElementTypes(const Mes for (auto element : elements) { MeshElemType t = element->getGeomType(); - if (t == MeshElemType::LINE) n_element_types[0]++; - if (t == MeshElemType::TRIANGLE) n_element_types[1]++; - if (t == MeshElemType::QUAD) n_element_types[2]++; - if (t == MeshElemType::TETRAHEDRON) n_element_types[3]++; - if (t == MeshElemType::HEXAHEDRON) n_element_types[4]++; - if (t == MeshElemType::PYRAMID) n_element_types[5]++; - if (t == MeshElemType::PRISM) n_element_types[6]++; + if (t == MeshElemType::LINE) + { + n_element_types[0]++; + } + if (t == MeshElemType::TRIANGLE) + { + n_element_types[1]++; + } + if (t == MeshElemType::QUAD) + { + n_element_types[2]++; + } + if (t == MeshElemType::TETRAHEDRON) + { + n_element_types[3]++; + } + if (t == MeshElemType::HEXAHEDRON) + { + n_element_types[4]++; + } + if (t == MeshElemType::PYRAMID) + { + n_element_types[5]++; + } + if (t == MeshElemType::PRISM) + { + n_element_types[6]++; + } } return n_element_types; } -} //end MeshLib +} // namespace MeshLib diff --git a/MeshLib/MeshInformation.h b/MeshLib/MeshInformation.h index cfb1e8c3e9a69d69b5f01849e8100e654892968e..c59bb97a14b19db1170127d250db1aaf97cfa715 100644 --- a/MeshLib/MeshInformation.h +++ b/MeshLib/MeshInformation.h @@ -70,4 +70,4 @@ public: }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshQuality/AngleSkewMetric.h b/MeshLib/MeshQuality/AngleSkewMetric.h index 1f5e6e8ec687bb0f0c16deb2436847c7663e15e6..cbf721f3f3991ef2411156ad3a1d91bba7ad7ecb 100644 --- a/MeshLib/MeshQuality/AngleSkewMetric.h +++ b/MeshLib/MeshQuality/AngleSkewMetric.h @@ -43,4 +43,4 @@ private: double const* const n1, double const* const n2, double &min_angle, double &max_angle) const; }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshQuality/EdgeRatioMetric.cpp b/MeshLib/MeshQuality/EdgeRatioMetric.cpp index 04842a352d962559051db8a38f36ef5ecf2e0533..d1d63de5b6c6c5c256086dafb43a245cb274316d 100644 --- a/MeshLib/MeshQuality/EdgeRatioMetric.cpp +++ b/MeshLib/MeshQuality/EdgeRatioMetric.cpp @@ -52,21 +52,27 @@ void EdgeRatioMetric::calculateQuality() case MeshElemType::PRISM: { std::vector<const MathLib::Point3d*> pnts; for (std::size_t j(0); j < 6; j++) + { pnts.push_back(elem.getNode(j)); + } _element_quality_metric[k] = checkPrism(pnts); break; } case MeshElemType::PYRAMID: { std::vector<const MathLib::Point3d*> pnts; for (std::size_t j(0); j < 5; j++) + { pnts.push_back(elem.getNode(j)); + } _element_quality_metric[k] = checkPyramid(pnts); break; } case MeshElemType::HEXAHEDRON: { std::vector<const MathLib::Point3d*> pnts; for (std::size_t j(0); j < 8; j++) + { pnts.push_back(elem.getNode(j)); + } _element_quality_metric[k] = checkHexahedron(pnts); break; } @@ -88,7 +94,9 @@ double EdgeRatioMetric::checkTriangle (MathLib::Point3d const& a, if (len0 < len1 && len0 < len2) { if (len1 < len2) + { return len0 / len2; + } return len0 / len1; } @@ -96,13 +104,17 @@ double EdgeRatioMetric::checkTriangle (MathLib::Point3d const& a, if (len1 < len2) { if (len0 < len2) + { return len1 / len2; + } return len1 / len0; } if (len0 < len1) + { return len2 / len1; + } return len2 / len0; } @@ -119,9 +131,15 @@ double EdgeRatioMetric::checkQuad (MathLib::Point3d const& a, // sort lengths - since this is a very small array we use bubble sort for (std::size_t i(0); i < 4; i++) + { for (std::size_t j(i + 1); j < 4; j++) + { if (sqr_lengths[i] >= sqr_lengths[j]) - std::swap (sqr_lengths[i], sqr_lengths[j]); + { + std::swap(sqr_lengths[i], sqr_lengths[j]); + } + } + } return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[3]); } @@ -137,9 +155,15 @@ double EdgeRatioMetric::checkTetrahedron (MathLib::Point3d const& a, // sort lengths - since this is a very small array we use bubble sort for (std::size_t i(0); i < 6; i++) + { for (std::size_t j(i + 1); j < 6; j++) + { if (sqr_lengths[i] >= sqr_lengths[j]) - std::swap (sqr_lengths[i], sqr_lengths[j]); + { + std::swap(sqr_lengths[i], sqr_lengths[j]); + } + } + } return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[5]); } @@ -158,9 +182,15 @@ double EdgeRatioMetric::checkPrism (std::vector<const MathLib::Point3d*> const& // sort lengths - since this is a very small array we use bubble sort for (std::size_t i(0); i < 9; i++) + { for (std::size_t j(i + 1); j < 9; j++) + { if (sqr_lengths[i] >= sqr_lengths[j]) - std::swap (sqr_lengths[i], sqr_lengths[j]); + { + std::swap(sqr_lengths[i], sqr_lengths[j]); + } + } + } return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[8]); } @@ -178,9 +208,15 @@ double EdgeRatioMetric::checkPyramid (std::vector<const MathLib::Point3d*> const // sort lengths - since this is a very small array we use bubble sort for (std::size_t i(0); i < 8; i++) + { for (std::size_t j(i + 1); j < 8; j++) + { if (sqr_lengths[i] >= sqr_lengths[j]) - std::swap (sqr_lengths[i], sqr_lengths[j]); + { + std::swap(sqr_lengths[i], sqr_lengths[j]); + } + } + } return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[7]); } @@ -202,9 +238,15 @@ double EdgeRatioMetric::checkHexahedron (std::vector<const MathLib::Point3d*> co // sort lengths - since this is a very small array we use bubble sort for (std::size_t i(0); i < 12; i++) + { for (std::size_t j(i + 1); j < 12; j++) + { if (sqr_lengths[i] >= sqr_lengths[j]) - std::swap (sqr_lengths[i], sqr_lengths[j]); + { + std::swap(sqr_lengths[i], sqr_lengths[j]); + } + } + } return sqrt(sqr_lengths[0]) / sqrt(sqr_lengths[11]); } diff --git a/MeshLib/MeshQuality/EdgeRatioMetric.h b/MeshLib/MeshQuality/EdgeRatioMetric.h index 478128d1522dd3675a6848ab80919ced43d2e38e..6ef677f5a8800de6bfd89d5c8598bf77dbdc2e1f 100644 --- a/MeshLib/MeshQuality/EdgeRatioMetric.h +++ b/MeshLib/MeshQuality/EdgeRatioMetric.h @@ -47,4 +47,4 @@ private: double checkPyramid (std::vector<const MathLib::Point3d*> const& pnts) const; double checkHexahedron (std::vector<const MathLib::Point3d*> const& pnts) const; }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshQuality/ElementQualityMetric.cpp b/MeshLib/MeshQuality/ElementQualityMetric.cpp index 754ebee8e9fe1d4ff96a8746ffaf070ea5458e8a..f827acaaa52c1d986ff48fa1306e260050c21a03 100644 --- a/MeshLib/MeshQuality/ElementQualityMetric.cpp +++ b/MeshLib/MeshQuality/ElementQualityMetric.cpp @@ -29,7 +29,10 @@ ElementQualityMetric::ElementQualityMetric(Mesh const& mesh) : BaseLib::Histogram<double> ElementQualityMetric::getHistogram (std::size_t n_bins) const { if (n_bins == 0) - n_bins = static_cast<std::size_t>(1 + 3.3 * log (static_cast<float>((_mesh.getNumberOfElements())))); + { + n_bins = static_cast<std::size_t>( + 1 + 3.3 * log(static_cast<float>((_mesh.getNumberOfElements())))); + } return BaseLib::Histogram<double>(getElementQuality(), n_bins, true); } diff --git a/MeshLib/MeshQuality/ElementQualityMetric.h b/MeshLib/MeshQuality/ElementQualityMetric.h index 6632006c207c223913b019bfd01301a591e93403..88d62720291d3811f5a9f08cf88f5c2ce1f390f1 100644 --- a/MeshLib/MeshQuality/ElementQualityMetric.h +++ b/MeshLib/MeshQuality/ElementQualityMetric.h @@ -60,4 +60,4 @@ protected: Mesh const& _mesh; std::vector<double> _element_quality_metric; }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshQuality/ElementSizeMetric.cpp b/MeshLib/MeshQuality/ElementSizeMetric.cpp index 5ae9f76c3e2d7cc41896552a48500883bed29d26..dae6f3eb73001c3a07545eac17986077ba9bf7e5 100644 --- a/MeshLib/MeshQuality/ElementSizeMetric.cpp +++ b/MeshLib/MeshQuality/ElementSizeMetric.cpp @@ -26,11 +26,17 @@ void ElementSizeMetric::calculateQuality() { std::size_t error_count(0); if (_mesh.getDimension() == 1) + { error_count = calc1dQuality(); + } else if (_mesh.getDimension() == 2) + { error_count = calc2dQuality(); + } else if (_mesh.getDimension() == 3) + { error_count = calc3dQuality(); + } INFO ("ElementSizeMetric::calculateQuality() minimum: %f, max_volume: %f", _min, _max); if (error_count > 0) @@ -47,12 +53,21 @@ std::size_t ElementSizeMetric::calc1dQuality() { double area(std::numeric_limits<double>::max()); _element_quality_metric[k] = elements[k]->getContent(); - if (_element_quality_metric[k] < sqrt(fabs(std::numeric_limits<double>::epsilon()))) + if (_element_quality_metric[k] < + sqrt(fabs(std::numeric_limits<double>::epsilon()))) + { error_count++; + } // update _min and _max values - if (_min > area) _min = area; - if (_max < area) _max = area; + if (_min > area) + { + _min = area; + } + if (_max < area) + { + _max = area; + } } return error_count; } @@ -74,11 +89,19 @@ std::size_t ElementSizeMetric::calc2dQuality() } double const area = elem.getContent(); if (area < sqrt(fabs(std::numeric_limits<double>::epsilon()))) + { error_count++; + } // update _min and _max values - if (_min > area) _min = area; - if (_max < area) _max = area; + if (_min > area) + { + _min = area; + } + if (_max < area) + { + _max = area; + } _element_quality_metric[k] = area; } return error_count; @@ -101,10 +124,18 @@ std::size_t ElementSizeMetric::calc3dQuality() double const volume (elem.getContent()); if (volume < sqrt(fabs(std::numeric_limits<double>::epsilon()))) + { error_count++; + } - if (_min > volume) _min = volume; - if (_max < volume) _max = volume; + if (_min > volume) + { + _min = volume; + } + if (_max < volume) + { + _max = volume; + } _element_quality_metric[k] = volume; } return error_count; diff --git a/MeshLib/MeshQuality/ElementSizeMetric.h b/MeshLib/MeshQuality/ElementSizeMetric.h index 32b9fc9cae04ccc3e2b226ff921bcf3a5e82685e..87730d76ad359f416201a0a7d56792a2d9edb9d1 100644 --- a/MeshLib/MeshQuality/ElementSizeMetric.h +++ b/MeshLib/MeshQuality/ElementSizeMetric.h @@ -35,4 +35,4 @@ private: std::size_t calc2dQuality(); std::size_t calc3dQuality(); }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshQuality/MeshValidation.cpp b/MeshLib/MeshQuality/MeshValidation.cpp index 30e79e567ebe72f5cc927594f492b0755dce3c4a..b17ba5f48678360b1bf1fbe40ef906cc23763d07 100644 --- a/MeshLib/MeshQuality/MeshValidation.cpp +++ b/MeshLib/MeshQuality/MeshValidation.cpp @@ -64,19 +64,29 @@ std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib: const ElementErrorCode e = elements[i]->validate(); error_code_vector.push_back(e); if (e.none()) + { continue; + } // increment error statistics const std::bitset< static_cast<std::size_t>(ElementErrorFlag::MaxValue) > flags (static_cast< std::bitset<static_cast<std::size_t>(ElementErrorFlag::MaxValue)> >(e)); - for (unsigned j=0; j<nErrorCodes; ++j) + for (unsigned j = 0; j < nErrorCodes; ++j) + { error_count[j] += flags[j]; + } } // if a larger volume threshold is given, evaluate elements again to add them even if they are formally okay if (min_volume > std::numeric_limits<double>::epsilon()) - for (std::size_t i=0; i<nElements; ++i) + { + for (std::size_t i = 0; i < nElements; ++i) + { if (elements[i]->getContent() < min_volume) + { error_code_vector[i].set(ElementErrorFlag::ZeroVolume); + } + } + } // output const auto error_sum(static_cast<unsigned>( @@ -85,9 +95,13 @@ std::vector<ElementErrorCode> MeshValidation::testElementGeometry(const MeshLib: { ElementErrorFlag flags[nErrorCodes] = { ElementErrorFlag::ZeroVolume, ElementErrorFlag::NonCoplanar, ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder }; - for (std::size_t i=0; i<nErrorCodes; ++i) + for (std::size_t i = 0; i < nErrorCodes; ++i) + { if (error_count[i]) - INFO ("%d elements found with %s.", error_count[i], ElementErrorCode::toString(flags[i]).c_str()); + INFO("%d elements found with %s.", + error_count[i], + ElementErrorCode::toString(flags[i]).c_str()); + } } else INFO ("No errors found."); @@ -125,7 +139,9 @@ MeshValidation::ElementErrorCodeOutput(const std::vector<ElementErrorCode> &erro ElementErrorCode::toString(flags[i]) + ".\n"); if (count) + { output[i] += ("ElementIDs: " + elementIdStr + "\n"); + } } return output; } @@ -133,7 +149,9 @@ MeshValidation::ElementErrorCodeOutput(const std::vector<ElementErrorCode> &erro unsigned MeshValidation::detectHoles(MeshLib::Mesh const& mesh) { if (mesh.getDimension() == 1) + { return 0; + } MeshLib::Mesh* boundary_mesh (MeshSurfaceExtraction::getMeshBoundary(mesh)); std::vector<MeshLib::Element*> const& elements (boundary_mesh->getElements()); @@ -167,8 +185,11 @@ void MeshValidation::trackSurface(MeshLib::Element const* element, std::vector<u for (std::size_t i=0; i<n_neighbors; ++i) { MeshLib::Element const* neighbor (elem->getNeighbor(i)); - if ( neighbor != nullptr && sfc_idx[neighbor->getID()] == std::numeric_limits<unsigned>::max()) + if (neighbor != nullptr && sfc_idx[neighbor->getID()] == + std::numeric_limits<unsigned>::max()) + { elem_stack.push(neighbor); + } } } } diff --git a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h index cdc32ceede35c9525f770be90c5bbaaddbad13d2..67a96afb40163e29d6107e1b4b9b1014a590eb46 100644 --- a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h +++ b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h @@ -31,4 +31,4 @@ public: void calculateQuality() override; }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshQuality/SizeDifferenceMetric.cpp b/MeshLib/MeshQuality/SizeDifferenceMetric.cpp index 7c9b5e8bcc7b0a673e5542a208ffdc16fb92fb5e..2f4950c73f8a00c453664370f4bec732340e5ef1 100644 --- a/MeshLib/MeshQuality/SizeDifferenceMetric.cpp +++ b/MeshLib/MeshQuality/SizeDifferenceMetric.cpp @@ -46,11 +46,15 @@ void SizeDifferenceMetric::calculateQuality() { MeshLib::Element const*const neighbor (elem.getNeighbor(i)); if (neighbor == nullptr) + { continue; + } double const vol_b (neighbor->getContent()); double const ratio = (vol_a > vol_b) ? vol_b / vol_a : vol_a / vol_b; if (ratio < worst_ratio) + { worst_ratio = ratio; + } } _element_quality_metric[k] = worst_ratio; } diff --git a/MeshLib/MeshQuality/SizeDifferenceMetric.h b/MeshLib/MeshQuality/SizeDifferenceMetric.h index 925a4c88d19d787d192bea91638c25d42a4e7f9f..f05754b9bb9a3c7f140254f4d50af72cc9b0270a 100644 --- a/MeshLib/MeshQuality/SizeDifferenceMetric.h +++ b/MeshLib/MeshQuality/SizeDifferenceMetric.h @@ -31,4 +31,4 @@ public: void calculateQuality() override; }; -} +} // namespace MeshLib diff --git a/MeshLib/MeshSearch/ElementSearch.cpp b/MeshLib/MeshSearch/ElementSearch.cpp index 267d73f2d5c690adaab5d48cd526c1b350718547..2fb71a0697452e8a76ab5f6d7d315dd07b20f357 100644 --- a/MeshLib/MeshSearch/ElementSearch.cpp +++ b/MeshLib/MeshSearch/ElementSearch.cpp @@ -29,7 +29,9 @@ std::vector<std::size_t> filter(Container const& container, Predicate const& p) std::size_t i = 0; for (auto value : container) { if (p(value)) + { matchedIDs.push_back(i); + } i++; } return matchedIDs; @@ -59,9 +61,13 @@ std::size_t ElementSearch::searchByBoundingBox( auto matchedIDs = filter(_mesh.getElements(), [&aabb](MeshLib::Element* e) { std::size_t const nElemNodes (e->getNumberOfBaseNodes()); - for (std::size_t n=0; n < nElemNodes; ++n) + for (std::size_t n = 0; n < nElemNodes; ++n) + { if (aabb.containsPoint(*e->getNode(n), 0)) - return true; // any node of element is in aabb. + { + return true; // any node of element is in aabb. + } + } return false; // no nodes of element are in aabb. }); diff --git a/MeshLib/MeshSearch/MeshElementGrid.cpp b/MeshLib/MeshSearch/MeshElementGrid.cpp index 6b0d352b35751ebd4dc43a1d17f761e4c9d09f4a..d575dc13ab9255176881a09e99b2c03b0fd62cb6 100644 --- a/MeshLib/MeshSearch/MeshElementGrid.cpp +++ b/MeshLib/MeshSearch/MeshElementGrid.cpp @@ -35,8 +35,10 @@ MeshElementGrid::MeshElementGrid(MeshLib::Mesh const& sfc_mesh) : for (std::size_t k(0); k < 3; ++k) { double const tolerance( std::nexttoward(max[k],std::numeric_limits<double>::max())-max[k]); - if (std::abs(max[k]-min[k]) > tolerance) + if (std::abs(max[k] - min[k]) > tolerance) + { dim[k] = true; + } } return dim; }; @@ -138,14 +140,20 @@ bool MeshElementGrid::sortElementInGridCells(MeshLib::Element const& element) // compute coordinates of the grid for each node of the element c = getGridCellCoordinates(*(static_cast<MathLib::Point3d const*>(element.getNode(k)))); if (!c.first) + { return false; + } for (std::size_t j(0); j < 3; ++j) { if (min[j] > c.second[j]) + { min[j] = c.second[j]; + } if (max[j] < c.second[j]) + { max[j] = c.second[j]; + } } } @@ -155,8 +163,10 @@ bool MeshElementGrid::sortElementInGridCells(MeshLib::Element const& element) // AABB the grid cell coordinates computed by getGridCellCoordintes() could // be to large (due to numerical errors). The following lines ensure that // the grid cell coordinates are in the valid range. - for (std::size_t k(0); k<3; ++k) - max[k] = std::min(_n_steps[k]-1, max[k]); + for (std::size_t k(0); k < 3; ++k) + { + max[k] = std::min(_n_steps[k] - 1, max[k]); + } // insert the element into the grid cells for (std::size_t i(min[0]); i<=max[0]; i++) { diff --git a/MeshLib/MeshSearch/NodeSearch.cpp b/MeshLib/MeshSearch/NodeSearch.cpp index 0fbb077e3719bdb725207a261dfce038383792c8..5a805af04dca667586c73ba22a91c78d63462412 100644 --- a/MeshLib/MeshSearch/NodeSearch.cpp +++ b/MeshLib/MeshSearch/NodeSearch.cpp @@ -49,7 +49,9 @@ std::size_t NodeSearch::searchNodesConnectedToOnlyGivenElements( for (std::size_t i=0; i<node_marked_counts.size(); i++) { if (node_marked_counts[i] == _mesh.getNode(i)->getElements().size()) + { connected_nodes.push_back(i); + } } this->updateUnion(connected_nodes); @@ -62,9 +64,13 @@ std::size_t NodeSearch::searchUnused() const std::vector<MeshLib::Node*> &nodes (_mesh.getNodes()); std::vector<std::size_t> del_node_idx; - for (unsigned i=0; i<nNodes; ++i) + for (unsigned i = 0; i < nNodes; ++i) + { if (nodes[i]->getNumberOfElements() == 0) + { del_node_idx.push_back(i); + } + } this->updateUnion(del_node_idx); return del_node_idx.size(); @@ -76,26 +82,38 @@ std::size_t NodeSearch::searchBoundaryNodes() if (_mesh.getDimension() == 1) { for (MeshLib::Node const* n : _mesh.getNodes()) + { if (n->getElements().size() == 1) + { vec_boundary_nodes.push_back(n->getID()); + } + } } else if (_mesh.getDimension() == 2) { for (MeshLib::Element const* elem : _mesh.getElements()) { if (elem->getDimension() < _mesh.getDimension()) + { continue; + } if (!elem->isBoundaryElement()) + { continue; + } std::size_t const n_edges (elem->getNumberOfEdges()); for (std::size_t i=0; i<n_edges; ++i) { if (elem->getNeighbor(i) != nullptr) + { continue; + } std::unique_ptr<MeshLib::Element const> edge(elem->getEdge(i)); - for (unsigned j=0; j<edge->getNumberOfNodes(); j++) + for (unsigned j = 0; j < edge->getNumberOfNodes(); j++) + { vec_boundary_nodes.push_back(edge->getNode(j)->getID()); + } } } } @@ -104,18 +122,26 @@ std::size_t NodeSearch::searchBoundaryNodes() for (MeshLib::Element const* elem : _mesh.getElements()) { if (elem->getDimension() < _mesh.getDimension()) + { continue; + } if (!elem->isBoundaryElement()) + { continue; + } std::size_t const n_faces (elem->getNumberOfFaces()); for (std::size_t i=0; i<n_faces; ++i) { if (elem->getNeighbor(i) != nullptr) + { continue; + } std::unique_ptr<MeshLib::Element const> face(elem->getFace(i)); - for (unsigned j=0; j<face->getNumberOfNodes(); j++) + for (unsigned j = 0; j < face->getNumberOfNodes(); j++) + { vec_boundary_nodes.push_back(face->getNode(j)->getID()); + } } } } diff --git a/MeshLib/MeshSurfaceExtraction.cpp b/MeshLib/MeshSurfaceExtraction.cpp index 8e0de43d3fd61f097b4f2ba56067b502fd9e8d4d..e480b4e7373ad83c608330b2b20336e486249950 100644 --- a/MeshLib/MeshSurfaceExtraction.cpp +++ b/MeshLib/MeshSurfaceExtraction.cpp @@ -90,7 +90,9 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface( subsfc_mesh.getDimension()); if (sfc_elements.empty()) + { return nullptr; + } std::vector<MeshLib::Node*> sfc_nodes; std::vector<std::size_t> node_id_map(subsfc_mesh.getNumberOfNodes()); @@ -104,12 +106,17 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface( { unsigned const n_elem_nodes(sfc_element->getNumberOfBaseNodes()); auto** new_nodes = new MeshLib::Node*[n_elem_nodes]; - for (unsigned k(0); k<n_elem_nodes; k++) + for (unsigned k(0); k < n_elem_nodes; k++) + { new_nodes[k] = sfc_nodes[node_id_map[sfc_element->getNode(k)->getID()]]; + } if (sfc_element->getGeomType() == MeshElemType::TRIANGLE) + { new_elements.push_back(new MeshLib::Tri(new_nodes)); - else { + } + else + { assert(sfc_element->getGeomType() == MeshElemType::QUAD); new_elements.push_back(new MeshLib::Quad(new_nodes)); } @@ -121,7 +128,9 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface( { id_map.reserve(sfc_nodes.size()); for (auto const* node : sfc_nodes) + { id_map.push_back(node->getID()); + } } MeshLib::Mesh* result( new Mesh(subsfc_mesh.getName() + "-Surface", sfc_nodes, new_elements)); @@ -152,8 +161,10 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface( MeshLib::Mesh* MeshSurfaceExtraction::getMeshBoundary(const MeshLib::Mesh &mesh) { - if (mesh.getDimension()==1) + if (mesh.getDimension() == 1) + { return nullptr; + } // For 3D meshes return the 2D surface if (mesh.getDimension()==3) @@ -170,13 +181,15 @@ MeshLib::Mesh* MeshSurfaceExtraction::getMeshBoundary(const MeshLib::Mesh &mesh) for (auto elem : org_elems) { std::size_t const n_edges (elem->getNumberOfEdges()); - for (std::size_t i=0; i<n_edges; ++i) + for (std::size_t i = 0; i < n_edges; ++i) + { if (elem->getNeighbor(i) == nullptr) { MeshLib::Element const*const edge (elem->getEdge(i)); boundary_elements.push_back(MeshLib::copyElement(edge, nodes)); delete edge; } + } } MeshLib::Mesh* result = new MeshLib::Mesh("Boundary Mesh", nodes, boundary_elements); MeshLib::NodeSearch ns(*result); @@ -209,7 +222,9 @@ void MeshSurfaceExtraction::get2DSurfaceElements( { const unsigned element_dimension(elem->getDimension()); if (element_dimension < mesh_dimension) + { continue; + } if (element_dimension == 2) { @@ -219,7 +234,9 @@ void MeshSurfaceExtraction::get2DSurfaceElements( if (MathLib::scalarProduct( FaceRule::getSurfaceNormal(face).getNormalizedVector(), norm_dir) > cos_theta) + { continue; + } } sfc_elements.push_back(elem->clone()); element_to_bulk_element_id_map.push_back(elem->getID()); @@ -228,12 +245,16 @@ void MeshSurfaceExtraction::get2DSurfaceElements( else { if (!elem->isBoundaryElement()) + { continue; + } const unsigned nFaces(elem->getNumberOfFaces()); for (unsigned j = 0; j < nFaces; ++j) { if (elem->getNeighbor(j) != nullptr) + { continue; + } auto const face = std::unique_ptr<MeshLib::Element const>{elem->getFace(j)}; @@ -248,11 +269,15 @@ void MeshSurfaceExtraction::get2DSurfaceElements( } } if (face->getGeomType() == MeshElemType::TRIANGLE) + { sfc_elements.push_back(new MeshLib::Tri( *static_cast<const MeshLib::Tri*>(face.get()))); + } else + { sfc_elements.push_back(new MeshLib::Quad( *static_cast<const MeshLib::Quad*>(face.get()))); + } element_to_bulk_element_id_map.push_back(elem->getID()); element_to_bulk_face_id_map.push_back(j); } @@ -302,7 +327,9 @@ std::vector<MeshLib::Node*> MeshSurfaceExtraction::getSurfaceNodes( node_id_map); for (auto e : sfc_elements) + { delete e; + } return sfc_nodes; } diff --git a/MeshLib/Node.cpp b/MeshLib/Node.cpp index 857c524d8faaae677ac4b09a6618ba347de88a1b..29ad1d2fe4ac8af337271fe33bc1e791a8d55f3e 100644 --- a/MeshLib/Node.cpp +++ b/MeshLib/Node.cpp @@ -45,15 +45,19 @@ void Node::updateCoordinates(double x, double y, double z) _x[2] = z; const std::size_t nElements (this->_elements.size()); - for (std::size_t i=0; i<nElements; i++) + for (std::size_t i = 0; i < nElements; i++) + { _elements[i]->computeVolume(); + } } bool isBaseNode(Node const& node) { // Check if node is connected. if (node.getNumberOfElements() == 0) + { return true; + } // In a mesh a node always belongs to at least one element. auto const e = node.getElement(0); @@ -62,5 +66,4 @@ bool isBaseNode(Node const& node) auto const local_index = e->getNodeIDinElement(&node); return local_index < n_base_nodes; } -} - +} // namespace MeshLib diff --git a/MeshLib/Node.h b/MeshLib/Node.h index 6db6d312242bc8898eaa37645342faa3248e008f..e3470fff3f2d4c0a39479487a64519b4a076a8d3 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -106,4 +106,4 @@ protected: /// is not connected to any element i.e. an unconnected node. bool isBaseNode(Node const& node); -} /* namespace */ +} // namespace MeshLib diff --git a/MeshLib/NodeAdjacencyTable.h b/MeshLib/NodeAdjacencyTable.h index 832c42541d7a4f1b5cac0d728a686166ff75860c..65150ce0c524b944eb11f3ac3481d241b8ab5b73 100644 --- a/MeshLib/NodeAdjacencyTable.h +++ b/MeshLib/NodeAdjacencyTable.h @@ -61,7 +61,9 @@ public: void createTable(std::vector<Node*> const& nodes) { if (_data.size() != nodes.size()) + { _data.resize(nodes.size()); + } for (auto n_ptr : nodes) { diff --git a/MeshLib/Properties.cpp b/MeshLib/Properties.cpp index 556f5ec80e893662e02b1f92f0ffa2156fd78869..60d0fe32530358402dcc742c20839c497b18aeae 100644 --- a/MeshLib/Properties.cpp +++ b/MeshLib/Properties.cpp @@ -38,7 +38,9 @@ std::vector<std::string> Properties::getPropertyVectorNames() const { std::vector<std::string> names; for (auto p : _properties) + { names.push_back(p.first); + } return names; } @@ -49,7 +51,9 @@ std::vector<std::string> Properties::getPropertyVectorNames( for (auto p : _properties) { if (p.second->getMeshItemType() == t) + { names.push_back(p.first); + } } return names; } @@ -88,7 +92,9 @@ Properties Properties::excludeCopyProperties( exclude_mesh_item_types.end(), name_vector_pair.second->getMeshItemType()) != exclude_mesh_item_types.end()) + { continue; + } std::vector<std::size_t> const exclude_positions{}; new_properties._properties.insert( diff --git a/MeshLib/PropertyVector.h b/MeshLib/PropertyVector.h index 41f1eef2d984d220ac043bf72953720c195a9f6d..4b695c5f63f886ac195056782b27af6ea77dd487 100644 --- a/MeshLib/PropertyVector.h +++ b/MeshLib/PropertyVector.h @@ -146,7 +146,9 @@ public: ~PropertyVector() override { for (auto v : _values) - delete [] v; + { + delete[] v; + } } /// The operator[] uses the item to group property map to access to the @@ -164,8 +166,11 @@ public: void initPropertyValue(std::size_t group_id, T const& value) { if (_n_components != 1) - OGS_FATAL("Single-component version of initPropertyValue() is called " - "for a multi-components PropertyVector<T*>"); + { + OGS_FATAL( + "Single-component version of initPropertyValue() is called " + "for a multi-components PropertyVector<T*>"); + } auto* p = new T[1]; p[0] = value; _values[group_id] = p; @@ -174,12 +179,17 @@ public: void initPropertyValue(std::size_t group_id, std::vector<T> const& values) { if (_n_components != static_cast<int>(values.size())) - OGS_FATAL("The size of provided values in initPropertyValue() is " - "not same as the number of components in PropertyVector<T*>"); + { + OGS_FATAL( + "The size of provided values in initPropertyValue() is " + "not same as the number of components in PropertyVector<T*>"); + } auto* p = new T[values.size()]; - for (unsigned i=0; i<values.size(); i++) + for (unsigned i = 0; i < values.size(); i++) + { p[i] = values[i]; + } _values[group_id] = p; } @@ -220,9 +230,12 @@ public: assert(tuple_index < getNumberOfTuples()); const double* p = this->operator[](tuple_index); if (p == nullptr) - OGS_FATAL("No data found in the property vector %s " - "for the tuple index %d and component %d", - getPropertyName().c_str(), tuple_index, component); + { + OGS_FATAL( + "No data found in the property vector %s " + "for the tuple index %d and component %d", + getPropertyName().c_str(), tuple_index, component); + } return p[component]; } diff --git a/MeshLib/Vtk/VtkMappedMeshSource.cpp b/MeshLib/Vtk/VtkMappedMeshSource.cpp index 8ea8d5816e99f31a50ce4990c74f866a308b7496..01e8f1161a73347c78bfba4e120b5f100ccda6ed 100644 --- a/MeshLib/Vtk/VtkMappedMeshSource.cpp +++ b/MeshLib/Vtk/VtkMappedMeshSource.cpp @@ -48,10 +48,14 @@ int VtkMappedMeshSource::ProcessRequest(vtkInformation* request, vtkInformationVector* outputVector) { if (request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) + { return this->RequestData(request, inputVector, outputVector); + } if (request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) + { return this->RequestInformation(request, inputVector, outputVector); + } return this->Superclass::ProcessRequest(request, inputVector, outputVector); } @@ -68,7 +72,9 @@ int VtkMappedMeshSource::RequestData(vtkInformation*, if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0) + { return 1; + } // Points this->Points->Reset(); @@ -92,7 +98,9 @@ int VtkMappedMeshSource::RequestData(vtkInformation*, ptIds->SetNumberOfIds(numNodes); for (unsigned i = 0; i < numNodes; ++i) + { ptIds->SetId(i, nodes[i]->getID()); + } if (cellType == VTK_WEDGE) { @@ -107,16 +115,22 @@ int VtkMappedMeshSource::RequestData(vtkInformation*, { std::array<vtkIdType, 15> ogs_nodeIds; for (unsigned i = 0; i < 15; ++i) + { ogs_nodeIds[i] = ptIds->GetId(i); + } for (unsigned i = 0; i < 3; ++i) { ptIds->SetId(i, ogs_nodeIds[i + 3]); ptIds->SetId(i + 3, ogs_nodeIds[i]); } for (unsigned i = 0; i < 3; ++i) + { ptIds->SetId(6 + i, ogs_nodeIds[8 - i]); + } for (unsigned i = 0; i < 3; ++i) + { ptIds->SetId(9 + i, ogs_nodeIds[14 - i]); + } ptIds->SetId(12, ogs_nodeIds[9]); ptIds->SetId(13, ogs_nodeIds[11]); ptIds->SetId(14, ogs_nodeIds[10]); @@ -134,17 +148,29 @@ int VtkMappedMeshSource::RequestData(vtkInformation*, ++name) { if (addProperty<double>(properties, *name)) + { continue; + } if (addProperty<float>(properties, *name)) + { continue; + } if (addProperty<int>(properties, *name)) + { continue; + } if (addProperty<unsigned>(properties, *name)) + { continue; + } if (addProperty<std::size_t>(properties, *name)) + { continue; + } if (addProperty<char>(properties, *name)) + { continue; + } DBUG("Mesh property '%s' with unknown data type.", *name->c_str()); } @@ -170,12 +196,16 @@ bool VtkMappedMeshSource::addProperty(MeshLib::Properties const& properties, std::string const& prop_name) const { if (!properties.existsPropertyVector<T>(prop_name)) + { return false; + } // TODO: Hack removing const auto* propertyVector = const_cast<MeshLib::PropertyVector<T>*>( properties.getPropertyVector<T>(prop_name)); if (!propertyVector) + { return false; + } vtkNew<vtkAOSDataArrayTemplate<T>> dataArray; const bool hasArrayOwnership = false; @@ -186,12 +216,18 @@ bool VtkMappedMeshSource::addProperty(MeshLib::Properties const& properties, dataArray->SetName(prop_name.c_str()); if (propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node) + { this->PointData->AddArray(dataArray.GetPointer()); + } else if (propertyVector->getMeshItemType() == MeshLib::MeshItemType::Cell) + { this->CellData->AddArray(dataArray.GetPointer()); + } else if (propertyVector->getMeshItemType() == MeshLib::MeshItemType::IntegrationPoint) + { this->FieldData->AddArray(dataArray.GetPointer()); + } return true; } diff --git a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h index 9f3145952f27d97c6afee5f99ba23f7b846fb3c4..d42a5e7235de046c51f5fb410f01fd138d9e4a60 100644 --- a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h +++ b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate-impl.h @@ -80,8 +80,10 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> outArray->SetNumberOfTuples(numTuples); const vtkIdType numPoints = ptIds->GetNumberOfIds(); - for(vtkIdType i = 0; i < numPoints; i++) + for (vtkIdType i = 0; i < numPoints; i++) + { outArray->SetTuple(i, this->GetTuple(ptIds->GetId(i))); + } } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> @@ -100,8 +102,10 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> return; } - for(vtkIdType daTubleId = 0; p1 <= p2; ++p1) + for (vtkIdType daTubleId = 0; p1 <= p2; ++p1) + { da->SetTuple(daTubleId++, this->GetTuple(p1)); + } } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> @@ -122,8 +126,10 @@ template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> { bool valid = true; Scalar val = vtkVariantCast<Scalar>(value, &valid); - if(valid) + if (valid) + { return this->Lookup(val, 0); + } return -1; } @@ -136,8 +142,10 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> if(valid) { vtkIdType index = 0; - while((index = this->Lookup(val, index)) >= 0) + while ((index = this->Lookup(val, index)) >= 0) + { ids->InsertNextId(index++); + } } } @@ -179,8 +187,10 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> { ids->Reset(); vtkIdType index = 0; - while((index = this->Lookup(value, index)) >= 0) + while ((index = this->Lookup(value, index)) >= 0) + { ids->InsertNextId(index++); + } } template <class Scalar> Scalar& VtkMeshNodalCoordinatesTemplate<Scalar> @@ -391,8 +401,10 @@ template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> { while(index <= this->MaxId) { - if(this->GetValueReference(index++) == val) + if (this->GetValueReference(index++) == val) + { return index; + } } return -1; } @@ -478,4 +490,4 @@ template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> } #endif // vtk version -} // end namespace +} // namespace MeshLib diff --git a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h index 4648ed22a1de9e52b624d818dd381ec51bcbee22..feb32368809d1fcaf888980bd4ad287b250768a6 100644 --- a/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h +++ b/MeshLib/Vtk/VtkMeshNodalCoordinatesTemplate.h @@ -131,6 +131,6 @@ private: double *TempDoubleArray; }; -} // end namespace +} // namespace MeshLib #include "VtkMeshNodalCoordinatesTemplate-impl.h" diff --git a/MeshLib/convertMeshToGeo.cpp b/MeshLib/convertMeshToGeo.cpp index bc1013cb0a418642fcf2bf0a65fdf4fe97d6f260..6f8f56db4a14565a0b429f6f5036ef09a40c585d 100644 --- a/MeshLib/convertMeshToGeo.cpp +++ b/MeshLib/convertMeshToGeo.cpp @@ -43,7 +43,9 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects points->reserve(mesh.getNumberOfNodes()); for (auto node_ptr : mesh.getNodes()) + { points->push_back(new GeoLib::Point(*node_ptr, node_ptr->getID())); + } geo_objects.addPointVec(std::move(points), mesh_name, nullptr, eps); } @@ -56,8 +58,10 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects auto sfcs = std::make_unique<std::vector<GeoLib::Surface*>>(); sfcs->reserve(nMatGroups); auto const& points = *geo_objects.getPointVec(mesh_name); - for (unsigned i=0; i<nMatGroups; ++i) + for (unsigned i = 0; i < nMatGroups; ++i) + { sfcs->push_back(new GeoLib::Surface(points)); + } const std::vector<MeshLib::Element*> &elements = mesh.getElements(); const std::size_t nElems (mesh.getNumberOfElements()); @@ -72,7 +76,11 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects auto surfaceId = !materialIds ? 0 : ((*materialIds)[i] - bounds.first); MeshLib::Element* e (elements[i]); if (e->getGeomType() == MeshElemType::TRIANGLE) - (*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]); + { + (*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], + id_map[e->getNodeIndex(1)], + id_map[e->getNodeIndex(2)]); + } if (e->getGeomType() == MeshElemType::QUAD) { (*sfcs)[surfaceId]->addTriangle(id_map[e->getNodeIndex(0)], id_map[e->getNodeIndex(1)], id_map[e->getNodeIndex(2)]); @@ -81,7 +89,13 @@ bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects // all other element types are ignored (i.e. lines) } - std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc){ if (sfc->getNumberOfTriangles()==0) delete sfc; sfc = nullptr;}); + std::for_each(sfcs->begin(), sfcs->end(), [](GeoLib::Surface* sfc) { + if (sfc->getNumberOfTriangles() == 0) + { + delete sfc; + } + sfc = nullptr; + }); auto sfcs_end = std::remove(sfcs->begin(), sfcs->end(), nullptr); sfcs->erase(sfcs_end, sfcs->end()); @@ -99,11 +113,16 @@ MeshLib::Mesh* convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::strin { auto* tri = sfc[i]; auto** tri_nodes = new MeshLib::Node*[3]; - for (unsigned j=0; j<3; j++) - tri_nodes[j] = new MeshLib::Node(tri->getPoint(j)->getCoords(), nodeId++); + for (unsigned j = 0; j < 3; j++) + { + tri_nodes[j] = + new MeshLib::Node(tri->getPoint(j)->getCoords(), nodeId++); + } elements.push_back(new MeshLib::Tri(tri_nodes, i)); - for (unsigned j=0; j<3; j++) + for (unsigned j = 0; j < 3; j++) + { nodes.push_back(tri_nodes[j]); + } } MeshLib::Mesh mesh_with_duplicated_nodes(mesh_name, nodes, elements); @@ -112,5 +131,4 @@ MeshLib::Mesh* convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::strin return rev.simplifyMesh(mesh_with_duplicated_nodes.getName(), eps); } -} - +} // namespace MeshLib diff --git a/MeshLib/convertMeshToGeo.h b/MeshLib/convertMeshToGeo.h index 8f70413d537e68080bf32d07ae438656e7cc5d67..acd482b7caf2e9a3e700d221bd7630c3bb4b4379 100644 --- a/MeshLib/convertMeshToGeo.h +++ b/MeshLib/convertMeshToGeo.h @@ -46,4 +46,4 @@ namespace MeshLib */ MeshLib::Mesh* convertSurfaceToMesh(const GeoLib::Surface &sfc, const std::string &mesh_name, double eps = std::numeric_limits<double>::epsilon()); -} // namespace + } // namespace MeshLib diff --git a/MeshLib/findElementsWithinRadius.cpp b/MeshLib/findElementsWithinRadius.cpp index 8d51c46bb9a82b13a5f576170f202b8650b2cf16..15963656f6c3314a9b70f07f95ce20b0efb6183c 100644 --- a/MeshLib/findElementsWithinRadius.cpp +++ b/MeshLib/findElementsWithinRadius.cpp @@ -26,7 +26,9 @@ std::vector<std::size_t> findElementsWithinRadius(Element const& start_element, // Special case for 0 radius. All other radii will include at least one // neighbor of the start element. if (radius_squared == 0.) + { return {start_element.getID()}; + } // Collect start element node coordinates into local contigiuos memory. std::vector<MathLib::Point3d> start_element_nodes; @@ -34,7 +36,9 @@ std::vector<std::size_t> findElementsWithinRadius(Element const& start_element, auto const start_element_n_nodes = start_element.getNumberOfNodes(); start_element_nodes.reserve(start_element_n_nodes); for (unsigned n = 0; n < start_element_n_nodes; ++n) + { start_element_nodes.push_back(*start_element.getNode(n)); + } } // Returns true if the test node is inside the radius of any of the @@ -44,7 +48,9 @@ std::vector<std::size_t> findElementsWithinRadius(Element const& start_element, for (auto const& n : start_element_nodes) { if (MathLib::sqrDist(*test_node, n) <= radius_squared) + { return true; + } } return false; }; @@ -56,7 +62,9 @@ std::vector<std::size_t> findElementsWithinRadius(Element const& start_element, for (unsigned i = 0; i < n_nodes; ++i) { if (node_inside_radius(element.getNode(i))) + { return true; + } } return false; }; @@ -75,10 +83,14 @@ std::vector<std::size_t> findElementsWithinRadius(Element const& start_element, { auto neighbor = element.getNeighbor(n); if (neighbor == nullptr) + { continue; + } auto x = visited_elements.find(neighbor->getID()); if (x != visited_elements.end()) + { continue; + } neighbors_to_visit.push_back(neighbor); @@ -96,9 +108,11 @@ std::vector<std::size_t> findElementsWithinRadius(Element const& start_element, // If any node is inside the radius, all neighbors are visited. if (element_in_radius(current_element)) + { mark_visited_and_add_neighbors(current_element); + } } return {std::begin(found_elements), std::end(found_elements)}; } -} +} // namespace MeshLib diff --git a/NumLib/Assembler/SerialExecutor.h b/NumLib/Assembler/SerialExecutor.h index eb2f2096ac6d1352d2cffe675832d8adc90d776e..2856d502824888a6890fdd43e72879d07a265037 100644 --- a/NumLib/Assembler/SerialExecutor.h +++ b/NumLib/Assembler/SerialExecutor.h @@ -53,7 +53,9 @@ struct SerialExecutor #endif { for (std::size_t i = 0; i < c.size(); i++) + { f(i, *c[i], std::forward<Args_>(args)...); + } } /// Executes the given \c method of the given \c object for each element @@ -199,7 +201,9 @@ struct SerialExecutor assert(c.size() == data.size()); for (std::size_t i = 0; i < c.size(); i++) + { f(i, *c[i], data[i], std::forward<Args_>(args)...); + } } }; diff --git a/NumLib/DOF/ComponentGlobalIndexDict.h b/NumLib/DOF/ComponentGlobalIndexDict.h index e752595a1c94a213a1bf2394385aaeeeb7b403e7..1d0c302b7722a8d90a130a717a7bc561ea09f7b9 100644 --- a/NumLib/DOF/ComponentGlobalIndexDict.h +++ b/NumLib/DOF/ComponentGlobalIndexDict.h @@ -75,9 +75,13 @@ struct LineByLocationAndComponentComparator bool operator()(Line const& a, Line const& b) const { if (a.location < b.location) + { return true; + } if (b.location < a.location) + { return false; + } // a.loc == b.loc return a.comp_id < b.comp_id; diff --git a/NumLib/DOF/ComputeSparsityPattern.cpp b/NumLib/DOF/ComputeSparsityPattern.cpp index 053d0d2c3eda1cbed9adf1234fd173487fe07cae..b3ab5c551b503bf25aec5e9b0e7de146831ba137 100644 --- a/NumLib/DOF/ComputeSparsityPattern.cpp +++ b/NumLib/DOF/ComputeSparsityPattern.cpp @@ -55,9 +55,13 @@ GlobalSparsityPattern computeSparsityPatternNonPETSc( { unsigned n_connected_dof = 0; for (auto an : node_adjacency_table.getAdjacentNodes(n)) + { n_connected_dof += global_idcs[an].size(); + } for (auto global_index : global_idcs[n]) + { sparsity_pattern[global_index] = n_connected_dof; + } } return sparsity_pattern; @@ -76,4 +80,4 @@ GlobalSparsityPattern computeSparsityPattern( #endif } -} +} // namespace NumLib diff --git a/NumLib/DOF/ComputeSparsityPattern.h b/NumLib/DOF/ComputeSparsityPattern.h index ddc668490c157e86b31d3fa0b146b664915d7857..0cf3606d0be75f1d1eff0d74fa6a828033455945 100644 --- a/NumLib/DOF/ComputeSparsityPattern.h +++ b/NumLib/DOF/ComputeSparsityPattern.h @@ -32,4 +32,4 @@ class LocalToGlobalIndexMap; */ GlobalSparsityPattern computeSparsityPattern( LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh); -} +} // namespace NumLib diff --git a/NumLib/DOF/DOFTableUtil.cpp b/NumLib/DOF/DOFTableUtil.cpp index a4bb14b296a6620f9f8401e563627a9c295827a4..ec8e7fd80d2ceb6f4eae01f1605b08bf05f8bc0f 100644 --- a/NumLib/DOF/DOFTableUtil.cpp +++ b/NumLib/DOF/DOFTableUtil.cpp @@ -98,8 +98,10 @@ double getNonGhostNodalValue(GlobalVector const& x, MeshLib::Mesh const& mesh, auto const index = dof_table.getGlobalIndex(l, global_component_id); assert (index != NumLib::MeshComponentMap::nop); - if (index < 0) // ghost node value + if (index < 0) + { // ghost node value return 0.0; + } return x.get(index); } diff --git a/NumLib/DOF/GlobalMatrixProviders.h b/NumLib/DOF/GlobalMatrixProviders.h index 21eb66178624e761bf35d7251fd562bac97ce5f0..57d096e5659fc26e53c074daf5b965273f70c168 100644 --- a/NumLib/DOF/GlobalMatrixProviders.h +++ b/NumLib/DOF/GlobalMatrixProviders.h @@ -27,4 +27,4 @@ struct GlobalMatrixProvider void cleanupGlobalMatrixProviders(); -} // MathLib +} // namespace NumLib diff --git a/NumLib/DOF/LocalToGlobalIndexMap.cpp b/NumLib/DOF/LocalToGlobalIndexMap.cpp index 31cc95921e51eaaed5e962e984ca5064f16d70c3..51844d49a06cc62da5513fbfffae1da6e03867e1 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.cpp +++ b/NumLib/DOF/LocalToGlobalIndexMap.cpp @@ -29,7 +29,7 @@ std::vector<T> to_cumulative(std::vector<T> const& vec) return result; } -} // no named namespace +} // namespace int LocalToGlobalIndexMap::getGlobalComponent(int const variable_id, int const component_id) const @@ -56,8 +56,10 @@ void LocalToGlobalIndexMap::findGlobalIndicesWithElementID( n < (*e)->getNodes()+(*e)->getNumberOfNodes(); ++n) { // Check if the element's node is in the given list of nodes. - if (set_nodes.find(*n)==set_nodes.end()) + if (set_nodes.find(*n) == set_nodes.end()) + { continue; + } MeshLib::Location l( mesh_id, MeshLib::MeshItemType::Node, (*n)->getID()); indices.push_back(_mesh_component_map.getGlobalIndex(l, comp_id)); @@ -90,8 +92,10 @@ void LocalToGlobalIndexMap::findGlobalIndices( n < (*e)->getNodes() + (*e)->getNumberOfNodes(); ++n) { // Check if the element's node is in the given list of nodes. - if (set_nodes.find(*n)==set_nodes.end()) + if (set_nodes.find(*n) == set_nodes.end()) + { continue; + } MeshLib::Location l( mesh_id, MeshLib::MeshItemType::Node, (*n)->getID()); auto const global_index = @@ -165,7 +169,9 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap( for (std::vector<MeshLib::Element*>const* eles : vec_var_elements) { for (auto e : *eles) + { max_elem_id = std::max(max_elem_id, e->getID()); + } } _rows.resize(max_elem_id + 1, _mesh_subsets.size()); @@ -205,10 +211,12 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap( { // Each subset in the mesh_subsets represents a single component. if (_mesh_subsets.size() != global_component_ids.size()) + { OGS_FATAL( "Number of mesh subsets is not equal to number of components. " "There are %d mesh subsets and %d components.", _mesh_subsets.size(), global_component_ids.size()); + } for (int i = 0; i < static_cast<int>(global_component_ids.size()); ++i) { @@ -231,7 +239,9 @@ LocalToGlobalIndexMap* LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( DBUG("Construct reduced local to global index map."); if (component_ids.empty()) + { OGS_FATAL("Expected non-empty vector of component ids."); + } // Elements of the new_mesh_subset's mesh. std::vector<MeshLib::Element*> const& elements = @@ -241,8 +251,10 @@ LocalToGlobalIndexMap* LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( std::vector<int> global_component_ids; for (auto component_id : component_ids) + { global_component_ids.push_back( getGlobalComponent(variable_id, component_id)); + } auto mesh_component_map = _mesh_component_map.getSubset( _mesh_subsets, new_mesh_subset, global_component_ids); @@ -251,7 +263,9 @@ LocalToGlobalIndexMap* LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( // The last component is moved after the for-loop. std::vector<MeshLib::MeshSubset> all_mesh_subsets; for (int i = 0; i < static_cast<int>(global_component_ids.size()) - 1; ++i) + { all_mesh_subsets.emplace_back(new_mesh_subset); + } all_mesh_subsets.emplace_back(std::move(new_mesh_subset)); return new LocalToGlobalIndexMap( @@ -285,7 +299,9 @@ LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( // The last component is moved after the for-loop. std::vector<MeshLib::MeshSubset> all_mesh_subsets; for (int i = 0; i < static_cast<int>(global_component_ids.size()) - 1; ++i) + { all_mesh_subsets.emplace_back(new_mesh_subset); + } all_mesh_subsets.emplace_back(std::move(new_mesh_subset)); return std::make_unique<LocalToGlobalIndexMap>( @@ -353,7 +369,9 @@ LocalToGlobalIndexMap::getNumberOfElementComponents(std::size_t const mesh_item_ for (Table::Index c = 0; c < _rows.cols(); ++c) { if (!_rows(mesh_item_id, c).empty()) + { n++; + } } return n; } @@ -368,7 +386,9 @@ std::vector<int> LocalToGlobalIndexMap::getElementVariableIDs( { auto comp_id = getGlobalComponent(i, j); if (!_rows(mesh_item_id, comp_id).empty()) + { vec.push_back(i); + } } } std::sort(vec.begin(), vec.end()); diff --git a/NumLib/DOF/MeshComponentMap.cpp b/NumLib/DOF/MeshComponentMap.cpp index 16c86273c24fece6075787b7ed96996be0221239..14f45525205c10f8ca686e564bb07d04b2271c60 100644 --- a/NumLib/DOF/MeshComponentMap.cpp +++ b/NumLib/DOF/MeshComponentMap.cpp @@ -102,15 +102,19 @@ MeshComponentMap::MeshComponentMap( std::size_t const mesh_id = c.getMeshID(); // mesh items are ordered first by node, cell, .... for (std::size_t j = 0; j < c.getNumberOfNodes(); j++) + { _dict.insert(Line( Location(mesh_id, MeshLib::MeshItemType::Node, c.getNodeID(j)), comp_id, global_index++)); + } comp_id++; } _num_local_dof = _dict.size(); if (order == ComponentOrder::BY_LOCATION) + { renumberByLocation(); + } } #endif // end of USE_PETSC @@ -217,8 +221,10 @@ std::vector<int> MeshComponentMap::getComponentIDs(const Location& l) const auto const &m = _dict.get<ByLocation>(); auto const p = m.equal_range(Line(l)); std::vector<int> vec_compID; - for (auto itr=p.first; itr!=p.second; ++itr) + for (auto itr = p.first; itr != p.second; ++itr) + { vec_compID.push_back(itr->comp_id); + } return vec_compID; } @@ -243,8 +249,10 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndices(const Location & auto const &m = _dict.get<ByLocation>(); auto const p = m.equal_range(Line(l)); std::vector<GlobalIndexType> global_indices; - for (auto itr=p.first; itr!=p.second; ++itr) + for (auto itr = p.first; itr != p.second; ++itr) + { global_indices.push_back(itr->global_index); + } return global_indices; } @@ -262,7 +270,9 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByLocation( { auto const p = m.equal_range(Line(l)); for (auto itr = p.first; itr != p.second; ++itr) + { global_indices.push_back(itr->global_index); + } } return global_indices; @@ -282,7 +292,9 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( { auto const p = m.equal_range(Line(l)); for (auto itr = p.first; itr != p.second; ++itr) + { pairs.emplace_back(itr->comp_id, itr->global_index); + } } auto CIPairLess = [](CIPair const& a, CIPair const& b) @@ -292,12 +304,16 @@ std::vector<GlobalIndexType> MeshComponentMap::getGlobalIndicesByComponent( // Create vector of global indices from sub dictionary sorting by component. if (!std::is_sorted(pairs.begin(), pairs.end(), CIPairLess)) + { std::stable_sort(pairs.begin(), pairs.end(), CIPairLess); + } std::vector<GlobalIndexType> global_indices; global_indices.reserve(pairs.size()); for (const auto& pair : pairs) + { global_indices.push_back(pair.second); + } return global_indices; } diff --git a/NumLib/DOF/SimpleMatrixVectorProvider.cpp b/NumLib/DOF/SimpleMatrixVectorProvider.cpp index 49cbee04ee7e6e294d60c2604b538444f7379c4f..cf343d8f30d99d37baa6fae06d6110eee6358810 100644 --- a/NumLib/DOF/SimpleMatrixVectorProvider.cpp +++ b/NumLib/DOF/SimpleMatrixVectorProvider.cpp @@ -51,8 +51,7 @@ transfer(std::map<MatVec*, std::size_t>& from_used, from_used.erase(it); } -} // detail - +} // namespace detail namespace NumLib { @@ -75,8 +74,10 @@ get_(std::size_t& id, if (do_search) { auto it = unused_map.find(id); - if (it != unused_map.end()) // unused matrix/vector found - return { ::detail::transfer(unused_map, used_map, it), false }; + if (it != unused_map.end()) + { // unused matrix/vector found + return {::detail::transfer(unused_map, used_map, it), false}; + } } // not searched or not found, so create a new one @@ -135,8 +136,10 @@ getMatrix(GlobalMatrix const& A) { std::size_t id = 0u; auto const& res = getMatrix_<false>(id, A); - if (!res.second) // no new object has been created + if (!res.second) + { // no new object has been created LinAlg::copy(A, *res.first); + } return *res.first; } @@ -145,8 +148,10 @@ SimpleMatrixVectorProvider:: getMatrix(GlobalMatrix const& A, std::size_t& id) { auto const& res = getMatrix_<true>(id, A); - if (!res.second) // no new object has been created + if (!res.second) + { // no new object has been created LinAlg::copy(A, *res.first); + } return *res.first; } @@ -209,8 +214,10 @@ getVector(GlobalVector const& x) { std::size_t id = 0u; auto const& res = getVector_<false>(id, x); - if (!res.second) // no new object has been created + if (!res.second) + { // no new object has been created LinAlg::copy(x, *res.first); + } return *res.first; } @@ -219,8 +226,10 @@ SimpleMatrixVectorProvider:: getVector(GlobalVector const& x, std::size_t& id) { auto const& res = getVector_<true>(id, x); - if (!res.second) // no new object has been created + if (!res.second) + { // no new object has been created LinAlg::copy(x, *res.first); + } return *res.first; } @@ -245,16 +254,24 @@ SimpleMatrixVectorProvider:: } for (auto& id_ptr : _unused_matrices) + { delete id_ptr.second; + } for (auto& ptr_id : _used_matrices) + { delete ptr_id.first; + } for (auto& id_ptr : _unused_vectors) + { delete id_ptr.second; + } for (auto& ptr_id : _used_vectors) + { delete ptr_id.first; + } } -} // MathLib +} // namespace NumLib diff --git a/NumLib/Distribution/Distribution.cpp b/NumLib/Distribution/Distribution.cpp index f20c22d2c8b9263b099cb289495cdad069069df6..2aef2ec8da4ea9e22badc94e1dbc679952d1f24e 100644 --- a/NumLib/Distribution/Distribution.cpp +++ b/NumLib/Distribution/Distribution.cpp @@ -33,4 +33,4 @@ std::vector<double> generateNodeValueDistribution( return vec_values; } -} //NumLib +} // namespace NumLib diff --git a/NumLib/Distribution/Distribution.h b/NumLib/Distribution/Distribution.h index afcad351cd278fa7df4ee1b414cce18bf0028975..36771244c9704546afc25a323ddc08352735152e 100644 --- a/NumLib/Distribution/Distribution.h +++ b/NumLib/Distribution/Distribution.h @@ -33,4 +33,4 @@ std::vector<double> generateNodeValueDistribution( const MeshLib::Mesh &msh, const std::vector<std::size_t> &vec_node_ids); -} // NumLib +} // namespace NumLib diff --git a/NumLib/Extrapolation/Extrapolator.h b/NumLib/Extrapolation/Extrapolator.h index e1183a85608fec5ed5a8775ae5a02b660f1c7388..0640f65268d4e2a24efdb46149220209be6042b8 100644 --- a/NumLib/Extrapolation/Extrapolator.h +++ b/NumLib/Extrapolation/Extrapolator.h @@ -56,4 +56,4 @@ public: virtual ~Extrapolator() = default; }; -} // namespace ProcessLib +} // namespace NumLib diff --git a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp index c769f32e99eefbf1ca4a57840bd8dbb1d529c387..f0b5689f404eed6c290714ae026dc4808b087e53 100644 --- a/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp +++ b/NumLib/Extrapolation/LocalLinearLeastSquaresExtrapolator.cpp @@ -33,9 +33,11 @@ LocalLinearLeastSquaresExtrapolator::LocalLinearLeastSquaresExtrapolator( * some more advanced process, like the TES process. */ if (dof_table.getNumberOfComponents() != 1) + { OGS_FATAL( "The d.o.f. table passed must be for one variable that has " "only one component!"); + } } void LocalLinearLeastSquaresExtrapolator::extrapolate( @@ -154,19 +156,23 @@ void LocalLinearLeastSquaresExtrapolator::extrapolateElement( static_cast<unsigned>(integration_point_values.size()); if (num_values % num_components != 0) + { OGS_FATAL( "The number of computed integration point values is not divisable " "by the number of num_components. Maybe the computed property is " "not a %d-component vector for each integration point.", num_components); + } // number of integration points in the element const auto num_int_pts = num_values / num_components; if (num_int_pts < num_nodes) + { OGS_FATAL( "Least squares is not possible if there are more nodes than" "integration points."); + } auto const pair_it_inserted = _qr_decomposition_cache.emplace( std::make_pair(num_nodes, num_int_pts), CachedData{}); @@ -280,11 +286,13 @@ void LocalLinearLeastSquaresExtrapolator::calculateResidualElement( auto const num_values = static_cast<unsigned>(int_pt_vals.size()); if (num_values % num_components != 0) + { OGS_FATAL( "The number of computed integration point values is not divisable " "by the number of num_components. Maybe the computed property is " "not a %d-component vector for each integration point.", num_components); + } // number of integration points in the element const auto num_int_pts = num_values / num_components; diff --git a/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp b/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp index 2025d57b0a7c4c5e5b5d09e60decca60471b6d4a..6147fbbccf65e834a3f207e4f06dfc2677a33aa3 100644 --- a/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp +++ b/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.cpp @@ -102,8 +102,10 @@ computeMappingMatrices( static void checkJacobianDeterminant(const double detJ, MeshLib::Element const& element) { - if (detJ > 0) // The usual case + if (detJ > 0) + { // The usual case return; + } if (detJ < 0) { @@ -379,6 +381,6 @@ OGS_INSTANTIATE_NATURAL_COORDINATES_MAPPING_FIX(TetRule4, ShapeTet4, 3); OGS_INSTANTIATE_NATURAL_COORDINATES_MAPPING_FIX(TriRule3, ShapeTri3, 3); OGS_INSTANTIATE_NATURAL_COORDINATES_MAPPING_FIX(TriRule6, ShapeTri6, 3); -} // detail +} // namespace detail -} // NumLib +} // namespace NumLib diff --git a/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.h b/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.h index 24505d3e09dcf50c4277598adb9712b0d00e8fb0..528738cadfd6a82dee9a5dee7ec2098f4b80b425 100644 --- a/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.h +++ b/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.h @@ -84,4 +84,4 @@ struct NaturalCoordinatesMapping } }; -} // NumLib +} // namespace NumLib diff --git a/NumLib/Fem/CoordinatesMapping/ShapeMatrices-impl.h b/NumLib/Fem/CoordinatesMapping/ShapeMatrices-impl.h index e5a8a5f473de526286ffe69ba6800d2d85335849..e3ef9f6eb83e79a0ea15d7b6b5cef1e439a058d6 100644 --- a/NumLib/Fem/CoordinatesMapping/ShapeMatrices-impl.h +++ b/NumLib/Fem/CoordinatesMapping/ShapeMatrices-impl.h @@ -25,8 +25,10 @@ void setMatrixZero(T &mat) //mat.setZero(); const std::size_t n = mat.rows()*mat.cols(); auto* v = mat.data(); - for (std::size_t i=0; i<n; i++) + for (std::size_t i = 0; i < n; i++) + { v[i] = .0; + } } template<class T> @@ -35,8 +37,10 @@ void setVectorZero(T &vec) //vec.setZero(); const std::size_t n = vec.size(); auto* v = vec.data(); - for (std::size_t i=0; i<n; i++) + for (std::size_t i = 0; i < n; i++) + { v[i] = .0; + } } /* @@ -88,7 +92,7 @@ inline void setZero(ShapeMatrices<T_N, T_DNDR, T_J, T_DNDX> &shape, ShapeDataFie setZero(shape, ShapeDataFieldType<ShapeMatrixType::DNDX>()); } -} //detail +} // namespace detail template <class T_N, class T_DNDR, class T_J, class T_DNDX> inline void ShapeMatrices<T_N, T_DNDR, T_J, T_DNDX>::setZero() @@ -121,5 +125,4 @@ std::ostream& operator<< (std::ostream &os, const ShapeMatrices<T_N, T_DNDR, T_J return os; } -} // NumLib - +} // namespace NumLib diff --git a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h index 2175b76e039c7b94df47878d7d48b7b54ad6066c..e42183e2869b5a3c9ac91a04800b764d3b1ba062 100644 --- a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h +++ b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h @@ -108,7 +108,6 @@ struct ShapeMatrices EIGEN_MAKE_ALIGNED_OPERATOR_NEW; }; // ShapeMatrices - -} // NumLib +} // namespace NumLib #include "ShapeMatrices-impl.h" diff --git a/NumLib/Fem/FiniteElement/C0IsoparametricElements.h b/NumLib/Fem/FiniteElement/C0IsoparametricElements.h index 40cd749e95d25176964ae02ca8c6614b1a8f1db9..df304db07395b6f3b8180ec1650e6f19d5a6a103 100644 --- a/NumLib/Fem/FiniteElement/C0IsoparametricElements.h +++ b/NumLib/Fem/FiniteElement/C0IsoparametricElements.h @@ -145,4 +145,4 @@ struct FePYRA13 TemplateIsoparametric<ShapePyra13, T_SHAPE_MATRIX_POLICY<ShapePyra13>>; }; -} // NumLib +} // namespace NumLib diff --git a/NumLib/Fem/Integration/IntegrationPoint.h b/NumLib/Fem/Integration/IntegrationPoint.h index 479ad6f0c02358686b815ddea23bcb6f87caf92b..04e88a8db4fa5a08dc8006927862f71c2001cf77 100644 --- a/NumLib/Fem/Integration/IntegrationPoint.h +++ b/NumLib/Fem/Integration/IntegrationPoint.h @@ -76,4 +76,4 @@ public: return 1; } }; -} +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeHex20-impl.h b/NumLib/Fem/ShapeFunction/ShapeHex20-impl.h index 1d87d7d5fdf979d0bdd92184b28ea4267b86027c..51be47245250dc52d07cd47ba7333504abb5c14f 100644 --- a/NumLib/Fem/ShapeFunction/ShapeHex20-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeHex20-impl.h @@ -48,7 +48,7 @@ inline double dShapeFunctionHexHQ_Middle(const double r, const double s, const d return 0.0; } -} +} // namespace namespace NumLib { @@ -125,5 +125,4 @@ void ShapeHex20::computeGradShapeFunction(const T_X &rst, T_N &dNdr) } } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeHex20.h b/NumLib/Fem/ShapeFunction/ShapeHex20.h index f45bd79c08e7f864f5e9a3c8294c7e8164007ed2..04b7bc0cafc3b11fd076f626e2fc32e556e4a508 100644 --- a/NumLib/Fem/ShapeFunction/ShapeHex20.h +++ b/NumLib/Fem/ShapeFunction/ShapeHex20.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeHex20-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeHex8-impl.h b/NumLib/Fem/ShapeFunction/ShapeHex8-impl.h index 63640d1b369315c7ec51104b432f094bf9a069c0..524c843807bd681a012e9303e1778dae42df00df 100644 --- a/NumLib/Fem/ShapeFunction/ShapeHex8-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeHex8-impl.h @@ -57,5 +57,4 @@ void ShapeHex8::computeGradShapeFunction(const T_X &r, T_N &dN) dN[23] = -dN[19]; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeHex8.h b/NumLib/Fem/ShapeFunction/ShapeHex8.h index c3e52b7c0c7aaaa341f1ae963637befa46038d26..16f4be583b357fcbf2f2006cd1beb15c0456e248 100644 --- a/NumLib/Fem/ShapeFunction/ShapeHex8.h +++ b/NumLib/Fem/ShapeFunction/ShapeHex8.h @@ -62,6 +62,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeHex8-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeLine2-impl.h b/NumLib/Fem/ShapeFunction/ShapeLine2-impl.h index 456e929a9732551a6fb95d69978e5b39cca8c814..4f2100611fd91b2dc8b00f9fc6162f1c64bfa69e 100644 --- a/NumLib/Fem/ShapeFunction/ShapeLine2-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeLine2-impl.h @@ -24,5 +24,4 @@ void ShapeLine2::computeGradShapeFunction(const T_X &/*r*/, T_N &dN) dN[1] = 0.5; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeLine2.h b/NumLib/Fem/ShapeFunction/ShapeLine2.h index 3b578cf79164ffc8f8fdb05b882f0ffcd90591a5..eee67f2ecd3c71382f493bb0b895c2d1fa572447 100644 --- a/NumLib/Fem/ShapeFunction/ShapeLine2.h +++ b/NumLib/Fem/ShapeFunction/ShapeLine2.h @@ -48,6 +48,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeLine2-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeLine3-impl.h b/NumLib/Fem/ShapeFunction/ShapeLine3-impl.h index 9b547f8dc5fa1fe19c52006d34d5055b7b3dfda9..74dd1f60f1425a758bfa6cd95b89cc2082bcaee9 100644 --- a/NumLib/Fem/ShapeFunction/ShapeLine3-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeLine3-impl.h @@ -26,5 +26,4 @@ void ShapeLine3::computeGradShapeFunction(const T_X &r, T_N &dN) dN[2] = -2.0 * r[0]; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeLine3.h b/NumLib/Fem/ShapeFunction/ShapeLine3.h index edb947f6a29f8ae864962c659ed1d5974ea55d8e..11c586720b9f21aeeed56fe41b7d86e3a0df76ef 100644 --- a/NumLib/Fem/ShapeFunction/ShapeLine3.h +++ b/NumLib/Fem/ShapeFunction/ShapeLine3.h @@ -43,6 +43,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeLine3-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapePoint1.h b/NumLib/Fem/ShapeFunction/ShapePoint1.h index 3d156cdc50e91e5b376a4d795a7e6e9eb70f5914..47ae0473fb4aa2b0a6aef43b7c54b0c53a6224ad 100644 --- a/NumLib/Fem/ShapeFunction/ShapePoint1.h +++ b/NumLib/Fem/ShapeFunction/ShapePoint1.h @@ -28,6 +28,6 @@ public: static const unsigned DIM = MeshElement::dimension; static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapePoint1-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapePrism15-impl.h b/NumLib/Fem/ShapeFunction/ShapePrism15-impl.h index 1f37d99964d26d47e2bd019214cf207b7651aa35..541eea847154050f2b4fc87bfeef3d3b26af5080 100644 --- a/NumLib/Fem/ShapeFunction/ShapePrism15-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapePrism15-impl.h @@ -131,5 +131,4 @@ void ShapePrism15::computeGradShapeFunction(const T_X &x, T_N &dN) dN[44] = -2.0 * L2 * t; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapePrism15.h b/NumLib/Fem/ShapeFunction/ShapePrism15.h index 89dc2d82303caa94471cdd423e818fc6ab00196f..26dab800d4bb7e728a146c231b6d5c26adc14882 100644 --- a/NumLib/Fem/ShapeFunction/ShapePrism15.h +++ b/NumLib/Fem/ShapeFunction/ShapePrism15.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapePrism15-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapePrism6-impl.h b/NumLib/Fem/ShapeFunction/ShapePrism6-impl.h index a4c6d0cd39a5fd283d3d084f3181b93ec2a4e85f..5ec27d1c8c135a0cba14e8023297c441056709c1 100644 --- a/NumLib/Fem/ShapeFunction/ShapePrism6-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapePrism6-impl.h @@ -53,5 +53,4 @@ void ShapePrism6::computeGradShapeFunction(const T_X &x, T_N &dN) dN[17] = -dN[14]; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapePrism6.h b/NumLib/Fem/ShapeFunction/ShapePrism6.h index 22e47ec019838586ce6c01708065eebe0614ea00..12dd8456be5b1d9ac83b7f883ce7143f0ef8974a 100644 --- a/NumLib/Fem/ShapeFunction/ShapePrism6.h +++ b/NumLib/Fem/ShapeFunction/ShapePrism6.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapePrism6-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapePyra13-impl.h b/NumLib/Fem/ShapeFunction/ShapePyra13-impl.h index 1f6b454336422c6f24967731e2617337cf4119a3..5f07094edb7a67e5696abeb16b4ba8446515aca6 100644 --- a/NumLib/Fem/ShapeFunction/ShapePyra13-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapePyra13-impl.h @@ -84,5 +84,4 @@ void ShapePyra13::computeGradShapeFunction(const T_X &x, T_N &dN) dN[38] = -0.5 * (1.0 - r) * (1.0 + s) * t; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapePyra13.h b/NumLib/Fem/ShapeFunction/ShapePyra13.h index 2967afae3a6d13caebdbc6d9ea4d720da09aef92..d66f49fac800488a1e7e81d3baa32771b9f3bbd2 100644 --- a/NumLib/Fem/ShapeFunction/ShapePyra13.h +++ b/NumLib/Fem/ShapeFunction/ShapePyra13.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapePyra13-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapePyra5-impl.h b/NumLib/Fem/ShapeFunction/ShapePyra5-impl.h index aef0468d8ca1f8325f457af04e49b7a1eabe09d6..5d9f43a74a98ceed07532ced9860064b6615e97c 100644 --- a/NumLib/Fem/ShapeFunction/ShapePyra5-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapePyra5-impl.h @@ -50,5 +50,4 @@ void ShapePyra5::computeGradShapeFunction(const T_X &x, T_N &dN) dN[14] = 0.5; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapePyra5.h b/NumLib/Fem/ShapeFunction/ShapePyra5.h index 9a4f07422a5cacce79206bbc86c7ba8e3c29362b..2bd1fd5a52566efbd0fe70d383bc5908f646df1c 100644 --- a/NumLib/Fem/ShapeFunction/ShapePyra5.h +++ b/NumLib/Fem/ShapeFunction/ShapePyra5.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapePyra5-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeQuad4-impl.h b/NumLib/Fem/ShapeFunction/ShapeQuad4-impl.h index 0f373d00dfc60bd018bbe6454dc06d771cbf1a9a..305c85c83cb72b9abf244e723f3f0b4c70174861 100644 --- a/NumLib/Fem/ShapeFunction/ShapeQuad4-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeQuad4-impl.h @@ -35,5 +35,4 @@ void ShapeQuad4::computeGradShapeFunction(const T_X &r, T_N &dN) dN[7] = -(1.0 + r[0]) / 4; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeQuad4.h b/NumLib/Fem/ShapeFunction/ShapeQuad4.h index 15e77920f386ea3142e8a8a043383b4d82501996..2857a0198624dd337934f0be4e8162fb83e5d769 100644 --- a/NumLib/Fem/ShapeFunction/ShapeQuad4.h +++ b/NumLib/Fem/ShapeFunction/ShapeQuad4.h @@ -56,6 +56,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeQuad4-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeQuad8-impl.h b/NumLib/Fem/ShapeFunction/ShapeQuad8-impl.h index a909cbb1e803fbb0addddb56ab27f90dcdcf2f98..bba05a1a3e8cb7296f402a8f9ebb4920ff333dbb 100644 --- a/NumLib/Fem/ShapeFunction/ShapeQuad8-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeQuad8-impl.h @@ -53,5 +53,4 @@ void ShapeQuad8::computeGradShapeFunction(const T_X &rs, T_N &dNdr) dNdr[15] = -(1 + r) * s; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeQuad8.h b/NumLib/Fem/ShapeFunction/ShapeQuad8.h index 6c7683d61666af104e0902e9247bf8c6ef8e23c0..c0fddbe933600b875f1b201d1e8f50bce4a111cd 100644 --- a/NumLib/Fem/ShapeFunction/ShapeQuad8.h +++ b/NumLib/Fem/ShapeFunction/ShapeQuad8.h @@ -43,6 +43,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeQuad8-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeQuad9-impl.h b/NumLib/Fem/ShapeFunction/ShapeQuad9-impl.h index 6ac7d32d6ec8ba8815a9f8249613a73549237220..fa08753f88d6f1e4853c8ea96e258dc50309a565 100644 --- a/NumLib/Fem/ShapeFunction/ShapeQuad9-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeQuad9-impl.h @@ -46,5 +46,4 @@ void ShapeQuad9::computeGradShapeFunction(const T_X& r, T_N& dNdr) dNdr[17] = 2 * r[1] * (r[0] * r[0] - 1); dNdr[9] = (r[1] + 0.5) * r[0] * (r[0] + 1) / 2; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeQuad9.h b/NumLib/Fem/ShapeFunction/ShapeQuad9.h index a47408472ffcb786b54e516863404f689b958a19..3e7154de0305a04905351fecde56adc759aab4dc 100644 --- a/NumLib/Fem/ShapeFunction/ShapeQuad9.h +++ b/NumLib/Fem/ShapeFunction/ShapeQuad9.h @@ -43,6 +43,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeQuad9-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeStaticConsts.cpp b/NumLib/Fem/ShapeFunction/ShapeStaticConsts.cpp index e0bdcef97d4fbda860d23f0a2619c88fc0e60268..a21c0a6f318f18cfa51a11cda3c1038cf69e9527 100644 --- a/NumLib/Fem/ShapeFunction/ShapeStaticConsts.cpp +++ b/NumLib/Fem/ShapeFunction/ShapeStaticConsts.cpp @@ -88,4 +88,4 @@ const unsigned ShapeTri3::NPOINTS; const unsigned ShapeTri6::DIM; const unsigned ShapeTri6::NPOINTS; -} +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeTet10-impl.h b/NumLib/Fem/ShapeFunction/ShapeTet10-impl.h index 3c8a7e5559e260562d29669b09be1b38dd43a322..23db9d96bfce76906567443f75e433fd546f2dda 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTet10-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeTet10-impl.h @@ -62,5 +62,4 @@ void ShapeTet10::computeGradShapeFunction(const T_X &r, T_N &dNdr) dNdr[29] = 4.0 * r[1]; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeTet10.h b/NumLib/Fem/ShapeFunction/ShapeTet10.h index 044176a8ddc0093fe6f858161a76760df3493386..6f032709cd3bdb9e3ce2dfc6b380aa301ee36bbc 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTet10.h +++ b/NumLib/Fem/ShapeFunction/ShapeTet10.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeTet10-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeTet4-impl.h b/NumLib/Fem/ShapeFunction/ShapeTet4-impl.h index 5df41174c9e41477c031feddaed581375eadf9ea..4a0d8bcb072f79558a8a1dbef6cccd40f4229e60 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTet4-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeTet4-impl.h @@ -41,5 +41,4 @@ void ShapeTet4::computeGradShapeFunction(const T_X &/*r*/, T_N &dNdr) dNdr[11] = 1.0; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeTet4.h b/NumLib/Fem/ShapeFunction/ShapeTet4.h index 6ec0c2d1617929debf98a3ec07a81518a2f815f7..b53b34f8bc53bfc0c7a002afaf9e53abb6a311e4 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTet4.h +++ b/NumLib/Fem/ShapeFunction/ShapeTet4.h @@ -44,6 +44,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeTet4-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeTri3-impl.h b/NumLib/Fem/ShapeFunction/ShapeTri3-impl.h index 0e191788706389d4d5897c576240fc763adb78ca..1303b669aa2067e4d6aa3b2734cfc9362aa0d390 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTri3-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeTri3-impl.h @@ -36,5 +36,4 @@ void ShapeTri3::computeGradShapeFunction(const T_X &/*r*/, T_N &dN) dN[5] = 1.0; } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeTri3.h b/NumLib/Fem/ShapeFunction/ShapeTri3.h index 557e1a2bfc37970423471ab56174ebb9342f4ced..b3c9901c61117e092a441e89df64fd446d018ac3 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTri3.h +++ b/NumLib/Fem/ShapeFunction/ShapeTri3.h @@ -57,6 +57,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeTri3-impl.h" diff --git a/NumLib/Fem/ShapeFunction/ShapeTri6-impl.h b/NumLib/Fem/ShapeFunction/ShapeTri6-impl.h index d0293c65843fc0b78bf7dc45a6f857a1578a052d..390433e03c1a624eebb2b675a22c8db53562f7cf 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTri6-impl.h +++ b/NumLib/Fem/ShapeFunction/ShapeTri6-impl.h @@ -43,5 +43,4 @@ void ShapeTri6::computeGradShapeFunction(const T_X &r, T_N &dNdr) dNdr[11] = 4. * (1 - r[0] - 2. * r[1]); // dN6/dL2 } -} - +} // namespace NumLib diff --git a/NumLib/Fem/ShapeFunction/ShapeTri6.h b/NumLib/Fem/ShapeFunction/ShapeTri6.h index 4f47a15411d987ad95e87224b1ca095bf6cd8d6c..d1854e185745047034d1bc87a63b0d1e40ae25f0 100644 --- a/NumLib/Fem/ShapeFunction/ShapeTri6.h +++ b/NumLib/Fem/ShapeFunction/ShapeTri6.h @@ -45,6 +45,6 @@ public: static const unsigned NPOINTS = MeshElement::n_all_nodes; }; -} +} // namespace NumLib #include "ShapeTri6-impl.h" diff --git a/NumLib/Fem/ShapeMatrixPolicy.h b/NumLib/Fem/ShapeMatrixPolicy.h index 05450d0961a467a2d6eaf9fdef4eb234c5419100..7f8d15f5996f12027e8999e693638ce495d1fa97 100644 --- a/NumLib/Fem/ShapeMatrixPolicy.h +++ b/NumLib/Fem/ShapeMatrixPolicy.h @@ -47,7 +47,7 @@ namespace detail using type = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>; }; -} // detail + } // namespace detail /// An implementation of ShapeMatrixPolicy using fixed size (compile-time) eigen /// matrices and vectors. diff --git a/NumLib/Function/ISpatialFunction.h b/NumLib/Function/ISpatialFunction.h index fe3e018ac7cb934845b81f181757149b86ccc5f3..f674a12c36b3325f9e71b5472d6e334e4b3b1834 100644 --- a/NumLib/Function/ISpatialFunction.h +++ b/NumLib/Function/ISpatialFunction.h @@ -35,4 +35,4 @@ public: virtual double operator()(const MathLib::Point3d& pnt) const = 0; }; -} // NumLib +} // namespace NumLib diff --git a/NumLib/Function/LinearInterpolationAlongPolyline.cpp b/NumLib/Function/LinearInterpolationAlongPolyline.cpp index a8bd96ea27168200aa55ba7f310e7eb8c5265065..8eff055a784e4c53aa51107ccc35ab7f7dcee7ab 100644 --- a/NumLib/Function/LinearInterpolationAlongPolyline.cpp +++ b/NumLib/Function/LinearInterpolationAlongPolyline.cpp @@ -42,7 +42,9 @@ MathLib::PiecewiseLinearInterpolation LinearInterpolationAlongPolyline::createIn { const std::size_t pnt_id = vec_interpolate_point_ids[i]; if (!ply.isPointIDInPolyline(pnt_id)) + { continue; + } for (std::size_t j=0; j<ply.getNumberOfPoints(); j++) { @@ -65,5 +67,4 @@ double LinearInterpolationAlongPolyline::operator()(const MathLib::Point3d& pnt) return dist>=0 ? _interpolation.getValue(dist) : _default_value; } -} // NumLib - +} // namespace NumLib diff --git a/NumLib/Function/LinearInterpolationAlongPolyline.h b/NumLib/Function/LinearInterpolationAlongPolyline.h index cdd1dbcfb8f8461a3c837c93d35fceb6672058e6..8e733c589ac30b45ba3d6930499ad99f3df489b4 100644 --- a/NumLib/Function/LinearInterpolationAlongPolyline.h +++ b/NumLib/Function/LinearInterpolationAlongPolyline.h @@ -75,4 +75,4 @@ private: const double _default_value; }; -} // NumLib +} // namespace NumLib diff --git a/NumLib/Function/LinearInterpolationOnSurface.cpp b/NumLib/Function/LinearInterpolationOnSurface.cpp index d917ff4a86960d8e6ba14b25944a0dabc5e59ae7..67e653cf5fc03f6d4ec8306a3ba9d5b082fb9934 100644 --- a/NumLib/Function/LinearInterpolationOnSurface.cpp +++ b/NumLib/Function/LinearInterpolationOnSurface.cpp @@ -43,10 +43,14 @@ LinearInterpolationOnSurface::LinearInterpolationOnSurface( double LinearInterpolationOnSurface::operator()(const MathLib::Point3d& pnt) const { if (!_sfc.isPntInBoundingVolume(pnt, 0)) + { return _default_value; + } auto* tri = _sfc.findTriangle(pnt); if (tri == nullptr) + { return _default_value; + } std::array<double, 3> pnt_values; for (unsigned j=0; j<3; j++) { @@ -68,8 +72,10 @@ double LinearInterpolationOnSurface::interpolateInTri( MathLib::Point3d const& pnt) const { std::vector<GeoLib::Point> pnts; - for (unsigned i=0; i<3; i++) + for (unsigned i = 0; i < 3; i++) + { pnts.emplace_back(*tri.getPoint(i)); + } pnts.emplace_back(pnt, -1); std::vector<GeoLib::Point*> p_pnts = {{&pnts[0], &pnts[1], &pnts[2], &pnts[3]}}; GeoLib::rotatePointsToXY(p_pnts.begin(), p_pnts.begin()+3, p_pnts.begin(), p_pnts.end()); @@ -104,11 +110,12 @@ double LinearInterpolationOnSurface::interpolateInTri( c[2] = 0.5/area*(v2[0]-v1[0]); double val = .0; - for (unsigned i=0; i<3; i++) - val += (a[i]+b[i]*v_pnt[0]+c[i]*v_pnt[1]) * vertex_values[i]; + for (unsigned i = 0; i < 3; i++) + { + val += (a[i] + b[i] * v_pnt[0] + c[i] * v_pnt[1]) * vertex_values[i]; + } return val; } -} // NumLib - +} // namespace NumLib diff --git a/NumLib/Function/LinearInterpolationOnSurface.h b/NumLib/Function/LinearInterpolationOnSurface.h index 0d3bd1c23b6bbeb80fa5fc5cafdabd4fd922395d..ac020a81393c0dd448fad9607c06805094ec0956 100644 --- a/NumLib/Function/LinearInterpolationOnSurface.h +++ b/NumLib/Function/LinearInterpolationOnSurface.h @@ -94,4 +94,4 @@ private: const double _default_value; }; -} // NumLib +} // namespace NumLib diff --git a/NumLib/Function/TemplateSpatialFunction.h b/NumLib/Function/TemplateSpatialFunction.h index d5a9c4ae6f5e64fcd63f9a46c65619989de881cd..f645ace89e37a494ad7e46274a4676993278d964 100644 --- a/NumLib/Function/TemplateSpatialFunction.h +++ b/NumLib/Function/TemplateSpatialFunction.h @@ -48,4 +48,4 @@ private: const T_FUNCTION _f; }; -} +} // namespace NumLib diff --git a/NumLib/IndexValueVector.h b/NumLib/IndexValueVector.h index 16ef2cab8e86f3fa089b3d4f4505ef92cdfc6b50..587b4c6436a9432a24c3d1565537fd3200479fb9 100644 --- a/NumLib/IndexValueVector.h +++ b/NumLib/IndexValueVector.h @@ -21,4 +21,4 @@ struct IndexValueVector final std::vector<double> values; }; -} +} // namespace NumLib diff --git a/NumLib/NamedFunctionCaller.cpp b/NumLib/NamedFunctionCaller.cpp index d4eeb01793b184ae56fca7ab2d7ffd456f62d0cb..50c2d58b9757347d5f039faaa40914cc55f9ff07 100644 --- a/NumLib/NamedFunctionCaller.cpp +++ b/NumLib/NamedFunctionCaller.cpp @@ -33,8 +33,10 @@ bool hasTopologicalOrdering(std::vector<std::vector<int>> const& graph) { for (int node_j : node_i_adjacencies) { - if (node_j >= 0) // ignore negative indices. + if (node_j >= 0) + { // ignore negative indices. ++number_incoming_edges[node_j]; + } } } @@ -61,7 +63,9 @@ bool hasTopologicalOrdering(std::vector<std::vector<int>> const& graph) for (int node_j : graph[node_i]) { if (node_j < 0) + { continue; // ignore negative indices + } if (--number_incoming_edges[node_j] == 0) { // Add a node without incoming edges to the queue. q.push_back(node_j); @@ -89,13 +93,17 @@ void traverse(std::vector<std::vector<int>> const& map_sink_source, callback(sink_fct, TraversePosition::StartNode); if (sink_fct < 0) + { return; + } auto const& si_so = map_sink_source[sink_fct]; std::size_t const num_args = si_so.size(); for (std::size_t sink_arg = 0; sink_arg != num_args; ++sink_arg) { if (sink_arg != 0) + { callback(sink_fct, TraversePosition::BetweenChildren); + } traverse(map_sink_source, si_so[sink_arg], callback); } diff --git a/NumLib/NewtonRaphson.h b/NumLib/NewtonRaphson.h index cff66487247f3138c110e994ed379da9afefe932..719b9dae759deecfe0e4cecced5a3742ea239e83 100644 --- a/NumLib/NewtonRaphson.h +++ b/NumLib/NewtonRaphson.h @@ -64,7 +64,9 @@ public: _residual_update(residual); if (residual.squaredNorm() < _tolerance_squared) + { break; // convergence criteria fulfilled. + } increment.noalias() = _linear_solver.compute(jacobian).solve(-residual); diff --git a/NumLib/ODESolver/ConvergenceCriterion.cpp b/NumLib/ODESolver/ConvergenceCriterion.cpp index 1e7fb09b7950cb958c4e4f69dd812476919984c7..04c39d19a8bcf008faca861befd724de1eb24af0 100644 --- a/NumLib/ODESolver/ConvergenceCriterion.cpp +++ b/NumLib/ODESolver/ConvergenceCriterion.cpp @@ -51,4 +51,4 @@ bool checkRelativeTolerance(const double reltol, const double numerator, std::abs(reltol) * (std::abs(denominator) + eps); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp b/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp index 72776e38b594516f4877aea06baec47a5b536b57..efc95b5ef217b8b3dd8e00c88c51c39400a66041 100644 --- a/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionDeltaX.cpp @@ -24,9 +24,11 @@ ConvergenceCriterionDeltaX::ConvergenceCriterionDeltaX( _reltol(std::move(relative_tolerance)) { if ((!_abstol) && (!_reltol)) + { OGS_FATAL( "At least one of absolute or relative tolerance has to be " "specified."); + } } void ConvergenceCriterionDeltaX::checkDeltaX(const GlobalVector& minus_delta_x, @@ -69,10 +71,12 @@ std::unique_ptr<ConvergenceCriterionDeltaX> createConvergenceCriterionDeltaX( auto const norm_type = MathLib::convertStringToVecNormType(norm_type_str); if (norm_type == MathLib::VecNormType::INVALID) + { OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); + } return std::make_unique<ConvergenceCriterionDeltaX>( std::move(abstol), std::move(reltol), norm_type); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionDeltaX.h b/NumLib/ODESolver/ConvergenceCriterionDeltaX.h index 8d54841dbef26cc898d071515c91f59db733d6fe..3f451db5ef3addfd6d8e53b70175325c1072f82a 100644 --- a/NumLib/ODESolver/ConvergenceCriterionDeltaX.h +++ b/NumLib/ODESolver/ConvergenceCriterionDeltaX.h @@ -44,4 +44,4 @@ private: std::unique_ptr<ConvergenceCriterionDeltaX> createConvergenceCriterionDeltaX( BaseLib::ConfigTree const& config); -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp index e3e75b604c7aa05dd525149b37bbd68af9fcdbdf..0a087016cf2f980d06dd19fbef73e4fdf979f3f6 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp @@ -26,19 +26,25 @@ ConvergenceCriterionPerComponentDeltaX::ConvergenceCriterionPerComponentDeltaX( _reltols(std::move(relative_tolerances)) { if (_abstols.size() != _reltols.size()) + { OGS_FATAL( "The number of absolute and relative tolerances given must be the " "same."); + } if (_abstols.empty()) + { OGS_FATAL("The given tolerances vector is empty."); + } } void ConvergenceCriterionPerComponentDeltaX::checkDeltaX( const GlobalVector& minus_delta_x, GlobalVector const& x) { if ((!_dof_table) || (!_mesh)) + { OGS_FATAL("D.o.f. table or mesh have not been set."); + } bool satisfied_abs = true; bool satisfied_rel = true; @@ -76,9 +82,11 @@ void ConvergenceCriterionPerComponentDeltaX::setDOFTable( if (_dof_table->getNumberOfComponents() != static_cast<int>(_abstols.size())) + { OGS_FATAL( "The number of components in the DOF table and the number of " "tolerances given do not match."); + } } std::unique_ptr<ConvergenceCriterionPerComponentDeltaX> @@ -98,9 +106,11 @@ createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree& config) config.getConfigParameter<std::string>("norm_type"); if ((!abstols) && (!reltols)) + { OGS_FATAL( "At least one of absolute or relative tolerance has to be " "specified."); + } if (!abstols) { abstols = std::vector<double>(reltols->size()); } else if (!reltols) { @@ -110,10 +120,12 @@ createConvergenceCriterionPerComponentDeltaX(const BaseLib::ConfigTree& config) auto const norm_type = MathLib::convertStringToVecNormType(norm_type_str); if (norm_type == MathLib::VecNormType::INVALID) + { OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); + } return std::make_unique<ConvergenceCriterionPerComponentDeltaX>( std::move(*abstols), std::move(*reltols), norm_type); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp index adcca76a16bc46af2c1f1bf8dffd425769b8e026..95fe6ef7a0a1afb6ba6082f06d378d86621e437d 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp @@ -27,12 +27,16 @@ ConvergenceCriterionPerComponentResidual:: _residual_norms_0(_abstols.size()) { if (_abstols.size() != _reltols.size()) + { OGS_FATAL( "The number of absolute and relative tolerances given must be the " "same."); + } if (_abstols.empty()) + { OGS_FATAL("The given tolerances vector is empty."); + } } @@ -40,7 +44,9 @@ void ConvergenceCriterionPerComponentResidual::checkDeltaX( const GlobalVector& minus_delta_x, GlobalVector const& x) { if ((!_dof_table) || (!_mesh)) + { OGS_FATAL("D.o.f. table or mesh have not been set."); + } for (unsigned global_component = 0; global_component < _abstols.size(); ++global_component) @@ -65,7 +71,9 @@ void ConvergenceCriterionPerComponentResidual::checkResidual( const GlobalVector& residual) { if ((!_dof_table) || (!_mesh)) + { OGS_FATAL("D.o.f. table or mesh have not been set."); + } bool satisfied_abs = true; // Make sure that in the first iteration the relative residual tolerance is @@ -110,9 +118,11 @@ void ConvergenceCriterionPerComponentResidual::setDOFTable( if (_dof_table->getNumberOfComponents() != static_cast<int>(_abstols.size())) + { OGS_FATAL( "The number of components in the DOF table and the number of " "tolerances given do not match."); + } } std::unique_ptr<ConvergenceCriterionPerComponentResidual> @@ -133,9 +143,11 @@ createConvergenceCriterionPerComponentResidual( config.getConfigParameter<std::string>("norm_type"); if ((!abstols) && (!reltols)) + { OGS_FATAL( "At least one of absolute or relative tolerance has to be " "specified."); + } if (!abstols) { abstols = std::vector<double>(reltols->size()); } else if (!reltols) { @@ -145,10 +157,12 @@ createConvergenceCriterionPerComponentResidual( auto const norm_type = MathLib::convertStringToVecNormType(norm_type_str); if (norm_type == MathLib::VecNormType::INVALID) + { OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); + } return std::make_unique<ConvergenceCriterionPerComponentResidual>( std::move(*abstols), std::move(*reltols), norm_type); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionResidual.cpp b/NumLib/ODESolver/ConvergenceCriterionResidual.cpp index 55ab58362354a94f160e73f9d7670f6a18b84005..8d2d61957f60ae661b29c782491168ebfa22c802 100644 --- a/NumLib/ODESolver/ConvergenceCriterionResidual.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionResidual.cpp @@ -24,9 +24,11 @@ ConvergenceCriterionResidual::ConvergenceCriterionResidual( _reltol(std::move(relative_tolerance)) { if ((!_abstol) && (!_reltol)) + { OGS_FATAL( "At least one of absolute or relative tolerance has to be " "specified."); + } } void ConvergenceCriterionResidual::checkDeltaX( @@ -103,10 +105,12 @@ createConvergenceCriterionResidual(const BaseLib::ConfigTree& config) auto const norm_type = MathLib::convertStringToVecNormType(norm_type_str); if (norm_type == MathLib::VecNormType::INVALID) + { OGS_FATAL("Unknown vector norm type `%s'.", norm_type_str.c_str()); + } return std::make_unique<ConvergenceCriterionResidual>( std::move(abstol), std::move(reltol), norm_type); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/ConvergenceCriterionResidual.h b/NumLib/ODESolver/ConvergenceCriterionResidual.h index e20e23098728aa30c9d22f29044e2d1e152d37de..f410856ddb43c9caa22e68e171a86e9885e9a34b 100644 --- a/NumLib/ODESolver/ConvergenceCriterionResidual.h +++ b/NumLib/ODESolver/ConvergenceCriterionResidual.h @@ -46,4 +46,4 @@ private: std::unique_ptr<ConvergenceCriterionResidual> createConvergenceCriterionResidual( BaseLib::ConfigTree const& config); -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/EquationSystem.h b/NumLib/ODESolver/EquationSystem.h index be4eb2b7533c647680f0d1b87b972507266b4d45..c64c62ade9f5cc227d07ad9e736af40be9a13f46 100644 --- a/NumLib/ODESolver/EquationSystem.h +++ b/NumLib/ODESolver/EquationSystem.h @@ -64,4 +64,4 @@ public: }; //! @} -} +} // namespace NumLib diff --git a/NumLib/ODESolver/MatrixTranslator.cpp b/NumLib/ODESolver/MatrixTranslator.cpp index 930a2f07c07dff40605e6682517250db35d6422a..a65c0dfb552d1023d65d2ca9e4db6364fac963e9 100644 --- a/NumLib/ODESolver/MatrixTranslator.cpp +++ b/NumLib/ODESolver/MatrixTranslator.cpp @@ -222,4 +222,4 @@ void MatrixTranslatorCrankNicolson< LinAlg::scale(_b_bar, 1.0 - theta); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/ODESolver/MatrixTranslator.h b/NumLib/ODESolver/MatrixTranslator.h index 0fce925f462659d518bd1aafd240e1867a53a9ae..b82b508e5a6641311465c05758c30bbd348de5dd 100644 --- a/NumLib/ODESolver/MatrixTranslator.h +++ b/NumLib/ODESolver/MatrixTranslator.h @@ -308,4 +308,4 @@ std::unique_ptr<MatrixTranslator<ODETag>> createMatrixTranslator( } //! @} -} +} // namespace NumLib diff --git a/NumLib/ODESolver/NonlinearSolver.cpp b/NumLib/ODESolver/NonlinearSolver.cpp index ae8d9419402d5aa807c37433b0ed556fe8a30e10..93dd4b71c46da5a2f0e61b1d8944f2e8f4eb58c7 100644 --- a/NumLib/ODESolver/NonlinearSolver.cpp +++ b/NumLib/ODESolver/NonlinearSolver.cpp @@ -94,7 +94,9 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Picard>::solve( else { if (postIterationCallback) + { postIterationCallback(iteration, x_new); + } switch (sys.postIteration(x_new)) { @@ -147,12 +149,16 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Picard>::solve( time_iteration.elapsed()); if (error_norms_met) + { break; + } // Avoid increment of the 'iteration' if the error norms are not met, // but maximum number of iterations is reached. if (iteration >= _maxiter) + { break; + } } if (iteration > _maxiter) @@ -234,7 +240,9 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Newton>::solve( INFO("[time] Applying Dirichlet BCs took %g s.", time_dirichlet); if (!sys.isLinear() && _convergence_criterion->hasResidualCheck()) + { _convergence_criterion->checkResidual(res); + } BaseLib::RunTime time_linear_solver; time_linear_solver.start(); @@ -255,7 +263,9 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Newton>::solve( LinAlg::axpy(x_new, -_damping, minus_delta_x); if (postIterationCallback) + { postIterationCallback(iteration, x_new); + } switch(sys.postIteration(x_new)) { @@ -302,12 +312,16 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Newton>::solve( time_iteration.elapsed()); if (error_norms_met) + { break; + } // Avoid increment of the 'iteration' if the error norms are not met, // but maximum number of iterations is reached. if (iteration >= _maxiter) + { break; + } } if (iteration > _maxiter) @@ -359,4 +373,4 @@ createNonlinearSolver(GlobalLinearSolver& linear_solver, } OGS_FATAL("Unsupported nonlinear solver type"); } -} +} // namespace NumLib diff --git a/NumLib/ODESolver/NonlinearSystem.h b/NumLib/ODESolver/NonlinearSystem.h index 8cb605e54ca0641f085ddd0813968d5ebafd117e..35fa141a85755a4f4d80cc428b5b63530bcfaed0 100644 --- a/NumLib/ODESolver/NonlinearSystem.h +++ b/NumLib/ODESolver/NonlinearSystem.h @@ -106,4 +106,4 @@ public: }; //! @} -} +} // namespace NumLib diff --git a/NumLib/ODESolver/TimeDiscretization.cpp b/NumLib/ODESolver/TimeDiscretization.cpp index 233892fb53bcf904eaf039c0e3e6fdd2b0b3c0b7..264db390acd010c3a4a94b9fe45fff0a925142c8 100644 --- a/NumLib/ODESolver/TimeDiscretization.cpp +++ b/NumLib/ODESolver/TimeDiscretization.cpp @@ -26,7 +26,9 @@ double TimeDiscretization::computeRelativeChangeFromPreviousTimestep( } if (!_dx) + { _dx = MathLib::MatrixVectorTraits<GlobalVector>::newInstance(x); + } auto& dx = *_dx; MathLib::LinAlg::copy(x, dx); // copy x to dx. @@ -37,11 +39,15 @@ double TimeDiscretization::computeRelativeChangeFromPreviousTimestep( const double norm_x = MathLib::LinAlg::norm(x, norm_type); if (norm_x > std::numeric_limits<double>::epsilon()) + { return norm_dx / norm_x; + } // Both of norm_x and norm_dx are close to zero if (norm_dx < std::numeric_limits<double>::epsilon()) + { return 1.0; + } // Only norm_x is close to zero return norm_dx / std::numeric_limits<double>::epsilon(); @@ -107,7 +113,7 @@ const double BDF_Coeffs[6][7] = { // coefficient of (for BDF(6), the oldest state, x_n, is always rightmost) // x_+6, x_+5, x_+4, x_+3, x_+2, x_+1, x_n }; -} +} // namespace detail double BackwardDifferentiationFormula::getNewXWeight() const { diff --git a/NumLib/ODESolver/TimeDiscretization.h b/NumLib/ODESolver/TimeDiscretization.h index 8eeceb1ff977cb3a214f652da34cc4a6791ebf80..32303aeb5b7c6742c6c38d127c8b710b25d47170 100644 --- a/NumLib/ODESolver/TimeDiscretization.h +++ b/NumLib/ODESolver/TimeDiscretization.h @@ -474,7 +474,9 @@ public: ~BackwardDifferentiationFormula() override { for (auto* x : _xs_old) + { NumLib::GlobalVectorProvider::provider.releaseVector(*x); + } } void setInitialState(const double t0, GlobalVector const& x0) override @@ -518,4 +520,4 @@ private: }; //! @} -} +} // namespace NumLib diff --git a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp index 2d608f6dc15a79b3d5c6fdabfda80c4e01540a4c..e6a8d73de1fd75aa3d233f987cfaed81f51d4a29 100644 --- a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp +++ b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp @@ -46,4 +46,4 @@ std::unique_ptr<TimeDiscretization> createTimeDiscretization( OGS_FATAL("Unrecognized time discretization type `%s'", type.c_str()); } -} +} // namespace NumLib diff --git a/NumLib/ODESolver/TimeDiscretizedODESystem.cpp b/NumLib/ODESolver/TimeDiscretizedODESystem.cpp index c352440db0b47b2e2667c00ebd345b172ca12492..5c0b725f06d733a0039a782d27dea75c43427322 100644 --- a/NumLib/ODESolver/TimeDiscretizedODESystem.cpp +++ b/NumLib/ODESolver/TimeDiscretizedODESystem.cpp @@ -21,7 +21,9 @@ void applyKnownSolutions(std::vector<Solutions> const* const known_solutions, Vector& x) { if (!known_solutions) + { return; + } for (auto const& bc : *known_solutions) { @@ -140,7 +142,9 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, GlobalVector& minus_delta_x) const { if (!_known_solutions) + { return; + } using IndexType = MathLib::MatrixVectorTraits<GlobalMatrix>::Index; std::vector<IndexType> ids; @@ -221,7 +225,9 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, GlobalVector& x) const { if (!_known_solutions) + { return; + } using IndexType = MathLib::MatrixVectorTraits<GlobalMatrix>::Index; std::vector<IndexType> ids; diff --git a/NumLib/ODESolver/TimeDiscretizedODESystem.h b/NumLib/ODESolver/TimeDiscretizedODESystem.h index 66967798fd0cfa1cd8ba37f452dadfc452f32981..913df22fbdb5fb9046f143c94c6d70feba8bb48e 100644 --- a/NumLib/ODESolver/TimeDiscretizedODESystem.h +++ b/NumLib/ODESolver/TimeDiscretizedODESystem.h @@ -245,4 +245,4 @@ private: }; //! @} -} +} // namespace NumLib diff --git a/NumLib/TimeStepping/Algorithms/EvolutionaryPIDcontroller.cpp b/NumLib/TimeStepping/Algorithms/EvolutionaryPIDcontroller.cpp index ca5103224da9055d1f73d1145f625fd4d403f43c..21e54d04033f5d22c8beb85927b274cacd30ffa9 100644 --- a/NumLib/TimeStepping/Algorithms/EvolutionaryPIDcontroller.cpp +++ b/NumLib/TimeStepping/Algorithms/EvolutionaryPIDcontroller.cpp @@ -127,7 +127,9 @@ double EvolutionaryPIDcontroller::limitStepSize( // step size is then reduced by half. if (std::fabs(limited_h - _ts_current.dt()) < std::numeric_limits<double>::min()) + { limited_h = std::max(_h_min, 0.5 * limited_h); + } // If the last time step was rejected and the new predicted time step // size is larger than the step size of the rejected step, the new step @@ -136,7 +138,9 @@ double EvolutionaryPIDcontroller::limitStepSize( // solver. In such case, this algorithm may give a large time step size // by using the diverged solution. if (limited_h > _ts_current.dt()) + { limited_h = std::max(_h_min, 0.5 * _ts_current.dt()); + } } return limited_h; } @@ -144,7 +148,9 @@ double EvolutionaryPIDcontroller::limitStepSize( double EvolutionaryPIDcontroller::checkSpecificTimeReached(const double h_new) { if (_fixed_output_times.empty()) + { return h_new; + } const double specific_time = _fixed_output_times.back(); if ((specific_time > _ts_current.current()) && diff --git a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp index f9fa3c9413072d759942b7e0ae235b1575e365ca..159635a2bb369732501d3b6cc356e4fbe02017b7 100644 --- a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp +++ b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp @@ -37,17 +37,23 @@ bool FixedTimeStepping::next(double const /*solution_error*/, if (_ts_current.steps() == _dt_vector.size() || std::abs(_ts_current.current() - _t_end) < std::numeric_limits<double>::epsilon()) + { return false; + } // confirm current time and move to the next if accepted if (accepted()) + { _ts_prev = _ts_current; + } // prepare the next time step info _ts_current = _ts_prev; double dt = _dt_vector[_ts_prev.steps()]; - if (_ts_prev.current() + dt > _t_end) // upper bound by t_end + if (_ts_prev.current() + dt > _t_end) + { // upper bound by t_end dt = _t_end - _ts_prev.current(); + } _ts_current += dt; return true; @@ -62,4 +68,4 @@ double FixedTimeStepping::computeEnd(double t_initial, return std::min(t_end, t_sum); } -} // NumLib +} // namespace NumLib diff --git a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h index 9c555b8af2ac750c82c514c2e044180717db2d9c..b7fdf291aebdb2c1d2ee2e6eabfdd61793838161 100644 --- a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h +++ b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h @@ -68,4 +68,4 @@ private: const std::vector<double>& dt_vector); }; -} // NumLib +} // namespace NumLib diff --git a/NumLib/TimeStepping/TimeStep.h b/NumLib/TimeStepping/TimeStep.h index 5eede2eb3780cf9140012369f78ebee9e74155c4..225fa46e367388950129ffea18dc4f7df76c5afd 100644 --- a/NumLib/TimeStepping/TimeStep.h +++ b/NumLib/TimeStepping/TimeStep.h @@ -122,4 +122,4 @@ private: std::size_t _steps; }; -} // NumLib +} // namespace NumLib diff --git a/ProcessLib/AbstractJacobianAssembler.h b/ProcessLib/AbstractJacobianAssembler.h index 40d17a1b5240d5e68e566be48e3ac5010f766c73..d433649e89a439fc21931a598585401c64859ca3 100644 --- a/ProcessLib/AbstractJacobianAssembler.h +++ b/ProcessLib/AbstractJacobianAssembler.h @@ -49,4 +49,4 @@ public: virtual ~AbstractJacobianAssembler() = default; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/AnalyticalJacobianAssembler.cpp b/ProcessLib/AnalyticalJacobianAssembler.cpp index eb888a882923535589b147211a7a030e0b00cd2f..4f463cc9dcbf60e3f01ed97e25fa14f69c6ba74f 100644 --- a/ProcessLib/AnalyticalJacobianAssembler.cpp +++ b/ProcessLib/AnalyticalJacobianAssembler.cpp @@ -38,4 +38,4 @@ void AnalyticalJacobianAssembler::assembleWithJacobianForStaggeredScheme( local_b_data, local_Jac_data, local_coupled_solutions); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/AnalyticalJacobianAssembler.h b/ProcessLib/AnalyticalJacobianAssembler.h index e2d11513eb58423d8423d8735e85f1f43db3de0f..c5045c8438dbdc89e07a884673e4895aef35a5a7 100644 --- a/ProcessLib/AnalyticalJacobianAssembler.h +++ b/ProcessLib/AnalyticalJacobianAssembler.h @@ -47,4 +47,4 @@ public: LocalCoupledSolutions const& local_coupled_solutions) override; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/BoundaryCondition.h b/ProcessLib/BoundaryCondition/BoundaryCondition.h index 4f6da3c40515b8989ce9b086d15697cfa472204e..127bbe49f24b29399f5fcbcec10980692e95e8a5 100644 --- a/ProcessLib/BoundaryCondition/BoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/BoundaryCondition.h @@ -59,4 +59,4 @@ public: virtual ~BoundaryCondition() = default; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp index 629d65334bff79e455c3e0cb865bf485030818c4..9fa65d6d983da45a302d5c925cdca8f3a26042d4 100644 --- a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp +++ b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.cpp @@ -18,7 +18,9 @@ void BoundaryConditionCollection::applyNaturalBC(const double t, GlobalMatrix* Jac) { for (auto const& bc : _boundary_conditions) + { bc->applyNaturalBC(t, x, K, b, Jac); + } } void BoundaryConditionCollection::addBCsForProcessVariables( diff --git a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h index 3f6bdca9084c5ed488100c06d1d90163a0a77f64..d957ef0e18d6d37773661f665525cbe0b7d7fa27 100644 --- a/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h +++ b/ProcessLib/BoundaryCondition/BoundaryConditionCollection.h @@ -65,5 +65,4 @@ private: std::vector<std::unique_ptr<ParameterBase>> const& _parameters; }; - -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryCondition.cpp index a81ca8489860f8151855bf548578af49093e212e..51e87faf7f4151c20bb5298abeef28fdad698510 100644 --- a/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryCondition.cpp @@ -161,7 +161,9 @@ void ConstraintDirichletBoundaryCondition::getEssentialBCValues( const auto g_idx = _dof_table_boundary->getGlobalIndex( l, _variable_id, _component_id); if (g_idx == NumLib::MeshComponentMap::nop) + { continue; + } // For the DDC approach (e.g. with PETSc option), the negative // index of g_idx means that the entry by that index is a ghost one, // which should be dropped. Especially for PETSc routines diff --git a/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryConditionLocalAssembler.h b/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryConditionLocalAssembler.h index 0db3f2e927a44691badda495e0e59323cdbe0606..87a351ca4aa3d9a9836d55ee97a63196bf4f5544 100644 --- a/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryConditionLocalAssembler.h +++ b/ProcessLib/BoundaryCondition/ConstraintDirichletBoundaryConditionLocalAssembler.h @@ -170,4 +170,4 @@ private: MathLib::Vector3 const _surface_element_normal; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.cpp b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.cpp index fc79b03e4de1868658e7101abb7b61c5c7a7ab68..58f9714b057c4008a2969dbff16a060679bf70b3 100644 --- a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.cpp +++ b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.cpp @@ -80,7 +80,9 @@ void getEssentialBCValuesLocal( {bc_mesh.getID(), MeshLib::MeshItemType::Node, id}, variable_id, component_id); if (global_index == NumLib::MeshComponentMap::nop) + { continue; + } // For the DDC approach (e.g. with PETSc option), the negative // index of global_index means that the entry by that index is a ghost // one, which should be dropped. Especially for PETSc routines @@ -95,4 +97,4 @@ void getEssentialBCValuesLocal( } } } -} // end of name space +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.h b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.h index 509b095407bbd0f8a5b6e7b078ac83e387b238be..db69d1b76a40fcd8c842f20655d30b5b07fd0ab0 100644 --- a/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.h +++ b/ProcessLib/BoundaryCondition/DirichletBoundaryConditionAuxiliaryFunctions.h @@ -51,4 +51,4 @@ void getEssentialBCValuesLocal( int const variable_id, int const component_id, const double t, GlobalVector const& x, NumLib::IndexValueVector<GlobalIndexType>& bc_values); -} // end of name space +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h b/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h index 7dd34ab153c4cd0713f5a82087facdf8156bac4f..cbbf16746a5a4aa1b7b6d9ca03db88e87975088e 100644 --- a/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h +++ b/ProcessLib/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h @@ -92,4 +92,4 @@ void GenericNaturalBoundaryCondition< _local_assemblers, *_dof_table_boundary, t, x, K, b, Jac); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition.h b/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition.h index 9fd4a8affb16a11b438046c795104c28bde96a8e..f308222367490039c62ee42620e1673078bc06fc 100644 --- a/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition.h @@ -54,6 +54,6 @@ private: _local_assemblers; }; -} // ProcessLib +} // namespace ProcessLib #include "GenericNonuniformNaturalBoundaryCondition-impl.h" diff --git a/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp index 142bee514e6613c4d555d1c848687f0c14a5b2a4..a94d1f6588b788fa866e895fded3ff5413846df4 100644 --- a/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.cpp @@ -48,4 +48,4 @@ std::unique_ptr<NeumannBoundaryCondition> createNeumannBoundaryCondition( component_id, global_dim, bc_mesh, param); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.h b/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.h index 03a0deed29f7f142e030980487efeec635ef4b8b..e9dd44035d2921d2f9c8ff96cd8ff55f31697146 100644 --- a/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/NeumannBoundaryCondition.h @@ -25,4 +25,4 @@ std::unique_ptr<NeumannBoundaryCondition> createNeumannBoundaryCondition( unsigned const shapefunction_order, unsigned const global_dim, std::vector<std::unique_ptr<ParameterBase>> const& parameters); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.cpp index 2d7098b76e631c20364cd95bfd5f09bc6c004bcf..5786e0947c6f2c3840e12746fe58fdfcdb1ec01b 100644 --- a/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.cpp @@ -60,4 +60,4 @@ createNonuniformDirichletBoundaryCondition( boundary_mesh, *property, dof_table, variable_id, component_id); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.h b/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.h index 38daf78ed68c13ff389f7452f2dc0b4034b0825b..ba67cb886f3236a3089ce0f421a5140486f857f8 100644 --- a/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/NonuniformDirichletBoundaryCondition.h @@ -94,7 +94,9 @@ public: {_boundary_mesh.getID(), MeshLib::MeshItemType::Node, node_id}, _variable_id, _component_id); if (global_index == NumLib::MeshComponentMap::nop) + { continue; + } // For the DDC approach (e.g. with PETSc option), the negative index // of global_index means that the entry by that index is a ghost // one, which should be dropped. Especially for PETSc routines @@ -124,4 +126,4 @@ createNonuniformDirichletBoundaryCondition( NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id, int const component_id); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.cpp index baa479cec33278d42754b4e285fb2af470dd5b9e..bbe963d3cae71e39349c59936f8ab09d2a3d15c0 100644 --- a/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.cpp @@ -89,4 +89,4 @@ createNonuniformNeumannBoundaryCondition( variable_id, component_id}); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.h b/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.h index 31a05504673134b4ee49235175a9ef8204043abd..50cb24c44bbb2fecef3e63215f83fc149e864a40 100644 --- a/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/NonuniformNeumannBoundaryCondition.h @@ -27,4 +27,4 @@ createNonuniformNeumannBoundaryCondition( int const component_id, unsigned const integration_order, unsigned const shapefunction_order, const MeshLib::Mesh& bulk_mesh); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h b/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h index 2356f22692679c57f9dbe066d395d6eedbdc0358..7f1315dced38b34461fd55ae631de1b4d8e2687d 100644 --- a/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h +++ b/ProcessLib/BoundaryCondition/NormalTractionBoundaryConditionLocalAssembler.h @@ -110,9 +110,11 @@ public: GlobalDim, displacement_size>::Zero(GlobalDim, displacement_size); for (int i = 0; i < static_cast<int>(GlobalDim); ++i) + { N_u.template block<1, displacement_size / GlobalDim>( i, i * displacement_size / GlobalDim) .noalias() = shape_matrices_u[ip].N; + } double const integration_weight = _integration_method.getWeightedPoint(ip).getWeight() * diff --git a/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp b/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp index dcfed5bdd7dee5f4427613cef907b88147c059ac..3f7870f9dbd4cb6af58022b840d0ac0da75f37c0 100644 --- a/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp +++ b/ProcessLib/BoundaryCondition/RobinBoundaryCondition.cpp @@ -51,4 +51,4 @@ std::unique_ptr<RobinBoundaryCondition> createRobinBoundaryCondition( RobinBoundaryConditionData{alpha, u_0}); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/RobinBoundaryCondition.h b/ProcessLib/BoundaryCondition/RobinBoundaryCondition.h index b477a5356195c1cca9af1d93ce33cd79f01a4f5e..30b8c941df7ddde65665e5b4a52c2e60109f459b 100644 --- a/ProcessLib/BoundaryCondition/RobinBoundaryCondition.h +++ b/ProcessLib/BoundaryCondition/RobinBoundaryCondition.h @@ -36,4 +36,4 @@ std::unique_ptr<RobinBoundaryCondition> createRobinBoundaryCondition( unsigned const shapefunction_order, unsigned const global_dim, std::vector<std::unique_ptr<ParameterBase>> const& parameters); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/BoundaryCondition/RobinBoundaryConditionLocalAssembler.h b/ProcessLib/BoundaryCondition/RobinBoundaryConditionLocalAssembler.h index 5e8992c56e88465cbf3f94c8255f5cb777926de1..715cbc137ca4a7d4cdedf35010c04e1d9e0a3214 100644 --- a/ProcessLib/BoundaryCondition/RobinBoundaryConditionLocalAssembler.h +++ b/ProcessLib/BoundaryCondition/RobinBoundaryConditionLocalAssembler.h @@ -91,4 +91,4 @@ public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/CentralDifferencesJacobianAssembler.cpp b/ProcessLib/CentralDifferencesJacobianAssembler.cpp index e8702cf9d08a7f9cc93ef0d78927ec4b0b322cfe..4e48ce4acc883b52603e5a367be2076605342eb2 100644 --- a/ProcessLib/CentralDifferencesJacobianAssembler.cpp +++ b/ProcessLib/CentralDifferencesJacobianAssembler.cpp @@ -19,7 +19,9 @@ CentralDifferencesJacobianAssembler::CentralDifferencesJacobianAssembler( : _absolute_epsilons(std::move(absolute_epsilons)) { if (_absolute_epsilons.empty()) + { OGS_FATAL("No values for the absolute epsilons have been given."); + } } void CentralDifferencesJacobianAssembler::assembleWithJacobian( @@ -170,4 +172,4 @@ createCentralDifferencesJacobianAssembler(BaseLib::ConfigTree const& config) std::move(abs_eps)); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/CentralDifferencesJacobianAssembler.h b/ProcessLib/CentralDifferencesJacobianAssembler.h index cb4009a68d975e3bb491513ae9680d896dbf5106..a0adf14797bd060966ab4baed7dc91c9132a2df1 100644 --- a/ProcessLib/CentralDifferencesJacobianAssembler.h +++ b/ProcessLib/CentralDifferencesJacobianAssembler.h @@ -71,4 +71,4 @@ private: std::unique_ptr<CentralDifferencesJacobianAssembler> createCentralDifferencesJacobianAssembler(BaseLib::ConfigTree const& config); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/ComponentTransport/ComponentTransportFEM.h b/ProcessLib/ComponentTransport/ComponentTransportFEM.h index 3a3196da2f9050e7ebfdd657f46b5f7577a63ded..6f036701cb8c174d40cff1499a19f010757ff684 100644 --- a/ProcessLib/ComponentTransport/ComponentTransportFEM.h +++ b/ProcessLib/ComponentTransport/ComponentTransportFEM.h @@ -362,8 +362,10 @@ public: w * dNdx.transpose() * density * K_over_mu * dNdx; if (_process_data.has_gravity) + { Bp += w * density * density * dNdx.transpose() * K_over_mu * b; + } } } } diff --git a/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp b/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp index db2ecd3bca8c04cf174f35f96e1cdb7c36000463..640fb0cd63127cfec1cc0692ec7debf9e4e1c970 100644 --- a/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp +++ b/ProcessLib/ComponentTransport/CreateComponentTransportProcess.cpp @@ -73,11 +73,13 @@ std::unique_ptr<Process> createComponentTransportProcess( }); if (it != collected_process_variables.end()) + { OGS_FATAL( "Number of components for process variable '%s' should be 1 rather " "than %d.", it->get().getName().c_str(), it->get().getNumberOfComponents()); + } // Allocate the collected process variables into a two-dimensional vector, // depending on what scheme is adopted @@ -134,10 +136,12 @@ std::unique_ptr<Process> createComponentTransportProcess( config.getConfigParameter<std::vector<double>>("specific_body_force"); assert(b.size() > 0 && b.size() < 4); if (b.size() < mesh.getDimension()) + { OGS_FATAL( "specific body force (gravity vector) has %d components, mesh " "dimension is %d", b.size(), mesh.getDimension()); + } bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) { diff --git a/ProcessLib/CoupledSolutionsForStaggeredScheme.cpp b/ProcessLib/CoupledSolutionsForStaggeredScheme.cpp index 287d26bf71b62be0be3c35c4d4c9ad84d9c2447d..366ebfc7cd15ef258e8258539a68b3e74ac20ced 100644 --- a/ProcessLib/CoupledSolutionsForStaggeredScheme.cpp +++ b/ProcessLib/CoupledSolutionsForStaggeredScheme.cpp @@ -33,7 +33,9 @@ std::vector<std::vector<double>> getPreviousLocalSolutions( const std::vector<std::vector<GlobalIndexType>>& indices) { if (cpl_xs.coupled_xs_t0.empty()) + { return {}; + } const auto number_of_coupled_solutions = cpl_xs.coupled_xs.size(); std::vector<std::vector<double>> local_xs_t0; @@ -53,7 +55,9 @@ std::vector<std::vector<double>> getCurrentLocalSolutions( const std::vector<std::vector<GlobalIndexType>>& indices) { if (cpl_xs.coupled_xs.empty()) + { return {}; + } const auto number_of_coupled_solutions = cpl_xs.coupled_xs.size(); std::vector<std::vector<double>> local_xs_t1; diff --git a/ProcessLib/CoupledSolutionsForStaggeredScheme.h b/ProcessLib/CoupledSolutionsForStaggeredScheme.h index f7b238847cecf2bc89352fa8cca79871ea66b622..3f6db1a17a144cdbb52440110eaa37be8d809690 100644 --- a/ProcessLib/CoupledSolutionsForStaggeredScheme.h +++ b/ProcessLib/CoupledSolutionsForStaggeredScheme.h @@ -94,4 +94,4 @@ std::vector<std::vector<double>> getPreviousLocalSolutions( std::vector<std::vector<double>> getCurrentLocalSolutions( const CoupledSolutionsForStaggeredScheme& cpl_xs, const std::vector<std::vector<GlobalIndexType>>& indices); -} // end of ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/CreateJacobianAssembler.cpp b/ProcessLib/CreateJacobianAssembler.cpp index ba253bc59890dd951d622bca1e65a4f2aa9a9ab3..898f18efad4f4313aab69222cec3be89e853ebb5 100644 --- a/ProcessLib/CreateJacobianAssembler.cpp +++ b/ProcessLib/CreateJacobianAssembler.cpp @@ -20,7 +20,9 @@ std::unique_ptr<AbstractJacobianAssembler> createJacobianAssembler( boost::optional<BaseLib::ConfigTree> const& config) { if (!config) + { return std::make_unique<AnalyticalJacobianAssembler>(); + } //! \ogs_file_param{prj__processes__process__jacobian_assembler__type} auto const type = config->peekConfigParameter<std::string>("type"); @@ -40,4 +42,4 @@ std::unique_ptr<AbstractJacobianAssembler> createJacobianAssembler( OGS_FATAL("Unknown Jacobian assembler type: `%s'.", type.c_str()); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/DeactivatedSubdomain.cpp b/ProcessLib/DeactivatedSubdomain.cpp index 82a715609663545487f12dfbe80103b342d982fe..26487b9ef304f39499d3eea6c16b5897f8f4f43f 100644 --- a/ProcessLib/DeactivatedSubdomain.cpp +++ b/ProcessLib/DeactivatedSubdomain.cpp @@ -99,7 +99,9 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( for (std::size_t i = 0; i < mesh.getNumberOfElements(); i++) { if (ids != (*material_ids)[i]) + { continue; + } auto* element = mesh.getElement(i); deactivated_elements.push_back( @@ -111,7 +113,9 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( const auto& connected_elements = node->getElements(); if (deactivation_flag_of_nodes[node->getID()]) + { continue; + } // Check whether this node is in an activated element. if (std::find_if( @@ -121,7 +125,9 @@ std::unique_ptr<DeactivatedSubdomain const> createDeactivatedSubdomain( return ids != (*material_ids)[connected_elem->getID()]; }) != connected_elements.end()) + { continue; + } deactivated_nodes.push_back(const_cast<MeshLib::Node*>(node)); deactivation_flag_of_nodes[node->getID()] = true; diff --git a/ProcessLib/Deformation/LinearBMatrix.h b/ProcessLib/Deformation/LinearBMatrix.h index e6322a6dde55be4b2a64ec7d8746397b3c7a8806..b30419ae88e698d365c0bee8e6f594c86d607f3e 100644 --- a/ProcessLib/Deformation/LinearBMatrix.h +++ b/ProcessLib/Deformation/LinearBMatrix.h @@ -30,7 +30,7 @@ void fillBMatrix2DCartesianPart(DNDX_Type const& dNdx, BMatrixType& B) B(0, i) = dNdx(0, i); } } -} // detail +} // namespace detail /// Fills a B-matrix based on given shape function dN/dx values. template <int DisplacementDim, diff --git a/ProcessLib/Deformation/MaterialForces.h b/ProcessLib/Deformation/MaterialForces.h index 12a7693d6055bff86f6a73341195c2f4d961886b..2ab9460cc58877da3fab83bf5e4e95df3bde4c5a 100644 --- a/ProcessLib/Deformation/MaterialForces.h +++ b/ProcessLib/Deformation/MaterialForces.h @@ -141,9 +141,12 @@ std::vector<double> const& getMaterialForces( eshelby_stress[4] -= sigma[2] * grad_u[4]; } else + { OGS_FATAL( - "Material forces not implemented for displacement dimension " + "Material forces not implemented for displacement " + "dimension " "other than 2 and 3."); + } auto const& w = _ip_data[ip].integration_weight; local_b += G.transpose() * eshelby_stress * w; diff --git a/ProcessLib/HT/HTFEM.h b/ProcessLib/HT/HTFEM.h index f96585ca9bd3493de65bdb30279b27dbe4988256..2ac9e6274e57aca51e23ae3b24afd0314592f5d1 100644 --- a/ProcessLib/HT/HTFEM.h +++ b/ProcessLib/HT/HTFEM.h @@ -192,7 +192,9 @@ protected: thermal_conductivity_fluid * porosity; if (!_material_properties.has_fluid_thermal_dispersivity) + { return thermal_conductivity * I; + } double const thermal_dispersivity_longitudinal = _material_properties.thermal_dispersivity_longitudinal(t, pos)[0]; @@ -205,8 +207,7 @@ protected: { return thermal_conductivity * I; } - else - { + GlobalDimMatrixType const thermal_dispersivity = fluid_density * specific_heat_capacity_fluid * (thermal_dispersivity_transversal * velocity_magnitude * I + @@ -214,7 +215,6 @@ protected: thermal_dispersivity_transversal) / velocity_magnitude * velocity * velocity.transpose()); return thermal_conductivity * I + thermal_dispersivity; - } } std::vector<double> const& getIntPtDarcyVelocityLocal( diff --git a/ProcessLib/HT/MonolithicHTFEM.h b/ProcessLib/HT/MonolithicHTFEM.h index bdeab13a09b23fc5b5d55e2718f81ce99c4e2efa..a9a7e20bf6d1c66c2deb7e293d8290d1d2ae5b85 100644 --- a/ProcessLib/HT/MonolithicHTFEM.h +++ b/ProcessLib/HT/MonolithicHTFEM.h @@ -178,7 +178,9 @@ public: N.transpose() * N; Mpp.noalias() += w * N.transpose() * specific_storage * N; if (process_data.has_gravity) + { Bp += w * fluid_density * dNdx.transpose() * K_over_mu * b; + } /* with Oberbeck-Boussing assumption density difference only exists * in buoyancy effects */ } diff --git a/ProcessLib/HT/StaggeredHTFEM-impl.h b/ProcessLib/HT/StaggeredHTFEM-impl.h index d9b257a5dcbeb1c0f14ea5a1dc60c0dfd8cdd258..0308f8608bc07d9c7bda5d103c2e6d75c2e74310 100644 --- a/ProcessLib/HT/StaggeredHTFEM-impl.h +++ b/ProcessLib/HT/StaggeredHTFEM-impl.h @@ -142,7 +142,9 @@ void StaggeredHTFEM<ShapeFunction, IntegrationMethod, GlobalDim>:: } if (!material_properties.has_fluid_thermal_expansion) + { return; + } // Add the thermal expansion term { diff --git a/ProcessLib/HydroMechanics/CreateLocalAssemblers.h b/ProcessLib/HydroMechanics/CreateLocalAssemblers.h index 6563b30f391662063ecebe9fc9a3af3236ade520..ebb76b8ae9067d1a869de67eec18bda9636d5646 100644 --- a/ProcessLib/HydroMechanics/CreateLocalAssemblers.h +++ b/ProcessLib/HydroMechanics/CreateLocalAssemblers.h @@ -81,6 +81,6 @@ void createLocalAssemblers( dof_table, shapefunction_order, mesh_elements, local_assemblers, std::forward<ExtraCtorArgs>(extra_ctor_args)...); } -} // HydroMechanics +} // namespace HydroMechanics -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h index 28a8ebe49b2da6c6811fa8aa59fa26cc84897e18..1e730badd8dde31195cfa1f4edb93d11a56b3025 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h @@ -83,10 +83,12 @@ HydroMechanicsLocalAssembler<ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim, displacement_size>::Zero(DisplacementDim, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { ip_data.N_u_op .template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = sm_u.N; + } ip_data.N_u = sm_u.N; ip_data.dNdx_u = sm_u.dNdx; diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h index 910c3f6f0705f9d3fc6c9af676fc6e5b9332d1dc..e56ae1a01dbf56c59e6a99ed399a72f585bf2cd7 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h @@ -82,7 +82,9 @@ struct IntegrationPointData final *material_state_variables, T); if (!solution) + { OGS_FATAL("Computation of local constitutive relation failed."); + } MathLib::KelvinVector::KelvinMatrixType<DisplacementDim> C; std::tie(sigma_eff, material_state_variables, C) = std::move(*solution); @@ -308,10 +310,14 @@ private: for (auto const& ip_data : _ip_data) { - if (component < 3) // xx, yy, zz components + if (component < 3) + { // xx, yy, zz components cache.push_back(ip_data.sigma_eff[component]); - else // mixed xy, yz, xz components + } + else + { // mixed xy, yz, xz components cache.push_back(ip_data.sigma_eff[component] / std::sqrt(2)); + } } return cache; diff --git a/ProcessLib/HydroMechanics/LocalDataInitializer.h b/ProcessLib/HydroMechanics/LocalDataInitializer.h index a5a6c94749e8f20f98267a5bd9d37302363b1884..123de39a53c53672309c6e72ce3bcf00cb2619ac 100644 --- a/ProcessLib/HydroMechanics/LocalDataInitializer.h +++ b/ProcessLib/HydroMechanics/LocalDataInitializer.h @@ -130,10 +130,12 @@ public: : _dof_table(dof_table) { if (shapefunction_order != 2) + { OGS_FATAL( "The given shape function order %d is not supported.\nOnly " "shape functions of order 2 are supported.", shapefunction_order); + } // /// Quads and Hexahedra /////////////////////////////////// #if (OGS_ENABLED_ELEMENTS & ENABLED_ELEMENT_TYPE_QUAD) != 0 && \ diff --git a/ProcessLib/LIE/Common/LevelSetFunction.cpp b/ProcessLib/LIE/Common/LevelSetFunction.cpp index 1ca4e5e4740ba3151ad94d1c904d767f2ea437d2..3ce37d764f4b9b25309d3442043889e99fec7a07 100644 --- a/ProcessLib/LIE/Common/LevelSetFunction.cpp +++ b/ProcessLib/LIE/Common/LevelSetFunction.cpp @@ -51,7 +51,9 @@ std::vector<double> uGlobalEnrichments( // pre-calculate levelsets for all fractures std::vector<double> levelsets(frac_props.size()); for (std::size_t i = 0; i < frac_props.size(); i++) + { levelsets[i] = Heaviside(levelsetFracture(*frac_props[i], x)); + } std::vector<double> enrichments(frac_props.size() + junction_props.size()); // fractures possibly with branches @@ -60,7 +62,9 @@ std::vector<double> uGlobalEnrichments( auto const* frac = frac_props[i]; double enrich = levelsets[i]; for (std::size_t j = 0; j < frac->branches_slave.size(); j++) + { enrich *= Heaviside(levelsetBranch(frac->branches_slave[j], x)); + } enrichments[i] = enrich; } @@ -89,7 +93,9 @@ std::vector<double> duGlobalEnrichments( // pre-calculate levelsets for all fractures std::vector<double> levelsets(frac_props.size()); for (std::size_t i = 0; i < frac_props.size(); i++) + { levelsets[i] = Heaviside(levelsetFracture(*frac_props[i], x)); + } std::vector<double> enrichments(frac_props.size() + junction_props.size()); enrichments[this_frac_local_index] = 1.0; @@ -100,11 +106,15 @@ std::vector<double> duGlobalEnrichments( for (auto const& branch : this_frac.branches_master) { if (branch.master_fracture_id != this_frac.fracture_id) + { continue; + } if (fracID_to_local.find(branch.slave_fracture_id) == fracID_to_local.end()) + { continue; + } double singned = boost::math::sign( this_frac.normal_vector.dot(branch.normal_vector_branch)); @@ -119,7 +129,9 @@ std::vector<double> duGlobalEnrichments( { auto const* junction = junction_props[i]; if (!BaseLib::contains(junction->fracture_ids, this_frac.fracture_id)) + { continue; + } auto another_frac_id = (junction->fracture_ids[0] == this_frac.fracture_id) diff --git a/ProcessLib/LIE/Common/MeshUtils.cpp b/ProcessLib/LIE/Common/MeshUtils.cpp index f2ce2311a9313536daffaa3d9a77b57a23b1fbd6..b66276a059ad8116df9fb7b428f9081abc1e70bb 100644 --- a/ProcessLib/LIE/Common/MeshUtils.cpp +++ b/ProcessLib/LIE/Common/MeshUtils.cpp @@ -35,18 +35,26 @@ public: MeshLib::NodeSearch nodeSearch(mesh); nodeSearch.searchBoundaryNodes(); for (auto i : nodeSearch.getSearchedNodeIDs()) + { _is_internal_node[i] = false; + } } bool operator()(MeshLib::Node const& node) const { if (!_is_internal_node[node.getID()] || !_mesh.isBaseNode(node.getID())) + { return false; + } unsigned n_connected_fracture_elements = 0; for (MeshLib::Element const* e : node.getElements()) + { if (e->getDimension() == _fracture_element_dim) + { n_connected_fracture_elements++; + } + } assert(n_connected_fracture_elements > 0); return (n_connected_fracture_elements == 1); @@ -71,20 +79,30 @@ void findFracutreIntersections( auto const n_fractures = vec_fracture_mat_IDs.size(); std::map<unsigned, unsigned> matID_to_fid; for (unsigned i = 0; i < n_fractures; i++) + { matID_to_fid[vec_fracture_mat_IDs[i]] = i; + } // make a vector all fracture nodes std::vector<std::size_t> all_fracture_nodes; for (auto& vec : vec_fracture_nodes) + { for (auto* node : vec) + { all_fracture_nodes.push_back(node->getID()); + } + } // create a table of a node id and connected material IDs std::map<std::size_t, std::vector<std::size_t>> frac_nodeID_to_matIDs; for (unsigned i = 0; i < n_fractures; i++) + { for (auto* node : vec_fracture_nodes[i]) + { frac_nodeID_to_matIDs[node->getID()].push_back( vec_fracture_mat_IDs[i]); + } + } auto const* const opt_material_ids = MeshLib::materialIDs(mesh); @@ -96,20 +114,28 @@ void findFracutreIntersections( auto const* node = mesh.getNode(entry.first); auto const& matIDs = entry.second; if (matIDs.size() < 2) + { continue; // no intersection + } std::vector<MeshLib::Element*> conn_fracture_elements; { for (auto const* e : node->getElements()) + { if (e->getDimension() == (mesh.getDimension() - 1)) + { conn_fracture_elements.push_back( const_cast<MeshLib::Element*>(e)); + } + } } std::map<int, int> vec_matID_counts; { for (auto matid : matIDs) + { vec_matID_counts[matid] = 0; + } for (auto const* e : conn_fracture_elements) { @@ -124,8 +150,10 @@ void findFracutreIntersections( for (auto* e : conn_fracture_elements) { auto e_matid = (*opt_material_ids)[e->getID()]; - if (matID_to_fid[e_matid] != fid) // only slave elements + if (matID_to_fid[e_matid] != fid) + { // only slave elements intersected_fracture_elements[fid].push_back(e); + } } } @@ -173,7 +201,9 @@ void findFracutreIntersections( } for (auto& eles : intersected_fracture_elements) + { BaseLib::makeVectorUnique(eles); + } DBUG("-> found %d branchs and %d junctions", vec_branch_nodeID_matIDs.size(), vec_junction_nodeID_matIDs.size()); @@ -201,9 +231,13 @@ void getFractureMatrixDataInMesh( for (MeshLib::Element* e : mesh.getElements()) { if (e->getDimension() == mesh.getDimension()) + { vec_matrix_elements.push_back(e); + } else + { all_fracture_elements.push_back(e); + } } DBUG("-> found total %d matrix elements and %d fracture elements", vec_matrix_elements.size(), all_fracture_elements.size()); @@ -215,7 +249,9 @@ void getFractureMatrixDataInMesh( OGS_FATAL("Could not access MaterialIDs property from mesh."); } for (MeshLib::Element* e : all_fracture_elements) + { vec_fracture_mat_IDs.push_back((*material_ids)[e->getID()]); + } BaseLib::makeVectorUnique(vec_fracture_mat_IDs); DBUG("-> found %d fracture material groups", vec_fracture_mat_IDs.size()); @@ -245,7 +281,9 @@ void getFractureMatrixDataInMesh( for (unsigned i = 0; i < e->getNumberOfNodes(); i++) { if (isCrackTip(*e->getNode(i))) + { continue; + } vec_nodes.push_back(const_cast<MeshLib::Node*>(e->getNode(i))); } } @@ -278,13 +316,17 @@ void getFractureMatrixDataInMesh( { MeshLib::Node const* node = e->getNode(i); if (isCrackTip(*node)) + { continue; + } for (unsigned j = 0; j < node->getNumberOfElements(); j++) { // only matrix elements if (node->getElement(j)->getDimension() < mesh.getDimension()) + { continue; + } vec_ele.push_back( const_cast<MeshLib::Element*>(node->getElement(j))); } diff --git a/ProcessLib/LIE/Common/PostUtils.cpp b/ProcessLib/LIE/Common/PostUtils.cpp index d929da00a7432b6c060a26b58d78f1644947844a..eaa7a56409d831e771417e77381694aa0bb3db11 100644 --- a/ProcessLib/LIE/Common/PostUtils.cpp +++ b/ProcessLib/LIE/Common/PostUtils.cpp @@ -105,12 +105,16 @@ PostProcessTool::PostProcessTool( { // only matrix elements if (org_e->getDimension() != org_mesh.getDimension()) + { continue; + } auto const eid = org_e->getID(); // keep original if the element has levelset=0 if ((*prop_levelset)[eid] == 0) + { continue; + } // replace fracture nodes with duplicated ones MeshLib::Element* e = new_eles[eid]; @@ -118,12 +122,16 @@ PostProcessTool::PostProcessTool( { const auto node_id = e->getNodeIndex(i); if (!includesNodeID(vec_fracture_nodes, node_id)) + { continue; + } // list of duplicated node IDs auto itr = _map_dup_newNodeIDs.find(node_id); if (itr == _map_dup_newNodeIDs.end()) + { continue; + } const auto& dup_newNodeIDs = itr->second; // choose new node id @@ -216,7 +224,9 @@ void PostProcessTool::createProperties() for (auto name : src_properties.getPropertyVectorNames()) { if (!src_properties.existsPropertyVector<T>(name)) + { continue; + } auto const* src_prop = src_properties.getPropertyVector<T>(name); auto const n_src_comp = src_prop->getNumberOfComponents(); @@ -255,7 +265,9 @@ void PostProcessTool::copyProperties() for (auto name : src_properties.getPropertyVectorNames()) { if (!src_properties.existsPropertyVector<T>(name)) + { continue; + } auto const* src_prop = src_properties.getPropertyVector<T>(name); auto* dest_prop = _output_mesh->getProperties().getPropertyVector<T>(name); @@ -268,19 +280,27 @@ void PostProcessTool::copyProperties() for (unsigned i = 0; i < _org_mesh.getNumberOfNodes(); i++) { for (int j = 0; j < n_src_comp; j++) + { (*dest_prop)[i * n_dest_comp + j] = (*src_prop)[i * n_src_comp + j]; + } // set zero for components not existing in the original for (int j = n_src_comp; j < n_dest_comp; j++) + { (*dest_prop)[i * n_dest_comp + j] = 0; + } } // copy duplicated for (auto itr : _map_dup_newNodeIDs) { for (int j = 0; j < n_dest_comp; j++) + { for (unsigned k = 0; k < itr.second.size(); k++) + { (*dest_prop)[itr.second[k] * n_dest_comp + j] = (*dest_prop)[itr.first * n_dest_comp + j]; + } + } } } else if (src_prop->getMeshItemType() == MeshLib::MeshItemType::Cell) @@ -311,7 +331,9 @@ void PostProcessTool::calculateTotalDisplacement(unsigned const n_fractures, for (unsigned i = 0; i < _output_mesh->getNodes().size(); i++) { for (int j = 0; j < n_u_comp; j++) + { total_u[i * n_u_comp + j] = u[i * n_u_comp + j]; + } } for (unsigned enrich_id = 0; enrich_id < n_fractures + n_junctions; @@ -326,13 +348,19 @@ void PostProcessTool::calculateTotalDisplacement(unsigned const n_fractures, for (MeshLib::Element const* e : _output_mesh->getElements()) { if (e->getDimension() != _output_mesh->getDimension()) + { continue; + } const double e_levelset = ele_levelset[e->getID()]; if (e_levelset == 0) + { continue; + } for (unsigned i = 0; i < e->getNumberOfNodes(); i++) + { nodal_levelset[e->getNodeIndex(i)] = e_levelset; + } } // update total displacements @@ -342,8 +370,10 @@ void PostProcessTool::calculateTotalDisplacement(unsigned const n_fractures, for (unsigned i = 0; i < _output_mesh->getNodes().size(); i++) { for (int j = 0; j < n_u_comp; j++) + { total_u[i * n_u_comp + j] += nodal_levelset[i] * g[i * n_u_comp + j]; + } } } } diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp index c2f9718668280bac36b929995553b7b1c126654a..fff96752fab05c40f110fd29a362cf9cc0f624fe 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.cpp @@ -101,5 +101,5 @@ createLiquidFlowMaterialProperties( std::move(porosity_models), std::move(storage_models), material_ids); } -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.h b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.h index 58c80b85caa28cfba45dd105da4d8adb9189652f..6721514df1baf9c78a3ceb2d830fbadf9a57bcf2 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.h +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowMaterialProperties.h @@ -47,5 +47,5 @@ createLiquidFlowMaterialProperties( std::vector<std::unique_ptr<ParameterBase>> const& parameters, MeshLib::PropertyVector<int> const* const material_ids); -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp index 5120d3c421bf60827a6e2a6eafa9ca8ced61b963..e9a2ec112fa8bce5a5ff547a479a2e230a9a3b3b 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.cpp @@ -108,5 +108,5 @@ std::unique_ptr<Process> createLiquidFlowProcess( reference_temperature, mat_config}}; } -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.h b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.h index ee7431f62afaf2c093eb449c7356e58c9f406af2..2ae8ebce567d18cea6456d2bf8d620f9c031827e 100644 --- a/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.h +++ b/ProcessLib/LiquidFlow/CreateLiquidFlowProcess.h @@ -27,4 +27,4 @@ std::unique_ptr<Process> createLiquidFlowProcess( unsigned const integration_order, BaseLib::ConfigTree const& config); } // end of namespace -} // end of namespace +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h index ab16c17850b32e674ece3de5b9b80a03c47bb7f7..eeff64bb5309618883c3c923c6204f1f99ce1cb0 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h +++ b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h @@ -39,14 +39,18 @@ void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: // _element->getDimension() assert(permeability.rows() == GlobalDim || permeability.rows() == 1); - if (permeability.size() == 1) // isotropic or 1D problem. + if (permeability.size() == 1) + { // isotropic or 1D problem. assembleMatrixAndVector<IsotropicCalculator>( material_id, t, local_x, local_M_data, local_K_data, local_b_data, pos, permeability); + } else + { assembleMatrixAndVector<AnisotropicCalculator>( material_id, t, local_x, local_M_data, local_K_data, local_b_data, pos, permeability); + } } template <typename ShapeFunction, typename IntegrationMethod, @@ -134,12 +138,16 @@ LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: // the assert must be changed to perm.rows() == _element->getDimension() assert(permeability.rows() == GlobalDim || permeability.rows() == 1); - if (permeability.size() == 1) // isotropic or 1D problem. + if (permeability.size() == 1) + { // isotropic or 1D problem. computeDarcyVelocityLocal<IsotropicCalculator>(local_x, permeability, velocity_cache_vectors); + } else + { computeDarcyVelocityLocal<AnisotropicCalculator>( local_x, permeability, velocity_cache_vectors); + } return velocity_cache; } @@ -222,7 +230,9 @@ void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: darcy_velocity_at_ips.col(ip).noalias() = -K * ip_data.dNdx * local_p; // gravity term if (gravitational_axis_id >= 0) + { darcy_velocity_at_ips.col(ip)[gravitational_axis_id] -= K * rho_g; + } } template <typename ShapeFunction, typename IntegrationMethod, @@ -271,5 +281,5 @@ void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: } } -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h index 82029659baef8835cd39609a9cb4330d2302cf74..da251f2404dfa866b99579f8ab21c0aa2d7be6ab 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h +++ b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h @@ -220,7 +220,7 @@ private: const LiquidFlowMaterialProperties& _material_properties; }; -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib #include "LiquidFlowLocalAssembler-impl.h" diff --git a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp index 83878977d2671447fb8bf995ef423e46f0bb52dd..014d585f99a164aa241d41d3d2fb28ada934bbfb 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp +++ b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.cpp @@ -102,5 +102,5 @@ Eigen::MatrixXd const& LiquidFlowMaterialProperties::getPermeability( 0.0); } -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h index 69aa2a3b1d5e2f44941c92fff09ab59961720e4d..2fdc8c838930c27a9e67815d0978f37eb4ae51e9 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h +++ b/ProcessLib/LiquidFlow/LiquidFlowMaterialProperties.h @@ -124,5 +124,5 @@ private: // Such property vectors will be added here if they are needed. }; -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp index cc95c385f452358ce824a1245fc7c6297ccdc0cc..a2f82b798fa94de43dfcce984a3b26bfec23e4f8 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp @@ -131,5 +131,5 @@ void LiquidFlowProcess::computeSecondaryVariableConcrete(const double t, getDOFTable(process_id), t, x, _coupled_solutions); } -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LiquidFlow/LiquidFlowProcess.h b/ProcessLib/LiquidFlow/LiquidFlowProcess.h index 38acf770fe02a366d59f55933b52a11478502e5b..21259b69d0443530e35f6cf28818b3fb939e45f8 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowProcess.h +++ b/ProcessLib/LiquidFlow/LiquidFlowProcess.h @@ -106,5 +106,5 @@ private: _local_assemblers; }; -} // end of namespace -} // end of namespace +} // namespace LiquidFlow +} // namespace ProcessLib diff --git a/ProcessLib/LocalAssemblerInterface.cpp b/ProcessLib/LocalAssemblerInterface.cpp index d243cba625eb6672ad47e4803d3ee0f7ddde5367..adc706ab2138a5d64f3995fb23931147c7b3a8d6 100644 --- a/ProcessLib/LocalAssemblerInterface.cpp +++ b/ProcessLib/LocalAssemblerInterface.cpp @@ -72,7 +72,9 @@ void LocalAssemblerInterface::computeSecondaryVariable( auto const indices = NumLib::getIndices(mesh_item_id, dof_table); if (coupled_xs != nullptr) + { return; + } auto const local_x = x.get(indices); computeSecondaryVariableConcrete(t, local_x); diff --git a/ProcessLib/LocalAssemblerTraits.h b/ProcessLib/LocalAssemblerTraits.h index 29b4f743f5290e27ebf0f913e8279c3b6755a718..533449d4900906dab72c3340a60216de113d30d2 100644 --- a/ProcessLib/LocalAssemblerTraits.h +++ b/ProcessLib/LocalAssemblerTraits.h @@ -233,4 +233,4 @@ static_assert(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG == 1, " Maybe you forgot to include some header file."); #endif -} +} // namespace ProcessLib diff --git a/ProcessLib/Output/CachedSecondaryVariable.cpp b/ProcessLib/Output/CachedSecondaryVariable.cpp index 91eb0ca0d4412a482045307876bca2e40c826e49..0e586ec44b6a0c583623994424f07816a6736273 100644 --- a/ProcessLib/Output/CachedSecondaryVariable.cpp +++ b/ProcessLib/Output/CachedSecondaryVariable.cpp @@ -23,7 +23,9 @@ std::vector<NumLib::NamedFunction> CachedSecondaryVariable::getNamedFunctions() double CachedSecondaryVariable::getValue() const { if (_needs_recomputation) + { evalFieldNoArgs(); + } return _cached_nodal_values.get(_context.index); } diff --git a/ProcessLib/Output/CreateSecondaryVariables.cpp b/ProcessLib/Output/CreateSecondaryVariables.cpp index cc966f3c07c472ba1dcc496f0143de4982cdbd13..57d583d05fa9aea47d0b3ea9d893e982b1f7dd39 100644 --- a/ProcessLib/Output/CreateSecondaryVariables.cpp +++ b/ProcessLib/Output/CreateSecondaryVariables.cpp @@ -25,7 +25,9 @@ void createSecondaryVariables( //! \ogs_file_param{prj__processes__process__secondary_variables} config.getConfigSubtreeOptional("secondary_variables"); if (!sec_vars_config) + { return; + } for ( auto sec_var_config : diff --git a/ProcessLib/Output/Output.cpp b/ProcessLib/Output/Output.cpp index 3d2f7cf2638d5ebdae7b0e5af8fcc3906414e780..588c6546379424e3128cca98c3be62af4d100b93 100644 --- a/ProcessLib/Output/Output.cpp +++ b/ProcessLib/Output/Output.cpp @@ -77,7 +77,9 @@ bool Output::shallDoOutput(unsigned timestep, double const t) bool make_output = timestep % each_steps == 0; if (_fixed_output_times.empty()) + { return make_output; + } const double specific_time = _fixed_output_times.back(); const double zero_threshold = std::numeric_limits<double>::min(); @@ -170,7 +172,9 @@ void Output::doOutputAlways(Process const& process, // output. if (!(process_id == static_cast<int>(_process_to_process_data.size()) - 1 || process.isMonolithicSchemeUsed())) + { return; + } std::string const output_file_name = constructFileName(_output_file_prefix, process_id, timestep, t) + @@ -189,7 +193,9 @@ void Output::doOutputAlways(Process const& process, for (auto const& mesh_output_name : _mesh_names_for_output) { if (process.getMesh().getName() == mesh_output_name) + { continue; + } auto& mesh = *BaseLib::findElementOrError( begin(_meshes), end(_meshes), [&mesh_output_name](auto const& m) { @@ -290,7 +296,9 @@ void Output::doOutputNonlinearIteration(Process const& process, // output. if (!(process_id == static_cast<int>(_process_to_process_data.size()) - 1 || process.isMonolithicSchemeUsed())) + { return; + } // Only check whether a process data is available for output. findProcessData(process, process_id); diff --git a/ProcessLib/Output/ProcessOutput.cpp b/ProcessLib/Output/ProcessOutput.cpp index 9f2b575c1cafeed64458d8b797aca50a69255404..34630fba305190b506998b88e8b501399cb37000 100644 --- a/ProcessLib/Output/ProcessOutput.cpp +++ b/ProcessLib/Output/ProcessOutput.cpp @@ -82,7 +82,9 @@ static void addSecondaryVariableResiduals( MeshLib::Mesh& mesh) { if (!var.fcts.eval_residuals) + { return; + } DBUG(" secondary variable %s residual", output_name.c_str()); auto const& property_name_res = output_name + "_residual"; diff --git a/ProcessLib/Parameter/ConstantParameter.cpp b/ProcessLib/Parameter/ConstantParameter.cpp index 5361c27c4024f60205e903a0d2e213f8935b0c13..5ccaab1592aa49d332a435957a832c4de3fa302c 100644 --- a/ProcessLib/Parameter/ConstantParameter.cpp +++ b/ProcessLib/Parameter/ConstantParameter.cpp @@ -48,7 +48,9 @@ std::unique_ptr<ParameterBase> createConstantParameter( config.getConfigParameter<std::vector<double>>("values"); if (values.empty()) + { OGS_FATAL("No value available for constant parameter."); + } DBUG("Using following values for the constant parameter:"); for (double const v : values) @@ -60,4 +62,4 @@ std::unique_ptr<ParameterBase> createConstantParameter( return std::make_unique<ConstantParameter<double>>(name, values); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/ConstantParameter.h b/ProcessLib/Parameter/ConstantParameter.h index 1e62a24c9ad817fd662deeb7086e243578fa25e3..75a3f1adbead46cc3b6112ff0f9e490c924d5f43 100644 --- a/ProcessLib/Parameter/ConstantParameter.h +++ b/ProcessLib/Parameter/ConstantParameter.h @@ -71,4 +71,4 @@ private: std::unique_ptr<ParameterBase> createConstantParameter( std::string const& name, BaseLib::ConfigTree const& config); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/CurveScaledParameter.cpp b/ProcessLib/Parameter/CurveScaledParameter.cpp index 25a5d0e116cbf272837669b54c658f75d6ccc428..0f941c7d7fdc0ed45c1b46d90749fb30b75c9f66 100644 --- a/ProcessLib/Parameter/CurveScaledParameter.cpp +++ b/ProcessLib/Parameter/CurveScaledParameter.cpp @@ -28,7 +28,9 @@ std::unique_ptr<ParameterBase> createCurveScaledParameter( auto const curve_it = curves.find(curve_name); if (curve_it == curves.end()) + { OGS_FATAL("Curve `%s' does not exists.", curve_name.c_str()); + } auto referenced_parameter_name = //! \ogs_file_param{prj__parameters__parameter__CurveScaled__parameter} @@ -40,4 +42,4 @@ std::unique_ptr<ParameterBase> createCurveScaledParameter( name, *curve_it->second, referenced_parameter_name); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/CurveScaledParameter.h b/ProcessLib/Parameter/CurveScaledParameter.h index 93441d29873f092ad4c9038d1547fe324d2b09e0..3e4babb03045cd949e84faf603e6b08d1fe71a72 100644 --- a/ProcessLib/Parameter/CurveScaledParameter.h +++ b/ProcessLib/Parameter/CurveScaledParameter.h @@ -70,4 +70,4 @@ std::unique_ptr<ParameterBase> createCurveScaledParameter( std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const& curves); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/FunctionParameter.cpp b/ProcessLib/Parameter/FunctionParameter.cpp index d5f88b071430c1932cbe05964cbdeb782a55be8e..2a943202e54dd6ec8c7eea4f1b3ad0bc39b97a1b 100644 --- a/ProcessLib/Parameter/FunctionParameter.cpp +++ b/ProcessLib/Parameter/FunctionParameter.cpp @@ -34,4 +34,4 @@ std::unique_ptr<ParameterBase> createFunctionParameter( name, mesh, vec_expressions); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/FunctionParameter.h b/ProcessLib/Parameter/FunctionParameter.h index a30ee3b10dffba5ad9f57546238bb42c23ae96bc..82b84338d58f7148e239bf91dc610e3d99968928 100644 --- a/ProcessLib/Parameter/FunctionParameter.h +++ b/ProcessLib/Parameter/FunctionParameter.h @@ -96,8 +96,10 @@ struct FunctionParameter final : public Parameter<T> z = node[2]; } - for (unsigned i=0; i<_vec_expression.size(); i++) + for (unsigned i = 0; i < _vec_expression.size(); i++) + { cache[i] = _vec_expression[i].value(); + } return cache; } @@ -113,4 +115,4 @@ std::unique_ptr<ParameterBase> createFunctionParameter( std::string const& name, BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/GroupBasedParameter.cpp b/ProcessLib/Parameter/GroupBasedParameter.cpp index dd589f82a1124f63c06921a187f10af764c4e37e..f6b256b233530dc06c5439f4af8291fb023d10fe 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.cpp +++ b/ProcessLib/Parameter/GroupBasedParameter.cpp @@ -56,7 +56,9 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( Values const values = p.getConfigParameter<Values>("values"); if (values.empty()) + { OGS_FATAL("No value available for constant parameter."); + } vec_index_values.emplace_back(index, values); } @@ -67,13 +69,21 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( { auto itr = std::find(group_id_property->begin(), group_id_property->end(), p.first); if (itr == group_id_property->end()) - OGS_FATAL("Specified property index %d does not exist in the property vector %s", - p.first, group_id_property_name.c_str()); + { + OGS_FATAL( + "Specified property index %d does not exist in the property " + "vector %s", + p.first, group_id_property_name.c_str()); + } if (p.second.size() != n_values) - OGS_FATAL("The length of some values (%d) is different from the first one (%d). " - "The length should be same for all index_values.", - p.second.size(), n_values); + { + OGS_FATAL( + "The length of some values (%d) is different from the first " + "one (%d). " + "The length should be same for all index_values.", + p.second.size(), n_values); + } } // create a mapping table @@ -81,18 +91,24 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( *std::max_element(group_id_property->begin(), group_id_property->end()); std::vector<Values> vec_values(max_index + 1); for (auto p : vec_index_values) + { vec_values[p.first] = p.second; + } if (group_id_property->getMeshItemType() == MeshLib::MeshItemType::Node) + { return std::make_unique< GroupBasedParameter<double, MeshLib::MeshItemType::Node>>( name, *group_id_property, vec_values); + } if (group_id_property->getMeshItemType() == MeshLib::MeshItemType::Cell) + { return std::make_unique< GroupBasedParameter<double, MeshLib::MeshItemType::Cell>>( name, *group_id_property, vec_values); + } OGS_FATAL("Mesh item type of the specified property is not supported."); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/GroupBasedParameter.h b/ProcessLib/Parameter/GroupBasedParameter.h index 092a11e704a1318b755959912ab60ace8397e702..67b7ecfcf6fead611e5dfd18bb42f3cfeaba7ece 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.h +++ b/ProcessLib/Parameter/GroupBasedParameter.h @@ -66,7 +66,9 @@ struct GroupBasedParameter final int const index = _property_index[item_id.get()]; auto const& values = _vec_values[index]; if (values.empty()) + { OGS_FATAL("No data found for the group index %d", index); + } return values; } @@ -94,4 +96,4 @@ std::unique_ptr<ParameterBase> createGroupBasedParameter( BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/MeshElementParameter.cpp b/ProcessLib/Parameter/MeshElementParameter.cpp index 22c1dd88d6ceae61b151bf2f5e593dc3385963c0..aaa20760daabe2547be608b521c9b409c9edf835 100644 --- a/ProcessLib/Parameter/MeshElementParameter.cpp +++ b/ProcessLib/Parameter/MeshElementParameter.cpp @@ -35,4 +35,4 @@ std::unique_ptr<ParameterBase> createMeshElementParameter( return std::make_unique<MeshElementParameter<double>>(name, *property); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/MeshElementParameter.h b/ProcessLib/Parameter/MeshElementParameter.h index 9bb6de3e92c6563778b100cfef5e95e3cd0e4ad1..1146105622d4fe12c8977ae5970bb94ef338d097 100644 --- a/ProcessLib/Parameter/MeshElementParameter.h +++ b/ProcessLib/Parameter/MeshElementParameter.h @@ -84,4 +84,4 @@ std::unique_ptr<ParameterBase> createMeshElementParameter( std::string const& name, BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/MeshNodeParameter.cpp b/ProcessLib/Parameter/MeshNodeParameter.cpp index b86295f5896d34f042ca314bd4de6abd7396a957..48fc8f5a281de41edd95e91a6145056f32da9d3e 100644 --- a/ProcessLib/Parameter/MeshNodeParameter.cpp +++ b/ProcessLib/Parameter/MeshNodeParameter.cpp @@ -35,4 +35,4 @@ std::unique_ptr<ParameterBase> createMeshNodeParameter( return std::make_unique<MeshNodeParameter<double>>(name, *property); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/MeshNodeParameter.h b/ProcessLib/Parameter/MeshNodeParameter.h index bda0426bda447fdabd825e8dc982a648efc9b78c..5c013c22dcf87e60395b2489022091d78c3d2aea 100644 --- a/ProcessLib/Parameter/MeshNodeParameter.h +++ b/ProcessLib/Parameter/MeshNodeParameter.h @@ -88,4 +88,4 @@ std::unique_ptr<ParameterBase> createMeshNodeParameter( std::string const& name, BaseLib::ConfigTree const& config, MeshLib::Mesh const& mesh); -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/Parameter.cpp b/ProcessLib/Parameter/Parameter.cpp index 0061e4ab4369b9c5f43385d02e6feb231d09561c..8d21a617f5c826b559ec5932ecacb0f8e8648c03 100644 --- a/ProcessLib/Parameter/Parameter.cpp +++ b/ProcessLib/Parameter/Parameter.cpp @@ -74,4 +74,4 @@ std::unique_ptr<ParameterBase> createParameter( OGS_FATAL("Cannot construct a parameter of given type '%s'.", type.c_str()); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Parameter/SpatialPosition.h b/ProcessLib/Parameter/SpatialPosition.h index f3366a4c19cb54b8d0bce64b884d30b5474d7a14..30a87e0973348680a2f3474f699b54845094e2e7 100644 --- a/ProcessLib/Parameter/SpatialPosition.h +++ b/ProcessLib/Parameter/SpatialPosition.h @@ -86,4 +86,4 @@ private: boost::optional<MathLib::TemplatePoint<double, 3>> _coordinates; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/PhaseField/CreatePhaseFieldProcess.cpp b/ProcessLib/PhaseField/CreatePhaseFieldProcess.cpp index 87f69ab3419c73cae2b2ac4824b740a61ef25f0a..f885a13e97d0286c83b15f5b2caf2e1d8af6da3a 100644 --- a/ProcessLib/PhaseField/CreatePhaseFieldProcess.cpp +++ b/ProcessLib/PhaseField/CreatePhaseFieldProcess.cpp @@ -150,11 +150,13 @@ std::unique_ptr<Process> createPhaseFieldProcess( config.getConfigParameter<std::vector<double>>( "specific_body_force"); if (b.size() != DisplacementDim) + { OGS_FATAL( "The size of the specific body force vector does not match the " "displacement dimension. Vector size is %d, displacement " "dimension is %d", b.size(), DisplacementDim); + } std::copy_n(b.data(), b.size(), specific_body_force.data()); } diff --git a/ProcessLib/PhaseField/PhaseFieldFEM-impl.h b/ProcessLib/PhaseField/PhaseFieldFEM-impl.h index c024ae5345a254a7f3d99a0a813823abb36c9414..f0140afa87d89c027667731afae3ccf82a37ba37 100644 --- a/ProcessLib/PhaseField/PhaseFieldFEM-impl.h +++ b/ProcessLib/PhaseField/PhaseFieldFEM-impl.h @@ -87,7 +87,9 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, auto local_pressure = 0.0; if (_process_data.crack_pressure) + { local_pressure = _process_data.unity_pressure; + } int const n_integration_points = _integration_method.getNumberOfPoints(); for (int ip = 0; ip < n_integration_points; ip++) @@ -126,9 +128,11 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u.template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } auto const rho_sr = _process_data.solid_density(t, x_position)[0]; auto const& b = _process_data.specific_body_force; @@ -185,9 +189,13 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, auto local_pressure = 0.0; if (_process_data.crack_pressure) + { local_pressure = _process_data.unity_pressure; + } else if (_process_data.propagating_crack) + { local_pressure = _process_data.pressure; + } int const n_integration_points = _integration_method.getNumberOfPoints(); for (int ip = 0; ip < n_integration_points; ip++) @@ -232,9 +240,11 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u.template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } local_Jac.noalias() += (2 * N.transpose() * N * strain_energy_tensile + @@ -306,9 +316,11 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u.template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } crack_volume += (N_u * u).dot(dNdx * d) * w; } @@ -376,9 +388,11 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u.template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } elastic_energy += _ip_data[ip].elastic_energy * w; @@ -388,8 +402,10 @@ void PhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, w; if (_process_data.crack_pressure) + { pressure_work += pressure_ip * (N_u * u_corrected).dot(dNdx * d) * w; + } } } } // namespace PhaseField diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 30a7889613f35d68ce9b8e3130938ba5f7dda32d..dac2b422919cbbdc1676e9c505c77f40b2d9ed95 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -112,8 +112,10 @@ ProcessVariable::ProcessVariable( DBUG("Constructing process variable %s", _name.c_str()); if (_shapefunction_order < 1 || 2 < _shapefunction_order) + { OGS_FATAL("The given shape function order %d is not supported", _shapefunction_order); + } // Boundary conditions if (auto bcs_config = @@ -131,8 +133,10 @@ ProcessVariable::ProcessVariable( bc_config.getConfigParameterOptional<int>("component"); if (!component_id && _n_components == 1) + { // default value for single component vars. component_id = 0; + } _bc_configs.emplace_back(std::move(bc_config), mesh, component_id); } @@ -158,8 +162,10 @@ ProcessVariable::ProcessVariable( st_config.getConfigParameterOptional<int>("component"); if (!component_id && _n_components == 1) + { // default value for single component vars. component_id = 0; + } _source_term_configs.emplace_back(std::move(st_config), mesh, component_id); @@ -219,7 +225,9 @@ ProcessVariable::createBoundaryConditions( } if (_deactivated_subdomains.empty()) + { return bcs; + } createBoundaryConditionsForDeactivatedSubDomains(dof_table, variable_id, parameters, bcs); @@ -293,7 +301,9 @@ void ProcessVariable::updateDeactivatedSubdomains(double const time) // Already initialized. if (!_ids_of_active_elements.empty()) + { return; + } auto const& deactivated_materialIDs = (*found_a_set)->materialIDs; @@ -306,7 +316,9 @@ void ProcessVariable::updateDeactivatedSubdomains(double const time) if (std::binary_search(deactivated_materialIDs.begin(), deactivated_materialIDs.end(), (*material_ids)[i])) + { continue; + } _ids_of_active_elements.push_back(_mesh.getElement(i)->getID()); } } @@ -320,9 +332,11 @@ std::vector<std::unique_ptr<SourceTerm>> ProcessVariable::createSourceTerms( std::vector<std::unique_ptr<SourceTerm>> source_terms; for (auto& config : _source_term_configs) + { source_terms.emplace_back(createSourceTerm( config, dof_table, config.mesh, variable_id, integration_order, _shapefunction_order, parameters)); + } return source_terms; } diff --git a/ProcessLib/RichardsComponentTransport/CreatePorousMediaProperties.cpp b/ProcessLib/RichardsComponentTransport/CreatePorousMediaProperties.cpp index abd0b04373efeaced66f0d8eab9979fdd02aaa88..5e9a684bdf5e673d5638ec9b767cb0ce2f804757 100644 --- a/ProcessLib/RichardsComponentTransport/CreatePorousMediaProperties.cpp +++ b/ProcessLib/RichardsComponentTransport/CreatePorousMediaProperties.cpp @@ -111,5 +111,5 @@ PorousMediaProperties createPorousMediaProperties( std::move(material_ids)}; } -} // namespace ComponentTransport +} // namespace RichardsComponentTransport } // namespace ProcessLib diff --git a/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp b/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp index eb145ecc0484cad0fc5d787cb1063df5fdfe4a51..fa960ea873d194a26d3a5dab70aaf2e69a53b01a 100644 --- a/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp +++ b/ProcessLib/RichardsComponentTransport/CreateRichardsComponentTransportProcess.cpp @@ -134,10 +134,12 @@ std::unique_ptr<Process> createRichardsComponentTransportProcess( config.getConfigParameter<std::vector<double>>("specific_body_force"); assert(b.size() > 0 && b.size() < 4); if (b.size() < mesh.getDimension()) + { OGS_FATAL( "specific body force (gravity vector) has %d components, mesh " "dimension is %d", b.size(), mesh.getDimension()); + } bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) { diff --git a/ProcessLib/RichardsComponentTransport/PorousMediaProperties.cpp b/ProcessLib/RichardsComponentTransport/PorousMediaProperties.cpp index 941d2b747925e4bb9fb439bf93ec38dd84d76bdf..042d0237a99f1719f8a4eced668048c6dcaea539 100644 --- a/ProcessLib/RichardsComponentTransport/PorousMediaProperties.cpp +++ b/ProcessLib/RichardsComponentTransport/PorousMediaProperties.cpp @@ -54,5 +54,5 @@ PorousMediaProperties::getRelativePermeability( { return *_relative_permeability_models[getMaterialID(pos)]; } -} -} +} // namespace RichardsComponentTransport +} // namespace ProcessLib diff --git a/ProcessLib/RichardsComponentTransport/PorousMediaProperties.h b/ProcessLib/RichardsComponentTransport/PorousMediaProperties.h index 30b773a7f98529cf04b099f23efd5d390a5e7986..1abc5850bed921c26d1a58230af9752bc398c69b 100644 --- a/ProcessLib/RichardsComponentTransport/PorousMediaProperties.h +++ b/ProcessLib/RichardsComponentTransport/PorousMediaProperties.h @@ -104,5 +104,5 @@ private: std::vector<int> _material_ids; }; -} -} +} // namespace RichardsComponentTransport +} // namespace ProcessLib diff --git a/ProcessLib/RichardsComponentTransport/RichardsComponentTransportFEM-impl.h b/ProcessLib/RichardsComponentTransport/RichardsComponentTransportFEM-impl.h index 379e2c7a76256ac5c784210478a9d22b9ea71f55..b8f236f4734d161a4a829e19c7982dd3591b761b 100644 --- a/ProcessLib/RichardsComponentTransport/RichardsComponentTransportFEM-impl.h +++ b/ProcessLib/RichardsComponentTransport/RichardsComponentTransportFEM-impl.h @@ -203,7 +203,9 @@ void LocalAssemblerData<ShapeFunction, IntegrationMethod, GlobalDim>::assemble( ip_data.mass_operator; if (_process_data.has_gravity) + { Bp += w * density * dNdx.transpose() * K_times_k_rel_over_mu * b; + } /* with Oberbeck-Boussing assumption density difference only exists * in buoyancy effects */ } diff --git a/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.cpp b/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.cpp index 609c88518dc2beeb7ab581d28f5b9683fba77094..4bed8c3f514e99f41fc1330581a29ecfaf3d34fa 100644 --- a/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.cpp +++ b/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.cpp @@ -114,5 +114,5 @@ createRichardsFlowMaterialProperties( std::move(relative_permeability_models)}}; } -} // end namespace -} // end namespace +} // namespace RichardsFlow +} // namespace ProcessLib diff --git a/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.h b/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.h index 7e91a36e5a9de84db90321697f7e997f7730206d..20731abc377cdc4d2150d1ca56c22d68a6e86e9f 100644 --- a/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.h +++ b/ProcessLib/RichardsFlow/CreateRichardsFlowMaterialProperties.h @@ -26,4 +26,4 @@ createRichardsFlowMaterialProperties( std::vector<std::unique_ptr<ParameterBase>> const& parameters); } // end namespace -} // end namespace +} // namespace ProcessLib diff --git a/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp b/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp index 1b0018ba310d4d893a25eea3085c30cea73c980b..24d1d4593a1205b6db57dca04a46b2ed88b6b4e6 100644 --- a/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp +++ b/ProcessLib/RichardsFlow/CreateRichardsFlowProcess.cpp @@ -66,7 +66,9 @@ std::unique_ptr<Process> createRichardsFlowProcess( Eigen::VectorXd specific_body_force(b.size()); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) + { std::copy_n(b.data(), b.size(), specific_body_force.data()); + } // has mass lumping //! \ogs_file_param{prj__processes__process__RICHARDS_FLOW__mass_lumping} diff --git a/ProcessLib/RichardsFlow/RichardsFlowFEM.h b/ProcessLib/RichardsFlow/RichardsFlowFEM.h index f1e802d0ff8c7abb4da6633d2f028f08fc79ee63..47faea78cd1edfc48a3c78e605adcdb57b9832ae 100644 --- a/ProcessLib/RichardsFlow/RichardsFlowFEM.h +++ b/ProcessLib/RichardsFlow/RichardsFlowFEM.h @@ -156,9 +156,13 @@ public: GlobalDimMatrixType permeability = GlobalDimMatrixType::Zero( _element.getDimension(), _element.getDimension()); if (perm.rows() == _element.getDimension()) + { permeability = perm; + } else if (perm.rows() == 1) + { permeability.diagonal().setConstant(perm(0, 0)); + } for (unsigned ip = 0; ip < n_integration_points; ip++) { @@ -268,9 +272,13 @@ public: GlobalDimMatrixType permeability = GlobalDimMatrixType::Zero( _element.getDimension(), _element.getDimension()); if (perm.rows() == _element.getDimension()) + { permeability = perm; + } else if (perm.rows() == 1) + { permeability.diagonal().setConstant(perm(0, 0)); + } unsigned const n_integration_points = _integration_method.getNumberOfPoints(); diff --git a/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.cpp b/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.cpp index 94e78cce43fe1602499637f4defad4d3cb0881e8..7d2a6f268eb5b3875807cba998a92343e6bbc867 100644 --- a/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.cpp +++ b/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.cpp @@ -155,5 +155,5 @@ double RichardsFlowMaterialProperties::getSaturationDerivative2( _capillary_pressure_models[material_id]->getd2PcdS2(saturation); return -d2pcdsw2 / boost::math::pow<3>(dpcdsw); } -} // end of namespace -} // end of namespace +} // namespace RichardsFlow +} // namespace ProcessLib diff --git a/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.h b/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.h index a9a4143417b08de4b40cf8fe13bea3395f78dee8..c75561c3811a96a2e206b6a2f9b62469568201dc 100644 --- a/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.h +++ b/ProcessLib/RichardsFlow/RichardsFlowMaterialProperties.h @@ -127,5 +127,5 @@ private: _relative_permeability_models; }; -} // end of namespace -} // end of namespace +} // namespace RichardsFlow +} // namespace ProcessLib diff --git a/ProcessLib/RichardsMechanics/IntegrationPointData.h b/ProcessLib/RichardsMechanics/IntegrationPointData.h index 1bf68252a87f111412aba1f0f5e06a0888651d8e..207a6276c74c2beb75d6eb000cfd0500be3adde0 100644 --- a/ProcessLib/RichardsMechanics/IntegrationPointData.h +++ b/ProcessLib/RichardsMechanics/IntegrationPointData.h @@ -82,7 +82,9 @@ struct IntegrationPointData final *material_state_variables, temperature); if (!solution) + { OGS_FATAL("Computation of local constitutive relation failed."); + } MathLib::KelvinVector::KelvinMatrixType<DisplacementDim> C; std::tie(sigma_eff, material_state_variables, C) = std::move(*solution); diff --git a/ProcessLib/RichardsMechanics/LocalDataInitializer.h b/ProcessLib/RichardsMechanics/LocalDataInitializer.h index 5e34224bd36136af7740579d39c57084428916c9..b6a4eb63db8b809d70a36e6d28a5804631c13c97 100644 --- a/ProcessLib/RichardsMechanics/LocalDataInitializer.h +++ b/ProcessLib/RichardsMechanics/LocalDataInitializer.h @@ -130,10 +130,12 @@ public: : _dof_table(dof_table) { if (shapefunction_order != 2) + { OGS_FATAL( "The given shape function order %d is not supported.\nOnly " "shape functions of order 2 are supported.", shapefunction_order); + } // /// Quads and Hexahedra /////////////////////////////////// #if (OGS_ENABLED_ELEMENTS & ENABLED_ELEMENT_TYPE_QUAD) != 0 && \ diff --git a/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h b/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h index dc0f58a397f7e664a4285c1fafeb6da13c9b14a1..0e6b8b81285d7c1672b00faaf305fdac370a88d2 100644 --- a/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h +++ b/ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h @@ -98,10 +98,12 @@ RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement, DisplacementDim, displacement_size>::Zero(DisplacementDim, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { ip_data.N_u_op .template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = sm_u.N; + } ip_data.N_u = sm_u.N; ip_data.dNdx_u = sm_u.dNdx; diff --git a/ProcessLib/SmallDeformation/CreateLocalAssemblers.h b/ProcessLib/SmallDeformation/CreateLocalAssemblers.h index 84bd037a408eef55928ba16530ac6058951978a6..4c13e909d0bc90d06b53022bbce523c60fe77be4 100644 --- a/ProcessLib/SmallDeformation/CreateLocalAssemblers.h +++ b/ProcessLib/SmallDeformation/CreateLocalAssemblers.h @@ -79,6 +79,6 @@ void createLocalAssemblers( dof_table, mesh_elements, local_assemblers, std::forward<ExtraCtorArgs>(extra_ctor_args)...); } -} // SmallDeformation +} // namespace SmallDeformation -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp index db5deddaafdf8f3136781e901f9c6b1148f83f97..5835471f4b252157ab5e221d8fbd037207697bae 100644 --- a/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp +++ b/ProcessLib/SmallDeformation/CreateSmallDeformationProcess.cpp @@ -83,11 +83,13 @@ createSmallDeformationProcess( config.getConfigParameter<std::vector<double>>( "specific_body_force"); if (b.size() != DisplacementDim) + { OGS_FATAL( "The size of the specific body force vector does not match the " "displacement dimension. Vector size is %d, displacement " "dimension is %d", b.size(), DisplacementDim); + } std::copy_n(b.data(), b.size(), specific_body_force.data()); } diff --git a/ProcessLib/SmallDeformation/SmallDeformationFEM.h b/ProcessLib/SmallDeformation/SmallDeformationFEM.h index 04042b4aede8e48d80990f1125912a374c6b72b0..3c5724bc7e28a9762579b3297ab6867daf1bb959 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationFEM.h +++ b/ProcessLib/SmallDeformation/SmallDeformationFEM.h @@ -229,10 +229,12 @@ public: displacement_size>::Zero(DisplacementDim, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u_op .template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } auto const x_coord = interpolateXCoordinate<ShapeFunction, ShapeMatricesType>( @@ -259,7 +261,9 @@ public: *state, _process_data.reference_temperature); if (!solution) + { OGS_FATAL("Computation of local constitutive relation failed."); + } MathLib::KelvinVector::KelvinMatrixType<DisplacementDim> C; std::tie(sigma, state, C) = std::move(*solution); diff --git a/ProcessLib/SmallDeformationNonlocal/CreateSmallDeformationNonlocalProcess.cpp b/ProcessLib/SmallDeformationNonlocal/CreateSmallDeformationNonlocalProcess.cpp index a9a75fcdc90f9b1eda030a4c6406e0d3c2c52482..9459c48d64d685d3e764a6920d4d3cbcf05abe92 100644 --- a/ProcessLib/SmallDeformationNonlocal/CreateSmallDeformationNonlocalProcess.cpp +++ b/ProcessLib/SmallDeformationNonlocal/CreateSmallDeformationNonlocalProcess.cpp @@ -83,11 +83,13 @@ std::unique_ptr<Process> createSmallDeformationNonlocalProcess( config.getConfigParameter<std::vector<double>>( "specific_body_force"); if (b.size() != DisplacementDim) + { OGS_FATAL( "The size of the specific body force vector does not match the " "displacement dimension. Vector size is %d, displacement " "dimension is %d", b.size(), DisplacementDim); + } std::copy_n(b.data(), b.size(), specific_body_force.data()); } diff --git a/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h b/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h index 12471bd169324bf6da8f719652dd5e563a68d8f9..30a243b0d462a0b67f9f53345dbf87c1e4d7dcab 100644 --- a/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h +++ b/ProcessLib/SmallDeformationNonlocal/SmallDeformationNonlocalFEM.h @@ -228,7 +228,9 @@ public: for (int ip = 0; ip < static_cast<int>(distances.size()); ++ip) { if (distances[ip] >= _process_data.internal_length_squared) + { continue; + } // save into current ip_k _ip_data[k].non_local_assemblers.push_back( {la->getIPDataPtr(ip), @@ -371,7 +373,9 @@ public: *state, _process_data.reference_temperature); if (!solution) + { OGS_FATAL("Computation of local constitutive relation failed."); + } std::tie(sigma, state, C) = std::move(*solution); @@ -815,10 +819,14 @@ private: for (auto const& ip_data : _ip_data) { - if (component < 3) // xx, yy, zz components + if (component < 3) + { // xx, yy, zz components cache.push_back(ip_data.sigma[component]); - else // mixed xy, yz, xz components + } + else + { // mixed xy, yz, xz components cache.push_back(ip_data.sigma[component] / std::sqrt(2)); + } } return cache; diff --git a/ProcessLib/SourceTerms/Python/CMakeLists.txt b/ProcessLib/SourceTerms/Python/CMakeLists.txt index 8ecddaea2e59a5715ef26188d8e27f4795415512..2fe58ad12a40af27a83d8bde04fe0f2d2cbb775f 100644 --- a/ProcessLib/SourceTerms/Python/CMakeLists.txt +++ b/ProcessLib/SourceTerms/Python/CMakeLists.txt @@ -14,7 +14,7 @@ target_compile_definitions(ProcessLibSourceTermPython PUBLIC OGS_USE_PYTHON) target_link_libraries(ProcessLibSourceTermPython - PUBLIC BaseLib MathLib MeshLib NumLib logog + PUBLIC BaseLib MathLib MeshLib NumLib logog ${Python_LIBRARIES} PRIVATE pybind11::pybind11) # For the embedded Python module diff --git a/ProcessLib/SourceTerms/SourceTermCollection.cpp b/ProcessLib/SourceTerms/SourceTermCollection.cpp index d7678b3f7512cd29cc830a0940608f22a956f5e9..8b48d84ee0700d6dcca61fd517bd74b187abc57c 100644 --- a/ProcessLib/SourceTerms/SourceTermCollection.cpp +++ b/ProcessLib/SourceTerms/SourceTermCollection.cpp @@ -33,7 +33,9 @@ void SourceTermCollection::integrate(const double t, GlobalVector const& x, GlobalVector& b, GlobalMatrix* jac) const { for (auto const& st : _source_terms) + { st->integrate(t, x, b, jac); + } } -} +} // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/SourceTermCollection.h b/ProcessLib/SourceTerms/SourceTermCollection.h index be718426a4893f5483de8b9c6adfab77526d415f..7de8a0747fcada3397143160c1235e0981341d52 100644 --- a/ProcessLib/SourceTerms/SourceTermCollection.h +++ b/ProcessLib/SourceTerms/SourceTermCollection.h @@ -37,4 +37,4 @@ private: std::vector<std::unique_ptr<ParameterBase>> const& _parameters; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/SourceTermConfig.h b/ProcessLib/SourceTerms/SourceTermConfig.h index 9c7b85fb93e478364d360e7c5e05dfa1989fbdff..5d85f55f8e5b508788460b1a66ce50312f2ad9f6 100644 --- a/ProcessLib/SourceTerms/SourceTermConfig.h +++ b/ProcessLib/SourceTerms/SourceTermConfig.h @@ -35,4 +35,4 @@ struct SourceTermConfig final boost::optional<int> const component_id; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/SurfaceFlux/SurfaceFluxLocalAssembler.h b/ProcessLib/SurfaceFlux/SurfaceFluxLocalAssembler.h index 2f17377a48a180225966b6b5b6ed3228ac9c8887..c4e1aa2a7adc3c4364de9a0f17e87fedac0a27ab 100644 --- a/ProcessLib/SurfaceFlux/SurfaceFluxLocalAssembler.h +++ b/ProcessLib/SurfaceFlux/SurfaceFluxLocalAssembler.h @@ -170,4 +170,4 @@ private: std::size_t _bulk_face_id; }; -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESLocalAssembler-impl.h b/ProcessLib/TES/TESLocalAssembler-impl.h index 966688a1e8eba1b771a5c0e58d4cb480a1ace5b1..c6ebc9ff1aa424137441f4743a10d85a8dadb433 100644 --- a/ProcessLib/TES/TESLocalAssembler-impl.h +++ b/ProcessLib/TES/TESLocalAssembler-impl.h @@ -39,12 +39,16 @@ void ogs5OutMat(const Mat& mat) { case MatOutType::OGS5: if (r != 0) + { std::printf("\n"); + } std::printf("|"); break; case MatOutType::PYTHON: if (r != 0) + { std::printf(",\n"); + } std::printf("["); break; } @@ -58,7 +62,9 @@ void ogs5OutMat(const Mat& mat) break; case MatOutType::PYTHON: if (c != 0) + { std::printf(","); + } std::printf(" %23.16g", mat(r, c)); break; } @@ -86,12 +92,16 @@ void ogs5OutVec(const Vec& vec) { case MatOutType::OGS5: if (r != 0) + { std::printf("\n"); + } std::printf("| %.16e | ", vec[r]); break; case MatOutType::PYTHON: if (r != 0) + { std::printf(",\n"); + } std::printf("[ %23.16g ]", vec[r]); break; } diff --git a/ProcessLib/TES/TESLocalAssemblerData.cpp b/ProcessLib/TES/TESLocalAssemblerData.cpp index 02e3137557ce55330ff1c33044cd84bce0509b1c..5592c1c281f451f65c62d1855f64b28567a5d0d0 100644 --- a/ProcessLib/TES/TESLocalAssemblerData.cpp +++ b/ProcessLib/TES/TESLocalAssemblerData.cpp @@ -27,5 +27,5 @@ TESLocalAssemblerData::TESLocalAssemblerData(AssemblyParams const& ap_, } TESLocalAssemblerData::~TESLocalAssemblerData() = default; -} -} // namespaces +} // namespace TES +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESLocalAssemblerData.h b/ProcessLib/TES/TESLocalAssemblerData.h index b8b2e72aecfb8903869d7894a89d987936cadd5a..ac5655134836f61bbb1c0af85e1f50795d3164c9 100644 --- a/ProcessLib/TES/TESLocalAssemblerData.h +++ b/ProcessLib/TES/TESLocalAssemblerData.h @@ -53,5 +53,5 @@ struct TESLocalAssemblerData std::vector<double> reaction_rate_prev_ts; // could also be calculated from // solid_density_prev_ts }; -} -} // namespaces +} // namespace TES +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESLocalAssemblerInner-fwd.h b/ProcessLib/TES/TESLocalAssemblerInner-fwd.h index dadc2e7f6aa0e7ebc659b6205d302d9bfe92d578..f7e20ed410b822bbe3903babd7c751ea870bd0f7 100644 --- a/ProcessLib/TES/TESLocalAssemblerInner-fwd.h +++ b/ProcessLib/TES/TESLocalAssemblerInner-fwd.h @@ -26,5 +26,5 @@ static_assert(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG == 1, static_assert(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG == 0, "inconsistent use of macros"); #endif -} -} +} // namespace TES +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESLocalAssemblerInner.cpp b/ProcessLib/TES/TESLocalAssemblerInner.cpp index 5792be92610d2ba141a3d6067191fa1d8af79d8b..6a83238662388c310b4f145fda1161b81cc9b564 100644 --- a/ProcessLib/TES/TESLocalAssemblerInner.cpp +++ b/ProcessLib/TES/TESLocalAssemblerInner.cpp @@ -31,5 +31,5 @@ static_assert(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG == 1, static_assert(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG == 0, "inconsistent use of macros"); #endif -} -} +} // namespace TES +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESOGS5MaterialModels.cpp b/ProcessLib/TES/TESOGS5MaterialModels.cpp index b8098f829e4947fba647a536bfd466a0d8df4984..c6476cb4c57862540fee19d808406a73d6b67f3e 100644 --- a/ProcessLib/TES/TESOGS5MaterialModels.cpp +++ b/ProcessLib/TES/TESOGS5MaterialModels.cpp @@ -31,5 +31,5 @@ const double FluidViscosityN2::C[5] = {-20.09997, 3.4376416, -1.4470051, const double FluidHeatConductivityH2O::a[4] = {0.0102811, 0.0299621, 0.0156146, -0.00422464}; -} // TES -} // ProcessLib +} // namespace TES +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESOGS5MaterialModels.h b/ProcessLib/TES/TESOGS5MaterialModels.h index feeaf98d04cf9a8b62c64497719d9efca31b94af..0036cf94fa347fc0827eb806ae8bb7960407a15d 100644 --- a/ProcessLib/TES/TESOGS5MaterialModels.h +++ b/ProcessLib/TES/TESOGS5MaterialModels.h @@ -338,9 +338,13 @@ struct FluidHeatConductivityH2O Q = 2 + (C[4] / dT_pow_3_5); if (T >= 1) + { S = 1 / dT; + } else + { S = C[5] / dT_pow_3_5; + } const double rho_pow_9_5 = std::pow(rho, 9. / 5.); const double rho_pow_Q = std::pow(rho, Q); @@ -399,5 +403,5 @@ inline double fluid_heat_conductivity(const double p, return k0 * x0 / (x0 + x1 * phi_12) + k1 * x1 / (x1 + x0 * phi_21); } -} // TES -} // ProcessLib +} // namespace TES +} // namespace ProcessLib diff --git a/ProcessLib/TES/TESProcess.cpp b/ProcessLib/TES/TESProcess.cpp index c04f685f1ca2bc0d0db5abf38fc29a4f89ad4b59..9fbc3bd3844a0cd07037d26cd339a5ba4e6a2ec3 100644 --- a/ProcessLib/TES/TESProcess.cpp +++ b/ProcessLib/TES/TESProcess.cpp @@ -197,7 +197,9 @@ void TESProcess::initializeSecondaryVariables() _secondary_variable_context); for (auto&& fct : solid_density->getNamedFunctions()) + { _named_function_caller.addNamedFunction(std::move(fct)); + } add2nd("solid_density", solid_density->getExtrapolator()); @@ -310,7 +312,9 @@ NumLib::IterationResult TESProcess::postIterationConcreteProcess( local_x_prev_ts_cache = _x_previous_timestep->get(r_c_indices.rows); if (!loc_asm.checkBounds(local_x_cache, local_x_prev_ts_cache)) + { check_passed = false; + } }; GlobalExecutor::executeDereferenced(check_variable_bounds, @@ -318,7 +322,9 @@ NumLib::IterationResult TESProcess::postIterationConcreteProcess( } if (!check_passed) + { return NumLib::IterationResult::REPEAT_ITERATION; + } // TODO remove DBUG("ts %lu iteration %lu (in current ts: %lu) try %u accepted", diff --git a/ProcessLib/TES/TESReactionAdaptor.cpp b/ProcessLib/TES/TESReactionAdaptor.cpp index e39c47f1e8530dc4cf744ce015765f76925c1fe8..d1fe25da245f0ff8f10ea8b7e6696526c50fabac 100644 --- a/ProcessLib/TES/TESReactionAdaptor.cpp +++ b/ProcessLib/TES/TESReactionAdaptor.cpp @@ -232,9 +232,13 @@ bool TESFEMReactionAdaptorAdsorption::checkBounds( if (alpha != 1.0) { if (alpha > 0.5) + { alpha = 0.5; + } if (alpha < 0.05) + { alpha = 0.05; + } if (_d.ap.number_of_try_of_iteration <= 3) { @@ -252,7 +256,9 @@ bool TESFEMReactionAdaptorAdsorption::checkBounds( void TESFEMReactionAdaptorAdsorption::preZerothTryAssemble() { if (_reaction_damping_factor < 1e-3) + { _reaction_damping_factor = 1e-3; + } _reaction_damping_factor = std::min(std::sqrt(_reaction_damping_factor), 10.0 * _reaction_damping_factor); @@ -356,11 +362,17 @@ ReactionRate TESFEMReactionAdaptorCaOH2::initReaction(const unsigned int int_pt) // cut off when limits are reached if (y_new[0] < _react.rho_low) + { rho_react = _react.rho_low; + } else if (y_new[0] > _react.rho_up) + { rho_react = _react.rho_up; + } else + { rho_react = y_new[0]; + } return {y_dot_new[0] * (1.0 - xv_NR), (1.0 - xv_NR) * rho_react + xv_NR * rho_NR}; diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp index bc503cf69445ab133b870d6f41816b76603c1d85..66c73326055f8a120e6df222699c1bec5460d340 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.cpp @@ -102,5 +102,5 @@ createThermalTwoPhaseFlowWithPPMaterialProperties( std::move(vapor_property)); } -} // end namespace -} // end namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.h index c4c4c47d82c9f0cd5e3d3291c3d95590794de203..e51387b61b7168386ad42179157ad798b7784357 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPMaterialProperties.h @@ -34,4 +34,4 @@ createThermalTwoPhaseFlowWithPPMaterialProperties( std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters); } // end namespace -} // end namespace +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp index 46c5e5f0cb973d41fae7756d79a5ec44dd71132a..cbe14e348f5adcc04733552aedacb75ff4590acf 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.cpp @@ -70,7 +70,9 @@ std::unique_ptr<Process> createThermalTwoPhaseFlowWithPPProcess( Eigen::VectorXd specific_body_force(b.size()); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) + { std::copy_n(b.data(), b.size(), specific_body_force.data()); + } //! \ogs_file_param{prj__processes__process__TWOPHASE_FLOW_THERMAL__mass_lumping} auto mass_lumping = config.getConfigParameter<bool>("mass_lumping"); @@ -141,5 +143,5 @@ std::unique_ptr<Process> createThermalTwoPhaseFlowWithPPProcess( mat_config, curves); } -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.h index b8bc02381339bc2bc4ba169390a03a1ae14466b8..bb93b33d64e2674760c4888b36f6bfc97281992c 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CreateThermalTwoPhaseFlowWithPPProcess.h @@ -27,5 +27,5 @@ std::unique_ptr<Process> createThermalTwoPhaseFlowWithPPProcess( std::map<std::string, std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const& curves); -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h index 7ad7932f9f34215644eec6f1de99c838590419bb..97ae3dd571699e26a2f48df4c9c5581f06cc3c58 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h @@ -154,9 +154,13 @@ void ThermalTwoPhaseFlowWithPPLocalAssembler< GlobalDimMatrixType permeability = GlobalDimMatrixType::Zero( _element.getDimension(), _element.getDimension()); if (perm.rows() == _element.getDimension()) + { permeability = perm; + } else if (perm.rows() == 1) + { permeability.diagonal().setConstant(perm(0, 0)); + } for (unsigned ip = 0; ip < n_integration_points; ip++) { @@ -466,5 +470,5 @@ void ThermalTwoPhaseFlowWithPPLocalAssembler< } // end of mass-lumping } -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler.h index 56dacfe2dddc80c45d8ae18c7351e3acce5ba185..e20b9b761bb482d7dfb70295c24b7a0eb44c036f 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPLocalAssembler.h @@ -190,7 +190,7 @@ private: static const int temperature_size = ShapeFunction::NPOINTS; }; -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib #include "ThermalTwoPhaseFlowWithPPLocalAssembler-impl.h" diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.cpp index dedf9f7a95c5b180721f2302173e06d74815c143..aa8fa51f48af57afa72f4e746e35dfdc3a946856 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.cpp @@ -134,9 +134,13 @@ ThermalTwoPhaseFlowWithPPMaterialProperties::calculateUnsatHeatConductivity( double lambda_pm = lambda_pm_dry + std::sqrt(Sw) * (lambda_pm_wet - lambda_pm_dry); if (Sw > 1) + { lambda_pm = lambda_pm_wet; + } else if (Sw < 0) + { lambda_pm = lambda_pm_dry; + } return lambda_pm; } @@ -204,5 +208,5 @@ ThermalTwoPhaseFlowWithPPMaterialProperties::getLiquidWaterEnthalpySimple( return heat_capacity_liquid_water * (temperature - CelsiusZeroInKelvin); } -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.h index 7bdd9de80f14a1ca8d199afcfd382611b213f6f5..91469113e1af1aa809f7e016ad94a23979281314 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPMaterialProperties.h @@ -143,5 +143,5 @@ private: _water_vapor_properties; }; -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.cpp index c47f5e5d6c881c3f8f322f17581c16456f758a84..a89fa3b1920fbeb933b22b2d532c0efd3c83d764 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.cpp @@ -124,5 +124,5 @@ void ThermalTwoPhaseFlowWithPPProcess::preTimestepConcreteProcess( delta_t); } -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.h index ea4be1ea6613993254e3b560226c7cca02a2c86f..d4aeb57f12b801537adaf8a11826f5ce9e73c1f4 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcess.h @@ -78,5 +78,5 @@ private: _local_assemblers; }; -} // end of namespace -} // end of namespace +} // namespace ThermalTwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcessData.h b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcessData.h index d138a24857bd142cd21622abe0027cc78b9a247d..fce7cd756476be3273499ded034d7d210f8bf3d4 100644 --- a/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcessData.h +++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/ThermalTwoPhaseFlowWithPPProcessData.h @@ -75,5 +75,5 @@ struct ThermalTwoPhaseFlowWithPPProcessData std::unique_ptr<ThermalTwoPhaseFlowWithPPMaterialProperties> material; }; -} // namespace TwoPhaseFlowWithPP +} // namespace ThermalTwoPhaseFlowWithPP } // namespace ProcessLib diff --git a/ProcessLib/ThermoMechanicalPhaseField/CreateThermoMechanicalPhaseFieldProcess.cpp b/ProcessLib/ThermoMechanicalPhaseField/CreateThermoMechanicalPhaseFieldProcess.cpp index b7fbd947bf252b443a1f9c9911819a988419c434..aef959058351cc5be07e0be588a56ab3cf98e3b1 100644 --- a/ProcessLib/ThermoMechanicalPhaseField/CreateThermoMechanicalPhaseFieldProcess.cpp +++ b/ProcessLib/ThermoMechanicalPhaseField/CreateThermoMechanicalPhaseFieldProcess.cpp @@ -199,11 +199,13 @@ std::unique_ptr<Process> createThermoMechanicalPhaseFieldProcess( config.getConfigParameter<std::vector<double>>( "specific_body_force"); if (specific_body_force.size() != DisplacementDim) + { OGS_FATAL( "The size of the specific body force vector does not match the " "displacement dimension. Vector size is %d, displacement " "dimension is %d", specific_body_force.size(), DisplacementDim); + } std::copy_n(b.data(), b.size(), specific_body_force.data()); } diff --git a/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldFEM-impl.h b/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldFEM-impl.h index e935ccf674caa17bbfa54a7d281357ef66592d6e..a8d23a00acd37e1a1394c0e20bedcad1b038e946 100644 --- a/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldFEM-impl.h +++ b/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldFEM-impl.h @@ -149,9 +149,11 @@ void ThermoMechanicalPhaseFieldLocalAssembler<ShapeFunction, IntegrationMethod, displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u.template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } local_Jac.noalias() += B.transpose() * C_eff * B * w; diff --git a/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp b/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp index 1555af12000ab76d319e3cef19e8ae5525b6a4c0..6e62d363d128a3ee25f9315730167eab25a4d2bc 100644 --- a/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp +++ b/ProcessLib/ThermoMechanics/CreateThermoMechanicsProcess.cpp @@ -144,11 +144,13 @@ std::unique_ptr<Process> createThermoMechanicsProcess( config.getConfigParameter<std::vector<double>>( "specific_body_force"); if (b.size() != DisplacementDim) + { OGS_FATAL( "The size of the specific body force vector does not match the " "displacement dimension. Vector size is %d, displacement " "dimension is %d", b.size(), DisplacementDim); + } std::copy_n(b.data(), b.size(), specific_body_force.data()); } diff --git a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h index 82080cbc3767d999ca8e66caf8bbfe0eae1cbf0b..adf3f482d5285da04f2ea6303f471d2955e0425a 100644 --- a/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h +++ b/ProcessLib/ThermoMechanics/ThermoMechanicsFEM.h @@ -186,7 +186,7 @@ public: { return setSigma(values); } - else if (name == "epsilon_ip") + if (name == "epsilon_ip") { return setEpsilon(values); } @@ -310,7 +310,9 @@ public: t, x_position, dt, eps_m_prev, eps_m, sigma_prev, *state, T_ip); if (!solution) + { OGS_FATAL("Computation of local constitutive relation failed."); + } MathLib::KelvinVector::KelvinMatrixType<DisplacementDim> C; std::tie(sigma, state, C) = std::move(*solution); @@ -328,9 +330,11 @@ public: displacement_size); for (int i = 0; i < DisplacementDim; ++i) + { N_u.template block<1, displacement_size / DisplacementDim>( i, i * displacement_size / DisplacementDim) .noalias() = N; + } // calculate real density // rho_s_{n+1} * (V_{n} + dV) = rho_s_n * V_n diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp index acae56e36cf298b7a83e12f01623ea7ddec04eec..990d7e062a97ed84634857f89e0dbe90ca7d8c78 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.cpp @@ -135,5 +135,5 @@ createTwoPhaseFlowWithPPMaterialProperties( std::move(relative_permeability_models)); } -} // end namespace -} // end namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.h b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.h index 27f262c11ed1477bf9f875923f966e80f579e006..4c76a9c9f18acd7402f48ba690d00af76413eacb 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.h +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPMaterialProperties.h @@ -27,4 +27,4 @@ createTwoPhaseFlowWithPPMaterialProperties( std::vector<std::unique_ptr<ParameterBase>> const& parameters); } // end namespace -} // end namespace +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp index 2cde552489dd9c9a73ac195bd6ac58d83a054f38..d4395852be655d130733f5029c58d801f962c000 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.cpp @@ -65,7 +65,9 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPPProcess( Eigen::VectorXd specific_body_force(b.size()); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) + { std::copy_n(b.data(), b.size(), specific_body_force.data()); + } //! \ogs_file_param{prj__processes__process__TWOPHASE_FLOW_PP__mass_lumping} auto const mass_lumping = config.getConfigParameter<bool>("mass_lumping"); @@ -101,5 +103,5 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPPProcess( mat_config, curves); } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.h b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.h index 015745d9e315f7d682f5f5abf3044d5af9236e75..b54f71fc9fe4883f93dfe97a83fa640f6baa4398 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.h +++ b/ProcessLib/TwoPhaseFlowWithPP/CreateTwoPhaseFlowWithPPProcess.h @@ -26,5 +26,5 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPPProcess( std::map<std::string, std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const& curves); -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler-impl.h b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler-impl.h index d350d5ac6ece4595f6312e29f712abba2d0b76c0..0b417f257f7e16eeda01547fe8c4432e37e6d0e1 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler-impl.h +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler-impl.h @@ -102,9 +102,13 @@ void TwoPhaseFlowWithPPLocalAssembler< GlobalDimMatrixType permeability = GlobalDimMatrixType::Zero( _element.getDimension(), _element.getDimension()); if (perm.rows() == _element.getDimension()) + { permeability = perm; + } else if (perm.rows() == 1) + { permeability.diagonal().setConstant(perm(0, 0)); + } for (unsigned ip = 0; ip < n_integration_points; ip++) { @@ -203,5 +207,5 @@ void TwoPhaseFlowWithPPLocalAssembler< } // end of mass-lumping } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h index 3ccb6e15a0948b61247607da88d740bf2c2e388e..1a8803d8c2ec742ab6e28ead214b5e233ea9036d 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPLocalAssembler.h @@ -189,7 +189,7 @@ private: static const int cap_pressure_size = ShapeFunction::NPOINTS; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib #include "TwoPhaseFlowWithPPLocalAssembler-impl.h" diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp index 4a4cfefd30a595fcb2eaa78bb8c20390a129f51b..d3bbc9dae0eed9a6de57b75edf62ee8bb8ae035a 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.cpp @@ -166,5 +166,5 @@ double TwoPhaseFlowWithPPMaterialProperties::getSaturationDerivative( _capillary_pressure_models[material_id]->getdPcdS(saturation); return 1 / dpcdsw; } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.h b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.h index 2116128350e8e1c8c6b34e4ba8b4ad7e0df95a72..cbb231317b045df0165d5a398d1cb50b0d1f1122 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.h +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPMaterialProperties.h @@ -126,5 +126,5 @@ protected: _relative_permeability_models; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.cpp b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.cpp index 4d8ce27151b46d1f306baa3b52ec61c5a18eaeae..fef16fc7939c0001ebeff98811108e285804cd1a 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.cpp @@ -109,5 +109,5 @@ void TwoPhaseFlowWithPPProcess::assembleWithJacobianConcreteProcess( xdot, dxdot_dx, dx_dx, M, K, b, Jac, _coupled_solutions); } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.h b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.h index 72fa5ea548a7ee1a69ea80091b7b5c49d194b90c..aa02ffce5b126ed2cbad2d4b2c8cf91af1f24b9a 100644 --- a/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.h +++ b/ProcessLib/TwoPhaseFlowWithPP/TwoPhaseFlowWithPPProcess.h @@ -72,5 +72,5 @@ private: _local_assemblers; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPP +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp index f91e3f2e0affe4ee835961fa94f162f5a9e9a5fc..92169a8af86ea2f70268514bd0555ebb8e38824b 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.cpp @@ -136,5 +136,5 @@ createTwoPhaseFlowPrhoMaterialProperties( std::move(_relative_permeability_models)); } -} // end namespace -} // end namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.h b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.h index 3e6941e86f8e6d34f51c231183719d80f2a43c77..e1091706484cd4cfa447b16001489a4e5584a55a 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowPrhoMaterialProperties.h @@ -27,4 +27,4 @@ createTwoPhaseFlowPrhoMaterialProperties( std::vector<std::unique_ptr<ParameterBase>> const& parameters); } // end namespace -} // end namespace +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp index 80334f779148ae8b58d2bec91ac5b314ca7a5996..d99cafe6698c46ab238a036b111e1b8cb6217b71 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.cpp @@ -65,7 +65,9 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPrhoProcess( Eigen::VectorXd specific_body_force(b.size()); bool const has_gravity = MathLib::toVector(b).norm() > 0; if (has_gravity) + { std::copy_n(b.data(), b.size(), specific_body_force.data()); + } //! \ogs_file_param{prj__processes__process__TWOPHASE_FLOW_PRHO__mass_lumping} auto const mass_lumping = config.getConfigParameter<bool>("mass_lumping"); @@ -114,5 +116,5 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPrhoProcess( mat_config, curves); } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.h b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.h index b4a338c2364c0cad7cdec74631ee047fc939d027..a3bae4de32f535342f402ab1372013c0de2dca13 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/CreateTwoPhaseFlowWithPrhoProcess.h @@ -26,5 +26,5 @@ std::unique_ptr<Process> createTwoPhaseFlowWithPrhoProcess( std::map<std::string, std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const& curves); -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler-impl.h b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler-impl.h index 62f5c7e15000aa3c6405c4527de6ac112d6f268b..126cda9130bc17bed5647f43d208f1b36d7d34a5 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler-impl.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler-impl.h @@ -87,9 +87,13 @@ void TwoPhaseFlowWithPrhoLocalAssembler< GlobalDimMatrixType permeability = GlobalDimMatrixType::Zero( _element.getDimension(), _element.getDimension()); if (perm.rows() == _element.getDimension()) + { permeability = perm; + } else if (perm.rows() == 1) + { permeability.diagonal().setConstant(perm(0, 0)); + } for (unsigned ip = 0; ip < n_integration_points; ip++) { @@ -129,7 +133,9 @@ void TwoPhaseFlowWithPrhoLocalAssembler< dSwdrho, drhoh2wet, drhoh2wet_drho)) + { OGS_FATAL("Computation of local constitutive relation failed."); + } double const pc = _process_data._material->getCapillaryPressure( material_id, t, pos, pl_int_pt, temperature, Sw); @@ -228,5 +234,5 @@ void TwoPhaseFlowWithPrhoLocalAssembler< } // end of mass-lumping } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h index ece7fb478152835066fc7408326d23b5de3a75ab..bcadbaa67ea439c52e126528335e29d3b639dca2 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoLocalAssembler.h @@ -189,7 +189,7 @@ private: static const int cap_pressure_size = ShapeFunction::NPOINTS; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib #include "TwoPhaseFlowWithPrhoLocalAssembler-impl.h" diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp index 12d80a3cd6078075836d84628bb6df5ce1ae156d..42d4c975b41a78bc8be0888c22ac0d1b73752576 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.cpp @@ -226,7 +226,9 @@ bool TwoPhaseFlowWithPrhoMaterialProperties::computeConstitutiveRelation( auto const success_iterations = newton_solver.solve(J_loc); if (!success_iterations) + { return false; + } } dsw_dpg = calculatedSwdP(pg, Sw, X_m, T, material_id); dsw_dX = calculatedSwdX(pg, X, Sw, X_m, T, material_id); @@ -362,7 +364,9 @@ double TwoPhaseFlowWithPrhoMaterialProperties::calculatedXmdX( double const dPC_dSw = _capillary_pressure_models[current_material_id]->getdPcdS(Sw); if ((1 - Sw) < (rho_equilibrium_wet_h2 - rho_wet_h2)) + { return 1.0; + } return HenryConstantH2 * H2 * dPC_dSw * dSwdX; } /** @@ -380,8 +384,10 @@ double TwoPhaseFlowWithPrhoMaterialProperties::calculatedXmdP( double const dPC_dSw = _capillary_pressure_models[current_material_id]->getdPcdS(Sw); if ((1 - Sw) < (rho_equilibrium_wet_h2 - rho_wet_h2)) + { return 0.0; + } return HenryConstantH2 * H2 * (1 + dPC_dSw * dSwdP); } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.h b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.h index 4493e0877846a92f9ce23d34bf5467c20d5bfdfa..855bf123db4061d2c3526ca395eb0a86094f1658 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoMaterialProperties.h @@ -188,5 +188,5 @@ private: int current_material_id) const; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.cpp b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.cpp index 2560399bf1041fc57803da36cfa108bd05e11dce..c7edce1501694411527954fc6b5353978d50eb48 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.cpp +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.cpp @@ -122,5 +122,5 @@ void TwoPhaseFlowWithPrhoProcess::preTimestepConcreteProcess( dt); } -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.h b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.h index 54f49a23527ac29ca2eaad59a8bbfd93caa55267..a21372a31a1f85e692c2cf381fe7e8f3ee563470 100644 --- a/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.h +++ b/ProcessLib/TwoPhaseFlowWithPrho/TwoPhaseFlowWithPrhoProcess.h @@ -73,5 +73,5 @@ private: _local_assemblers; }; -} // end of namespace -} // end of namespace +} // namespace TwoPhaseFlowWithPrho +} // namespace ProcessLib diff --git a/ProcessLib/Utils/CreateLocalAssemblers.h b/ProcessLib/Utils/CreateLocalAssemblers.h index 6669366fdc1541d7a73571f839156f2b885fab00..e73de6b710b62af096723cd56e5acf7d21c75b06 100644 --- a/ProcessLib/Utils/CreateLocalAssemblers.h +++ b/ProcessLib/Utils/CreateLocalAssemblers.h @@ -99,4 +99,4 @@ void createLocalAssemblers( } } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Utils/InitShapeMatrices.h b/ProcessLib/Utils/InitShapeMatrices.h index 875bd01ef8694297376b85b0e453059f7c7a0434..10228ee919e3c62954ded87d2e28cb27ab0c17f6 100644 --- a/ProcessLib/Utils/InitShapeMatrices.h +++ b/ProcessLib/Utils/InitShapeMatrices.h @@ -60,4 +60,4 @@ double interpolateXCoordinate( return fe.interpolateZerothCoordinate(N); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/Utils/ProcessUtils.cpp b/ProcessLib/Utils/ProcessUtils.cpp index a2c36ae98862ad903f11facc6b95924b07c25fb4..4e1a78210b1d122dfeaceac76bfd8ad5667860cf 100644 --- a/ProcessLib/Utils/ProcessUtils.cpp +++ b/ProcessLib/Utils/ProcessUtils.cpp @@ -82,7 +82,9 @@ std::vector<std::reference_wrapper<ProcessVariable>> findProcessVariables( auto var_names = pv_config.getConfigParameterList<std::string>(tag); if (var_names.empty()) + { OGS_FATAL("No entity is found with config tag <%s>.", tag.c_str()); + } std::vector<std::string> cached_var_names; @@ -96,7 +98,9 @@ std::vector<std::reference_wrapper<ProcessVariable>> findProcessVariables( BaseLib::makeVectorUnique(cached_var_names); if (cached_var_names.size() != var_names.size()) + { OGS_FATAL("Found duplicates with config tag <%s>.", tag.c_str()); + } return vars; } diff --git a/ProcessLib/Utils/ProcessUtils.h b/ProcessLib/Utils/ProcessUtils.h index 11199ccc7e66cc91a602a4ad755d2fa32c8bd724..db0c80256476acbc5eb5636c204f667c9b214672 100644 --- a/ProcessLib/Utils/ProcessUtils.h +++ b/ProcessLib/Utils/ProcessUtils.h @@ -124,4 +124,4 @@ Parameter<ParameterDataType>& findParameter( return findParameter<ParameterDataType>(name, parameters, num_components); } -} // ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/VariableTransformation.h b/ProcessLib/VariableTransformation.h index 5e652cf691973771d8fa1f96c63ce12c34966e95..2f00a1d20f9985f1474a20a513cf46a871bfeb83 100644 --- a/ProcessLib/VariableTransformation.h +++ b/ProcessLib/VariableTransformation.h @@ -84,4 +84,4 @@ private: }; using Trafo = ProcessLib::TrafoScale; -} +} // namespace ProcessLib diff --git a/Tests/AutoCheckTools.h b/Tests/AutoCheckTools.h index 5121a6867e1b167a63343150ca15fef8a573d774..1b121bf50c73fc43dac71c18c2e222e968847598 100644 --- a/Tests/AutoCheckTools.h +++ b/Tests/AutoCheckTools.h @@ -27,7 +27,7 @@ std::ostream& operator<<(std::ostream& os, std::array<T, N> const& array) os << "]"; return os; } -} +} // namespace std namespace autocheck { diff --git a/Tests/BaseLib/TestAlgorithm.cpp b/Tests/BaseLib/TestAlgorithm.cpp index 47acd45e97561da6e318464dbb63bd22eab41533..e8b445f150c897407a757e4ed7040df94162a863 100644 --- a/Tests/BaseLib/TestAlgorithm.cpp +++ b/Tests/BaseLib/TestAlgorithm.cpp @@ -51,7 +51,9 @@ TEST(BaseLibAlgorithm, excludeObjectCopy) ASSERT_EQ(size - ex_positions.size(), c1.size()); for (std::size_t i(0); i < c1.size(); i++) + { ASSERT_EQ(c1[i], v[size / 10 + i]); + } // do not copy element 0, 2, 4, 6, 8, 10, 12, 14, 16, 18 std::transform(ex_positions.begin(), ex_positions.end(), @@ -62,9 +64,13 @@ TEST(BaseLibAlgorithm, excludeObjectCopy) ASSERT_EQ(size - ex_positions.size(), c2.size()); for (std::size_t i(0); i < ex_positions.size(); i++) + { ASSERT_EQ(c2[i], v[2 * i + 1]); + } for (std::size_t i(ex_positions.size()); i < c2.size(); i++) + { ASSERT_EQ(c2[i], v[ex_positions.size() + i]); + } // do not copy the last element ex_positions.clear(); @@ -74,5 +80,7 @@ TEST(BaseLibAlgorithm, excludeObjectCopy) ASSERT_EQ(size - ex_positions.size(), c3.size()); for (std::size_t i(0); i < c3.size(); i++) + { ASSERT_EQ(c3[i], v[i]); + } } diff --git a/Tests/BaseLib/TestQuicksort.cpp b/Tests/BaseLib/TestQuicksort.cpp index 6839986dda3c1de8e392c4a9d2e789c0b4ce2083..8dc82631299e3ce3e55223eb07caaf77bec6efc4 100644 --- a/Tests/BaseLib/TestQuicksort.cpp +++ b/Tests/BaseLib/TestQuicksort.cpp @@ -60,7 +60,9 @@ TEST_F(BaseLibQuicksort, SortsAsSTLSort) { std::vector<std::size_t> perm(xs.size()); if (!xs.empty()) + { BaseLib::quicksort(xs, 0, xs.size(), perm); + } return std::is_sorted(xs.begin(), xs.end()); }; @@ -100,11 +102,13 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutations) BaseLib::quicksort(xs, 0, xs.size(), perm); for (std::size_t i = 0; i < perm.size(); ++i) + { if (perm[i] != i) { std::cerr << i << " " << perm[i] << "\n"; return false; } + } return true; }; @@ -127,17 +131,21 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsWithPointer) std::iota(perm.begin(), perm.end(), 0); std::vector<int*> p_xs; - for (int & x : xs) + for (int& x : xs) + { p_xs.push_back(&x); + } BaseLib::quicksort(p_xs, 0, p_xs.size(), perm); for (std::size_t i = 0; i < perm.size(); ++i) + { if (perm[i] != i) { std::cerr << i << " " << perm[i] << "\n"; return false; } + } return true; }; @@ -169,7 +177,12 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverse) BaseLib::quicksort(xs, 0, xs.size(), perm); for (std::size_t i = 0; i < perm.size(); ++i) - if (perm[i] != perm.size() - i - 1) return false; + { + if (perm[i] != perm.size() - i - 1) + { + return false; + } + } return true; }; @@ -199,13 +212,20 @@ TEST_F(BaseLibQuicksort, ReportCorrectPermutationsReverseWithPointer) std::iota(perm.begin(), perm.end(), 0); std::vector<int*> p_xs; - for (int & x : xs) + for (int& x : xs) + { p_xs.push_back(&x); + } BaseLib::quicksort(p_xs, 0, p_xs.size(), perm); for (std::size_t i = 0; i < perm.size(); ++i) - if (perm[i] != perm.size() - i - 1) return false; + { + if (perm[i] != perm.size() - i - 1) + { + return false; + } + } return true; }; @@ -227,7 +247,9 @@ struct randomSortedPairGenerator { auto p = std::make_tuple(source(), source()); if (std::get<0>(p) > std::get<1>(p)) + { std::swap(std::get<0>(p), std::get<1>(p)); + } return p; } @@ -235,11 +257,13 @@ struct randomSortedPairGenerator TEST_F(BaseLibQuicksort, SortsRangeAsSTLSort) { - auto quicksortSortsRangeAsSTLSort = [](std::vector<int>& xs, - std::tuple<std::size_t, std::size_t> const& range) -> bool - { + auto quicksortSortsRangeAsSTLSort = + [](std::vector<int>& xs, + std::tuple<std::size_t, std::size_t> const& range) -> bool { if (xs.empty()) + { return true; + } std::vector<std::size_t> perm(xs.size()); std::iota(perm.begin(), perm.end(), 0); diff --git a/Tests/FileIO/TestCsvReader.cpp b/Tests/FileIO/TestCsvReader.cpp index 02a93ce919f79df372c066aa1e31de7984b9c00b..fd12ecb4dacfe85aa0290030b56cc33bb0b0e144 100644 --- a/Tests/FileIO/TestCsvReader.cpp +++ b/Tests/FileIO/TestCsvReader.cpp @@ -65,9 +65,13 @@ TEST_F(CsvInterfaceTest, SimpleReadPoints) ASSERT_TRUE((*points[i])[2] == (*points2[i])[1]); } for (auto p : points) + { delete p; + } for (auto p : points2) + { delete p; + } } /// Dealing with unconvertable data types @@ -101,7 +105,9 @@ TEST_F(CsvInterfaceTest, MissingValues) ASSERT_EQ(7, points.size()); ASSERT_NEAR(437.539, (*points[4])[2], std::numeric_limits<double>::epsilon()); for (auto p : points) + { delete p; + } } /// Reading 2D points @@ -111,10 +117,14 @@ TEST_F(CsvInterfaceTest, Points2D) _result = FileIO::CsvInterface::readPoints(_file_name, '\t', points, "x", "y"); ASSERT_EQ(0, _result); ASSERT_EQ(10, points.size()); - for (auto & point : points) + for (auto& point : points) + { ASSERT_NEAR(0, (*point)[2], std::numeric_limits<double>::epsilon()); + } for (auto p : points) + { delete p; + } } /// Dealing with non-sequential column order @@ -142,11 +152,17 @@ TEST_F(CsvInterfaceTest, CoordinateOrder) ASSERT_EQ((*points1[i])[1], (*points3[i])[0]); } for (auto p : points1) + { delete p; + } for (auto p : points2) + { delete p; + } for (auto p : points3) + { delete p; + } } /// Getting single columns diff --git a/Tests/FileIO/TestCsvWriter.cpp b/Tests/FileIO/TestCsvWriter.cpp index 02df8afabf0185c3759164ac204049003495afab..a27f5038a143f6ab1add8c45e750151c18873194 100644 --- a/Tests/FileIO/TestCsvWriter.cpp +++ b/Tests/FileIO/TestCsvWriter.cpp @@ -26,8 +26,10 @@ TEST(CsvWriter, WriteReadTest) std::vector<int> int_vec { 1, 2, 4, 8, 16, 32, 64 }; std::vector<double> dbl_vec; std::srand ( static_cast<unsigned>(std::time(nullptr)) ); - for (std::size_t i=0; i<int_vec.size(); ++i) + for (std::size_t i = 0; i < int_vec.size(); ++i) + { dbl_vec.push_back(static_cast<double>(std::rand()) / RAND_MAX); + } FileIO::CsvInterface csv; bool added; diff --git a/Tests/FileIO/TestGmlInterface.h b/Tests/FileIO/TestGmlInterface.h index 17c7c900681f44a1891e92416d29a222abfc3a27..3ecb41c5eedfdaa7baab5b77e5a2b1ce97f9760b 100644 --- a/Tests/FileIO/TestGmlInterface.h +++ b/Tests/FileIO/TestGmlInterface.h @@ -106,7 +106,9 @@ public: } if (!name.empty()) + { line_name_map.insert(std::make_pair(name, line_id)); + } }; auto const& pnt_vec = *(geo_objects.getPointVecObj(geo_name)); @@ -136,8 +138,10 @@ public: auto const lines = geo_objects.getPolylineVec(geo_name); GeoLib::Polyline* line = (*lines)[ply_id]; EXPECT_EQ(pnt_ids.size(), line->getNumberOfPoints()); - for (std::size_t k(0); k<pnt_ids.size(); ++k) + for (std::size_t k(0); k < pnt_ids.size(); ++k) + { EXPECT_EQ(pnt_ids[k], line->getPointID(k)); + } std::string line_name; line_vec->getNameOfElementByID(ply_id, line_name); EXPECT_EQ(name, line_name); @@ -189,8 +193,10 @@ public: auto const& sfc_vec = *(sfcs.getVector()); auto const& sfc = *(sfc_vec[sfc_id]); EXPECT_EQ(tri_ids.size(), sfc.getNumberOfTriangles()); - for (std::size_t k(0); k<tri_ids.size(); ++k) + for (std::size_t k(0); k < tri_ids.size(); ++k) + { checkTriangleIDs(*(sfc[k]), tri_ids[k]); + } std::string sfc_name; sfcs.getNameOfElementByID(sfc_id, sfc_name); diff --git a/Tests/FileIO/TestTetGenInterface.cpp b/Tests/FileIO/TestTetGenInterface.cpp index 660b42273f63e0021276c58c4fb024180e4e8bcc..67bc16078ceb513583ff21fcb75e3c0bdf1ddebc 100644 --- a/Tests/FileIO/TestTetGenInterface.cpp +++ b/Tests/FileIO/TestTetGenInterface.cpp @@ -75,8 +75,11 @@ TEST(FileIO, DISABLED_TetGenSmeshInterface) std::vector<GeoLib::Surface*> const& new_sfc (*geo_objects.getSurfaceVec(tg_new_name)); ASSERT_EQ(ref_sfc.size(), new_sfc.size()); - for (std::size_t i=0; i<ref_sfc.size(); ++i) - ASSERT_EQ(ref_sfc[i]->getNumberOfTriangles(), new_sfc[i]->getNumberOfTriangles()); + for (std::size_t i = 0; i < ref_sfc.size(); ++i) + { + ASSERT_EQ(ref_sfc[i]->getNumberOfTriangles(), + new_sfc[i]->getNumberOfTriangles()); + } std::remove(output_name.c_str()); } diff --git a/Tests/GeoLib/AutoCheckGenerators.cpp b/Tests/GeoLib/AutoCheckGenerators.cpp index 02373fef674ff96a1e3f8b31fb9077c80d8e3d53..67d27c2b67e4083b0c6b5edd440ad25384b277ef 100644 --- a/Tests/GeoLib/AutoCheckGenerators.cpp +++ b/Tests/GeoLib/AutoCheckGenerators.cpp @@ -23,10 +23,14 @@ GeoLib::LineSegment translate(MathLib::Vector3 const& translation, { auto a = std::make_unique<GeoLib::Point>(line_seg.getBeginPoint()); auto b = std::make_unique<GeoLib::Point>(line_seg.getEndPoint()); - for (std::size_t k(0); k<3; ++k) + for (std::size_t k(0); k < 3; ++k) + { (*a)[k] += translation[k]; - for (std::size_t k(0); k<3; ++k) + } + for (std::size_t k(0); k < 3; ++k) + { (*b)[k] += translation[k]; + } return GeoLib::LineSegment{a.release(), b.release(), true}; } diff --git a/Tests/GeoLib/TestAABB.cpp b/Tests/GeoLib/TestAABB.cpp index 39c9a1e797fe79d776346bdb8c9eb71bb9f90308..e9c269be7fe3e8ace5a7c56316aab54ed2f35410 100644 --- a/Tests/GeoLib/TestAABB.cpp +++ b/Tests/GeoLib/TestAABB.cpp @@ -225,7 +225,9 @@ TEST(GeoLib, AABBAllPointsWithNegativeCoordinatesI) ASSERT_NEAR(-1.0, max_pnt[2], std::numeric_limits<double>::epsilon()); for (auto p : pnts) + { delete p; + } } TEST(GeoLib, AABBAllPointsWithNegativeCoordinatesII) @@ -270,23 +272,54 @@ TEST(GeoLib, AABBSinglePoint) // points around the aabb are also checked. for (int i(-1); i<2; ++i) { // Modify the first coordinate of p. - if (i==-1) p[0] = std::nextafter(pnts.front()[0], to_lowest); - else if (i==0) p[0] = pnts.front()[0]; - else p[0] = std::nextafter(pnts.front()[0], to_max); + if (i == -1) + { + p[0] = std::nextafter(pnts.front()[0], to_lowest); + } + else if (i == 0) + { + p[0] = pnts.front()[0]; + } + else + { + p[0] = std::nextafter(pnts.front()[0], to_max); + } for (int j(-1); j<2; ++j) { // Modify the second coordinate of p. - if (j==-1) p[1] = std::nextafter(pnts.front()[1], to_lowest); - else if (j==0) p[1] = pnts.front()[1]; - else p[1] = std::nextafter(pnts.front()[1], to_max); + if (j == -1) + { + p[1] = std::nextafter(pnts.front()[1], to_lowest); + } + else if (j == 0) + { + p[1] = pnts.front()[1]; + } + else + { + p[1] = std::nextafter(pnts.front()[1], to_max); + } for (int k(-1); k<2; ++k) { // Modify the third coordinate of p. - if (k==-1) p[2] = std::nextafter(pnts.front()[2], to_lowest); - else if (k==0) p[2] = pnts.front()[2]; - else p[2] = std::nextafter(pnts.front()[2], to_max); + if (k == -1) + { + p[2] = std::nextafter(pnts.front()[2], to_lowest); + } + else if (k == 0) + { + p[2] = pnts.front()[2]; + } + else + { + p[2] = std::nextafter(pnts.front()[2], to_max); + } if (i == 0 && j == 0 && k == 0) + { ASSERT_TRUE(aabb.containsPoint(p, 0)); + } else + { ASSERT_FALSE(aabb.containsPoint(p, 0)); + } } } } diff --git a/Tests/GeoLib/TestBoundingSphere.cpp b/Tests/GeoLib/TestBoundingSphere.cpp index 18ef1ffb8df8a188aa326724db700eceed4d920b..cc09d2c865be302ef94e3ab6c4b87fcfaa75fa20 100644 --- a/Tests/GeoLib/TestBoundingSphere.cpp +++ b/Tests/GeoLib/TestBoundingSphere.cpp @@ -117,7 +117,9 @@ TEST(GeoLib, TestBoundingSphere) std::vector<MathLib::Point3d*>>(s.getRandomSpherePoints(1000)); GeoLib::MinimalBoundingSphere t(*sphere_points); for (auto p : *sphere_points) + { delete p; + } MathLib::Point3d center = s.getCenter(); ASSERT_NEAR(0.5, center[0], std::numeric_limits<double>::epsilon()); ASSERT_NEAR(0.5, center[1], std::numeric_limits<double>::epsilon()); diff --git a/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp b/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp index 0a87a17669b26cb326b888fe95a7a6f81f13d247..ba0f15adc5552df178265f16498340e570b10802 100644 --- a/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp +++ b/Tests/GeoLib/TestComputeAndInsertAllIntersectionPoints.cpp @@ -52,8 +52,10 @@ TEST(GeoLib, TestComputeAndInsertAllIntersectionPoints) ply0->addPoint(0); ply0->addPoint(1); auto* ply1(new GeoLib::Polyline(pnts)); - for (std::size_t k(2); k<pnts.size(); ++k) + for (std::size_t k(2); k < pnts.size(); ++k) + { ply1->addPoint(k); + } auto* plys(new std::vector<GeoLib::Polyline*>); plys->push_back(ply0); plys->push_back(ply1); diff --git a/Tests/GeoLib/TestDuplicateGeometry.cpp b/Tests/GeoLib/TestDuplicateGeometry.cpp index e40f66ec26459bdb8edead4f1436be583e07d702..51dea32e6114365bdab137e2b1478f2049f13895 100644 --- a/Tests/GeoLib/TestDuplicateGeometry.cpp +++ b/Tests/GeoLib/TestDuplicateGeometry.cpp @@ -73,8 +73,10 @@ TEST(GeoLib, DuplicateGeometry) { int n_ply_pnts (rand() % 100 + 2); auto* line = new GeoLib::Polyline(*geo.getPointVec(input_name)); - for (std::size_t j=0; j<static_cast<std::size_t>(n_ply_pnts); ++j) + for (std::size_t j = 0; j < static_cast<std::size_t>(n_ply_pnts); ++j) + { line->addPoint(rand() % n_pnts); + } plys->push_back(line); } geo.addPolylineVec(std::move(plys), input_name); @@ -94,8 +96,11 @@ TEST(GeoLib, DuplicateGeometry) std::size_t const n_ply_pnts ((*new_plys)[i]->getNumberOfPoints()); ASSERT_EQ(n_ply_pnts, (*plys)[i]->getNumberOfPoints()); ASSERT_EQ((*new_plys)[i]->getNumberOfSegments(), (*plys)[i]->getNumberOfSegments()); - for (std::size_t j=0; j<n_ply_pnts; ++j) - ASSERT_EQ((*plys)[i]->getPointID(j), (*new_plys)[i]->getPointID(j)); + for (std::size_t j = 0; j < n_ply_pnts; ++j) + { + ASSERT_EQ((*plys)[i]->getPointID(j), + (*new_plys)[i]->getPointID(j)); + } } std::vector<GeoLib::Polyline*>& mod_plys (dup.getPolylineVectorCopy()); @@ -111,12 +116,18 @@ TEST(GeoLib, DuplicateGeometry) { int n_tris (rand() % 10); auto* sfc = new GeoLib::Surface(*geo.getPointVec(input_name)); - for (std::size_t j=0; j<static_cast<std::size_t>(n_tris); ++j) + for (std::size_t j = 0; j < static_cast<std::size_t>(n_tris); ++j) + { sfc->addTriangle(rand() % n_pnts, rand() % n_pnts, rand() % n_pnts); + } if (sfc->getNumberOfTriangles() > 0) + { sfcs->push_back(sfc); + } else + { delete sfc; + } } n_sfcs = sfcs->size(); geo.addSurfaceVec(std::move(sfcs), input_name); @@ -135,9 +146,14 @@ TEST(GeoLib, DuplicateGeometry) { std::size_t const n_tris ((*new_sfcs)[i]->getNumberOfTriangles()); ASSERT_EQ(n_tris, (*sfcs)[i]->getNumberOfTriangles()); - for (std::size_t j=0; j<n_tris; ++j) - for (std::size_t k=0; k<3; ++k) - ASSERT_EQ((*(*(*sfcs)[i])[j])[k], (*(*(*new_sfcs)[i])[j])[k]); + for (std::size_t j = 0; j < n_tris; ++j) + { + for (std::size_t k = 0; k < 3; ++k) + { + ASSERT_EQ((*(*(*sfcs)[i])[j])[k], + (*(*(*new_sfcs)[i])[j])[k]); + } + } } std::vector<GeoLib::Point*>& mod_pnts (dup.getPointVectorCopy()); diff --git a/Tests/GeoLib/TestOctTree.cpp b/Tests/GeoLib/TestOctTree.cpp index e064e0852ba861530144d55abbec32ada575a726..05f557f0b04c63b7e6df9036e1c29d2bab36fc04 100644 --- a/Tests/GeoLib/TestOctTree.cpp +++ b/Tests/GeoLib/TestOctTree.cpp @@ -184,16 +184,20 @@ TEST_F(GeoLibOctTree, TestWithEquidistantPoints3d) ASSERT_EQ(static_cast<std::size_t>(3), result.size()); // insert some points not resulting in a further refinement of SWL - for (std::size_t k(4); k<11; ++k) + for (std::size_t k(4); k < 11; ++k) + { ASSERT_TRUE(oct_tree->addPoint(ps_ptr[k], ret_pnt)); + } result.clear(); oct_tree->getPointsInRange(range_query_ll, range_query_ur, result); ASSERT_EQ(static_cast<std::size_t>(3), result.size()); // insert some points *resulting* in a further refinement of SWL - for (std::size_t k(11); k<25; ++k) + for (std::size_t k(11); k < 25; ++k) + { ASSERT_TRUE(oct_tree->addPoint(ps_ptr[k], ret_pnt)); + } result.clear(); oct_tree->getPointsInRange(range_query_ll, range_query_ur, result); @@ -201,8 +205,10 @@ TEST_F(GeoLibOctTree, TestWithEquidistantPoints3d) // insert all points with z = -5.0 - this does not result in a further // refinement of SWL - for (std::size_t k(25); k<121; ++k) + for (std::size_t k(25); k < 121; ++k) + { ASSERT_TRUE(oct_tree->addPoint(ps_ptr[k], ret_pnt)); + } result.clear(); oct_tree->getPointsInRange(range_query_ll, range_query_ur, result); @@ -228,7 +234,9 @@ TEST_F(GeoLibOctTree, TestWithEquidistantPoints3d) range_query_ll[2] = -4.75; oct_tree->getPointsInRange(range_query_ll, range_query_ur, result); for (auto p : result) + { std::cout << *p << "\n"; + } ASSERT_EQ(static_cast<std::size_t>(0), result.size()); result.clear(); diff --git a/Tests/GeoLib/TestPolygon.cpp b/Tests/GeoLib/TestPolygon.cpp index c4d69f1718b000c4652a0fcf057b21ec21d3348c..8f14534b5eb3f6f6ab04f89be384a7919ca789ba 100644 --- a/Tests/GeoLib/TestPolygon.cpp +++ b/Tests/GeoLib/TestPolygon.cpp @@ -67,8 +67,10 @@ public: ~PolygonTest() override { delete _polygon; - for (auto & _pnt : _pnts) + for (auto& _pnt : _pnts) + { delete _pnt; + } } protected: @@ -78,8 +80,10 @@ protected: TEST_F(PolygonTest, isPntInPolygonCheckCorners) { - for (auto & _pnt : _pnts) + for (auto& _pnt : _pnts) + { EXPECT_TRUE(_polygon->isPntInPolygon(*_pnt)); + } } TEST_F(PolygonTest, isPntInPolygonCheckPointsRestOnPolygonEdges) @@ -190,8 +194,10 @@ TEST_F(PolygonTest, isPolylineInPolygon) outer_ply.addPoint(0); outer_ply.addPoint(1); ASSERT_FALSE(_polygon->isPolylineInPolygon(outer_ply)); - for (auto & pnt : pnts) + for (auto& pnt : pnts) + { delete pnt; + } pnts.clear(); pnts.push_back(new GeoLib::Point(-1.0,2.0,0.0)); // 3 @@ -200,8 +206,10 @@ TEST_F(PolygonTest, isPolylineInPolygon) inner_ply.addPoint(0); inner_ply.addPoint(1); ASSERT_TRUE(_polygon->isPolylineInPolygon(inner_ply)); - for (auto & pnt : pnts) + for (auto& pnt : pnts) + { delete pnt; + } } TEST_F(PolygonTest, CopyConstructor) @@ -212,5 +220,7 @@ TEST_F(PolygonTest, CopyConstructor) // Check if all line segments of the original polygon are contained in the // copy for (auto const& segment : *_polygon) + { ASSERT_TRUE(polygon_copy.containsSegment(segment)); + } } diff --git a/Tests/GeoLib/TestPolyline.cpp b/Tests/GeoLib/TestPolyline.cpp index 4faa70e255ea57134666d1ab50c08b8e2ad8dcb7..75e4305c3006c049f34be838e971028fbc9d8c89 100644 --- a/Tests/GeoLib/TestPolyline.cpp +++ b/Tests/GeoLib/TestPolyline.cpp @@ -109,6 +109,8 @@ TEST(GeoLib, PolylineTest) } ASSERT_EQ(ply.getNumberOfSegments(), segment_cnt); - for (auto & ply_pnt : ply_pnts) + for (auto& ply_pnt : ply_pnts) + { delete ply_pnt; + } } diff --git a/Tests/GeoLib/TestSimplePolygonTree.cpp b/Tests/GeoLib/TestSimplePolygonTree.cpp index 6b29a86da1820a711088c2da7148920dc55dc966..c631c8a3f3d249b9077528b2f281ff1b4659aa82 100644 --- a/Tests/GeoLib/TestSimplePolygonTree.cpp +++ b/Tests/GeoLib/TestSimplePolygonTree.cpp @@ -92,8 +92,10 @@ public: delete _p1; delete _p2; delete _p3; - for (auto & _pnt : _pnts) + for (auto& _pnt : _pnts) + { delete _pnt; + } } protected: diff --git a/Tests/GeoLib/TestSortSegments.cpp b/Tests/GeoLib/TestSortSegments.cpp index af79ae76d46ee7a2a866a2bb090d3831e442bd1c..7e2a05d8f72b1d1ba11b4af6cd4d52502f3900b1 100644 --- a/Tests/GeoLib/TestSortSegments.cpp +++ b/Tests/GeoLib/TestSortSegments.cpp @@ -71,15 +71,21 @@ TEST_F(GeoLibSortLineSegments, SortSubSegments) double eps(std::numeric_limits<double>::epsilon()); if (MathLib::sqrDist(s0.getBeginPoint(), sub_segments.front().getBeginPoint()) >= eps) + { return false; + } if (MathLib::sqrDist(s0.getEndPoint(), sub_segments.back().getEndPoint()) >= eps) + { return false; + } for (std::size_t k(0); k < sub_segments.size() - 1; ++k) { if (MathLib::sqrDist(sub_segments[k].getEndPoint(), sub_segments[k + 1].getBeginPoint()) >= eps) + { return false; + } } return true; }; @@ -96,7 +102,10 @@ TEST_F(GeoLibSortLineSegments, SortSubSegments) std::vector<GeoLib::LineSegment> sub_segments; partitionSegment(s0, sub_seg_ids, dt, sub_segments); GeoLib::sortSegments(s0.getBeginPoint(), sub_segments); - if (!checkSortedSubSegments(s0, sub_segments)) return false; + if (!checkSortedSubSegments(s0, sub_segments)) + { + return false; + } } while (std::next_permutation(sub_seg_ids.begin(), sub_seg_ids.end())); return true; }; diff --git a/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp b/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp index 11fd33e8c64f71096e155f6d9730b3e0037dc4c9..b686161f3abaeff5abc543e856b08b4e379fd496 100644 --- a/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp +++ b/Tests/GeoLib/TestSurfaceIsPointInSurface.cpp @@ -96,9 +96,13 @@ TEST(GeoLib, SurfaceIsPointInSurface) normal_dist_ur(random_engine_mt19937), normal_dist_ur(random_engine_mt19937), 0.0}})); - for (std::size_t k(0); k<3; ++k) + for (std::size_t k(0); k < 3; ++k) + { if (ll[k] > ur[k]) + { std::swap(ll[k], ur[k]); + } + } // random discretization of the domain std::default_random_engine re(rd()); @@ -144,8 +148,10 @@ TEST(GeoLib, SurfaceIsPointInSurface) for (auto const p : pnts) { EXPECT_TRUE(sfc->isPntInSfc(*p, eps)); MathLib::Point3d q(*p); - for (std::size_t k(0); k<3; ++k) + for (std::size_t k(0); k < 3; ++k) + { q[k] += displacement[k]; + } EXPECT_FALSE(sfc->isPntInSfc(q, eps)); } // test edge middle points of the triangles diff --git a/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp b/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp index cbcc039937edb6766b6180e07c0f3b537513fb56..94d93cc0554d7f4ddf335cd3691f70896ccfe3f8 100644 --- a/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp +++ b/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp @@ -126,9 +126,13 @@ TEST(MaterialPorousMedium, checkCapillaryPressureCurve) ASSERT_NEAR(dpc_dS[i], pc_model->getdPcdS(S[i]), 1.e-5); if (i == S.size() - 1) + { // Minimum Pc to maximum saturation ASSERT_NEAR(0.9, pc_model->getSaturation(pc[i]), 1.e-5); + } else + { ASSERT_NEAR(S[i], pc_model->getSaturation(pc[i]), 1.e-5); + } } } diff --git a/Tests/MaterialLib/TestRelativePermeabilityModel.cpp b/Tests/MaterialLib/TestRelativePermeabilityModel.cpp index cf1e2ec527a6678ce2e79404e670881d80050e1d..df05d51a27aee8e24235c3cea3a2281256458f2f 100644 --- a/Tests/MaterialLib/TestRelativePermeabilityModel.cpp +++ b/Tests/MaterialLib/TestRelativePermeabilityModel.cpp @@ -127,7 +127,9 @@ TEST(MaterialPorousMedium, checkWettingPhaseBrooksCoreyOilGas) // i == S.size() -1, S(=0.85) is limited to 0.8, and the numerical // derivative of krel is unavailable. if (i == S.size() - 1) + { continue; + } // Compare the derivative with numerical one. ASSERT_NEAR((perm_model->getValue(S[i] + perturbation) - perm_model->getValue(S[i])) / diff --git a/Tests/MathLib/TestDenseMatrix.cpp b/Tests/MathLib/TestDenseMatrix.cpp index 1139d1b1f495f847c7a9778d66c895e4d6094e47..d199904e6caf778219a3ebcddd5470f8e8c55b87 100644 --- a/Tests/MathLib/TestDenseMatrix.cpp +++ b/Tests/MathLib/TestDenseMatrix.cpp @@ -20,9 +20,13 @@ TEST(MathLib, DenseMatrixTransposeInPlace) // square matrix DenseMatrix<double> m1(3,3); unsigned cnt = 0; - for (unsigned i=0; i<m1.getNumberOfRows(); i++) - for (unsigned j=0; j<m1.getNumberOfColumns(); j++) - m1(i,j) = cnt++; + for (unsigned i = 0; i < m1.getNumberOfRows(); i++) + { + for (unsigned j = 0; j < m1.getNumberOfColumns(); j++) + { + m1(i, j) = cnt++; + } + } double expected_m1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; ASSERT_EQ(3u, m1.getNumberOfRows()); ASSERT_EQ(3u, m1.getNumberOfColumns()); @@ -36,9 +40,13 @@ TEST(MathLib, DenseMatrixTransposeInPlace) // non-square matrix 1 DenseMatrix<double> m2(2,3); cnt = 0; - for (unsigned i=0; i<m2.getNumberOfRows(); i++) - for (unsigned j=0; j<m2.getNumberOfColumns(); j++) - m2(i,j) = cnt++; + for (unsigned i = 0; i < m2.getNumberOfRows(); i++) + { + for (unsigned j = 0; j < m2.getNumberOfColumns(); j++) + { + m2(i, j) = cnt++; + } + } ASSERT_EQ(2u, m2.getNumberOfRows()); ASSERT_EQ(3u, m2.getNumberOfColumns()); double expected_m2[] = {0, 1, 2, 3, 4, 5}; @@ -52,9 +60,13 @@ TEST(MathLib, DenseMatrixTransposeInPlace) // non-square matrix 2 DenseMatrix<double> m3(3,2); cnt = 0; - for (unsigned i=0; i<m3.getNumberOfRows(); i++) - for (unsigned j=0; j<m3.getNumberOfColumns(); j++) - m3(i,j) = cnt++; + for (unsigned i = 0; i < m3.getNumberOfRows(); i++) + { + for (unsigned j = 0; j < m3.getNumberOfColumns(); j++) + { + m3(i, j) = cnt++; + } + } ASSERT_EQ(3u, m3.getNumberOfRows()); ASSERT_EQ(2u, m3.getNumberOfColumns()); double expected_m3[] = {0, 1, 2, 3, 4, 5}; diff --git a/Tests/MathLib/TestEigenCSR.cpp b/Tests/MathLib/TestEigenCSR.cpp index a70ad78a02f56ab2dc059fb5ff28c726342cec51..9fb4a852f2a17c8f6367b2b5fbae1f623d3ba11f 100644 --- a/Tests/MathLib/TestEigenCSR.cpp +++ b/Tests/MathLib/TestEigenCSR.cpp @@ -58,7 +58,10 @@ TEST(MathLibEigen, Eigen2CSR) for (int row=0; row<nrows; ++row) { for (int col = -1; col<=1; ++col) { int cidx = row + col; - if (cidx < 0 || cidx >= ncols) continue; + if (cidx < 0 || cidx >= ncols) + { + continue; + } const double val = (col == 0) ? 2.0 : -1.0; values.push_back(val); @@ -71,13 +74,19 @@ TEST(MathLibEigen, Eigen2CSR) for (int row=0; row<nrows; ++row) { for (int col = -1; col<=1; ++col) { int cidx = row + col; - if (cidx < 0 || cidx >= ncols) continue; + if (cidx < 0 || cidx >= ncols) + { + continue; + } mat.coeffRef(row, cidx) = 4.0 * mat.coeff(row, cidx); } } // adapt entries of CSR matrix - for (auto& v : values) v *= 4.0; + for (auto& v : values) + { + v *= 4.0; + } mat.makeCompressed(); diff --git a/Tests/MathLib/TestGaussLegendreIntegration.cpp b/Tests/MathLib/TestGaussLegendreIntegration.cpp index f5526c0cdb3057b6386f8c192ec9eb9c2b01f7f3..aa74b68729751dce88ec5ba994b3a543de710cae 100644 --- a/Tests/MathLib/TestGaussLegendreIntegration.cpp +++ b/Tests/MathLib/TestGaussLegendreIntegration.cpp @@ -77,7 +77,9 @@ public: : _e(e) { if (is_axially_symmetric) + { OGS_FATAL("Only testing Cartesian meshes!"); + } } double integrate(const Function& f, @@ -457,7 +459,9 @@ OGS_DONT_TEST_THIS_IF_PETSC(MathLib, IntegrationGaussLegendreTet) for (unsigned polynomial_order : {0, 1, 2}) { if (polynomial_order > 2 * integration_order - 1) + { break; + } DBUG(" == polynomial order: %u.", polynomial_order); auto f = GaussLegendreTest::getF(polynomial_order); @@ -484,7 +488,9 @@ OGS_DONT_TEST_THIS_IF_PETSC(MathLib, IntegrationGaussLegendreHex) for (unsigned polynomial_order : {0, 1, 2}) { if (polynomial_order > 2 * integration_order - 1) + { break; + } DBUG(" == polynomial order: %u.", polynomial_order); auto f = GaussLegendreTest::getF(polynomial_order); diff --git a/Tests/MathLib/TestLinearSolver.cpp b/Tests/MathLib/TestLinearSolver.cpp index 462bf5273415fbf16ec175da7d2c267c96b0ba06..7fe0c4ddbacd1bc36bd08dfb79a8206ddae1d1a3 100644 --- a/Tests/MathLib/TestLinearSolver.cpp +++ b/Tests/MathLib/TestLinearSolver.cpp @@ -62,8 +62,12 @@ void setMatrix9x9(T_Mat &mat) 0, 0, 0, 0, -3.33333e-012, -1.66667e-012, 0, -1.66667e-012, 6.66667e-012 }; for (unsigned i = 0; i < 9; i++) + { for (unsigned j = 0; j < 9; j++) - mat.setValue(i, j, d_mat[i*9+j]); + { + mat.setValue(i, j, d_mat[i * 9 + j]); + } + } } template<typename IntType> struct Example1 @@ -85,9 +89,18 @@ template<typename IntType> struct Example1 std::fill(vec_dirichlet_bc_value.begin()+3, vec_dirichlet_bc_value.end(), 1.0); for (std::size_t i=0; i<9; i++) { - if (i%3==0) exH[i] = 1.0; - if (i%3==1) exH[i] = 0.5; - if (i%3==2) exH[i] = 0.; + if (i % 3 == 0) + { + exH[i] = 1.0; + } + if (i % 3 == 1) + { + exH[i] = 0.5; + } + if (i % 3 == 2) + { + exH[i] = 0.; + } } } @@ -109,8 +122,10 @@ void checkLinearSolverInterface(T_MATRIX &A, BaseLib::ConfigTree const& ls_optio for (std::size_t j=0; j<ex1.dim_eqs; j++) { double v = ex1.mat.get(i, j); - if (v!=.0) + if (v != .0) + { A.add(i, j, v); + } } } diff --git a/Tests/MathLib/TestNonlinear1D.cpp b/Tests/MathLib/TestNonlinear1D.cpp index 1f4e99803ace6dde278569a414c4dee7c43a3af3..8dcb62bc8c497a2149563854d1b1645132d5f7d3 100644 --- a/Tests/MathLib/TestNonlinear1D.cpp +++ b/Tests/MathLib/TestNonlinear1D.cpp @@ -44,7 +44,10 @@ TYPED_TEST(MathLibRegulaFalsi, QuadraticFunction) old_range = range; DBUG("%2i -- x ~ %23.16g, range = %23.16g", n+1, rf.getResult(), range); - if (range < std::numeric_limits<double>::epsilon()) break; + if (range < std::numeric_limits<double>::epsilon()) + { + break; + } } auto const error = std::abs(f(rf.getResult())); diff --git a/Tests/MathLib/TestODESolver.cpp b/Tests/MathLib/TestODESolver.cpp index 012eb39802407595baad31198913c86090cbc26b..1efffb440b22d5e70849dfafb1ffd714368f1d5d 100644 --- a/Tests/MathLib/TestODESolver.cpp +++ b/Tests/MathLib/TestODESolver.cpp @@ -20,7 +20,10 @@ bool f(const double, MathLib::ODE::MappedConstVector<1> const& y, MathLib::ODE::MappedVector<1>& ydot) { - if (y[0] <= 0.0) return false; + if (y[0] <= 0.0) + { + return false; + } ydot[0] = -15.0 * y[0]; return true; @@ -31,7 +34,10 @@ bool df(const double /*t*/, MathLib::ODE::MappedConstVector<1> const& /*ydot*/, MathLib::ODE::MappedMatrix<1, 1>& jac) { - if (y[0] <= 0.0) return false; + if (y[0] <= 0.0) + { + return false; + } jac(0, 0) = -15.0; return true; @@ -47,7 +53,10 @@ bool f_extra(const double, MathLib::ODE::MappedVector<1>& ydot, ExtraData& data) { - if (y[0] <= 0.0) return false; + if (y[0] <= 0.0) + { + return false; + } ydot[0] = -data.value * y[0]; return true; @@ -121,7 +130,10 @@ TEST(MathLibCVodeTest, Exponential) ASSERT_EQ(any_ode_solver_libs_available(), !!ode_solver); // Don't run the test if the ODE solver could not be constructed. - if (!ode_solver) return; + if (!ode_solver) + { + return; + } ode_solver->setFunction(f, nullptr); ode_solver->setTolerance(abs_tol, rel_tol); @@ -160,7 +172,10 @@ TEST(MathLibCVodeTest, ExponentialExtraData) ASSERT_EQ(any_ode_solver_libs_available(), !!ode_solver); // Don't run the test if the ODE solver could not be constructed. - if (!ode_solver) return; + if (!ode_solver) + { + return; + } ExtraData data; auto f_lambda = [&](double t, @@ -224,7 +239,10 @@ TEST(MathLibCVodeTest, ExponentialWithJacobian) ASSERT_EQ(any_ode_solver_libs_available(), !!ode_solver); // Don't run the test if the ODE solver could not be constructed. - if (!ode_solver) return; + if (!ode_solver) + { + return; + } ode_solver->setFunction(f, df); ode_solver->setTolerance(abs_tol, rel_tol); @@ -265,7 +283,10 @@ TEST(MathLibCVodeTest, ExponentialWithJacobianNewton) ASSERT_EQ(any_ode_solver_libs_available(), !!ode_solver); // Don't run the test if the ODE solver could not be constructed. - if (!ode_solver) return; + if (!ode_solver) + { + return; + } ode_solver->setFunction(f, df); ode_solver->setTolerance(abs_tol, rel_tol); diff --git a/Tests/MeshLib/MeshProperties.cpp b/Tests/MeshLib/MeshProperties.cpp index f3ef3fea4930060c6f161205a80f21be793e5668..b23c5e27be5d87bcdbf2ebbfbe5d27ed046552e9 100644 --- a/Tests/MeshLib/MeshProperties.cpp +++ b/Tests/MeshLib/MeshProperties.cpp @@ -89,13 +89,17 @@ TEST_F(MeshLibProperties, PropertyVectorTestIntegrationPoint) std::size_t const size = offsets[i + 1] - offsets[i]; ASSERT_EQ(n_integration_points, size); for (int ip = 0; ip < n_integration_points; ++ip) + { ASSERT_EQ(i + ip * 0.01, p[offsets[i] + ip]); + } } { // Last element std::size_t const size = p.size() - offsets[i]; ASSERT_EQ(n_integration_points, size); for (int ip = 0; ip < n_integration_points; ++ip) + { ASSERT_EQ(i + ip * 0.01, p[offsets[i] + ip]); + } } } diff --git a/Tests/MeshLib/TestAddLayerToMesh.cpp b/Tests/MeshLib/TestAddLayerToMesh.cpp index e62788d41a326224287f04b752b0ef2371232ee1..cf050321c262dfbf197ab38e7f089d48cfe8cdfc 100644 --- a/Tests/MeshLib/TestAddLayerToMesh.cpp +++ b/Tests/MeshLib/TestAddLayerToMesh.cpp @@ -33,8 +33,12 @@ namespace AddLayerValidation ElementErrorFlag::NonCoplanar, ElementErrorFlag::NonConvex, ElementErrorFlag::NodeOrder}; std::vector<ElementErrorCode> const codes (MeshLib::MeshValidation::testElementGeometry(mesh)); for (auto code : codes) - for (std::size_t j=0; j<nErrorFlags-reduce_tests; ++j) + { + for (std::size_t j = 0; j < nErrorFlags - reduce_tests; ++j) + { ASSERT_FALSE(code[flags[j]]); + } + } } void testZCoords2D(MeshLib::Mesh const& input, MeshLib::Mesh const& output, double height) @@ -50,10 +54,12 @@ namespace AddLayerValidation void testZCoords3D(MeshLib::Mesh const& input, MeshLib::Mesh const& output, double height) { std::size_t const nNodes (input.getNumberOfNodes()); - for (std::size_t i=0; i<nNodes; ++i) + for (std::size_t i = 0; i < nNodes; ++i) + { ASSERT_EQ((*input.getNode(i))[2] + height, (*output.getNode(i))[2]); + } } -}; + } // namespace AddLayerValidation TEST(MeshLib, AddTopLayerToLineMesh) { diff --git a/Tests/MeshLib/TestBoundaryElementSearch.cpp b/Tests/MeshLib/TestBoundaryElementSearch.cpp index 90dbd22939e3af95333dd5ba59ad3f2fb14081c5..801cbc2905caf8ec06f7055f90eac808a6051e7d 100644 --- a/Tests/MeshLib/TestBoundaryElementSearch.cpp +++ b/Tests/MeshLib/TestBoundaryElementSearch.cpp @@ -37,7 +37,9 @@ public: ~MeshLibBoundaryElementSearchInSimpleQuadMesh() override { for (auto p : _pnts) + { delete p; + } } protected: @@ -68,7 +70,9 @@ public: ~MeshLibBoundaryElementSearchInSimpleHexMesh() override { for (auto p : _pnts) + { delete p; + } } void TestHexSurfacesBoundaryElementSearcher( @@ -170,7 +174,9 @@ void MeshLibBoundaryElementSearchInSimpleHexMesh:: auto connected_nodes_b = MeshLib::getUniqueNodes(found_faces_sfc_b); ASSERT_EQ(n_nodes_2d, connected_nodes_b.size()); for (auto node : connected_nodes_b) + { ASSERT_EQ(0.0, (*node)[2]); // check z coordinates + } // perform search on the front surface GeoLib::Surface sfc_front(_pnts); @@ -186,7 +192,9 @@ void MeshLibBoundaryElementSearchInSimpleHexMesh:: auto connected_nodes_f = MeshLib::getUniqueNodes(found_faces_sfc_f); ASSERT_EQ(n_nodes_2d, connected_nodes_f.size()); for (auto node : connected_nodes_f) + { ASSERT_EQ(0.0, (*node)[1]); // check y coordinates + } } TEST_F(MeshLibBoundaryElementSearchInSimpleHexMesh, SurfaceSearch) diff --git a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp index 95502a1f277cd8053d8f1e6f975cea8f36d146e2..c69d37beb0bf4decb0a8c1d22bd5303519a035c7 100644 --- a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp +++ b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp @@ -67,7 +67,7 @@ std::unique_ptr<MeshLib::Line> createLine(std::array<double, 3> const& a, return createLine({{0.0, 0.0, 0.0}}, {{2./sqrt(3), 2./sqrt(3), 2./sqrt(3)}}); } -}; + } // namespace TestLine2 namespace TestQuad4 { @@ -118,7 +118,7 @@ std::unique_ptr<MeshLib::Quad> createQuad(std::array<double, 3> const& a, {{0.0, -1.0, -1.0}}, {{0.0, 1.0, -1.0}}); } -}; + } // namespace TestQuad4 #if 0 // keep this function for debugging @@ -169,7 +169,9 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineY) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } TEST(MeshLib, CoordinatesMappingLocalLowerDimLineZ) @@ -188,7 +190,9 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineZ) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } TEST(MeshLib, CoordinatesMappingLocalLowerDimLineXY) @@ -207,7 +211,9 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineXY) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } TEST(MeshLib, CoordinatesMappingLocalLowerDimLineXYZ) @@ -226,7 +232,9 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimLineXYZ) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadXZ) @@ -247,7 +255,9 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadXZ) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadYZ) @@ -268,7 +278,9 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadYZ) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadXYZ) @@ -289,6 +301,8 @@ TEST(MeshLib, CoordinatesMappingLocalLowerDimQuadXYZ) CHECK_COORDS(ele,mapping); for (std::size_t n = 0; n < ele->getNumberOfNodes(); ++n) + { delete ele->getNode(n); + } } diff --git a/Tests/MeshLib/TestElementConstants.cpp b/Tests/MeshLib/TestElementConstants.cpp index f16fb963c3074735ceb7fa4ea6cc73297704b39b..7d2e91b70a837747214a14529173cecba84ee5a8 100644 --- a/Tests/MeshLib/TestElementConstants.cpp +++ b/Tests/MeshLib/TestElementConstants.cpp @@ -32,7 +32,9 @@ TEST(MeshLib, ElementConstantsQuad4) ASSERT_EQ(4u, quad.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } TEST(MeshLib, ElementConstantsQuad8) @@ -59,7 +61,9 @@ TEST(MeshLib, ElementConstantsQuad8) ASSERT_EQ(4u, quad8.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } TEST(MeshLib, ElementConstantsQuad9) @@ -87,7 +91,9 @@ TEST(MeshLib, ElementConstantsQuad9) ASSERT_EQ(4u, quad9.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } TEST(MeshLib, ElementConstantsHex8) @@ -112,7 +118,9 @@ TEST(MeshLib, ElementConstantsHex8) ASSERT_EQ(8u, ele.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } TEST(MeshLib, ElementConstantsHex20) @@ -149,7 +157,9 @@ TEST(MeshLib, ElementConstantsHex20) ASSERT_EQ( 8u, ele.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } TEST(MeshLib, ElementConstantsTet4) @@ -170,7 +180,9 @@ TEST(MeshLib, ElementConstantsTet4) ASSERT_EQ(4u, ele.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } TEST(MeshLib, ElementConstantsTet10) @@ -198,6 +210,8 @@ TEST(MeshLib, ElementConstantsTet10) ASSERT_EQ( 4u, ele.getNumberOfBaseNodes()); for (auto n : nodes) + { delete n; + } } diff --git a/Tests/MeshLib/TestElementStatus.cpp b/Tests/MeshLib/TestElementStatus.cpp index bcdcc900557885755bded436ab726f93a2f860a1..5abc688ede292b9aa66ec2017a62caae0d53fb59 100644 --- a/Tests/MeshLib/TestElementStatus.cpp +++ b/Tests/MeshLib/TestElementStatus.cpp @@ -39,8 +39,11 @@ TEST(MeshLib, ElementStatus) for (unsigned i=0; i<elements_per_side; ++i) { - for (unsigned j=0; j<elements_per_side; ++j) - (*material_id_properties)[elements[i*elements_per_side + j]->getID()] = i; + for (unsigned j = 0; j < elements_per_side; ++j) + { + (*material_id_properties)[elements[i * elements_per_side + j] + ->getID()] = i; + } } { diff --git a/Tests/MeshLib/TestFindElementsWithinRadius.cpp b/Tests/MeshLib/TestFindElementsWithinRadius.cpp index 00684cee6761ea48e5d5cf392864bf782802dfb3..c9c946db16916a8a2376740aac07eceec2fb466f 100644 --- a/Tests/MeshLib/TestFindElementsWithinRadius.cpp +++ b/Tests/MeshLib/TestFindElementsWithinRadius.cpp @@ -83,7 +83,9 @@ std::vector<Node const*> findNodesWithinRadius(Mesh const& mesh, auto const* n = mesh.getNode(i); auto const distance_squared = MathLib::sqrDist(node, *n); if (distance_squared > radius * radius) + { continue; + } nodes.push_back(n); } diff --git a/Tests/MeshLib/TestFlipElements.cpp b/Tests/MeshLib/TestFlipElements.cpp index 953ee224a577c4a2bd48d39a6dcef78a67e64581..b65ab7164786e8d1de6a967b71be9a8db3a87955 100644 --- a/Tests/MeshLib/TestFlipElements.cpp +++ b/Tests/MeshLib/TestFlipElements.cpp @@ -80,12 +80,16 @@ TEST(MeshLib, FlipHexMesh) ASSERT_EQ(nullptr, result); std::vector<MeshLib::Node*> nodes; - for (std::size_t i=0; i<mesh->getNumberOfNodes(); ++i) + for (std::size_t i = 0; i < mesh->getNumberOfNodes(); ++i) + { nodes.push_back(new MeshLib::Node(*mesh->getNode(i))); + } std::unique_ptr<MeshLib::Element> elem (MeshLib::createFlippedElement(*mesh->getElement(0), nodes)); ASSERT_EQ(nullptr, elem); for (MeshLib::Node* n : nodes) + { delete n; + } } TEST(MeshLib, DoubleFlipQuadMesh) @@ -96,9 +100,13 @@ TEST(MeshLib, DoubleFlipQuadMesh) ASSERT_EQ(mesh->getNumberOfNodes(), result2->getNumberOfNodes()); ASSERT_EQ(mesh->getNumberOfElements(), result2->getNumberOfElements()); - for (std::size_t i=0; i<result2->getNumberOfElements(); ++i) - for (std::size_t j=0; j<4; ++j) + for (std::size_t i = 0; i < result2->getNumberOfElements(); ++i) + { + for (std::size_t j = 0; j < 4; ++j) + { ASSERT_EQ(mesh->getElement(i)->getNode(j)->getID(), result2->getElement(i)->getNode(j)->getID()); + } + } } diff --git a/Tests/MeshLib/TestLineMesh.cpp b/Tests/MeshLib/TestLineMesh.cpp index 932e705864328d17ca1d37d419c73791f0058a36..e9e08e82c314fb0f40ded399a8e86c221a4a54ff 100644 --- a/Tests/MeshLib/TestLineMesh.cpp +++ b/Tests/MeshLib/TestLineMesh.cpp @@ -42,7 +42,9 @@ TEST_F(MeshLibLineMesh, Construction) // All elements have maximum two neighbors. std::vector<MeshLib::Element*> const& elements = mesh->getElements(); for (auto e : elements) + { ASSERT_EQ(2u, e->getNumberOfNeighbors()); + } ASSERT_NEAR(extent/mesh_size, mesh->getMinEdgeLength(),std::numeric_limits<double>::epsilon()); ASSERT_NEAR(extent/mesh_size, mesh->getMaxEdgeLength(),std::numeric_limits<double>::epsilon()); @@ -54,8 +56,12 @@ TEST_F(MeshLibLineMesh, ElementNeigbors) { unsigned count = 0; for (int i = 0; i < 2; i++) + { if (e->getNeighbor(i) != nullptr) + { count++; + } + } return count; }; diff --git a/Tests/MeshLib/TestMeshGenerator.cpp b/Tests/MeshLib/TestMeshGenerator.cpp index 42cb007fc673b6b8a0b3ca1e510f16481d02169a..5e367faf74276cf5d1e06649f29d1766627079e6 100644 --- a/Tests/MeshLib/TestMeshGenerator.cpp +++ b/Tests/MeshLib/TestMeshGenerator.cpp @@ -126,8 +126,10 @@ TEST(MeshLib, MeshGeneratorRegularPrism) ASSERT_EQ((n_x+1) * (n_y+1) * (n_z+1), mesh->getNumberOfNodes()); std::size_t count (0); - for (std::size_t k=0; k<(n_z+1); ++k) - for (std::size_t j=0; j<(n_y+1); ++j) + for (std::size_t k = 0; k < (n_z + 1); ++k) + { + for (std::size_t j = 0; j < (n_y + 1); ++j) + { for (std::size_t i=0; i<(n_x+1); ++i) { const MeshLib::Node* node (mesh->getNode(count++)); @@ -135,4 +137,6 @@ TEST(MeshLib, MeshGeneratorRegularPrism) ASSERT_DOUBLE_EQ(static_cast<double>(j*2), (*node)[1]); ASSERT_DOUBLE_EQ(static_cast<double>(k*2), (*node)[2]); } + } + } } diff --git a/Tests/MeshLib/TestMeshNodeSearch.cpp b/Tests/MeshLib/TestMeshNodeSearch.cpp index a6bfd86dfe2e265e3adad4d2d0033c997994e9c1..83a116f98c96cec1c13b54ce1ffb17f4e7ae77be 100644 --- a/Tests/MeshLib/TestMeshNodeSearch.cpp +++ b/Tests/MeshLib/TestMeshNodeSearch.cpp @@ -146,8 +146,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::vector<std::size_t> const& found_ids_ply0(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply0)); ASSERT_EQ(100u, found_ids_ply0.size()); - for (std::size_t k(0); k<found_ids_ply0.size(); k++) + for (std::size_t k(0); k < found_ids_ply0.size(); k++) + { ASSERT_EQ(k, found_ids_ply0[k]); + } GeoLib::Polyline ply1(pnts); ply1.addPoint(2); @@ -155,8 +157,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::vector<std::size_t> const& found_ids_ply1(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply1)); ASSERT_EQ(100u, found_ids_ply1.size()); - for (std::size_t k(0); k<found_ids_ply1.size(); k++) + for (std::size_t k(0); k < found_ids_ply1.size(); k++) + { ASSERT_EQ(k, found_ids_ply1[k]); + } GeoLib::Polyline ply2(pnts); ply2.addPoint(4); @@ -165,8 +169,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::size_t offset((_number_of_subdivisions_per_direction+1)*_number_of_subdivisions_per_direction); ASSERT_EQ(100u, found_ids_ply2.size()); - for (std::size_t k(0); k<found_ids_ply2.size(); k++) + for (std::size_t k(0); k < found_ids_ply2.size(); k++) + { ASSERT_EQ(offset + k, found_ids_ply2[k]); + } GeoLib::Polyline ply3(pnts); ply3.addPoint(6); @@ -174,8 +180,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::vector<std::size_t> const& found_ids_ply3(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply3)); ASSERT_EQ(100u, found_ids_ply3.size()); - for (std::size_t k(0); k<found_ids_ply3.size(); k++) + for (std::size_t k(0); k < found_ids_ply3.size(); k++) + { ASSERT_EQ(offset + k, found_ids_ply3[k]); + } // left border GeoLib::Polyline ply4(pnts); @@ -184,8 +192,11 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::vector<std::size_t> const& found_ids_ply4(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply4)); ASSERT_EQ(100u, found_ids_ply4.size()); - for (std::size_t k(0); k<found_ids_ply4.size(); k++) - ASSERT_EQ(k*(_number_of_subdivisions_per_direction+1), found_ids_ply4[k]); + for (std::size_t k(0); k < found_ids_ply4.size(); k++) + { + ASSERT_EQ(k * (_number_of_subdivisions_per_direction + 1), + found_ids_ply4[k]); + } // right border GeoLib::Polyline ply5(pnts); @@ -194,8 +205,12 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::vector<std::size_t> const& found_ids_ply5(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply5)); ASSERT_EQ(100u, found_ids_ply5.size()); - for (std::size_t k(0); k<found_ids_ply5.size(); k++) - ASSERT_EQ(k*(_number_of_subdivisions_per_direction+1)+_number_of_subdivisions_per_direction, found_ids_ply5[k]); + for (std::size_t k(0); k < found_ids_ply5.size(); k++) + { + ASSERT_EQ(k * (_number_of_subdivisions_per_direction + 1) + + _number_of_subdivisions_per_direction, + found_ids_ply5[k]); + } // diagonal GeoLib::Polyline ply6(pnts); @@ -204,8 +219,11 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, PolylineSearch) std::vector<std::size_t> const& found_ids_ply6(mesh_node_searcher.getMeshNodeIDsAlongPolyline(ply6)); ASSERT_EQ(100u, found_ids_ply6.size()); - for (std::size_t k(0); k<found_ids_ply6.size(); k++) - ASSERT_EQ(k*(_number_of_subdivisions_per_direction+1)+k, found_ids_ply6[k]); + for (std::size_t k(0); k < found_ids_ply6.size(); k++) + { + ASSERT_EQ(k * (_number_of_subdivisions_per_direction + 1) + k, + found_ids_ply6[k]); + } std::for_each(pnts.begin(), pnts.end(), [](GeoLib::Point* pnt) { delete pnt; }); } @@ -235,8 +253,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, SurfaceSearch) mesh_node_searcher.getMeshNodeIDsAlongSurface(sfc0)); ASSERT_EQ(_quad_mesh->getNumberOfNodes(), found_ids_sfc0.size()); - for (std::size_t k(0); k<found_ids_sfc0.size(); k++) + for (std::size_t k(0); k < found_ids_sfc0.size(); k++) + { ASSERT_EQ(k, found_ids_sfc0[k]); + } // bottom half domain GeoLib::Surface sfc1(pnts); @@ -247,8 +267,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleQuadMesh, SurfaceSearch) mesh_node_searcher.getMeshNodeIDsAlongSurface(sfc1)); ASSERT_EQ(_quad_mesh->getNumberOfNodes()/2, found_ids_sfc1.size()); - for (std::size_t k(0); k<found_ids_sfc1.size(); k++) + for (std::size_t k(0); k < found_ids_sfc1.size(); k++) + { ASSERT_EQ(k, found_ids_sfc1[k]); + } std::for_each(pnts.begin(), pnts.end(), [](GeoLib::Point* pnt) { delete pnt; }); } @@ -283,8 +305,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) std::vector<std::size_t> const& found_ids_sfc_b( mesh_node_searcher.getMeshNodeIDsAlongSurface(sfc_bottom)); ASSERT_EQ(n_nodes_2d, found_ids_sfc_b.size()); - for (std::size_t k(0); k<found_ids_sfc_b.size(); k++) + for (std::size_t k(0); k < found_ids_sfc_b.size(); k++) + { ASSERT_EQ(k, found_ids_sfc_b[k]); + } // top surface GeoLib::Surface sfc_top(pnts); @@ -295,8 +319,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) mesh_node_searcher.getMeshNodeIDsAlongSurface(sfc_top)); ASSERT_EQ(n_nodes_2d, found_ids_sfc_t.size()); const std::size_t offset_t = n_nodes_3d - n_nodes_2d; - for (std::size_t k(0); k<found_ids_sfc_t.size(); k++) + for (std::size_t k(0); k < found_ids_sfc_t.size(); k++) + { ASSERT_EQ(offset_t + k, found_ids_sfc_t[k]); + } // front GeoLib::Surface sfc_front(pnts); @@ -308,8 +334,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) ASSERT_EQ(n_nodes_2d, found_ids_sfc_f.size()); std::size_t cnt=0; for (std::size_t k(0); k<n_nodes_1d; k++) { - for (std::size_t i(0); i<n_nodes_1d; i++) - ASSERT_EQ(k*n_nodes_2d+i, found_ids_sfc_f[cnt++]); + for (std::size_t i(0); i < n_nodes_1d; i++) + { + ASSERT_EQ(k * n_nodes_2d + i, found_ids_sfc_f[cnt++]); + } } // back @@ -324,8 +352,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) const std::size_t y_offset = n_nodes_1d*(n_nodes_1d-1); for (std::size_t k(0); k<n_nodes_1d; k++) { const std::size_t z_offset = n_nodes_2d*k; - for (std::size_t i(0); i<n_nodes_1d; i++) + for (std::size_t i(0); i < n_nodes_1d; i++) + { ASSERT_EQ(z_offset + y_offset + i, found_ids_sfc_back[cnt++]); + } } // left @@ -339,8 +369,10 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) cnt = 0; for (std::size_t k(0); k<n_nodes_1d; k++) { const std::size_t z_offset = n_nodes_2d*k; - for (std::size_t j(0); j<n_nodes_1d; j++) - ASSERT_EQ(z_offset + j*n_nodes_1d, found_ids_sfc_left[cnt++]); + for (std::size_t j(0); j < n_nodes_1d; j++) + { + ASSERT_EQ(z_offset + j * n_nodes_1d, found_ids_sfc_left[cnt++]); + } } // right @@ -354,8 +386,11 @@ TEST_F(MeshLibMeshNodeSearchInSimpleHexMesh, SurfaceSearch) cnt = 0; for (std::size_t k(0); k<n_nodes_1d; k++) { const std::size_t z_offset = n_nodes_2d*k; - for (std::size_t j(0); j<n_nodes_1d; j++) - ASSERT_EQ(z_offset + (j+1)*n_nodes_1d-1, found_ids_sfc_right[cnt++]); + for (std::size_t j(0); j < n_nodes_1d; j++) + { + ASSERT_EQ(z_offset + (j + 1) * n_nodes_1d - 1, + found_ids_sfc_right[cnt++]); + } } diff --git a/Tests/MeshLib/TestMoveMeshNodes.cpp b/Tests/MeshLib/TestMoveMeshNodes.cpp index 127efff154adc5b403795e494250304d41151445..0d8d51078961a71441d054d20a67014b9bd16719 100644 --- a/Tests/MeshLib/TestMoveMeshNodes.cpp +++ b/Tests/MeshLib/TestMoveMeshNodes.cpp @@ -56,8 +56,12 @@ TEST(MeshLib, moveMeshNodes) } for (auto n : nodes) + { delete n; + } for (auto n : nodes_copy) + { delete n; + } } diff --git a/Tests/MeshLib/TestProjectMeshOnPlane.cpp b/Tests/MeshLib/TestProjectMeshOnPlane.cpp index ad351c6bea4b9b0645740d903681084d1c0ba962..d0752bc5b444b7eec37600dd7f3b753d74da33dd 100644 --- a/Tests/MeshLib/TestProjectMeshOnPlane.cpp +++ b/Tests/MeshLib/TestProjectMeshOnPlane.cpp @@ -29,12 +29,18 @@ public: { std::size_t const n_nodes (100); std::vector<MeshLib::Node*> nodes; - for (std::size_t i=1; i<=n_nodes; i++) - nodes.push_back(new MeshLib::Node(static_cast<double>(i), static_cast<double>(i), i*0.5)); + for (std::size_t i = 1; i <= n_nodes; i++) + { + nodes.push_back(new MeshLib::Node(static_cast<double>(i), + static_cast<double>(i), i * 0.5)); + } std::vector<MeshLib::Element*> elements; - for (std::size_t i=0; i<n_nodes-1; i++) - elements.push_back(new MeshLib::Line(std::array<MeshLib::Node*,2>{{nodes[i], nodes[i+1]}})); + for (std::size_t i = 0; i < n_nodes - 1; i++) + { + elements.push_back(new MeshLib::Line( + std::array<MeshLib::Node*, 2>{{nodes[i], nodes[i + 1]}})); + } _mesh = std::make_unique<MeshLib::Mesh>("TestMesh", nodes, elements); } @@ -51,8 +57,11 @@ TEST_F(ProjectionTest, ProjectToXY) { MathLib::Point3d origin (std::array<double,3>{{0,0,static_cast<double>(p)}}); MeshLib::Mesh* result = MeshLib::projectMeshOntoPlane(*_mesh, origin, normal); - for (std::size_t i=0; i<n_nodes; i++) - ASSERT_NEAR(static_cast<double>(p), (*result->getNode(i))[2], std::numeric_limits<double>::epsilon()); + for (std::size_t i = 0; i < n_nodes; i++) + { + ASSERT_NEAR(static_cast<double>(p), (*result->getNode(i))[2], + std::numeric_limits<double>::epsilon()); + } delete result; } } @@ -66,8 +75,11 @@ TEST_F(ProjectionTest, ProjectToXZ) { MathLib::Point3d origin (std::array<double,3>{{0,static_cast<double>(p),0}}); MeshLib::Mesh* result = MeshLib::projectMeshOntoPlane(*_mesh, origin, normal); - for (std::size_t i=0; i<n_nodes; i++) - ASSERT_NEAR(static_cast<double>(p), (*result->getNode(i))[1], std::numeric_limits<double>::epsilon()); + for (std::size_t i = 0; i < n_nodes; i++) + { + ASSERT_NEAR(static_cast<double>(p), (*result->getNode(i))[1], + std::numeric_limits<double>::epsilon()); + } delete result; } } @@ -81,8 +93,11 @@ TEST_F(ProjectionTest, ProjectToYZ) { MathLib::Point3d origin (std::array<double,3>{{static_cast<double>(p),0,0}}); MeshLib::Mesh* result = MeshLib::projectMeshOntoPlane(*_mesh, origin, normal); - for (std::size_t i=0; i<n_nodes; i++) - ASSERT_NEAR(static_cast<double>(p), (*result->getNode(i))[0], std::numeric_limits<double>::epsilon()); + for (std::size_t i = 0; i < n_nodes; i++) + { + ASSERT_NEAR(static_cast<double>(p), (*result->getNode(i))[0], + std::numeric_limits<double>::epsilon()); + } delete result; } } @@ -96,8 +111,10 @@ TEST_F(ProjectionTest, NormalDirection) MathLib::Point3d origin (std::array<double,3>{{0,0,0}}); MeshLib::Mesh* result_p = MeshLib::projectMeshOntoPlane(*_mesh, origin, normal_p); MeshLib::Mesh* result_n = MeshLib::projectMeshOntoPlane(*_mesh, origin, normal_n); - for (std::size_t i=0; i<n_nodes; i++) + for (std::size_t i = 0; i < n_nodes; i++) + { ASSERT_EQ((*result_p->getNode(i))[2], (*result_n->getNode(i))[2]); + } delete result_p; delete result_n; } @@ -113,8 +130,10 @@ TEST_F(ProjectionTest, NormalLength) { normal[2] = static_cast<double>(p); MeshLib::Mesh* result_p = MeshLib::projectMeshOntoPlane(*_mesh, origin, normal); - for (std::size_t i=0; i<n_nodes; i++) + for (std::size_t i = 0; i < n_nodes; i++) + { ASSERT_EQ((*result->getNode(i))[2], (*result_p->getNode(i))[2]); + } delete result_p; } delete result; diff --git a/Tests/MeshLib/TestQuadMesh.cpp b/Tests/MeshLib/TestQuadMesh.cpp index 8690389fa5a6010de08fc90e4dee7a10cc1fd7dd..357df5b6c9b811dff662b837e41177dc41cf86d3 100644 --- a/Tests/MeshLib/TestQuadMesh.cpp +++ b/Tests/MeshLib/TestQuadMesh.cpp @@ -79,16 +79,24 @@ class MeshLibQuadMesh : public ::testing::Test { // left for (std::size_t j = 1; j < elements_stride; ++j) + { f(getElement(0, j), 0, j); + } // right for (std::size_t j = 1; j < elements_stride; ++j) + { f(getElement(elements_stride, j), elements_stride, j); + } // bottom for (std::size_t i = 1; i < elements_stride; ++i) + { f(getElement(i, 0), i, 0); + } // top for (std::size_t i = 1; i < elements_stride; ++i) + { f(getElement(i, elements_stride), i, elements_stride); + } } template <typename F> @@ -96,8 +104,12 @@ class MeshLibQuadMesh : public ::testing::Test testInsideElements(F const&& f) { for (std::size_t i = 1; i < elements_stride; ++i) + { for (std::size_t j = 1; j < elements_stride; ++j) + { f(getElement(i, j), i, j); + } + } } template <typename F> @@ -105,8 +117,12 @@ class MeshLibQuadMesh : public ::testing::Test testAllElements(F const&& f) { for (std::size_t i = 0; i < elements_stride; ++i) + { for (std::size_t j = 0; j < elements_stride; ++j) + { f(getElement(i, j), i, j); + } + } } template <typename F> @@ -126,16 +142,24 @@ class MeshLibQuadMesh : public ::testing::Test { // left for (std::size_t j = 1; j < nodes_stride; ++j) + { f(getNode(0, j), 0, j); + } // right for (std::size_t j = 1; j < nodes_stride; ++j) + { f(getNode(nodes_stride, j), nodes_stride, j); + } // bottom for (std::size_t i = 1; i < nodes_stride; ++i) + { f(getNode(i, 0), i, 0); + } // top for (std::size_t i = 1; i < nodes_stride; ++i) + { f(getNode(i, nodes_stride), i, nodes_stride); + } } template <typename F> @@ -143,8 +167,12 @@ class MeshLibQuadMesh : public ::testing::Test testInsideNodes(F const&& f) { for (std::size_t i = 1; i < nodes_stride; ++i) + { for (std::size_t j = 1; j < nodes_stride; ++j) + { f(getNode(i, j), i, j); + } + } } }; @@ -171,8 +199,12 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors) { unsigned count = 0; for (int i = 0; i < 4; i++) + { if (e->getNeighbor(i) != nullptr) + { count++; + } + } return count; }; @@ -181,17 +213,19 @@ TEST_F(MeshLibQuadMesh, ElementNeighbors) return std::make_pair(getNeighbor(i), getNeighbor(j)); }; - auto testNeighbors = [this]( - MeshLib::Element const* const e, - std::size_t const i, - std::size_t const j, - std::pair<Indices, Indices> const& neighbors) - { + auto testNeighbors = [this](MeshLib::Element const* const e, + std::size_t const i, + std::size_t const j, + std::pair<Indices, Indices> const& neighbors) { for (auto i_neighbor : neighbors.first) + { ASSERT_TRUE(e->hasNeighbor(getElement(i_neighbor, j))); + } for (auto j_neighbor : neighbors.second) + { ASSERT_TRUE(e->hasNeighbor(getElement(i, j_neighbor))); + } }; // Two neighbors for corner elements. @@ -268,9 +302,13 @@ TEST_F(MeshLibQuadMesh, NodeToElementConnectivity) EXPECT_EQ(1u, node->getNumberOfElements()); if (i == nodes_stride) + { i--; + } if (j == nodes_stride) + { j--; + } EXPECT_EQ(getElement(i, j), node->getElement(0)); }); diff --git a/Tests/MeshLib/TestQuadraticMesh.cpp b/Tests/MeshLib/TestQuadraticMesh.cpp index 03f1b2b42be63b3e710dd54281d7ab37be6d5762..e4d2e9545b5e46300bab610fa27b277dbd0cdea4 100644 --- a/Tests/MeshLib/TestQuadraticMesh.cpp +++ b/Tests/MeshLib/TestQuadraticMesh.cpp @@ -38,10 +38,15 @@ TEST(MeshLib, QuadraticOrderMesh_Line) ASSERT_EQ(2u, e->getNumberOfBaseNodes()); ASSERT_EQ(3u, e->getNumberOfNodes()); - for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) + for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++) + { ASSERT_TRUE(mesh->isBaseNode(e->getNodeIndex(i))); - for (unsigned i=e->getNumberOfBaseNodes(); i<e->getNumberOfNodes(); i++) + } + for (unsigned i = e->getNumberOfBaseNodes(); i < e->getNumberOfNodes(); + i++) + { ASSERT_FALSE(mesh->isBaseNode(e->getNodeIndex(i))); + } } for (MeshLib::Node const* node : mesh->getNodes()) @@ -76,10 +81,15 @@ TEST(MeshLib, QuadraticOrderMesh_Quad) ASSERT_EQ(4u, e->getNumberOfBaseNodes()); ASSERT_EQ(8u, e->getNumberOfNodes()); - for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) + for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++) + { ASSERT_TRUE(mesh->isBaseNode(e->getNodeIndex(i))); - for (unsigned i=e->getNumberOfBaseNodes(); i<e->getNumberOfNodes(); i++) + } + for (unsigned i = e->getNumberOfBaseNodes(); i < e->getNumberOfNodes(); + i++) + { ASSERT_FALSE(mesh->isBaseNode(e->getNodeIndex(i))); + } } auto const& mesh_nodes = mesh->getNodes(); @@ -131,7 +141,9 @@ TEST(MeshLib, QuadraticOrderMesh_LineQuad) linear_mesh = MeshGeoToolsLib::appendLinesAlongPolylines(*linear_quad_mesh.get(), ply_vec); for (auto p : pnts) + { delete p; + } } ASSERT_EQ(6u, linear_mesh->getNumberOfElements()); @@ -155,10 +167,15 @@ TEST(MeshLib, QuadraticOrderMesh_LineQuad) ASSERT_EQ(3u, e->getNumberOfNodes()); } - for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++) + for (unsigned i = 0; i < e->getNumberOfBaseNodes(); i++) + { ASSERT_TRUE(mesh->isBaseNode(e->getNodeIndex(i))); - for (unsigned i=e->getNumberOfBaseNodes(); i<e->getNumberOfNodes(); i++) + } + for (unsigned i = e->getNumberOfBaseNodes(); i < e->getNumberOfNodes(); + i++) + { ASSERT_FALSE(mesh->isBaseNode(e->getNodeIndex(i))); + } } auto const& mesh_nodes = mesh->getNodes(); diff --git a/Tests/MeshLib/TestRasterToMesh.cpp b/Tests/MeshLib/TestRasterToMesh.cpp index 43c0e55a564406899edbf53d2980de3b4c07c588..376530b3a78ab142bd8f1cce643f3f71746e318b 100644 --- a/Tests/MeshLib/TestRasterToMesh.cpp +++ b/Tests/MeshLib/TestRasterToMesh.cpp @@ -140,7 +140,9 @@ TEST_F(RasterToMeshTest, convertRasterToTriMeshValue) std::vector<MeshLib::Node*> const& nodes = mesh->getNodes(); for (MeshLib::Node* n : nodes) + { ASSERT_NEAR(0, (*n)[2], std::numeric_limits<double>::epsilon()); + } std::array<unsigned, 7> n_types = MeshLib::MeshInformation::getNumberOfElementTypes(*mesh); @@ -171,7 +173,9 @@ TEST_F(RasterToMeshTest, convertRasterToQuadMeshValue) std::vector<MeshLib::Node*> const& nodes = mesh->getNodes(); for (MeshLib::Node* n : nodes) + { ASSERT_TRUE((*n)[2] == 0); + } std::array<unsigned, 7> n_types = MeshLib::MeshInformation::getNumberOfElementTypes(*mesh); @@ -202,7 +206,9 @@ TEST_F(RasterToMeshTest, convertRasterToPrismMeshValue) std::vector<MeshLib::Node*> const& nodes = mesh->getNodes(); for (MeshLib::Node* n : nodes) + { ASSERT_TRUE(((*n)[2] == 0) || ((*n)[2] == _spacing)); + } std::array<unsigned, 7> n_types = MeshLib::MeshInformation::getNumberOfElementTypes(*mesh); @@ -233,7 +239,9 @@ TEST_F(RasterToMeshTest, convertRasterToHexMeshValue) std::vector<MeshLib::Node*> const& nodes = mesh->getNodes(); for (MeshLib::Node* n : nodes) + { ASSERT_TRUE(((*n)[2] == 0) || ((*n)[2] == _spacing)); + } std::array<unsigned, 7> n_types = MeshLib::MeshInformation::getNumberOfElementTypes(*mesh); @@ -255,7 +263,9 @@ TEST_F(RasterToMeshTest, convertRasterToQuadMeshNone) std::vector<MeshLib::Node*> const& nodes = mesh->getNodes(); for (MeshLib::Node* n : nodes) + { ASSERT_TRUE((*n)[2] == 0); + } std::array<unsigned, 7> n_types = MeshLib::MeshInformation::getNumberOfElementTypes(*mesh); diff --git a/Tests/MeshLib/TestRemove.cpp b/Tests/MeshLib/TestRemove.cpp index 7f1b0aed921476a4aea9aa21784109b8b3b37f45..a28a0bbe0d90cdd4845a1250039abfe34b3c2c44 100644 --- a/Tests/MeshLib/TestRemove.cpp +++ b/Tests/MeshLib/TestRemove.cpp @@ -30,8 +30,10 @@ TEST(MeshLib, RemoveNodes) MeshLib::MeshGenerator::generateLineMesh(1.0, 9)}; std::vector<std::size_t> removed_node_ids; - for (std::size_t i=0; i<5; i++) + for (std::size_t i = 0; i < 5; i++) + { removed_node_ids.push_back(i); + } auto new_mesh = std::unique_ptr<MeshLib::Mesh>{ MeshLib::removeNodes(*mesh, removed_node_ids, "")}; @@ -39,8 +41,10 @@ TEST(MeshLib, RemoveNodes) ASSERT_EQ(5u, new_mesh->getNumberOfNodes()); ASSERT_EQ(5u, new_mesh->getNumberOfBaseNodes()); ASSERT_EQ(4u, new_mesh->getNumberOfElements()); - for (std::size_t i=0; i<new_mesh->getNumberOfNodes(); i++) - ASSERT_TRUE(*mesh->getNode(5+i) == *new_mesh->getNode(i)); + for (std::size_t i = 0; i < new_mesh->getNumberOfNodes(); i++) + { + ASSERT_TRUE(*mesh->getNode(5 + i) == *new_mesh->getNode(i)); + } } TEST(MeshLib, RemoveElements) @@ -49,8 +53,10 @@ TEST(MeshLib, RemoveElements) MeshLib::MeshGenerator::generateLineMesh(1.0, 9)}; std::vector<std::size_t> removed_ele_ids; - for (std::size_t i=0; i<5; i++) + for (std::size_t i = 0; i < 5; i++) + { removed_ele_ids.push_back(i); + } auto new_mesh = std::unique_ptr<MeshLib::Mesh>{ MeshLib::removeElements(*mesh, removed_ele_ids, "")}; @@ -58,6 +64,8 @@ TEST(MeshLib, RemoveElements) ASSERT_EQ(5u, new_mesh->getNumberOfNodes()); ASSERT_EQ(5u, new_mesh->getNumberOfBaseNodes()); ASSERT_EQ(4u, new_mesh->getNumberOfElements()); - for (std::size_t i=0; i<new_mesh->getNumberOfNodes(); i++) - ASSERT_TRUE(*mesh->getNode(5+i) == *new_mesh->getNode(i)); + for (std::size_t i = 0; i < new_mesh->getNumberOfNodes(); i++) + { + ASSERT_TRUE(*mesh->getNode(5 + i) == *new_mesh->getNode(i)); + } } diff --git a/Tests/MeshLib/TestVtkMappedMeshSource.cpp b/Tests/MeshLib/TestVtkMappedMeshSource.cpp index 217bf031e50f59532114dc7c2ead283adbebb546..bde8caac0460b16bbbce316de5606add2570941e 100644 --- a/Tests/MeshLib/TestVtkMappedMeshSource.cpp +++ b/Tests/MeshLib/TestVtkMappedMeshSource.cpp @@ -239,8 +239,10 @@ TEST_F(InSituMesh, DISABLED_MappedMeshSourceRoundtrip) { for(bool compressed : { true, false }) { - if(dataMode == vtkXMLWriter::Ascii && compressed) + if (dataMode == vtkXMLWriter::Ascii && compressed) + { continue; + } MeshLib::IO::VtuInterface vtuInterface(mesh, dataMode, compressed); ASSERT_TRUE(vtuInterface.writeToFile(test_data_file)); @@ -327,7 +329,9 @@ TEST_F(InSituMesh, DISABLED_MappedMeshSourceRoundtrip) doubleProps->getNumberOfTuples()); ASSERT_EQ(newDoubleProps->size(), doubleProps->size()); for (std::size_t i = 0; i < doubleProps->size(); i++) + { ASSERT_EQ((*newDoubleProps)[i], (*doubleProps)[i]); + } auto unsignedProps = meshProperties.getPropertyVector<unsigned>( "CellUnsignedProperty"); @@ -340,7 +344,9 @@ TEST_F(InSituMesh, DISABLED_MappedMeshSourceRoundtrip) unsignedProps->getNumberOfTuples()); ASSERT_EQ(newUnsignedIds->size(), unsignedProps->size()); for (std::size_t i = 0; i < unsignedProps->size(); i++) + { ASSERT_EQ((*newUnsignedIds)[i], (*unsignedProps)[i]); + } { // Field data auto p = @@ -353,7 +359,9 @@ TEST_F(InSituMesh, DISABLED_MappedMeshSourceRoundtrip) ASSERT_EQ(new_p->getNumberOfTuples(), p->getNumberOfTuples()); ASSERT_EQ(new_p->size(), p->size()); for (std::size_t i = 0; i < unsignedProps->size(); i++) + { ASSERT_EQ((*newUnsignedIds)[i], (*unsignedProps)[i]); + } } auto const* const materialIds = @@ -366,7 +374,9 @@ TEST_F(InSituMesh, DISABLED_MappedMeshSourceRoundtrip) materialIds->getNumberOfTuples()); ASSERT_EQ(newMaterialIds->size(), materialIds->size()); for (std::size_t i = 0; i < materialIds->size(); i++) + { ASSERT_EQ((*newMaterialIds)[i], (*materialIds)[i]); + } } } } diff --git a/Tests/MeshLib/TestVtkMeshConverter.cpp b/Tests/MeshLib/TestVtkMeshConverter.cpp index abeab5b2ae7cf862c84a0782571234268a7dd430..2e7c455c3c5e5ffb5dbca9d8153700089081796b 100644 --- a/Tests/MeshLib/TestVtkMeshConverter.cpp +++ b/Tests/MeshLib/TestVtkMeshConverter.cpp @@ -76,7 +76,9 @@ public: pointIds->SetNumberOfComponents(1); pointIds->SetName("PointIDs"); for (int i = 0; i < 12; ++i) + { pointIds->InsertNextTuple1(i); + } vtu->GetPointData()->AddArray(pointIds); auto materialIds = vtkSmartPointer<vtkUnsignedIntArray>::New(); @@ -107,6 +109,8 @@ TEST_F(TestVtkMeshConverter, Conversion) ASSERT_NE(nullptr, materialIds); auto vtkMaterialIds = vtu->GetCellData()->GetArray("MaterialIDs"); ASSERT_EQ(materialIds->size(), vtkMaterialIds->GetNumberOfTuples()); - for(std::size_t i = 0; i < materialIds->size(); i++) + for (std::size_t i = 0; i < materialIds->size(); i++) + { ASSERT_EQ((*materialIds)[i], vtkMaterialIds->GetTuple1(i)); + } } diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h b/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h index fe375c29d75a690988e607104844f7821e64cc80..f3a1c67c712573b7bc61ade9c4f7425d33ca326e 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestHex8.h @@ -119,4 +119,4 @@ const double TestHex8::cl_exp_J[dim*dim] = {0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0 const double TestHex8::cl_exp_detJ = -1.; const double TestHex8::ze_exp_J[dim*dim] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}; -} +} // namespace CoordinatesMappingTestData diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h b/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h index f0ca7ce94d9eadb0a77db5de39fe92206886c07b..eb896fa5037428809ba97519a025029569e65230 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestLine2.h @@ -97,4 +97,4 @@ const double TestLine2::cl_exp_J[dim*dim] = {-1.}; const double TestLine2::cl_exp_detJ = -1; const double TestLine2::ze_exp_J[dim*dim] = {0.0}; -} +} // namespace CoordinatesMappingTestData diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h b/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h index 4e05d64656bf7144f5e6a2b1f75cf87b75f2c3aa..dba98fbdd65b0a278cae40d86cf4e4c90b044405 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestLine3.h @@ -100,4 +100,4 @@ const double TestLine3::ir_exp_dNdx[dim * e_nnodes] = {0, 0.5, -0.5}; const double TestLine3::cl_exp_J[dim * dim] = {-1.}; const double TestLine3::cl_exp_detJ = -1; const double TestLine3::ze_exp_J[dim * dim] = {0.0}; -} +} // namespace CoordinatesMappingTestData diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h b/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h index 336594fa0aa9b7aba53c2ff82a1225de21db8752..eba1c523d7839481a53bad99d5c697bbf1211c84 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestQuad4.h @@ -99,4 +99,4 @@ const double TestQuad4::cl_exp_J[dim*dim] = {0.0, 1.0, 1.0, 0.0}; const double TestQuad4::cl_exp_detJ = -1.; const double TestQuad4::ze_exp_J[dim*dim] = {1.0, 0.0, 0.0, 0.0}; -} +} // namespace CoordinatesMappingTestData diff --git a/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h b/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h index c8440a1e5e79de93ae1d79607d5d62527efef0f0..ebe8b120ed89b8a58eea17f00f388f50e80cdbf2 100644 --- a/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h +++ b/Tests/NumLib/CoordinatesMappingTestData/TestTri3.h @@ -94,4 +94,4 @@ const double TestTri3::cl_exp_J[dim*dim] = {0.0, 1.0, 1.0, 0.0}; const double TestTri3::cl_exp_detJ = -1.; const double TestTri3::ze_exp_J[dim*dim] = {1.0, 0.0, 1.0, 0.0}; -} +} // namespace CoordinatesMappingTestData diff --git a/Tests/NumLib/FeTestData/MatrixTools.h b/Tests/NumLib/FeTestData/MatrixTools.h index 15a2efcabefb2ea0836882303b4ccc1aaf0a1737..40ab6b1136591ffd1da6c9951c60d6d7a07bcc9a 100644 --- a/Tests/NumLib/FeTestData/MatrixTools.h +++ b/Tests/NumLib/FeTestData/MatrixTools.h @@ -32,4 +32,4 @@ inline void setIdentityMatrix(unsigned dim, T_MATRIX &m) m(i,i) = 1.0; } -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeHEX20.h b/Tests/NumLib/FeTestData/TestFeHEX20.h index 8684e285eabe8d88399c9d80b7f25f335ceb62bd..23d5d791d971c8e0fbb9e1de6da271ab9dd29393 100644 --- a/Tests/NumLib/FeTestData/TestFeHEX20.h +++ b/Tests/NumLib/FeTestData/TestFeHEX20.h @@ -71,4 +71,4 @@ public: double getVolume() const { return 1.0; } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeHEX8.h b/Tests/NumLib/FeTestData/TestFeHEX8.h index 446fcb7d64136e9258ac36f19787913b2dcee580..027b1863a366397af10948aafe1598b816dbb337 100644 --- a/Tests/NumLib/FeTestData/TestFeHEX8.h +++ b/Tests/NumLib/FeTestData/TestFeHEX8.h @@ -89,4 +89,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeLINE2.h b/Tests/NumLib/FeTestData/TestFeLINE2.h index c7e4c835e7cfc0a62c9d7937107ff90d574fd3bb..3eb8460b42f062a873ef4f2bd0e669cf3f3682f2 100644 --- a/Tests/NumLib/FeTestData/TestFeLINE2.h +++ b/Tests/NumLib/FeTestData/TestFeLINE2.h @@ -69,4 +69,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeLINE2Y.h b/Tests/NumLib/FeTestData/TestFeLINE2Y.h index 91d024489ac624a5081e5f7bc5921a27562a84c8..1f60bf89edd83355eff53f5969cc7e2e01f8e292 100644 --- a/Tests/NumLib/FeTestData/TestFeLINE2Y.h +++ b/Tests/NumLib/FeTestData/TestFeLINE2Y.h @@ -68,4 +68,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeLINE3.h b/Tests/NumLib/FeTestData/TestFeLINE3.h index 0264551d8287a14dbb960b32c57b369e8d798ac5..a9c410e33c4007e164e70daaeb898aa65430f31b 100644 --- a/Tests/NumLib/FeTestData/TestFeLINE3.h +++ b/Tests/NumLib/FeTestData/TestFeLINE3.h @@ -71,4 +71,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFePRISM15.h b/Tests/NumLib/FeTestData/TestFePRISM15.h index 510be3dc9ef66b8aff2178c4e212df633bbf4e07..a9f68e0912721f58e4d642d510005d66c77de2ad 100644 --- a/Tests/NumLib/FeTestData/TestFePRISM15.h +++ b/Tests/NumLib/FeTestData/TestFePRISM15.h @@ -67,4 +67,4 @@ public: double getVolume() const { return 0.0625; } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFePRISM6.h b/Tests/NumLib/FeTestData/TestFePRISM6.h index 2d55a1bb3e1e60aee7f6507d98e93bfefb348e69..dd888b0f221de1012a81108a6a39a8244ac867a8 100644 --- a/Tests/NumLib/FeTestData/TestFePRISM6.h +++ b/Tests/NumLib/FeTestData/TestFePRISM6.h @@ -82,4 +82,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFePYRA13.h b/Tests/NumLib/FeTestData/TestFePYRA13.h index b782cf442feb084a07f5158945638dba11a47428..789c4c171c7fa2b16b5633157cd8371ab407eeb6 100644 --- a/Tests/NumLib/FeTestData/TestFePYRA13.h +++ b/Tests/NumLib/FeTestData/TestFePYRA13.h @@ -63,4 +63,4 @@ public: double getVolume() const { return 0.5 * 0.5 * 0.25 / 3.0; } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFePYRA5.h b/Tests/NumLib/FeTestData/TestFePYRA5.h index dbb8aa29d5a09ebe1de95edf43f58f76ec2ff44f..48fb323a8c6dccba10a150d607f7b3f7fccc712e 100644 --- a/Tests/NumLib/FeTestData/TestFePYRA5.h +++ b/Tests/NumLib/FeTestData/TestFePYRA5.h @@ -78,4 +78,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeQUAD4.h b/Tests/NumLib/FeTestData/TestFeQUAD4.h index b6f44cc87962afc3bad8972a0e39e1db1912a45d..21f43b1f644b468cd441db2aab0a53ddd4cd5290 100644 --- a/Tests/NumLib/FeTestData/TestFeQUAD4.h +++ b/Tests/NumLib/FeTestData/TestFeQUAD4.h @@ -77,4 +77,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeQUAD8.h b/Tests/NumLib/FeTestData/TestFeQUAD8.h index 23cec38b663248fa396af9d2e30ded0ba11b66d1..3833def51314a319bd4b3e97b0b85c20fec31a4c 100644 --- a/Tests/NumLib/FeTestData/TestFeQUAD8.h +++ b/Tests/NumLib/FeTestData/TestFeQUAD8.h @@ -67,4 +67,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeQUAD9.h b/Tests/NumLib/FeTestData/TestFeQUAD9.h index 0f09d39079174497346acf1ff35cb9412a0a3bcc..e1737ee7bd349048acda47febfb8d99e062c7d1d 100644 --- a/Tests/NumLib/FeTestData/TestFeQUAD9.h +++ b/Tests/NumLib/FeTestData/TestFeQUAD9.h @@ -68,4 +68,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeTET10.h b/Tests/NumLib/FeTestData/TestFeTET10.h index 07c8b053121e5e06df606795d171120581c55ba7..e6f50c56ea0d69519088ed55676d10d939b82a5c 100644 --- a/Tests/NumLib/FeTestData/TestFeTET10.h +++ b/Tests/NumLib/FeTestData/TestFeTET10.h @@ -60,4 +60,4 @@ public: double getVolume() const { return 1.0 / 6.; } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeTET4.h b/Tests/NumLib/FeTestData/TestFeTET4.h index bd4afad000f037a6d71d5315dfd89ae3deb14928..ef9b9eeab4982ac57076be78cc706a205b63b501 100644 --- a/Tests/NumLib/FeTestData/TestFeTET4.h +++ b/Tests/NumLib/FeTestData/TestFeTET4.h @@ -75,4 +75,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeTRI3.h b/Tests/NumLib/FeTestData/TestFeTRI3.h index 76a19f7f4fdf06f1fcc8215b8043c03983bc7ce8..4c002b247fb42da27a0bacb08c1af362007b3bcc 100644 --- a/Tests/NumLib/FeTestData/TestFeTRI3.h +++ b/Tests/NumLib/FeTestData/TestFeTRI3.h @@ -73,4 +73,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/FeTestData/TestFeTRI6.h b/Tests/NumLib/FeTestData/TestFeTRI6.h index d7335a8dbc8768a9f98ecce3476ba5920e87ea75..edff402f176b0d02ecc119d7f5926ef021f4f54a 100644 --- a/Tests/NumLib/FeTestData/TestFeTRI6.h +++ b/Tests/NumLib/FeTestData/TestFeTRI6.h @@ -74,4 +74,4 @@ public: } }; -} // namespace +} // namespace FeTestData diff --git a/Tests/NumLib/LocalToGlobalIndexMap.cpp b/Tests/NumLib/LocalToGlobalIndexMap.cpp index a23299869cb6a56ff7929a59fc17ce4362364491..399f728280a55db33bb3ffe78c1b3d4341b39587 100644 --- a/Tests/NumLib/LocalToGlobalIndexMap.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMap.cpp @@ -96,7 +96,9 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_SubsetByComponent) std::array<std::size_t, 3> const ids = {{ 0, 5, 8 }}; std::vector<MeshLib::Element*> some_elements; for (std::size_t id : ids) + { some_elements.push_back(mesh->getElement(id)->clone()); + } auto boundary_mesh = MeshLib::createMeshFromElementSelection("boundary_mesh", some_elements); diff --git a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp index 28b2d9e844db1aee2066c39da0080c2f0b85d5b0..a3f8c73a64712c376180fe01631b04c358b49fac 100644 --- a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp @@ -337,9 +337,12 @@ TEST_F(NumLibLocalToGlobalIndexMapMultiDOFTest, DISABLED_TestMultiCompByComponen { int const num_components = 5; for (int c = 0; c < num_components; ++c) + { test<NL::ComponentOrder::BY_COMPONENT>( - num_components, c, ComputeGlobalIndexByComponent{ - (mesh_subdivs + 1) * (mesh_subdivs + 1)}); + num_components, c, + ComputeGlobalIndexByComponent{(mesh_subdivs + 1) * + (mesh_subdivs + 1)}); + } } #ifndef USE_PETSC @@ -350,8 +353,10 @@ TEST_F(NumLibLocalToGlobalIndexMapMultiDOFTest, DISABLED_TestMultiCompByLocation { int const num_components = 5; for (int c = 0; c < num_components; ++c) + { test<NL::ComponentOrder::BY_LOCATION>( num_components, c, ComputeGlobalIndexByLocation{num_components}); + } } #ifndef USE_PETSC diff --git a/Tests/NumLib/SteadyDiffusion2DExample1.h b/Tests/NumLib/SteadyDiffusion2DExample1.h index 2b0b828aee6f0d0dde3f3bbcf81a3057faad0047..d8f91bc10ed87b0f43055d9a7807c700c825ac7f 100644 --- a/Tests/NumLib/SteadyDiffusion2DExample1.h +++ b/Tests/NumLib/SteadyDiffusion2DExample1.h @@ -89,7 +89,9 @@ template<typename IndexType>struct SteadyDiffusion2DExample1 { msh = MeshLib::MeshGenerator::generateRegularQuadMesh(2.0, mesh_subdivs); for (auto* node : msh->getNodes()) + { vec_nodeIDs.push_back(node->getID()); + } vec_DirichletBC_id.resize(2 * mesh_stride); for (std::size_t i = 0; i < mesh_stride; i++) { @@ -109,17 +111,27 @@ template<typename IndexType>struct SteadyDiffusion2DExample1 // copy upper triangle to lower to localA for symmetry for (std::size_t i = 0; i < 4; i++) + { for (std::size_t j = 0; j < i; j++) - _localA(i,j) = _localA(j,i); + { + _localA(i, j) = _localA(j, i); + } + } //_localA *= 1.e-11/6.0; for (std::size_t i = 0; i < 4; i++) + { for (std::size_t j = 0; j < 4; j++) - _localA(i,j) *= 1.e-11 / 6.0; + { + _localA(i, j) *= 1.e-11 / 6.0; + } + } // Fill rhs with zero; for (std::size_t i = 0; i < 4; i++) + { _localRhs[i] = 0; + } } vec_DirichletBC_value.resize(2 * mesh_stride); @@ -127,8 +139,12 @@ template<typename IndexType>struct SteadyDiffusion2DExample1 std::fill_n(vec_DirichletBC_value.begin() + mesh_stride, mesh_stride, 1); exact_solutions.resize(dim_eqs); for (std::size_t i = 0; i < mesh_stride; i++) + { for (std::size_t j = 0; j < mesh_stride; j++) - exact_solutions[i*mesh_stride + j] = j * 1./mesh_subdivs; + { + exact_solutions[i * mesh_stride + j] = j * 1. / mesh_subdivs; + } + } } ~SteadyDiffusion2DExample1() diff --git a/Tests/NumLib/TestComponentNorms.cpp b/Tests/NumLib/TestComponentNorms.cpp index 0e8a15d45abc2a44d96e2d6c6381621c6beb33ff..d6d1c30223a48e554730dcef3fc64452676e6a8e 100644 --- a/Tests/NumLib/TestComponentNorms.cpp +++ b/Tests/NumLib/TestComponentNorms.cpp @@ -31,8 +31,10 @@ static std::vector<MeshLib::MeshSubset> createMeshSubsets( MeshLib::MeshSubset const& mesh_subset, unsigned const num_components) { std::vector<MeshLib::MeshSubset> mesh_subsets; - for (unsigned i=0; i<num_components; ++i) + for (unsigned i = 0; i < num_components; ++i) + { mesh_subsets.emplace_back(mesh_subset); + } return mesh_subsets; } diff --git a/Tests/NumLib/TestCoordinatesMapping.cpp b/Tests/NumLib/TestCoordinatesMapping.cpp index a6e9734eb51fc92ae52a613e4e6e0a619c8cec47..ab90bfc1b1f54be39d214b6e9f8f639561efadc3 100644 --- a/Tests/NumLib/TestCoordinatesMapping.cpp +++ b/Tests/NumLib/TestCoordinatesMapping.cpp @@ -77,16 +77,24 @@ public: vec_eles.push_back(clockwiseEle); vec_eles.push_back(zeroVolumeEle); for (auto e : vec_eles) + { for (unsigned i = 0; i < e->getNumberOfNodes(); i++) + { vec_nodes.push_back(e->getNode(i)); + } + } } ~NumLibFemNaturalCoordinatesMappingTest() override { for (auto itr = vec_nodes.begin(); itr != vec_nodes.end(); ++itr) + { delete *itr; + } for (auto itr = vec_eles.begin(); itr != vec_eles.end(); ++itr) + { delete *itr; + } } const double eps; @@ -227,7 +235,9 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckNaturalShape) shape, this->global_dim); double exp_J[TestFixture::dim * TestFixture::dim] = {0.0}; for (unsigned i = 0; i < this->dim; i++) + { exp_J[i + this->dim * i] = 1.0; + } ASSERT_ARRAY_NEAR(this->nat_exp_N, shape.N.data(), shape.N.size(), this->eps); @@ -310,7 +320,9 @@ TEST(NumLib, FemNaturalCoordinatesMappingLineY) double exp_J[dim * dim] = {0.0}; for (unsigned i = 0; i < dim; i++) + { exp_J[i + dim * i] = 1.0; + } const double eps(std::numeric_limits<double>::epsilon()); ASSERT_ARRAY_NEAR(TestLine2::nat_exp_N, shape.N.data(), shape.N.size(), @@ -324,6 +336,8 @@ TEST(NumLib, FemNaturalCoordinatesMappingLineY) ASSERT_ARRAY_NEAR(exp_dNdx, shape.dNdx.data(), shape.dNdx.size(), eps); for (auto n = 0u; n < line->getNumberOfNodes(); ++n) + { delete line->getNode(n); + } delete line; } diff --git a/Tests/NumLib/TestExtrapolation.cpp b/Tests/NumLib/TestExtrapolation.cpp index 7b8f778525a548fb530a74541048e86a30e47410..0d247a0be1258634865133d04541e9b3e781fa37 100644 --- a/Tests/NumLib/TestExtrapolation.cpp +++ b/Tests/NumLib/TestExtrapolation.cpp @@ -120,7 +120,9 @@ public: { cache.clear(); for (auto value : _int_pt_values) + { cache.push_back(2.0 * value); + } return cache; } @@ -243,7 +245,7 @@ void extrapolate(ExtrapolationTestProcess const& pcs, EXPECT_GT(tolerance_dx, dx_norm); } -} // anonymous namespace +} // namespace ExtrapolationTest #ifndef USE_PETSC TEST(NumLib, Extrapolation) diff --git a/Tests/NumLib/TestFe.cpp b/Tests/NumLib/TestFe.cpp index 59ddcc0c164048c5626b631d78e4d97cb15403f7..2d5351dffcd91c2b3e39673758ed8127a7ab446a 100644 --- a/Tests/NumLib/TestFe.cpp +++ b/Tests/NumLib/TestFe.cpp @@ -71,7 +71,7 @@ using TestTypes = TestCase<TestFeQUAD4, EigenFixedShapeMatrixPolicy>, TestCase<TestFeTET4, EigenFixedShapeMatrixPolicy>, TestCase<TestFeTRI3, EigenFixedShapeMatrixPolicy>>; -} +} // namespace template <class T> class NumLibFemIsoTest : public ::testing::Test, public T::TestFeType @@ -131,16 +131,24 @@ class NumLibFemIsoTest : public ::testing::Test, public T::TestFeType // for destructor vec_eles.push_back(mesh_element); for (auto e : vec_eles) + { for (unsigned i = 0; i < e->getNumberOfNodes(); i++) + { vec_nodes.push_back(e->getNode(i)); + } + } } ~NumLibFemIsoTest() override { for (auto itr = vec_nodes.begin(); itr != vec_nodes.end(); ++itr) + { delete *itr; + } for (auto itr = vec_eles.begin(); itr != vec_eles.end(); ++itr) + { delete *itr; + } } diff --git a/Tests/NumLib/TestGradShapeFunction.cpp b/Tests/NumLib/TestGradShapeFunction.cpp index 01c8bf2b60763c16f0227eea8002d11083e3071f..d05d1dbb4e7eb7f814b4cb52182fc696485969b8 100644 --- a/Tests/NumLib/TestGradShapeFunction.cpp +++ b/Tests/NumLib/TestGradShapeFunction.cpp @@ -98,7 +98,7 @@ using TestTypes = TestCase<TestFeTET10, EigenFixedShapeMatrixPolicy>, TestCase<TestFeTRI3, EigenFixedShapeMatrixPolicy>, TestCase<TestFeTRI6, EigenFixedShapeMatrixPolicy>>; -} +} // namespace template <class T> class GradShapeFunctionTest : public ::testing::Test, public T::TestFeType @@ -134,16 +134,24 @@ public: // only for destructor because class element has nodes in pointer type. vec_eles.push_back(mesh_element); for (auto e : vec_eles) + { for (unsigned i = 0; i < e->getNumberOfNodes(); i++) + { vec_nodes.push_back(e->getNode(i)); + } + } } ~GradShapeFunctionTest() override { for (auto itr = vec_nodes.begin(); itr != vec_nodes.end(); ++itr) + { delete *itr; + } for (auto itr = vec_eles.begin(); itr != vec_eles.end(); ++itr) + { delete *itr; + } } IntegrationMethod integration_method; diff --git a/Tests/NumLib/TestMeshComponentMap.cpp b/Tests/NumLib/TestMeshComponentMap.cpp index 37b0ef185930ddcf2df683cf4a2c3e3ffddc8efc..3fdcd6f7a741e7b97b2d696c74e3cf9a326e6b1c 100644 --- a/Tests/NumLib/TestMeshComponentMap.cpp +++ b/Tests/NumLib/TestMeshComponentMap.cpp @@ -267,8 +267,10 @@ TEST_F(NumLibMeshComponentMapTest, DISABLED_MulticomponentVariable) Location const l_boundary(boundary_mesh.getID(), MeshItemType::Node, id); for (auto const& c : selected_component_ids) + { EXPECT_EQ(cmap->getGlobalIndex(l_bulk, c), cmap_subset.getGlobalIndex(l_boundary, c)); + } } } @@ -307,7 +309,9 @@ TEST_F(NumLibMeshComponentMapTest, Location const l_boundary(boundary_mesh.getID(), MeshItemType::Node, id); for (auto const& c : selected_component_ids) + { EXPECT_EQ(cmap->getGlobalIndex(l_bulk, c), cmap_subset.getGlobalIndex(l_boundary, c)); + } } } diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index bc79134f9bbcbaba3ad222ad8539770f9db95777..335b5faca35f32bf110429373f3e7cb5fca2a28f 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -107,8 +107,10 @@ public: EXPECT_TRUE(loop.loop(t0, x0, t_end, delta_t, cb).error_norms_met); } - for (auto& x : sol.solutions) + for (auto& x : sol.solutions) + { MathLib::LinAlg::setLocalAccessibleVector(x); + } return sol; } diff --git a/Tests/NumLib/TestSerialExecutor.cpp b/Tests/NumLib/TestSerialExecutor.cpp index c54aa0500984dbd9fb5b23754cbe88faa0a24123..f231c353a134d9825dd1b17f62d91e238ddc0d3d 100644 --- a/Tests/NumLib/TestSerialExecutor.cpp +++ b/Tests/NumLib/TestSerialExecutor.cpp @@ -33,7 +33,10 @@ public: PtrContainer container; container.reserve(size); - for (auto& el : container_back) container.push_back(&el); + for (auto& el : container_back) + { + container.push_back(&el); + } cb(container, reference); diff --git a/Tests/NumLib/TestSerialLinearSolver.cpp b/Tests/NumLib/TestSerialLinearSolver.cpp index bdf3425d49d77686db7aa758aade0cc590ea1145..8b1bf6a737f8adc96d39083ba175178f06500847 100644 --- a/Tests/NumLib/TestSerialLinearSolver.cpp +++ b/Tests/NumLib/TestSerialLinearSolver.cpp @@ -139,10 +139,14 @@ TEST(NumLibSerialLinearSolver, Steady2DdiffusionQuadElem) // copy solution to double vector std::vector<double> solution(x->size()); for (GlobalIndexType i = 0; i < x->size(); ++i) + { solution[i] = (*x)[i]; + } ASSERT_ARRAY_NEAR(&ex1.exact_solutions[0], &solution[0], ex1.dim_eqs, 1.e-5); for (auto p : local_assemblers) + { delete p; + } } diff --git a/Tests/NumLib/TestShapeFunctions.cpp b/Tests/NumLib/TestShapeFunctions.cpp index a4e3c586f25f7d00f60833b47a8f55973ba48590..9aff183d2e12a098c4ec00d52f366de739384e79 100644 --- a/Tests/NumLib/TestShapeFunctions.cpp +++ b/Tests/NumLib/TestShapeFunctions.cpp @@ -52,7 +52,9 @@ struct NaturalPointGenerator std::is_same<ShapeFunction, NumLib::ShapeQuad9>::value || std::is_same<ShapeFunction, NumLib::ShapeHex8>::value || std::is_same<ShapeFunction, NumLib::ShapeHex20>::value) + { return tuple; + } if (std::is_same<ShapeFunction, NumLib::ShapeTri3>::value || std::is_same<ShapeFunction, NumLib::ShapeTri6>::value || std::is_same<ShapeFunction, NumLib::ShapeTet4>::value || @@ -69,9 +71,11 @@ struct NaturalPointGenerator if (std::accumulate(std::begin(mapped_tuple), std::end(mapped_tuple), 0.) > ShapeFunction::DIM / 2.) + { std::transform(std::begin(mapped_tuple), std::end(mapped_tuple), std::begin(mapped_tuple), [](double const& v) { return 1. - v; }); + } return mapped_tuple; } OGS_FATAL("NaturalPointGenerator: Unknown shape function type."); @@ -83,7 +87,7 @@ struct NaturalPointGenerator } }; -} +} // namespace autocheck namespace ac = autocheck; using namespace NumLib; diff --git a/Tests/NumLib/TestSpatialFunction.cpp b/Tests/NumLib/TestSpatialFunction.cpp index 8aeb8e77c79f67e09e9e9381b292944ac0cdd15d..5307bd20373ecc43c3ab994ac0a5b000cdbcd746 100644 --- a/Tests/NumLib/TestSpatialFunction.cpp +++ b/Tests/NumLib/TestSpatialFunction.cpp @@ -36,7 +36,9 @@ TEST(NumLib, SpatialFunctionLinear) { GeoLib::Point pt(0, 0, 0); for (unsigned i = 0; i < 3; ++i) - pt[i] = (double) rand() - (RAND_MAX / 2.0); + { + pt[i] = (double)rand() - (RAND_MAX / 2.0); + } double expected = 1+2*pt[0]+3*pt[1]+4*pt[2]; ASSERT_DOUBLE_EQ(expected, f(pt)); } @@ -59,8 +61,10 @@ TEST(NumLib, SpatialFunctionInterpolationPolyline) ply0, vec_point_ids, vec_point_values, std::numeric_limits<double>::epsilon(), std::numeric_limits<double>::max()); // normal - for (unsigned k=0; k<10; k++) - ASSERT_DOUBLE_EQ(k*10., interpolate(GeoLib::Point(k,0,0))); + for (unsigned k = 0; k < 10; k++) + { + ASSERT_DOUBLE_EQ(k * 10., interpolate(GeoLib::Point(k, 0, 0))); + } // failure // x diff --git a/Tests/NumLib/TimeLoopSingleODE.h b/Tests/NumLib/TimeLoopSingleODE.h index 5b370a6feb50faba7c7ee56c7880ef17d6a88dbf..55bac5c8f669b95a187c2cffa4cc7e0e37e23f60 100644 --- a/Tests/NumLib/TimeLoopSingleODE.h +++ b/Tests/NumLib/TimeLoopSingleODE.h @@ -115,7 +115,9 @@ NumLib::NonlinearSolverStatus TimeLoopSingleODE<NLTag>::loop( nonlinear_solver_status = _nonlinear_solver->solve(x, nullptr); if (!nonlinear_solver_status.error_norms_met) + { break; + } time_disc.pushState(t, x, _ode_sys); diff --git a/Tests/NumLib/TimeSteppingTestingTools.h b/Tests/NumLib/TimeSteppingTestingTools.h index b499a760d421618391ea6c68b107f0498533bb47..1dd7982d4c3785209cbbe72872dd60b5bb238e10 100644 --- a/Tests/NumLib/TimeSteppingTestingTools.h +++ b/Tests/NumLib/TimeSteppingTestingTools.h @@ -44,7 +44,9 @@ std::vector<double> timeStepping(T_TIME_STEPPING& algorithm, NumLib::TimeStep t = algorithm.getTimeStep(); //INFO("t: n=%d,t=%g,dt=%g", t.steps(), t.current(), t.dt()); if (obj) - (*obj)(algorithm); // do something + { + (*obj)(algorithm); // do something + } if (algorithm.accepted()) { vec_t.push_back(t.current()); } else { diff --git a/Tests/ProcessLib/LIE/TestLIE.cpp b/Tests/ProcessLib/LIE/TestLIE.cpp index eaef9e7883b4654274846d3512ff4e62d1e6f0b5..ec8e8b7bb616f3ecbcfec59f838a92e366414eb0 100644 --- a/Tests/ProcessLib/LIE/TestLIE.cpp +++ b/Tests/ProcessLib/LIE/TestLIE.cpp @@ -28,7 +28,9 @@ std::unique_ptr<MeshLib::Mesh> createTriangle( { auto** nodes = new MeshLib::Node*[3]; for (std::size_t i = 0; i < points.size(); ++i) + { nodes[i] = new MeshLib::Node(points[i]); + } MeshLib::Element* e = new MeshLib::Tri(nodes); return std::make_unique<MeshLib::Mesh>( @@ -41,7 +43,9 @@ std::unique_ptr<MeshLib::Mesh> createLine( { auto** nodes = new MeshLib::Node*[2]; for (std::size_t i = 0; i < points.size(); ++i) + { nodes[i] = new MeshLib::Node(points[i]); + } MeshLib::Element* e = new MeshLib::Line(nodes); return std::make_unique<MeshLib::Mesh>( @@ -51,7 +55,7 @@ std::unique_ptr<MeshLib::Mesh> createLine( const double eps = std::numeric_limits<double>::epsilon(); -} +} // namespace TEST(LIE, rotationMatrixXYTriangle) { diff --git a/Tests/ProcessLib/TestJacobianAssembler.cpp b/Tests/ProcessLib/TestJacobianAssembler.cpp index bb98764cc165f7d991eb33d56babb0d719f11fc0..9b63e22baedb49a870ee050bb402b7d37ddbce5c 100644 --- a/Tests/ProcessLib/TestJacobianAssembler.cpp +++ b/Tests/ProcessLib/TestJacobianAssembler.cpp @@ -168,8 +168,10 @@ struct MatDiagXSquared auto mat = MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); - for (std::size_t i=0; i<x_data.size(); ++i) + for (std::size_t i = 0; i < x_data.size(); ++i) + { mat(i, i) = x_data[i] * x_data[i]; + } } // dM/dx * y = diag(2*x*X, 2*y*Y, 2*z*Z, ...) @@ -180,8 +182,10 @@ struct MatDiagXSquared auto dMdxTy = MathLib::createZeroedMatrix(dMdxTy_data, x_data.size(), x_data.size()); - for (std::size_t i=0; i<x_data.size(); ++i) + for (std::size_t i = 0; i < x_data.size(); ++i) + { dMdxTy(i, i) = 2.0 * x_data[i] * y_data[i]; + } } }; @@ -193,7 +197,9 @@ struct VecXSquared { vec_data = x_data; for (auto& v : vec_data) + { v *= v; + } } // dv/dx = diag(2x, 2y, 2z, ...) @@ -521,22 +527,28 @@ private: if (LocAsm::asmM) { ASSERT_EQ(x.size()*x.size(), M_data_cd.size()); ASSERT_EQ(x.size()*x.size(), M_data_ana.size()); - for (std::size_t i=0; i<x.size()*x.size(); ++i) + for (std::size_t i = 0; i < x.size() * x.size(); ++i) + { EXPECT_NEAR(M_data_ana[i], M_data_cd[i], eps); + } } if (LocAsm::asmK) { ASSERT_EQ(x.size()*x.size(), K_data_cd.size()); ASSERT_EQ(x.size()*x.size(), K_data_ana.size()); - for (std::size_t i=0; i<x.size()*x.size(); ++i) + for (std::size_t i = 0; i < x.size() * x.size(); ++i) + { EXPECT_NEAR(K_data_ana[i], K_data_cd[i], eps); + } } if (LocAsm::asmb) { ASSERT_EQ(x.size(), b_data_cd.size()); ASSERT_EQ(x.size(), b_data_ana.size()); - for (std::size_t i=0; i<x.size(); ++i) + for (std::size_t i = 0; i < x.size(); ++i) + { EXPECT_NEAR(b_data_ana[i], b_data_cd[i], eps); + } } ASSERT_EQ(x.size()*x.size(), Jac_data_cd.size()); diff --git a/Tests/testrunner.cpp b/Tests/testrunner.cpp index 55f70ce13860237383d24b1e3d9d4069446cd066..8ea08406c875fe3fbbce36dabcc969cc159da80e 100644 --- a/Tests/testrunner.cpp +++ b/Tests/testrunner.cpp @@ -37,10 +37,14 @@ int main(int argc, char* argv[]) #endif for (int i = 1; i < argc; i++) { - if(i + 1 == argc) + if (i + 1 == argc) + { break; - if(std::strcmp(argv[i], "-l") == 0) + } + if (std::strcmp(argv[i], "-l") == 0) + { logLevel = argv[i + 1]; + } } setlocale(LC_ALL, "C"); diff --git a/scripts/cmake/MetisSetup.cmake b/scripts/cmake/MetisSetup.cmake index 0f07f424c12911f025fe9e72aef035e97c734a83..5ed1234541a482f91f9f3c55dc871c053666826a 100644 --- a/scripts/cmake/MetisSetup.cmake +++ b/scripts/cmake/MetisSetup.cmake @@ -23,6 +23,9 @@ include_directories(BEFORE ${METIS_PATH}/libmetis) file(GLOB metis_sources ${METIS_PATH}/libmetis/*.c) # Build libmetis. add_library(metis ${GKlib_sources} ${metis_sources}) +if(OPENMP_FOUND) + target_link_libraries(metis OpenMP::OpenMP_C) +endif() if(BUILD_SHARED_LIBS) install(TARGETS metis LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() diff --git a/scripts/docker/Dockerfile.clang.full b/scripts/docker/Dockerfile.clang.full index ea6ed90e84240b0f9b84c6a742c847e95aeff4c7..ad86bb7ce4455fa617ce5d1055e8c828b8e9f452 100644 --- a/scripts/docker/Dockerfile.clang.full +++ b/scripts/docker/Dockerfile.clang.full @@ -1,6 +1,6 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 -# Generated with https://github.com/ufz/ogs-container-maker/commit/0930f12 +# Generated with https://github.com/ufz/ogs-container-maker/commit/7790259 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -12,14 +12,15 @@ RUN apt-get update -y && \ # LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - clang-5.0 && \ + clang-7 && \ rm -rf /var/lib/apt/lists/* -RUN update-alternatives --install /usr/bin/clang clang $(which clang-5.0) 30 && \ - update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-5.0) 30 +RUN update-alternatives --install /usr/bin/clang clang $(which clang-7) 30 && \ + update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-7) 30 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - clang-tidy-5.0 && \ + clang-tidy-7 \ + clang-format-7 && \ rm -rf /var/lib/apt/lists/* # OGS base building block @@ -45,7 +46,8 @@ RUN apt-get update -y && \ RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://cmake.org/files/v3.13/cmake-3.13.4-Linux-x86_64.sh && \ /bin/sh /var/tmp/cmake-3.13.4-Linux-x86_64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.13.4-Linux-x86_64.sh -RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN apt-get update && \ + curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common && \ apt-add-repository ppa:git-core/ppa -y && \ @@ -75,19 +77,19 @@ LABEL org.opengeosys.pm=conan \ org.opengeosys.pm.conan.user_home=/opt/conan \ org.opengeosys.pm.conan.version=1.12.2 -# Include-what-you-use for clang version 5.0 +# Include-what-you-use for clang version 7 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ libncurses5-dev \ zlib1g-dev \ - llvm-5.0-dev \ - libclang-5.0-dev && \ + llvm-7-dev \ + libclang-7-dev && \ rm -rf /var/lib/apt/lists/* -RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/include-what-you-use/include-what-you-use/archive/clang_5.0.tar.gz && \ - mkdir -p /var/tmp && tar -x -f /var/tmp/clang_5.0.tar.gz -C /var/tmp -z && \ - mkdir -p /var/tmp/build && cd /var/tmp/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/iwyy -DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-5.0 /var/tmp/include-what-you-use-clang_5.0 && \ +RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/include-what-you-use/include-what-you-use/archive/clang_7.0.tar.gz && \ + mkdir -p /var/tmp && tar -x -f /var/tmp/clang_7.0.tar.gz -C /var/tmp -z && \ + mkdir -p /var/tmp/build && cd /var/tmp/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/iwyy -DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-7 /var/tmp/include-what-you-use-clang_7.0 && \ cmake --build /var/tmp/build --target install -- -j$(nproc) && \ - rm -rf /var/tmp/clang_5.0.tar.gz /var/tmp/build /var/tmp/include-what-you-use-clang_5.0 + rm -rf /var/tmp/clang_7.0.tar.gz /var/tmp/build /var/tmp/include-what-you-use-clang_7.0 ENV PATH=/usr/local/iwyy/bin:$PATH # Package manager Conan building block @@ -102,6 +104,11 @@ ENV CCACHE_DIR=/opt/cache \ LABEL ccache.dir=/opt/cache \ ccache.size=15G +RUN apt-get update -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + sudo && \ + rm -rf /var/lib/apt/lists/* + # Jenkins node RUN groupadd --gid 1001 jenkins && \ adduser --uid 500 --gid 1001 --disabled-password --gecos "" jenkins && \ diff --git a/scripts/docker/Dockerfile.clang.minimal b/scripts/docker/Dockerfile.clang.minimal index 82f4eb825da0af3f3fb3d80d3ad65c80aeafc933..dc26c2e555b3887fe5972ebd65b6f0b0bb499259 100644 --- a/scripts/docker/Dockerfile.clang.minimal +++ b/scripts/docker/Dockerfile.clang.minimal @@ -1,6 +1,6 @@ -FROM ubuntu:17.10 +FROM ubuntu:18.04 -# Generated with https://github.com/ufz/ogs-container-maker/commit/0930f12 +# Generated with https://github.com/ufz/ogs-container-maker/commit/7790259 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -12,14 +12,15 @@ RUN apt-get update -y && \ # LLVM compiler RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - clang-5.0 && \ + clang-7 && \ rm -rf /var/lib/apt/lists/* -RUN update-alternatives --install /usr/bin/clang clang $(which clang-5.0) 30 && \ - update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-5.0) 30 +RUN update-alternatives --install /usr/bin/clang clang $(which clang-7) 30 && \ + update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-7) 30 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - clang-tidy-5.0 && \ + clang-tidy-7 \ + clang-format-7 && \ rm -rf /var/lib/apt/lists/* # OGS base building block @@ -45,7 +46,8 @@ RUN apt-get update -y && \ RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://cmake.org/files/v3.13/cmake-3.13.4-Linux-x86_64.sh && \ /bin/sh /var/tmp/cmake-3.13.4-Linux-x86_64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.13.4-Linux-x86_64.sh -RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN apt-get update && \ + curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common && \ apt-add-repository ppa:git-core/ppa -y && \ @@ -87,6 +89,11 @@ ENV CCACHE_DIR=/opt/cache \ LABEL ccache.dir=/opt/cache \ ccache.size=15G +RUN apt-get update -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + sudo && \ + rm -rf /var/lib/apt/lists/* + # Jenkins node RUN groupadd --gid 1001 jenkins && \ adduser --uid 500 --gid 1001 --disabled-password --gecos "" jenkins && \ diff --git a/scripts/docker/Dockerfile.gcc.full b/scripts/docker/Dockerfile.gcc.full index 9f0bc50aaac2d60e52027cd014a2ff974741f34e..a241e31ac54fa8d30a59c1486765e47993036598 100644 --- a/scripts/docker/Dockerfile.gcc.full +++ b/scripts/docker/Dockerfile.gcc.full @@ -1,6 +1,6 @@ FROM ubuntu:17.10 -# Generated with https://github.com/ufz/ogs-container-maker/commit/0930f12 +# Generated with https://github.com/ufz/ogs-container-maker/commit/1f5dba5 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -47,7 +47,8 @@ RUN apt-get update -y && \ RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://cmake.org/files/v3.13/cmake-3.13.4-Linux-x86_64.sh && \ /bin/sh /var/tmp/cmake-3.13.4-Linux-x86_64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.13.4-Linux-x86_64.sh -RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN apt-get update && \ + curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common && \ apt-add-repository ppa:git-core/ppa -y && \ @@ -77,15 +78,6 @@ LABEL org.opengeosys.pm=conan \ org.opengeosys.pm.conan.user_home=/opt/conan \ org.opengeosys.pm.conan.version=1.12.2 -# CVode version 2.8.2 - -RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/ufz/cvode/archive/2.8.2.tar.gz && \ - mkdir -p /var/tmp && tar -x -f /var/tmp/2.8.2.tar.gz -C /var/tmp -z && \ - mkdir -p /var/tmp/build && cd /var/tmp/build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local/cvode -DEXAMPLES_INSTALL=OFF -DBUILD_SHARED_LIBS=OFF /var/tmp/cvode-2.8.2 && \ - cmake --build /var/tmp/build --target install -- -j$(nproc) && \ - rm -rf /var/tmp/2.8.2.tar.gz /var/tmp/build /var/tmp/cvode-2.8.2 -ENV CVODE_ROOT=/usr/local/cvode - # cppcheck version 1.83 RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://github.com/danmar/cppcheck/archive/1.83.tar.gz && \ @@ -99,8 +91,7 @@ RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ doxygen \ graphviz \ - texlive-base \ - sudo && \ + texlive-base && \ rm -rf /var/lib/apt/lists/* # pip @@ -124,6 +115,11 @@ ENV CCACHE_DIR=/opt/cache \ LABEL ccache.dir=/opt/cache \ ccache.size=15G +RUN apt-get update -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + sudo && \ + rm -rf /var/lib/apt/lists/* + # Jenkins node RUN groupadd --gid 1001 jenkins && \ adduser --uid 500 --gid 1001 --disabled-password --gecos "" jenkins && \ diff --git a/scripts/docker/Dockerfile.gcc.gui b/scripts/docker/Dockerfile.gcc.gui index 486b6b5dc92e41423aa62a3fa2fbf8730fb3fe79..3263de16f33bed7badf0f581e1f127d77a17558b 100644 --- a/scripts/docker/Dockerfile.gcc.gui +++ b/scripts/docker/Dockerfile.gcc.gui @@ -1,6 +1,6 @@ FROM ubuntu:17.10 -# Generated with https://github.com/ufz/ogs-container-maker/commit/0930f12 +# Generated with https://github.com/ufz/ogs-container-maker/commit/1f5dba5 RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -47,7 +47,8 @@ RUN apt-get update -y && \ RUN mkdir -p /var/tmp && wget -q -nc --no-check-certificate -P /var/tmp https://cmake.org/files/v3.13/cmake-3.13.4-Linux-x86_64.sh && \ /bin/sh /var/tmp/cmake-3.13.4-Linux-x86_64.sh --prefix=/usr/local --skip-license && \ rm -rf /var/tmp/cmake-3.13.4-Linux-x86_64.sh -RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash +RUN apt-get update && \ + curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash RUN apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common && \ apt-add-repository ppa:git-core/ppa -y && \ @@ -96,6 +97,11 @@ ENV CCACHE_DIR=/opt/cache \ LABEL ccache.dir=/opt/cache \ ccache.size=15G +RUN apt-get update -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + sudo && \ + rm -rf /var/lib/apt/lists/* + # Jenkins node RUN groupadd --gid 1001 jenkins && \ adduser --uid 500 --gid 1001 --disabled-password --gecos "" jenkins && \