From fc4ab51d643a9f98f6d9711e6053e047143e5752 Mon Sep 17 00:00:00 2001 From: Wenqing Wang Date: Thu, 4 Apr 2024 15:45:43 +0200 Subject: [PATCH 1/2] [Process/LocalAssembler] Changed the type of local_x in postNonLinearSolverConcrete --- .../HydroMechanics/HydroMechanicsFEM-impl.h | 21 ++++++------------- ProcessLib/HydroMechanics/HydroMechanicsFEM.h | 4 ++-- .../HydroMechanics/HydroMechanicsProcess.cpp | 2 +- ProcessLib/LocalAssemblerInterface.cpp | 8 +++---- ProcessLib/LocalAssemblerInterface.h | 18 +++++++--------- .../ThermoMechanicalPhaseFieldProcess.cpp | 2 +- 6 files changed, 22 insertions(+), 33 deletions(-) diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h index ba348315069..482f6e97247 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h @@ -874,8 +874,8 @@ template void HydroMechanicsLocalAssembler:: - postNonLinearSolverConcrete(std::vector const& local_x, - std::vector const& local_x_prev, + postNonLinearSolverConcrete(Eigen::VectorXd const& local_x, + Eigen::VectorXd const& local_x_prev, double const t, double const dt, int const process_id) { @@ -894,14 +894,9 @@ void HydroMechanicsLocalAssemblerfixed_stress_over_time_step) { auto const p = - Eigen::Map const>( - local_x.data(), pressure_size); - + local_x.template segment(pressure_index); auto const p_prev = - Eigen::Map const>( - local_x_prev.data(), pressure_size); + local_x_prev.template segment(pressure_index); for (int ip = 0; ip < n_integration_points; ip++) { @@ -928,12 +923,8 @@ void HydroMechanicsLocalAssembler(MPL::EmptyVariableArray, x_position, t, dt); - const int displacement_offset = - (!staggered_scheme_ptr) ? displacement_index : 0; - - auto u = Eigen::Map const>( - local_x.data() + displacement_offset, displacement_size); + auto const u = + local_x.template segment(displacement_index); MPL::VariableArray vars; vars.temperature = T_ref; diff --git a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h index 0f6ce91936e..45dcdc49d94 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsFEM.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsFEM.h @@ -271,8 +271,8 @@ class HydroMechanicsLocalAssembler double const t, double const dt, Eigen::VectorXd const& local_xs, Eigen::VectorXd const& local_x_prev) override; - void postNonLinearSolverConcrete(std::vector const& local_x, - std::vector const& local_x_prev, + void postNonLinearSolverConcrete(Eigen::VectorXd const& local_x, + Eigen::VectorXd const& local_x_prev, double const t, double const dt, int const process_id) override; diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp index 03816784d57..7219b8596b6 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp +++ b/ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp @@ -412,7 +412,7 @@ void HydroMechanicsProcess::postNonLinearSolverConcreteProcess( // Calculate strain, stress or other internal variables of mechanics. GlobalExecutor::executeSelectedMemberOnDereferenced( &LocalAssemblerIF::postNonLinearSolver, _local_assemblers, - getActiveElementIDs(), getDOFTable(process_id), x, x_prev, t, dt, + getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt, process_id); } diff --git a/ProcessLib/LocalAssemblerInterface.cpp b/ProcessLib/LocalAssemblerInterface.cpp index 36452f07772..fdd5d1a9107 100644 --- a/ProcessLib/LocalAssemblerInterface.cpp +++ b/ProcessLib/LocalAssemblerInterface.cpp @@ -130,14 +130,14 @@ void LocalAssemblerInterface::postTimestep( void LocalAssemblerInterface::postNonLinearSolver( std::size_t const mesh_item_id, - NumLib::LocalToGlobalIndexMap const& dof_table, + std::vector const& dof_tables, std::vector const& x, std::vector const& x_prev, double const t, double const dt, int const process_id) { - auto const indices = NumLib::getIndices(mesh_item_id, dof_table); - auto const local_x = x[process_id]->get(indices); - auto const local_x_prev = x_prev[process_id]->get(indices); + auto const local_x = NumLib::getLocalX(mesh_item_id, dof_tables, x); + auto const local_x_prev = + NumLib::getLocalX(mesh_item_id, dof_tables, x_prev); postNonLinearSolverConcrete(local_x, local_x_prev, t, dt, process_id); } diff --git a/ProcessLib/LocalAssemblerInterface.h b/ProcessLib/LocalAssemblerInterface.h index 0b05ce8697f..e1296def8a0 100644 --- a/ProcessLib/LocalAssemblerInterface.h +++ b/ProcessLib/LocalAssemblerInterface.h @@ -22,7 +22,6 @@ class LocalToGlobalIndexMap; namespace ProcessLib { - /*! Common interface for local assemblers * NumLib::ODESystemTag::FirstOrderImplicitQuasilinear ODE systems. * @@ -92,12 +91,12 @@ class LocalAssemblerInterface std::vector const& x_prev, double const t, double const dt, int const process_id); - void postNonLinearSolver(std::size_t const mesh_item_id, - NumLib::LocalToGlobalIndexMap const& dof_table, - std::vector const& x, - std::vector const& x_prev, - double const t, double const dt, - int const process_id); + void postNonLinearSolver( + std::size_t const mesh_item_id, + std::vector const& dof_tables, + std::vector const& x, + std::vector const& x_prev, double const t, + double const dt, int const process_id); /// Computes the flux in the point \c p_local_coords that is given in local /// coordinates using the values from \c local_x. @@ -127,7 +126,6 @@ class LocalAssemblerInterface } virtual void initializeConcrete() {} - virtual void preTimestepConcrete(std::vector const& /*local_x*/, double const /*t*/, double const /*dt*/) { @@ -141,8 +139,8 @@ class LocalAssemblerInterface } virtual void postNonLinearSolverConcrete( - std::vector const& /*local_x*/, - std::vector const& /*local_x_prev*/, double const /*t*/, + Eigen::VectorXd const& /*local_x*/, + Eigen::VectorXd const& /*local_x_prev*/, double const /*t*/, double const /*dt*/, int const /*process_id*/) { } diff --git a/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess.cpp b/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess.cpp index 7d817d6c0cd..2000e1411f7 100644 --- a/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess.cpp +++ b/ProcessLib/ThermoMechanicalPhaseField/ThermoMechanicalPhaseFieldProcess.cpp @@ -315,7 +315,7 @@ void ThermoMechanicalPhaseFieldProcess:: GlobalExecutor::executeSelectedMemberOnDereferenced( &LocalAssemblerInterface::postNonLinearSolver, _local_assemblers, - pv.getActiveElementIDs(), getDOFTable(process_id), x, x_prev, t, dt, + pv.getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt, process_id); } From 1d409e940a3afc80151e3d4a26efed88db65d7da Mon Sep 17 00:00:00 2001 From: Wenqing Wang Date: Thu, 4 Apr 2024 16:02:16 +0200 Subject: [PATCH 2/2] [Process] Removed an unused member of LocalAssemblerInterface, computeSecondaryVariableWithCoupledProcessConcrete --- ProcessLib/LocalAssemblerInterface.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ProcessLib/LocalAssemblerInterface.h b/ProcessLib/LocalAssemblerInterface.h index e1296def8a0..ba852d125fd 100644 --- a/ProcessLib/LocalAssemblerInterface.h +++ b/ProcessLib/LocalAssemblerInterface.h @@ -152,12 +152,6 @@ class LocalAssemblerInterface Eigen::VectorXd const& /*local_x_prev*/) { } - - virtual void computeSecondaryVariableWithCoupledProcessConcrete( - double const /*t*/, std::vector> const& - /*coupled_local_solutions*/) - { - } }; } // namespace ProcessLib