Skip to content

Commit

Permalink
Merge branch 'imprv_local_x_arg_non_linear' into 'master'
Browse files Browse the repository at this point in the history
[Process]  Changed the type of local_x in LocalAssemblerInterface::postNonLinearSolverConcrete

Closes #3469

See merge request ogs/ogs!4979
  • Loading branch information
endJunction committed Apr 17, 2024
2 parents f0096cd + 1d409e9 commit b561871
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 39 deletions.
21 changes: 6 additions & 15 deletions ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
void HydroMechanicsLocalAssembler<ShapeFunctionDisplacement,
ShapeFunctionPressure, DisplacementDim>::
postNonLinearSolverConcrete(std::vector<double> const& local_x,
std::vector<double> 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)
{
Expand All @@ -894,14 +894,9 @@ void HydroMechanicsLocalAssembler<ShapeFunctionDisplacement,
if (!staggered_scheme_ptr->fixed_stress_over_time_step)
{
auto const p =
Eigen::Map<typename ShapeMatricesTypePressure::
template VectorType<pressure_size> const>(
local_x.data(), pressure_size);

local_x.template segment<pressure_size>(pressure_index);
auto const p_prev =
Eigen::Map<typename ShapeMatricesTypePressure::
template VectorType<pressure_size> const>(
local_x_prev.data(), pressure_size);
local_x_prev.template segment<pressure_size>(pressure_index);

for (int ip = 0; ip < n_integration_points; ip++)
{
Expand All @@ -928,12 +923,8 @@ void HydroMechanicsLocalAssembler<ShapeFunctionDisplacement,
.template value<double>(MPL::EmptyVariableArray, x_position, t,
dt);

const int displacement_offset =
(!staggered_scheme_ptr) ? displacement_index : 0;

auto u = Eigen::Map<typename ShapeMatricesTypeDisplacement::
template VectorType<displacement_size> const>(
local_x.data() + displacement_offset, displacement_size);
auto const u =
local_x.template segment<displacement_size>(displacement_index);

MPL::VariableArray vars;
vars.temperature = T_ref;
Expand Down
4 changes: 2 additions & 2 deletions ProcessLib/HydroMechanics/HydroMechanicsFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> const& local_x,
std::vector<double> 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;

Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void HydroMechanicsProcess<DisplacementDim>::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);
}

Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/LocalAssemblerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ void LocalAssemblerInterface::postTimestep(

void LocalAssemblerInterface::postNonLinearSolver(
std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> 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);
}
Expand Down
24 changes: 8 additions & 16 deletions ProcessLib/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class LocalToGlobalIndexMap;

namespace ProcessLib
{

/*! Common interface for local assemblers
* NumLib::ODESystemTag::FirstOrderImplicitQuasilinear ODE systems.
*
Expand Down Expand Up @@ -92,12 +91,12 @@ class LocalAssemblerInterface
std::vector<GlobalVector*> 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<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev,
double const t, double const dt,
int const process_id);
void postNonLinearSolver(
std::size_t const mesh_item_id,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> 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.
Expand Down Expand Up @@ -127,7 +126,6 @@ class LocalAssemblerInterface
}

virtual void initializeConcrete() {}

virtual void preTimestepConcrete(std::vector<double> const& /*local_x*/,
double const /*t*/, double const /*dt*/)
{
Expand All @@ -141,8 +139,8 @@ class LocalAssemblerInterface
}

virtual void postNonLinearSolverConcrete(
std::vector<double> const& /*local_x*/,
std::vector<double> 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*/)
{
}
Expand All @@ -154,12 +152,6 @@ class LocalAssemblerInterface
Eigen::VectorXd const& /*local_x_prev*/)
{
}

virtual void computeSecondaryVariableWithCoupledProcessConcrete(
double const /*t*/, std::vector<std::vector<double>> const&
/*coupled_local_solutions*/)
{
}
};

} // namespace ProcessLib
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void ThermoMechanicalPhaseFieldProcess<DisplacementDim>::

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);
}

Expand Down

0 comments on commit b561871

Please sign in to comment.