diff --git a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp index 0907d6069ea6090e647b6533e562ce807f299c55..f856bd08bf350ec11dd0c8c6b1224195f1de28bd 100644 --- a/MeshLib/MeshEditing/ConvertToLinearMesh.cpp +++ b/MeshLib/MeshEditing/ConvertToLinearMesh.cpp @@ -95,7 +95,7 @@ std::unique_ptr<MeshLib::Mesh> convertToLinearMesh(MeshLib::Mesh const& org_mesh // copy only base node values for (unsigned i=0; i<org_mesh.getNumberOfBaseNodes(); i++) { - for (unsigned j=0; j<n_src_comp; j++) + for (int j = 0; j < n_src_comp; j++) (*new_prop)[i*n_src_comp+j] = (*src_prop)[i*n_src_comp+j]; } } diff --git a/MeshLib/PropertyVector.h b/MeshLib/PropertyVector.h index a7ed674afee0c57748ea4959ff2072651d0bed92..12ca85b9f92e5b64d11c5751a9d7544c8069c00f 100644 --- a/MeshLib/PropertyVector.h +++ b/MeshLib/PropertyVector.h @@ -33,7 +33,7 @@ public: MeshItemType getMeshItemType() const { return _mesh_item_type; } std::string const& getPropertyName() const { return _property_name; } - std::size_t getNumberOfComponents() const { return _n_components; } + int getNumberOfComponents() const { return _n_components; } protected: PropertyVectorBase(std::string property_name, @@ -44,7 +44,7 @@ protected: _property_name(std::move(property_name)) {} - std::size_t const _n_components; + int const _n_components; MeshItemType const _mesh_item_type; std::string const _property_name; }; @@ -174,7 +174,7 @@ public: void initPropertyValue(std::size_t group_id, std::vector<T> const& values) { - if (_n_components != values.size()) + 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*>"); diff --git a/NumLib/DOF/DOFTableUtil.cpp b/NumLib/DOF/DOFTableUtil.cpp index c7b22f5b09fb301120dac1be31c677febd6c225a..5c4472af284f84d6fcf12fc0afd1425c20d5a951 100644 --- a/NumLib/DOF/DOFTableUtil.cpp +++ b/NumLib/DOF/DOFTableUtil.cpp @@ -133,7 +133,8 @@ std::vector<GlobalIndexType> getIndices( // Local matrices and vectors will always be ordered by component // no matter what the order of the global matrix is. - for (unsigned c = 0; c < dof_table.getNumberOfComponents(); ++c) { + for (int c = 0; c < dof_table.getNumberOfComponents(); ++c) + { auto const& idcs = dof_table(mesh_item_id, c).rows; indices.reserve(indices.size() + idcs.size()); indices.insert(indices.end(), idcs.begin(), idcs.end()); @@ -152,7 +153,7 @@ NumLib::LocalToGlobalIndexMap::RowColumnIndices getRowColumnIndices( // Local matrices and vectors will always be ordered by component, // no matter what the order of the global matrix is. - for (unsigned c = 0; c < dof_table.getNumberOfComponents(); ++c) + for (int c = 0; c < dof_table.getNumberOfComponents(); ++c) { auto const& idcs = dof_table(id, c).rows; indices.reserve(indices.size() + idcs.size()); diff --git a/NumLib/DOF/LocalToGlobalIndexMap.cpp b/NumLib/DOF/LocalToGlobalIndexMap.cpp index 5c892d56c4b09e6efcf6a09567af0cf6ea86486b..18e6131bbfe28f1f734a2c3d975a3e5bf75476a7 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.cpp +++ b/NumLib/DOF/LocalToGlobalIndexMap.cpp @@ -31,11 +31,10 @@ std::vector<T> to_cumulative(std::vector<T> const& vec) } // no named namespace template <typename ElementIterator> -void -LocalToGlobalIndexMap::findGlobalIndicesWithElementID( +void LocalToGlobalIndexMap::findGlobalIndicesWithElementID( ElementIterator first, ElementIterator last, std::vector<MeshLib::Node*> const& nodes, std::size_t const mesh_id, - const unsigned comp_id, const unsigned comp_id_write) + const int comp_id, const int comp_id_write) { std::unordered_set<MeshLib::Node*> const set_nodes(nodes.begin(), nodes.end()); @@ -62,12 +61,11 @@ LocalToGlobalIndexMap::findGlobalIndicesWithElementID( } } - template <typename ElementIterator> void LocalToGlobalIndexMap::findGlobalIndices( ElementIterator first, ElementIterator last, std::vector<MeshLib::Node*> const& nodes, std::size_t const mesh_id, - const unsigned comp_id, const unsigned comp_id_write) + const int comp_id, const int comp_id_write) { _rows.resize(std::distance(first, last), _mesh_subsets.size()); @@ -100,13 +98,14 @@ void LocalToGlobalIndexMap::findGlobalIndices( LocalToGlobalIndexMap::LocalToGlobalIndexMap( std::vector<MeshLib::MeshSubsets>&& mesh_subsets, NumLib::ComponentOrder const order) - : LocalToGlobalIndexMap(std::move(mesh_subsets), std::vector<unsigned>(mesh_subsets.size(), 1), order) + : LocalToGlobalIndexMap(std::move(mesh_subsets), + std::vector<int>(mesh_subsets.size(), 1), order) { } LocalToGlobalIndexMap::LocalToGlobalIndexMap( std::vector<MeshLib::MeshSubsets>&& mesh_subsets, - std::vector<unsigned> const& vec_var_n_components, + std::vector<int> const& vec_var_n_components, NumLib::ComponentOrder const order) : _mesh_subsets(std::move(mesh_subsets)), _mesh_component_map(_mesh_subsets, order), @@ -144,7 +143,7 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap( LocalToGlobalIndexMap::LocalToGlobalIndexMap( std::vector<MeshLib::MeshSubsets>&& mesh_subsets, - std::vector<unsigned> const& vec_var_n_components, + std::vector<int> const& vec_var_n_components, std::vector<std::vector<MeshLib::Element*> const*> const& vec_var_elements, NumLib::ComponentOrder const order) : _mesh_subsets(std::move(mesh_subsets)), @@ -200,7 +199,7 @@ LocalToGlobalIndexMap::LocalToGlobalIndexMap( : _mesh_subsets(std::move(mesh_subsets)), _mesh_component_map(std::move(mesh_component_map)), _variable_component_offsets( - to_cumulative(std::vector<unsigned>(1, 1))) // Single variable only. + to_cumulative(std::vector<int>(1, 1))) // Single variable only. { // Each subset in the mesh_subsets represents a single component. if (_mesh_subsets.size() != global_component_ids.size()) @@ -272,8 +271,8 @@ LocalToGlobalIndexMap::size() const return _rows.rows(); } -LocalToGlobalIndexMap::RowColumnIndices -LocalToGlobalIndexMap::operator()(std::size_t const mesh_item_id, const unsigned component_id) const +LocalToGlobalIndexMap::RowColumnIndices LocalToGlobalIndexMap::operator()( + std::size_t const mesh_item_id, const int component_id) const { return RowColumnIndices(_rows(mesh_item_id, component_id), _columns(mesh_item_id, component_id)); @@ -334,7 +333,7 @@ std::ostream& operator<<(std::ostream& os, LocalToGlobalIndexMap const& map) for (std::size_t e=0; e<map.size(); ++e) { os << "== e " << e << " ==\n"; - for (std::size_t c=0; c<map.getNumberOfComponents(); ++c) + for (int c = 0; c < map.getNumberOfComponents(); ++c) { auto const& line = map._rows(e, c); diff --git a/NumLib/DOF/LocalToGlobalIndexMap.h b/NumLib/DOF/LocalToGlobalIndexMap.h index c557febd7583f1f1fb17d6d58aaf3d10b53db99a..62137174a7a15e6c99cbb8a28594b789fa622e51 100644 --- a/NumLib/DOF/LocalToGlobalIndexMap.h +++ b/NumLib/DOF/LocalToGlobalIndexMap.h @@ -58,10 +58,9 @@ public: /// The size of the vector should be equal to the number of variables. Sum of the entries /// should be equal to the size of the mesh_subsets. /// \param order type of ordering values in a vector - LocalToGlobalIndexMap( - std::vector<MeshLib::MeshSubsets>&& mesh_subsets, - std::vector<unsigned> const& vec_var_n_components, - NumLib::ComponentOrder const order); + LocalToGlobalIndexMap(std::vector<MeshLib::MeshSubsets>&& mesh_subsets, + std::vector<int> const& vec_var_n_components, + NumLib::ComponentOrder const order); /// Creates a MeshComponentMap internally and stores the global indices for /// the given mesh elements @@ -74,8 +73,9 @@ public: /// \param order type of ordering values in a vector LocalToGlobalIndexMap( std::vector<MeshLib::MeshSubsets>&& mesh_subsets, - std::vector<unsigned> const& vec_var_n_components, - std::vector<std::vector<MeshLib::Element*>const*> const& vec_var_elements, + std::vector<int> const& vec_var_n_components, + std::vector<std::vector<MeshLib::Element*> const*> const& + vec_var_elements, NumLib::ComponentOrder const order); /// Derive a LocalToGlobalIndexMap constrained to a set of mesh subsets and @@ -114,9 +114,10 @@ public: return _variable_component_offsets[variable_id+1] - _variable_component_offsets[variable_id]; } - std::size_t getNumberOfComponents() const { return _mesh_subsets.size(); } + int getNumberOfComponents() const { return _mesh_subsets.size(); } - RowColumnIndices operator()(std::size_t const mesh_item_id, const unsigned component_id) const; + RowColumnIndices operator()(std::size_t const mesh_item_id, + const int component_id) const; std::size_t getNumberOfElementDOF(std::size_t const mesh_item_id) const; @@ -185,18 +186,16 @@ private: NumLib::MeshComponentMap&& mesh_component_map); template <typename ElementIterator> - void - findGlobalIndices(ElementIterator first, ElementIterator last, - std::vector<MeshLib::Node*> const& nodes, - std::size_t const mesh_id, - const unsigned component_id, const unsigned comp_id_write); + void findGlobalIndices(ElementIterator first, ElementIterator last, + std::vector<MeshLib::Node*> const& nodes, + std::size_t const mesh_id, const int component_id, + const int comp_id_write); template <typename ElementIterator> - void - findGlobalIndicesWithElementID(ElementIterator first, ElementIterator last, - std::vector<MeshLib::Node*> const& nodes, - std::size_t const mesh_id, - const unsigned component_id, const unsigned comp_id_write); + void findGlobalIndicesWithElementID( + ElementIterator first, ElementIterator last, + std::vector<MeshLib::Node*> const& nodes, std::size_t const mesh_id, + const int component_id, const int comp_id_write); /// The global component id for the specific variable (like velocity) and a /// component (like x, or y, or z). @@ -219,7 +218,7 @@ private: /// \see _rows Table const& _columns = _rows; - std::vector<unsigned> const _variable_component_offsets; + std::vector<int> const _variable_component_offsets; #ifndef NDEBUG /// Prints first rows of the table, every line, and the mesh component map. friend std::ostream& operator<<(std::ostream& os, LocalToGlobalIndexMap const& map); diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp index b82dda5dde67d9f265b189189bd81f991adfdbe8..efad64b69804751ca619bf945ae0ca5f363c91f7 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentDeltaX.cpp @@ -74,7 +74,8 @@ void ConvergenceCriterionPerComponentDeltaX::setDOFTable( _dof_table = &dof_table; _mesh = &mesh; - if (_dof_table->getNumberOfComponents() != _abstols.size()) + 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."); diff --git a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp index 33f08ee3ddb059cd56fde544f8b0315bc999ae97..959efd27a8d18fbb88b464b2058ea78335333ea2 100644 --- a/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp +++ b/NumLib/ODESolver/ConvergenceCriterionPerComponentResidual.cpp @@ -108,7 +108,8 @@ void ConvergenceCriterionPerComponentResidual::setDOFTable( _dof_table = &dof_table; _mesh = &mesh; - if (_dof_table->getNumberOfComponents() != _abstols.size()) + 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."); diff --git a/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition-impl.h b/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition-impl.h index 6450b93aa5dcebefed8973310d33c78af099542b..ea227b6b0d42d23226f033e620996d2f099c6071 100644 --- a/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition-impl.h +++ b/ProcessLib/BoundaryCondition/GenericNonuniformNaturalBoundaryCondition-impl.h @@ -75,7 +75,7 @@ void GenericNonuniformNaturalBoundaryCondition< std::vector<MeshLib::MeshSubsets> all_mesh_subsets{ _mesh_subset_all_nodes.get()}; - std::vector<unsigned> vec_var_n_components{1}; + std::vector<int> vec_var_n_components{1}; _dof_table_boundary = std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets), vec_var_n_components, diff --git a/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFluxLocalAssembler.h b/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFluxLocalAssembler.h index 1b26ce5b51a6f16a3e5d37dfb1bec2175196a1f0..1ff62051b35fe261c01e9d028903c755816f3189 100644 --- a/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFluxLocalAssembler.h +++ b/ProcessLib/CalculateSurfaceFlux/CalculateSurfaceFluxLocalAssembler.h @@ -129,7 +129,7 @@ public: auto const bulk_flux = bulk_process.getFlux(_bulk_element_id, bulk_element_point, x); - for (std::size_t component_id(0); + for (int component_id(0); component_id < balance.getNumberOfComponents(); ++component_id) { diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h b/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h index 37f1ee599b92b100b8c6631c77eae89cc0f0c94b..a84d9389bcef9e1f230084ebe49e1bdc5602c236 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h @@ -68,7 +68,7 @@ void HydroMechanicsProcess<DisplacementDim>::constructDofTable() getProcessVariables()[1].get().getNumberOfComponents(), [&]() { return MeshLib::MeshSubsets{_mesh_subset_all_nodes.get()}; }); - std::vector<unsigned> const vec_n_components{1, DisplacementDim}; + std::vector<int> const vec_n_components{1, DisplacementDim}; _local_to_global_index_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(all_mesh_subsets), vec_n_components, diff --git a/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h b/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h index 54a41e4a48f79ad64f6aec7a15baeba2eb31124c..c01bb661b1fdc567de4a47c6a5c0c8a0d32094f4 100644 --- a/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h +++ b/ProcessLib/LIE/BoundaryCondition/GenericNaturalBoundaryCondition-impl.h @@ -42,8 +42,7 @@ GenericNaturalBoundaryCondition<BoundaryConditionData, _elements(std::move(elements)), _integration_order(integration_order) { - assert(component_id < - static_cast<int>(dof_table_bulk.getNumberOfComponents())); + assert(component_id < dof_table_bulk.getNumberOfComponents()); std::vector<MeshLib::Node*> nodes = MeshLib::getUniqueNodes(_elements); DBUG("Found %d nodes for Natural BCs for the variable %d and component %d", diff --git a/ProcessLib/LIE/Common/PostUtils.cpp b/ProcessLib/LIE/Common/PostUtils.cpp index 40b399035bccab8cc46a820aa2916383dd7ac388..710436952bfbf5f498dc981aa577d7758b492e46 100644 --- a/ProcessLib/LIE/Common/PostUtils.cpp +++ b/ProcessLib/LIE/Common/PostUtils.cpp @@ -177,17 +177,17 @@ void PostProcessTool::copyProperties() // copy existing for (unsigned i = 0; i < _org_mesh.getNumberOfNodes(); i++) { - for (unsigned j = 0; j < n_src_comp; j++) + 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 (unsigned j = n_src_comp; j < n_dest_comp; j++) + 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 (unsigned j = 0; j < n_dest_comp; j++) + for (int j = 0; j < n_dest_comp; j++) (*dest_prop)[itr.second * n_dest_comp + j] = (*dest_prop)[itr.first * n_dest_comp + j]; } @@ -218,7 +218,7 @@ void PostProcessTool::calculateTotalDisplacement(unsigned const n_fractures) total_u.resize(u.size()); for (unsigned i = 0; i < _output_mesh->getNodes().size(); i++) { - for (unsigned j = 0; j < n_u_comp; j++) + for (int j = 0; j < n_u_comp; j++) total_u[i * n_u_comp + j] = u[i * n_u_comp + j]; } @@ -248,7 +248,7 @@ void PostProcessTool::calculateTotalDisplacement(unsigned const n_fractures) "displacement_jump" + std::to_string(fracture_id + 1)); for (unsigned i = 0; i < _output_mesh->getNodes().size(); i++) { - for (unsigned j = 0; j < n_u_comp; j++) + 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/LIE/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp index ac106b37e4939f51677c361f8e52c433db9d8a7a..8be9402bbe8c82c81df4444e49f79f736cf22173 100644 --- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp +++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp @@ -147,7 +147,7 @@ void HydroMechanicsProcess<GlobalDim>::constructDofTable() // Collect the mesh subsets in a vector. std::vector<MeshLib::MeshSubsets> all_mesh_subsets; - std::vector<unsigned> vec_n_components; + std::vector<int> vec_n_components; std::vector<std::vector<MeshLib::Element*> const*> vec_var_elements; // pressure vec_n_components.push_back(1); diff --git a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp index 1035c8e2214c37a8bd46be6d9918a82dec07701b..4be30ae1334f83f8807dfcb0a0a6087f86373db8 100644 --- a/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp +++ b/ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp @@ -142,8 +142,8 @@ void SmallDeformationProcess<DisplacementDim>::constructDofTable() [&]() { return MeshLib::MeshSubsets{ms.get()}; }); } - std::vector<unsigned> const vec_n_components( - 1 + _vec_fracture_mat_IDs.size(), DisplacementDim); + std::vector<int> const vec_n_components(1 + _vec_fracture_mat_IDs.size(), + DisplacementDim); std::vector<std::vector<MeshLib::Element*>const*> vec_var_elements; vec_var_elements.push_back(&_vec_matrix_elements); diff --git a/ProcessLib/Parameter/ConstantParameter.h b/ProcessLib/Parameter/ConstantParameter.h index cfc08b74205914668f296310c92dbf54c006c5a9..8dcdd18a76f063bf0a7711f16f4ea21c2bb12ac1 100644 --- a/ProcessLib/Parameter/ConstantParameter.h +++ b/ProcessLib/Parameter/ConstantParameter.h @@ -35,9 +35,9 @@ struct ConstantParameter final : public Parameter<T> bool isTimeDependent() const override { return false; } - unsigned getNumberOfComponents() const override + int getNumberOfComponents() const override { - return static_cast<unsigned>(_values.size()); + return static_cast<int>(_values.size()); } std::vector<T> const& operator()( diff --git a/ProcessLib/Parameter/CurveScaledParameter.h b/ProcessLib/Parameter/CurveScaledParameter.h index 0891d69b16a302e05b4c71ee9f50fd54b3907cd4..5092bf1f41bff010404012c6b3460d4f82ac11ff 100644 --- a/ProcessLib/Parameter/CurveScaledParameter.h +++ b/ProcessLib/Parameter/CurveScaledParameter.h @@ -38,7 +38,7 @@ struct CurveScaledParameter final : public Parameter<T> { _cache.resize(_parameter->getNumberOfComponents()); } - unsigned getNumberOfComponents() const override + int getNumberOfComponents() const override { return _parameter->getNumberOfComponents(); } @@ -50,7 +50,8 @@ struct CurveScaledParameter final : public Parameter<T> { auto const scaling = _curve.getValue(t); auto const num_comp = _parameter->getNumberOfComponents(); - for (std::size_t c = 0; c < num_comp; ++c) { + for (int c = 0; c < num_comp; ++c) + { _cache[c] = scaling * tup[c]; } return _cache; diff --git a/ProcessLib/Parameter/GroupBasedParameter.h b/ProcessLib/Parameter/GroupBasedParameter.h index e31c28ceb1877c95df7ab18332a3422ad7cb2f1f..4736b9b88e97169c6d3f1d0909686eea1a4b27b7 100644 --- a/ProcessLib/Parameter/GroupBasedParameter.h +++ b/ProcessLib/Parameter/GroupBasedParameter.h @@ -51,9 +51,11 @@ struct GroupBasedParameter final bool isTimeDependent() const override { return false; } - unsigned getNumberOfComponents() const override + int getNumberOfComponents() const override { - return _vec_values.empty() ? 0 : _vec_values.front().size(); + return _vec_values.empty() + ? 0 + : static_cast<int>(_vec_values.front().size()); } std::vector<T> const& operator()(double const /*t*/, diff --git a/ProcessLib/Parameter/MeshElementParameter.h b/ProcessLib/Parameter/MeshElementParameter.h index 966fe7dd9bb7de37901c3ca5ad80a6bda7661adc..634bc457a925428ed4e9d3b5c91cdb4761e82a39 100644 --- a/ProcessLib/Parameter/MeshElementParameter.h +++ b/ProcessLib/Parameter/MeshElementParameter.h @@ -32,7 +32,7 @@ struct MeshElementParameter final : public Parameter<T> { bool isTimeDependent() const override { return false; } - unsigned getNumberOfComponents() const override + int getNumberOfComponents() const override { return _property.getNumberOfComponents(); } @@ -43,7 +43,8 @@ struct MeshElementParameter final : public Parameter<T> { auto const e = pos.getElementID(); assert(e); auto const num_comp = _property.getNumberOfComponents(); - for (std::size_t c=0; c<num_comp; ++c) { + for (int c = 0; c < num_comp; ++c) + { _cache[c] = _property.getComponent(*e, c); } return _cache; diff --git a/ProcessLib/Parameter/MeshNodeParameter.h b/ProcessLib/Parameter/MeshNodeParameter.h index a6d1da482be3c28dcefc98dad73046b9112a3282..5faacd279f17e978acbf8b9d9e5ed4a877e16076 100644 --- a/ProcessLib/Parameter/MeshNodeParameter.h +++ b/ProcessLib/Parameter/MeshNodeParameter.h @@ -32,7 +32,7 @@ struct MeshNodeParameter final : public Parameter<T> { bool isTimeDependent() const override { return false; } - unsigned getNumberOfComponents() const override + int getNumberOfComponents() const override { return _property.getNumberOfComponents(); } @@ -43,7 +43,8 @@ struct MeshNodeParameter final : public Parameter<T> { auto const n = pos.getNodeID(); assert(n); auto const num_comp = _property.getNumberOfComponents(); - for (std::size_t c=0; c<num_comp; ++c) { + for (int c = 0; c < num_comp; ++c) + { _cache[c] = _property.getComponent(*n, c); } return _cache; diff --git a/ProcessLib/Parameter/Parameter.h b/ProcessLib/Parameter/Parameter.h index 73c94cf78f255b2b31bf9153da8352a564627889..158ba10f71743e1ce0f3b2430bbfef2f2a989f6a 100644 --- a/ProcessLib/Parameter/Parameter.h +++ b/ProcessLib/Parameter/Parameter.h @@ -67,7 +67,7 @@ struct Parameter : public ParameterBase //! Returns the number of components this Parameter has at every position and //! point in time. - virtual unsigned getNumberOfComponents() const = 0; + virtual int getNumberOfComponents() const = 0; //! Returns the parameter value at the given time and position. virtual std::vector<T> const& operator()( diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index 9d066191a12a2b8d1d095835d88f3424068fad0d..109f8e9faa420abbc3d3acc3c70b915a969f501b 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -183,7 +183,7 @@ void Process::constructDofTable() } // Create a vector of the number of variable components - std::vector<unsigned> vec_var_n_components; + std::vector<int> vec_var_n_components; for (ProcessVariable const& pv : _process_variables) vec_var_n_components.push_back(pv.getNumberOfComponents()); diff --git a/ProcessLib/Utils/ProcessUtils.h b/ProcessLib/Utils/ProcessUtils.h index c7aa7de6f33d7830051bcf440be515029b46ca58..a1163a18b083f54227456663be550564a3e933fe 100644 --- a/ProcessLib/Utils/ProcessUtils.h +++ b/ProcessLib/Utils/ProcessUtils.h @@ -55,7 +55,7 @@ template <typename ParameterDataType> Parameter<ParameterDataType>& findParameter( std::string const& parameter_name, std::vector<std::unique_ptr<ParameterBase>> const& parameters, - unsigned const num_components) + int const num_components) { // Find corresponding parameter by name. auto const parameter_it = std::find_if( @@ -111,7 +111,7 @@ template <typename ParameterDataType> Parameter<ParameterDataType>& findParameter( BaseLib::ConfigTree const& process_config, std::string const& tag, std::vector<std::unique_ptr<ParameterBase>> const& parameters, - unsigned const num_components) + int const num_components) { // Find parameter name in process config. //! \ogs_file_special diff --git a/Tests/NumLib/LocalToGlobalIndexMap.cpp b/Tests/NumLib/LocalToGlobalIndexMap.cpp index aa0a332ef9bad51919279f3d3263fba7f7af88a7..5d5f2c61f58186542184ede2bb261e5d3765482c 100644 --- a/Tests/NumLib/LocalToGlobalIndexMap.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMap.cpp @@ -41,8 +41,8 @@ protected: std::unique_ptr<MeshLib::MeshSubset const> nodesSubset; //data component 0 and 1 are assigned to all nodes in the mesh - static std::size_t const comp0_id = 0; - static std::size_t const comp1_id = 1; + static int const comp0_id = 0; + static int const comp1_id = 1; std::vector<MeshLib::MeshSubsets> components; std::unique_ptr<NumLib::LocalToGlobalIndexMap const> dof_map; @@ -126,7 +126,7 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon // test 2 variables (1st variable with 1 component, 2nd variable with 2 components) components.emplace_back(nodesSubset.get()); - std::vector<unsigned> vec_var_n_components{1, 2}; + std::vector<int> vec_var_n_components{1, 2}; dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(components), @@ -134,10 +134,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(30, dof_map->dofSizeWithGhosts()); - ASSERT_EQ(3u, dof_map->getNumberOfComponents()); + ASSERT_EQ(3, dof_map->getNumberOfComponents()); ASSERT_EQ(2u, dof_map->getNumberOfVariables()); - ASSERT_EQ(1u, dof_map->getNumberOfVariableComponents(0)); - ASSERT_EQ(2u, dof_map->getNumberOfVariableComponents(1)); + ASSERT_EQ(1, dof_map->getNumberOfVariableComponents(0)); + ASSERT_EQ(2, dof_map->getNumberOfVariableComponents(1)); MeshLib::Location l_node0(mesh->getID(), MeshLib::MeshItemType::Node, 0); @@ -155,7 +155,7 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon // test 2 variables (1st variable with 2 component, 2nd variable with 1 components) components.emplace_back(nodesSubset.get()); - std::vector<unsigned> vec_var_n_components{2, 1}; + std::vector<int> vec_var_n_components{2, 1}; dof_map = std::make_unique<NumLib::LocalToGlobalIndexMap>( std::move(components), @@ -163,10 +163,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(30, dof_map->dofSizeWithGhosts()); - ASSERT_EQ(3u, dof_map->getNumberOfComponents()); + ASSERT_EQ(3, dof_map->getNumberOfComponents()); ASSERT_EQ(2u, dof_map->getNumberOfVariables()); - ASSERT_EQ(2u, dof_map->getNumberOfVariableComponents(0)); - ASSERT_EQ(1u, dof_map->getNumberOfVariableComponents(1)); + ASSERT_EQ(2, dof_map->getNumberOfVariableComponents(0)); + ASSERT_EQ(1, dof_map->getNumberOfVariableComponents(1)); MeshLib::Location l_node0(mesh->getID(), MeshLib::MeshItemType::Node, 0); @@ -190,7 +190,7 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon std::make_unique<MeshLib::MeshSubset>(*mesh, &var2_nodes); components.emplace_back(var2_subset.get()); - std::vector<unsigned> vec_var_n_components{2, 1}; + std::vector<int> vec_var_n_components{2, 1}; std::vector<std::vector<MeshLib::Element*>const*> vec_var_elements; vec_var_elements.push_back(&mesh->getElements()); std::vector<MeshLib::Element*> var2_elements{const_cast<MeshLib::Element*>(mesh->getElement(1))}; @@ -203,10 +203,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(22u, dof_map->dofSizeWithGhosts()); - ASSERT_EQ(3u, dof_map->getNumberOfComponents()); + ASSERT_EQ(3, dof_map->getNumberOfComponents()); ASSERT_EQ(2u, dof_map->getNumberOfVariables()); - ASSERT_EQ(2u, dof_map->getNumberOfVariableComponents(0)); - ASSERT_EQ(1u, dof_map->getNumberOfVariableComponents(1)); + ASSERT_EQ(2, dof_map->getNumberOfVariableComponents(0)); + ASSERT_EQ(1, dof_map->getNumberOfVariableComponents(1)); MeshLib::Location l_node0(mesh->getID(), MeshLib::MeshItemType::Node, 0); @@ -243,7 +243,7 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon std::make_unique<MeshLib::MeshSubset>(*mesh, &var2_nodes); components.emplace_back(var2_subset.get()); - std::vector<unsigned> vec_var_n_components{2, 1}; + std::vector<int> vec_var_n_components{2, 1}; std::vector<std::vector<MeshLib::Element*>const*> vec_var_elements; vec_var_elements.push_back(&mesh->getElements()); std::vector<MeshLib::Element*> var2_elements{const_cast<MeshLib::Element*>(mesh->getElement(1))}; @@ -256,10 +256,10 @@ TEST_F(NumLibLocalToGlobalIndexMapTest, DISABLED_MultipleVariablesMultipleCompon NumLib::ComponentOrder::BY_COMPONENT); ASSERT_EQ(21u, dof_map->dofSizeWithGhosts()); - ASSERT_EQ(3u, dof_map->getNumberOfComponents()); + ASSERT_EQ(3, dof_map->getNumberOfComponents()); ASSERT_EQ(2u, dof_map->getNumberOfVariables()); - ASSERT_EQ(2u, dof_map->getNumberOfVariableComponents(0)); - ASSERT_EQ(1u, dof_map->getNumberOfVariableComponents(1)); + ASSERT_EQ(2, dof_map->getNumberOfVariableComponents(0)); + ASSERT_EQ(1, dof_map->getNumberOfVariableComponents(1)); MeshLib::Location l_node0(mesh->getID(), MeshLib::MeshItemType::Node, 0); diff --git a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp index 436e1809fa3ca383570d17a826422da1ec3ea375..6a96ee4a8a53e908b9391c3991d3a03e0cc5f03a 100644 --- a/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp +++ b/Tests/NumLib/LocalToGlobalIndexMapMultiComponent.cpp @@ -79,18 +79,18 @@ public: delete e; } - void initComponents(const unsigned num_components, + void initComponents(const int num_components, const int selected_component, const NL::ComponentOrder order) { assert(selected_component < static_cast<int>(num_components)); std::vector<MeshLib::MeshSubsets> components; - for (unsigned i=0; i<num_components; ++i) + for (int i = 0; i < num_components; ++i) { components.emplace_back(mesh_items_all_nodes.get()); } - std::vector<unsigned> vec_var_n_components(1, num_components); + std::vector<int> vec_var_n_components(1, num_components); dof_map = std::make_unique<NL::LocalToGlobalIndexMap>( std::move(components), vec_var_n_components, order); @@ -104,18 +104,18 @@ public: } // Multi-component version. - void initComponents(unsigned const num_components, + void initComponents(int const num_components, std::vector<int> const& selected_components, NL::ComponentOrder const order) { assert(selected_components.size() <= num_components); std::vector<MeshLib::MeshSubsets> components; - for (unsigned i = 0; i < num_components; ++i) + for (int i = 0; i < num_components; ++i) { components.emplace_back(mesh_items_all_nodes.get()); } - std::vector<unsigned> vec_var_n_components(1, num_components); + std::vector<int> vec_var_n_components(1, num_components); dof_map = std::make_unique<NL::LocalToGlobalIndexMap>( std::move(components), vec_var_n_components, order); @@ -129,13 +129,13 @@ public: } template <NL::ComponentOrder order> - void test(const unsigned num_components, const unsigned selected_component, + void test(const int num_components, const int selected_component, std::function<std::size_t(std::size_t, std::size_t)> const& compute_global_index); // Multicomponent version template <NL::ComponentOrder order> - void test(const unsigned num_components, + void test(const int num_components, std::vector<int> const& selected_component, std::function<std::size_t(std::size_t, std::size_t)> const& compute_global_index); @@ -175,11 +175,10 @@ struct ComputeGlobalIndexByLocation } }; - template <NL::ComponentOrder ComponentOrder> void NumLibLocalToGlobalIndexMapMultiDOFTest::test( - const unsigned num_components, - const unsigned selected_component, + const int num_components, + const int selected_component, std::function<std::size_t(std::size_t, std::size_t)> const& compute_global_index) { @@ -197,7 +196,7 @@ void NumLibLocalToGlobalIndexMapMultiDOFTest::test( auto const element_nodes_size = mesh->getElement(e)->getNumberOfNodes(); auto const ptr_element_nodes = mesh->getElement(e)->getNodes(); - for (unsigned c=0; c<dof_map->getNumberOfComponents(); ++c) + for (int c = 0; c < dof_map->getNumberOfComponents(); ++c) { auto const& global_idcs = (*dof_map)(e, c).rows; ASSERT_EQ(element_nodes_size, global_idcs.size()); @@ -216,7 +215,7 @@ void NumLibLocalToGlobalIndexMapMultiDOFTest::test( { ASSERT_EQ(1, dof_map_boundary->getNumberOfComponents()); - for (unsigned c=0; c<1; ++c) + for (int c = 0; c < 1; ++c) { auto const& global_idcs = (*dof_map_boundary)(e, c).rows; @@ -239,7 +238,7 @@ void NumLibLocalToGlobalIndexMapMultiDOFTest::test( // Multicomponent version template <NL::ComponentOrder ComponentOrder> void NumLibLocalToGlobalIndexMapMultiDOFTest::test( - unsigned const num_components, + int const num_components, std::vector<int> const& selected_components, std::function<std::size_t(std::size_t, std::size_t)> const& compute_global_index) @@ -259,7 +258,7 @@ void NumLibLocalToGlobalIndexMapMultiDOFTest::test( auto const element_nodes_size = mesh->getElement(e)->getNumberOfNodes(); auto const ptr_element_nodes = mesh->getElement(e)->getNodes(); - for (unsigned c = 0; c < dof_map->getNumberOfComponents(); ++c) + for (int c = 0; c < dof_map->getNumberOfComponents(); ++c) { auto const& global_idcs = (*dof_map)(e, c).rows; ASSERT_EQ(element_nodes_size, global_idcs.size()); @@ -279,7 +278,7 @@ void NumLibLocalToGlobalIndexMapMultiDOFTest::test( ASSERT_EQ(selected_components.size(), dof_map_boundary->getNumberOfComponents()); - for (unsigned c = 0; c < selected_components.size(); ++c) + for (int c = 0; c < static_cast<int>(selected_components.size()); ++c) { auto const& global_idcs = (*dof_map_boundary)(e, c).rows; @@ -308,7 +307,7 @@ void assert_equal(NL::LocalToGlobalIndexMap const& dof1, NL::LocalToGlobalIndexM for (unsigned e=0; e<dof1.size(); ++e) { - for (unsigned c=0; c<dof1.getNumberOfComponents(); ++c) + for (int c = 0; c < dof1.getNumberOfComponents(); ++c) { EXPECT_EQ(dof1(e, c).rows, dof2(e, c).rows); EXPECT_EQ(dof1(e, c).columns, dof2(e, c).columns); @@ -322,7 +321,7 @@ TEST_F(NumLibLocalToGlobalIndexMapMultiDOFTest, Test1Comp) TEST_F(NumLibLocalToGlobalIndexMapMultiDOFTest, DISABLED_Test1Comp) #endif { - unsigned const num_components = 1; + int const num_components = 1; test<NL::ComponentOrder::BY_LOCATION>( num_components, 0, ComputeGlobalIndexByComponent{num_components}); @@ -344,8 +343,8 @@ TEST_F(NumLibLocalToGlobalIndexMapMultiDOFTest, TestMultiCompByComponent) TEST_F(NumLibLocalToGlobalIndexMapMultiDOFTest, DISABLED_TestMultiCompByComponent) #endif { - unsigned const num_components = 5; - for (unsigned c = 0; c < num_components; ++c) + 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)});