diff --git a/Applications/FileIO/Legacy/OGSIOVer4.cpp b/Applications/FileIO/Legacy/OGSIOVer4.cpp index 39fedc30652f8469273142dfd69df88f60dba8d5..d8e9aef6f914136b41566cc03245f501e2f09fa0 100644 --- a/Applications/FileIO/Legacy/OGSIOVer4.cpp +++ b/Applications/FileIO/Legacy/OGSIOVer4.cpp @@ -310,7 +310,7 @@ std::string readSurface(std::istream& in, std::vector& polygon_vec, std::vector& sfc_vec, std::map& sfc_names, - const std::vector& ply_vec, + const std::vector* const ply_vec, const std::map& ply_vec_names, GeoLib::PointVec& pnt_vec, std::string const& path, std::vector& errors) @@ -367,6 +367,11 @@ std::string readSurface(std::istream& in, (line.find('#') == std::string::npos) && (line.find('$') == std::string::npos)) { + if (ply_vec == nullptr) + { + OGS_FATAL("The polyline vector is not allocated."); + } + // we did read the name of a polyline -> search the id for // polyline auto it(ply_vec_names.find(line)); @@ -376,10 +381,10 @@ std::string readSurface(std::istream& in, } else { - ply_id = ply_vec.size(); + ply_id = ply_vec->size(); } - if (ply_id == ply_vec.size()) + if (ply_id == ply_vec->size()) { WARN("readSurface(): polyline for surface not found!"); errors.emplace_back( @@ -426,20 +431,27 @@ std::string readSurface(std::istream& in, else { // surface created by polygon - if (ply_id != std::numeric_limits::max() && - ply_id != ply_vec.size()) + if (ply_id != std::numeric_limits::max()) { - if (ply_vec[ply_id]->isClosed()) + if (ply_vec == nullptr) { - polygon_vec.push_back( - new GeoLib::Polygon(*(ply_vec[ply_id]), true)); + OGS_FATAL("The polyline vector is not allocated."); } - else + + if (ply_id != ply_vec->size()) { - WARN( - "readSurface(): cannot create surface {:s} from polyline " - "{:d} since polyline is not closed.", - name, ply_id); + if ((*ply_vec)[ply_id]->isClosed()) + { + polygon_vec.push_back( + new GeoLib::Polygon(*((*ply_vec)[ply_id]), true)); + } + else + { + WARN( + "readSurface(): cannot create surface {:s} from " + "polyline {:d} since polyline is not closed.", + name, ply_id); + } } } } @@ -458,7 +470,7 @@ std::string readSurface(std::istream& in, std::string readSurfaces( std::istream& in, std::vector& sfc_vec, std::map& sfc_names, - const std::vector& ply_vec, + const std::vector* const ply_vec, const std::map& ply_vec_names, GeoLib::PointVec& pnt_vec, const std::string& path, std::vector& errors, GeoLib::GEOObjects& geo, @@ -587,7 +599,7 @@ bool readGLIFileV4(const std::string& fname, { INFO("GeoLib::readGLIFile(): read surfaces from stream."); - readSurfaces(in, sfc_vec, sfc_names, *geo.getPolylineVec(unique_name), + readSurfaces(in, sfc_vec, sfc_names, geo.getPolylineVec(unique_name), ply_names_copy, point_vec, path, errors, geo, unique_name, gmsh_path); INFO("GeoLib::readGLIFile(): \tok, {:d} surfaces read.", diff --git a/Applications/Utils/GeoTools/generateGeometry.cpp b/Applications/Utils/GeoTools/generateGeometry.cpp index 2f55b02e77c7dcea0ce9b53fbe12ee8fa896e7a2..ab714d56a2e0aad6f31dd27983b66bf84ca88708 100644 --- a/Applications/Utils/GeoTools/generateGeometry.cpp +++ b/Applications/Utils/GeoTools/generateGeometry.cpp @@ -85,6 +85,8 @@ std::vector generateQuadPoints( begin, end, number_of_subdivisions); quad_points.insert(quad_points.end(), intermediate_points.begin(), --intermediate_points.end()); + delete intermediate_points.back(); // Release last point, other points + // are managed by GEOObjects. }; addPointsOnLine(points[0], points[1], number_of_subdivisions_per_edge[0]); diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index 9de23263070bee61c4ab9c706917206e5a71acac..2ad862e7e4eda7c24dade7d90bca9060a11013c8 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -308,6 +308,11 @@ PhreeqcIO::PhreeqcIO(GlobalLinearSolver& linear_solver, } } +PhreeqcIO::~PhreeqcIO() +{ + DestroyIPhreeqc(phreeqc_instance_id); +} + void PhreeqcIO::initialize() { _num_chemical_systems = chemical_system_index_map.size(); diff --git a/ChemistryLib/PhreeqcIO.h b/ChemistryLib/PhreeqcIO.h index 5b48e35d61d3f6391ae74b5fc46aaa3838a83a33..c0b35908a6db38209d8eea57ea0330dd6a650b3e 100644 --- a/ChemistryLib/PhreeqcIO.h +++ b/ChemistryLib/PhreeqcIO.h @@ -43,6 +43,8 @@ public: std::unique_ptr&& dump, Knobs&& knobs); + ~PhreeqcIO(); + void initialize() override; void initializeChemicalSystemConcrete( diff --git a/GeoLib/Raster.h b/GeoLib/Raster.h index 8fe81757d09d086b0b750bf6aba7acfba1f8f291..3c14cadb58f06295ced11b51699ec73b9117007d 100644 --- a/GeoLib/Raster.h +++ b/GeoLib/Raster.h @@ -65,6 +65,7 @@ public: static_cast(std::distance(begin, end)); if (number_of_input_values != _header.n_cols * _header.n_rows) { + delete[] _raster_data; throw std::out_of_range( "Number of raster data mismatch, need " + std::to_string(_header.n_cols * _header.n_rows) + diff --git a/NumLib/DOF/LocalToGlobalIndexMap.cpp b/NumLib/DOF/LocalToGlobalIndexMap.cpp index 7465e1d3ad5375fcd193398bb37b0ed96f28a8d4..2f8abfbff8395852eda5ad7ed58d13726ef17e68 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.cpp +++ b/NumLib/DOF/LocalToGlobalIndexMap.cpp @@ -233,7 +233,8 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap( } } -LocalToGlobalIndexMap* LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( +std::unique_ptr +LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( int const variable_id, std::vector const& component_ids, MeshLib::MeshSubset&& new_mesh_subset) const @@ -269,7 +270,7 @@ LocalToGlobalIndexMap* LocalToGlobalIndexMap::deriveBoundaryConstrainedMap( } all_mesh_subsets.emplace_back(std::move(new_mesh_subset)); - return new LocalToGlobalIndexMap( + return std::make_unique( std::move(all_mesh_subsets), global_component_ids, _variable_component_offsets, elements, std::move(mesh_component_map), ConstructorTag{}); diff --git a/NumLib/DOF/LocalToGlobalIndexMap.h b/NumLib/DOF/LocalToGlobalIndexMap.h index 73ad9a138a4e2bc4400e0a089fd44daf230aa84d..6f0f3c731a229f4f0c0d1cafec41cd52a538b6a1 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.h +++ b/NumLib/DOF/LocalToGlobalIndexMap.h @@ -92,7 +92,7 @@ public: /// Derive a LocalToGlobalIndexMap constrained to the mesh subset and mesh /// subset's elements. A new mesh component map will be constructed using /// the passed mesh_subset for the given variable and component ids. - LocalToGlobalIndexMap* deriveBoundaryConstrainedMap( + std::unique_ptr deriveBoundaryConstrainedMap( int const variable_id, std::vector const& component_ids, MeshLib::MeshSubset&& new_mesh_subset) const; diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp index 75a20344b421c3d18fb8a62fbafe79dbf68c0606..deee0186bd235b5fac0d28e80c83cb6936c359ea 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/ConstraintDirichletBoundaryCondition.cpp @@ -63,8 +63,8 @@ ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition( // Create local DOF table from intersected mesh subsets for the given // variable and component ids. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - variable_id, {component_id}, std::move(bc_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + variable_id, {component_id}, std::move(bc_mesh_subset)); auto const& bc_elements(_bc_mesh.getElements()); _local_assemblers.resize(bc_elements.size()); diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/CreateSourceTerm.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/CreateSourceTerm.cpp index a31c1ce3770de9e43a31fe2d0e6db947f0eabea5..9ddb5e57ab4e478a7f405438290b9eb3358c8cde 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/CreateSourceTerm.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/CreateSourceTerm.cpp @@ -65,10 +65,10 @@ std::unique_ptr createSourceTerm( if (type == "Nodal") { - std::unique_ptr dof_table_source_term( + auto dof_table_source_term = dof_table_bulk.deriveBoundaryConstrainedMap( variable_id, {*config.component_id}, - std::move(source_term_mesh_subset))); + std::move(source_term_mesh_subset)); return ProcessLib::createNodalSourceTerm( config.config, config.mesh, std::move(dof_table_source_term), source_term_mesh.getID(), variable_id, *config.component_id, @@ -77,10 +77,10 @@ std::unique_ptr createSourceTerm( if (type == "Line" || type == "Volumetric") { - std::unique_ptr dof_table_source_term( + auto dof_table_source_term = dof_table_bulk.deriveBoundaryConstrainedMap( variable_id, {*config.component_id}, - std::move(source_term_mesh_subset))); + std::move(source_term_mesh_subset)); auto const& bulk_mesh_dimension = dof_table_bulk.getMeshSubset(variable_id, *config.component_id) .getMesh() @@ -94,9 +94,9 @@ std::unique_ptr createSourceTerm( if (type == "Python") { #ifdef OGS_USE_PYTHON - std::unique_ptr dof_table_source_term( + auto dof_table_source_term = dof_table_bulk.deriveBoundaryConstrainedMap( - std::move(source_term_mesh_subset))); + std::move(source_term_mesh_subset)); return ProcessLib::createPythonSourceTerm( config.config, config.mesh, std::move(dof_table_source_term), diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp index f6d9a30cda701cc0c6f8ed5d3dd588205106bdf9..34ae8e52d8342f691bfdb68d33631c34534b0097 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/DeactivatedSubdomainDirichlet.cpp @@ -47,8 +47,8 @@ void DeactivatedSubdomainDirichlet::config( // Create local DOF table from the BC mesh subset for the given variable // and component id. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - _variable_id, {_component_id}, std::move(subdomain_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + _variable_id, {_component_id}, std::move(subdomain_mesh_subset)); } void DeactivatedSubdomainDirichlet::getEssentialBCValues( diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryCondition.cpp index 61c37a656f17076f03b72c6c59d45c682217f198..58f17b8c893cc01b093404d0ee819c7002cb3180 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryCondition.cpp @@ -41,8 +41,8 @@ DirichletBoundaryCondition::DirichletBoundaryCondition( // Create local DOF table from the BC mesh subset for the given variable // and component id. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - variable_id, {component_id}, std::move(bc_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + variable_id, {component_id}, std::move(bc_mesh_subset)); } void DirichletBoundaryCondition::getEssentialBCValues( diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryConditionWithinTimeInterval.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryConditionWithinTimeInterval.cpp index 0061e6142ab6f90e939b7c437a83808295eb1672..80e0e7f43ce7426a93c752125935adb5e1c414eb 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryConditionWithinTimeInterval.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/DirichletBoundaryConditionWithinTimeInterval.cpp @@ -47,8 +47,8 @@ void DirichletBoundaryConditionWithinTimeInterval::config( // Create local DOF table from the BC mesh subset for the given variable // and component id. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - _variable_id, {_component_id}, std::move(bc_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + _variable_id, {_component_id}, std::move(bc_mesh_subset)); } void DirichletBoundaryConditionWithinTimeInterval::getEssentialBCValues( diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/GenericNaturalBoundaryCondition-impl.h b/ProcessLib/BoundaryConditionAndSourceTerm/GenericNaturalBoundaryCondition-impl.h index 1d997e15f31751e63c051c081245fc22f3833acc..2bbda253f1ddb6694662ccea41ecfb3b560845d8 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/GenericNaturalBoundaryCondition-impl.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/GenericNaturalBoundaryCondition-impl.h @@ -62,8 +62,8 @@ GenericNaturalBoundaryCondition( diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/NormalTractionBoundaryCondition-impl.h b/ProcessLib/BoundaryConditionAndSourceTerm/NormalTractionBoundaryCondition-impl.h index f74824c975e139d41bd9c8af51b0655e1fc849b6..d5171a21cdb818aa042e664976df49949ac2ef2a 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/NormalTractionBoundaryCondition-impl.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/NormalTractionBoundaryCondition-impl.h @@ -48,8 +48,8 @@ NormalTractionBoundaryCondition:: // Create local DOF table from the BC mesh subset for the given variable and // component ids. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - variable_id, component_ids, std::move(bc_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + variable_id, component_ids, std::move(bc_mesh_subset)); BoundaryConditionAndSourceTerm::detail::createLocalAssemblers< GlobalDim, LocalAssemblerImplementation>( diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/PrimaryVariableConstraintDirichletBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/PrimaryVariableConstraintDirichletBoundaryCondition.cpp index 220e13b398ed73adcfa3f3aa74a8aeae05935209..5d6a0381f1252812c60e4f18f123b07c02c9ffda 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/PrimaryVariableConstraintDirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/PrimaryVariableConstraintDirichletBoundaryCondition.cpp @@ -47,8 +47,8 @@ PrimaryVariableConstraintDirichletBoundaryCondition:: // Create local DOF table from the BC mesh subset for the given variable // and component id. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - variable_id, {component_id}, std::move(bc_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + variable_id, {component_id}, std::move(bc_mesh_subset)); } void PrimaryVariableConstraintDirichletBoundaryCondition::getEssentialBCValues( diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/SolutionDependentDirichletBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/SolutionDependentDirichletBoundaryCondition.cpp index 07aa6d68218a79764c25834350821d34cdbf5018..59b5f10fac0968007eda3791fb421a060f95354d 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/SolutionDependentDirichletBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/SolutionDependentDirichletBoundaryCondition.cpp @@ -39,8 +39,8 @@ SolutionDependentDirichletBoundaryCondition:: // Create local DOF table from the BC mesh subset for the given variable // and component id. - _dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap( - variable_id, {component_id}, std::move(bc_mesh_subset))); + _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap( + variable_id, {component_id}, std::move(bc_mesh_subset)); if (bc_mesh.getProperties().existsPropertyVector(property_name)) { diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryCondition.cpp b/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryCondition.cpp index 861b2e963a7f9083f31464f7dfdfa3254d5c3331..64d5ed10f11e6c13addec9e53eda74a564bb21f7 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryCondition.cpp +++ b/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryCondition.cpp @@ -74,8 +74,8 @@ createVariableDependentNeumannBoundaryCondition( std::vector const& bc_nodes = bc_mesh.getNodes(); MeshLib::MeshSubset bc_mesh_subset(bc_mesh, bc_nodes); - auto const& dof_table_boundary_other_variable = - *dof_table.deriveBoundaryConstrainedMap( + auto dof_table_boundary_other_variable = + dof_table.deriveBoundaryConstrainedMap( (variable_id + 1) % 2, {component_id}, std::move(bc_mesh_subset)); // In case of partitioned mesh the boundary could be empty, i.e. there is no @@ -97,7 +97,8 @@ createVariableDependentNeumannBoundaryCondition( component_id, global_dim, bc_mesh, VariableDependentNeumannBoundaryConditionData{ constant, coefficient_current_variable, coefficient_other_variable, - coefficient_mixed_variables, dof_table_boundary_other_variable}); + coefficient_mixed_variables, + std::move(dof_table_boundary_other_variable)}); } } // namespace ProcessLib diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryConditionLocalAssembler.h b/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryConditionLocalAssembler.h index 8866826090198d962aade1c4962b819378b663b6..495dd3ee31bbd98d471bb68a808cbeca75bcd8f8 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryConditionLocalAssembler.h +++ b/ProcessLib/BoundaryConditionAndSourceTerm/VariableDependentNeumannBoundaryConditionLocalAssembler.h @@ -25,7 +25,8 @@ struct VariableDependentNeumannBoundaryConditionData ParameterLib::Parameter const& coefficient_other_variable; ParameterLib::Parameter const& coefficient_mixed_variables; // Used for mapping boundary nodes to bulk nodes. - NumLib::LocalToGlobalIndexMap const& dof_table_boundary_other_variable; + std::unique_ptr + dof_table_boundary_other_variable; }; template @@ -84,7 +85,7 @@ public: auto const indices_current_variable = NumLib::getIndices(mesh_item_id, dof_table_boundary); auto const indices_other_variable = NumLib::getIndices( - mesh_item_id, _data.dof_table_boundary_other_variable); + mesh_item_id, *_data.dof_table_boundary_other_variable); std::vector const local_current_variable = x[process_id]->get(indices_current_variable); std::vector const local_other_variable = diff --git a/Tests/NumLib/LocalToGlobalIndexMap.cpp b/Tests/NumLib/LocalToGlobalIndexMap.cpp index 8d6528da1576950e22b56ae99bbd5d3452b8c5e2..0f19c92faa24b6e0727025a9a7d66479f6156f80 100644 --- a/Tests/NumLib/LocalToGlobalIndexMap.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMap.cpp @@ -111,10 +111,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_SubsetByComponent) MeshLib::MeshSubset selected_component(*boundary_mesh, boundary_mesh->getNodes()); - auto dof_map_subset = std::unique_ptr{ + auto dof_map_subset = dof_map->deriveBoundaryConstrainedMap(1, // variable id {0}, // component id - std::move(selected_component))}; + std::move(selected_component)); // There must be as many rows as nodes in the input times the number of // components. diff --git a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp index 314a251df777ca8f4f4e346ee00bdb2438edd7f5..77d0468c025a7a639a46bd92ebaca8c711d6669c 100644 --- a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp @@ -90,10 +90,10 @@ public: MeL::MeshSubset components_boundary{*mesh_items_boundary}; - dof_map_boundary.reset(dof_map->deriveBoundaryConstrainedMap( + dof_map_boundary = dof_map->deriveBoundaryConstrainedMap( 0, // variable id {selected_component}, - std::move(components_boundary))); + std::move(components_boundary)); } // Multi-component version. @@ -114,10 +114,10 @@ public: MeL::MeshSubset components_boundary{*mesh_items_boundary}; - dof_map_boundary.reset(dof_map->deriveBoundaryConstrainedMap( + dof_map_boundary = dof_map->deriveBoundaryConstrainedMap( 0, // variable id selected_components, - std::move(components_boundary))); + std::move(components_boundary)); } template