diff --git a/NumLib/DOF/DOFTableUtil.h b/NumLib/DOF/DOFTableUtil.h index e350c2714b1ad2734de573e00630e596bd3a231b..5787097cd224225735b030f1d0434ec094a4b296 100644 --- a/NumLib/DOF/DOFTableUtil.h +++ b/NumLib/DOF/DOFTableUtil.h @@ -49,4 +49,41 @@ double norm(GlobalVector const& x, unsigned const global_component, MathLib::VecNormType norm_type, LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh); +/// Copies part of a global vector for the given variable into output_vector +/// while applying a function to each value. +/// +/// \attention The output_vector is accessed through node id and component, +/// therefore multiple meshes are not supported. +template <typename Functor> +void transformVariableFromGlobalVector( + GlobalVector const& input_vector, int const variable_id, + NumLib::LocalToGlobalIndexMap const& local_to_global_index_map, + MeshLib::PropertyVector<double>& output_vector, Functor mapFunction) +{ + std::fill(begin(output_vector), end(output_vector), + std::numeric_limits<double>::quiet_NaN()); + + int const n_components = + local_to_global_index_map.getNumberOfVariableComponents(variable_id); + for (int component = 0; component < n_components; ++component) + { + auto const& mesh_subsets = + local_to_global_index_map.getMeshSubsets(variable_id, component); + assert(mesh_subsets.size() == + 1); // Multiple meshes are not supported by the output_vector. + for (auto const& ms : mesh_subsets) + { + auto const mesh_id = ms->getMeshID(); + for (auto const& node : ms->getNodes()) + { + auto const node_id = node->getID(); + MeshLib::Location const l(mesh_id, MeshLib::MeshItemType::Node, + node_id); + output_vector.getComponent(node_id, component) = mapFunction( + input_vector[local_to_global_index_map.getGlobalIndex( + l, variable_id, component)]); + } + } + } +} } // namespace NumLib diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp index 181bc0ae1a0eb508445b11a9285abe9652b2d69c..4bd2f123f8d0a822559598d2a8af7f0018ce34a1 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp @@ -15,7 +15,6 @@ #include "NumLib/DOF/ComputeSparsityPattern.h" #include "ProcessLib/HydroMechanics/CreateLocalAssemblers.h" #include "ProcessLib/Process.h" -#include "ProcessLib/Utils/GlobalVectorUtils.h" #include "HydroMechanicsFEM.h" #include "HydroMechanicsProcessData.h" diff --git a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp index 87fed2424bc6d9668f8571a420fe8a28295c13b7..2e5df29452c02d7e5a162075ab8c7efb3603e91c 100644 --- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp +++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp @@ -16,11 +16,11 @@ #include "MeshLib/MeshInformation.h" #include "MeshLib/Properties.h" +#include "NumLib/DOF/DOFTableUtil.h" #include "NumLib/DOF/LocalToGlobalIndexMap.h" #include "ProcessLib/LIE/BoundaryCondition/BoundaryConditionBuilder.h" #include "ProcessLib/LIE/Common/MeshUtils.h" -#include "ProcessLib/Utils/GlobalVectorUtils.h" #include "LocalAssembler/CreateLocalAssemblers.h" #include "LocalAssembler/HydroMechanicsLocalAssemblerFracture.h" diff --git a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp index 67b24bf70c1f11b67b21287dc5caccd8f7fa6f4d..b4edf3827c90d75c6b3e3c31319f410e4a082160 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp +++ b/ProcessLib/SmallDeformation/SmallDeformationProcess.cpp @@ -15,7 +15,6 @@ #include "BaseLib/Functional.h" #include "ProcessLib/Process.h" #include "ProcessLib/SmallDeformation/CreateLocalAssemblers.h" -#include "ProcessLib/Utils/GlobalVectorUtils.h" #include "SmallDeformationFEM.h" diff --git a/ProcessLib/Utils/GlobalVectorUtils.h b/ProcessLib/Utils/GlobalVectorUtils.h deleted file mode 100644 index 906feffe1693d22ae0baa6dd92203309d54891ea..0000000000000000000000000000000000000000 --- a/ProcessLib/Utils/GlobalVectorUtils.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#include "MeshLib/Properties.h" - -#include "NumLib/DOF/LocalToGlobalIndexMap.h" - -namespace ProcessLib -{ -/// Copies part of a global vector for the given variable into output vector -/// while applying a function to each value. -/// -/// \attention The output_vector is accessed through node id and component, -/// therefore multiple meshes are not supported. -template <typename Functor> -void transformVariableFromGlobalVector( - GlobalVector const& input_vector, int const variable_id, - NumLib::LocalToGlobalIndexMap const& local_to_global_index_map, - MeshLib::PropertyVector<double>& output_vector, Functor mapFunction) -{ - std::fill(begin(output_vector), end(output_vector), - std::numeric_limits<double>::quiet_NaN()); - - int const n_components = - local_to_global_index_map.getNumberOfVariableComponents(variable_id); - for (int component = 0; component < n_components; ++component) - { - auto const& mesh_subsets = - local_to_global_index_map.getMeshSubsets(variable_id, component); - assert(mesh_subsets.size() == - 1); // Multiple meshes are not supported by the output_vector. - for (auto const& ms : mesh_subsets) - { - auto const mesh_id = ms->getMeshID(); - for (auto const& node : ms->getNodes()) - { - auto const node_id = node->getID(); - MeshLib::Location const l(mesh_id, MeshLib::MeshItemType::Node, - node_id); - output_vector.getComponent(node_id, component) = mapFunction( - input_vector[local_to_global_index_map.getGlobalIndex( - l, variable_id, component)]); - } - } - } -} -} // namespace ProcessLib