Commit 8e8d3bd8 authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov

Merge branch 'AddPostTimeStepInterface' into 'master'

[PL/CT] Add postTimeStep interface

See merge request ogs/ogs!3262
parents 86443d72 8df4d40c
......@@ -974,6 +974,11 @@ public:
ele_velocity_mat.rowwise().sum() / n_integration_points;
}
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/, double const /*dt*/) override
{
}
private:
MeshLib::Element const& _element;
ComponentTransportProcessData const& _process_data;
......
......@@ -289,30 +289,28 @@ void ComponentTransportProcess::computeSecondaryVariableConcrete(
void ComponentTransportProcess::postTimestepConcreteProcess(
std::vector<GlobalVector*> const& x,
const double t,
const double /*delta_t*/,
const double dt,
int const process_id)
{
// For the monolithic scheme, process_id is always zero.
if (_use_monolithic_scheme && process_id != 0)
{
OGS_FATAL(
"The condition of process_id = 0 must be satisfied for "
"monolithic ComponentTransportProcess, which is a single process.");
}
if (!_use_monolithic_scheme && process_id != 0)
if (process_id != 0)
{
DBUG(
"This is the transport part of the staggered "
"ComponentTransportProcess.");
return;
}
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
dof_tables.reserve(x.size());
std::generate_n(std::back_inserter(dof_tables), x.size(),
[&]() { return _local_to_global_index_map.get(); });
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&ComponentTransportLocalAssemblerInterface::postTimestep,
_local_assemblers, pv.getActiveElementIDs(), dof_tables, x, t, dt);
if (!_surfaceflux) // computing the surfaceflux is optional
{
return;
}
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
_surfaceflux->integrate(x, t, *this, process_id, _integration_order, _mesh,
pv.getActiveElementIDs());
}
......
......@@ -133,7 +133,7 @@ public:
void postTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
const double t,
const double delta_t,
const double dt,
int const process_id) override;
private:
......
......@@ -178,7 +178,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/,
double const /*dt*/) override
{
......
......@@ -492,12 +492,24 @@ void HydroMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
std::vector<GlobalVector*> const& x, double const t, double const dt,
const int process_id)
{
if (process_id != 0)
{
return;
}
DBUG("PostTimestep HydroMechanicsProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
auto const n_processes = x.size();
dof_tables.reserve(n_processes);
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
dof_tables.push_back(&getDOFTable(process_id));
}
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerIF::postTimestep, _local_assemblers,
pv.getActiveElementIDs(), getDOFTable(process_id), *x[process_id], t,
dt);
pv.getActiveElementIDs(), dof_tables, x, t, dt);
}
template <int DisplacementDim>
......
......@@ -459,19 +459,28 @@ void HydroMechanicsProcess<GlobalDim>::postTimestepConcreteProcess(
std::vector<GlobalVector*> const& x, const double t, double const dt,
int const process_id)
{
DBUG("Compute the secondary variables for HydroMechanicsProcess.");
const auto& dof_table = getDOFTable(process_id);
if (process_id == 0)
{
DBUG("PostTimestep HydroMechanicsProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
auto const n_processes = x.size();
dof_tables.reserve(n_processes);
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
dof_tables.push_back(&getDOFTable(process_id));
}
ProcessLib::ProcessVariable const& pv =
getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&HydroMechanicsLocalAssemblerInterface::postTimestep,
_local_assemblers, pv.getActiveElementIDs(), dof_table,
*x[process_id], t, dt);
_local_assemblers, pv.getActiveElementIDs(), dof_tables, x, t, dt);
}
DBUG("Compute the secondary variables for HydroMechanicsProcess.");
const auto& dof_table = getDOFTable(process_id);
// Copy displacement jumps in a solution vector to mesh property
// Remark: the copy is required because mesh properties for primary
// variables are set during output and are not ready yet when this function
......
......@@ -100,13 +100,11 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& local_x_,
const double t, double const dt) override
void postTimestepConcrete(Eigen::VectorXd const& local_x_, const double t,
double const dt) override
{
auto const local_dof_size = local_x_.size();
_local_u.setZero();
for (unsigned i = 0; i < local_dof_size; i++)
for (Eigen::Index i = 0; i < local_x_.rows(); i++)
{
_local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
}
......
......@@ -131,11 +131,22 @@ void LocalAssemblerInterface::preTimestep(
void LocalAssemblerInterface::postTimestep(
std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table, GlobalVector const& x,
double const t, double const dt)
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
std::vector<GlobalVector*> const& x, double const t, double const dt)
{
auto const indices = NumLib::getIndices(mesh_item_id, dof_table);
auto const local_x = x.get(indices);
std::vector<double> local_x_vec;
auto const n_processes = x.size();
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
auto const indices =
NumLib::getIndices(mesh_item_id, *dof_tables[process_id]);
assert(!indices.empty());
auto const local_solution = x[process_id]->get(indices);
local_x_vec.insert(std::end(local_x_vec), std::begin(local_solution),
std::end(local_solution));
}
auto const local_x = MathLib::toVector(local_x_vec);
postTimestepConcrete(local_x, t, dt);
}
......
......@@ -89,10 +89,10 @@ public:
GlobalVector const& x, double const t,
double const delta_t);
virtual void postTimestep(std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
GlobalVector const& x, double const t,
double const dt);
virtual void postTimestep(
std::size_t const mesh_item_id,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
std::vector<GlobalVector*> const& x, double const t, double const dt);
void postNonLinearSolver(std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
......@@ -141,7 +141,7 @@ private:
{
}
virtual void postTimestepConcrete(std::vector<double> const& /*local_x*/,
virtual void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/, double const /*dt*/)
{
}
......
......@@ -240,7 +240,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/, double const /*dt*/) override
{
unsigned const n_integration_points =
......
......@@ -147,7 +147,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/,
double const /*dt*/) override
{
......
......@@ -543,16 +543,22 @@ void RichardsMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
std::vector<GlobalVector*> const& x, double const t, double const dt,
const int process_id)
{
DBUG("PostTimestep RichardsMechanicsProcess.");
if (hasMechanicalProcess(process_id))
{
DBUG("PostTimestep RichardsMechanicsProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
auto const n_processes = x.size();
dof_tables.reserve(n_processes);
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
dof_tables.push_back(&getDOFTable(process_id));
}
ProcessLib::ProcessVariable const& pv =
getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerIF::postTimestep, _local_assemblers,
pv.getActiveElementIDs(), *_local_to_global_index_map,
*x[process_id], t, dt);
pv.getActiveElementIDs(), dof_tables, x, t, dt);
}
}
......
......@@ -319,7 +319,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const t, double const dt) override
{
unsigned const n_integration_points =
......
......@@ -245,13 +245,15 @@ void SmallDeformationProcess<DisplacementDim>::postTimestepConcreteProcess(
int const process_id)
{
DBUG("PostTimestep SmallDeformationProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
dof_tables.reserve(x.size());
std::generate_n(std::back_inserter(dof_tables), x.size(),
[&]() { return _local_to_global_index_map.get(); });
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::postTimestep, _local_assemblers,
pv.getActiveElementIDs(), *_local_to_global_index_map, *x[process_id],
t, dt);
pv.getActiveElementIDs(), dof_tables, x, t, dt);
std::unique_ptr<GlobalVector> material_forces;
ProcessLib::SmallDeformation::writeMaterialForces(
......
......@@ -529,7 +529,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/, double const /*dt*/) override
{
unsigned const n_integration_points =
......
......@@ -302,13 +302,15 @@ void SmallDeformationNonlocalProcess<DisplacementDim>::
int const process_id)
{
DBUG("PostTimestep SmallDeformationNonlocalProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
dof_tables.reserve(x.size());
std::generate_n(std::back_inserter(dof_tables), x.size(),
[&]() { return _local_to_global_index_map.get(); });
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::postTimestep, _local_assemblers,
pv.getActiveElementIDs(), *_local_to_global_index_map, *x[process_id],
t, dt);
pv.getActiveElementIDs(), dof_tables, x, t, dt);
}
template <int DisplacementDim>
......
......@@ -109,7 +109,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/,
double const /*dt*/) override
{
......
......@@ -350,10 +350,23 @@ void ThermoHydroMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
std::vector<GlobalVector*> const& x, double const t, double const dt,
const int process_id)
{
if (process_id != 0)
{
return;
}
DBUG("PostTimestep ThermoHydroMechanicsProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
auto const n_processes = x.size();
dof_tables.reserve(n_processes);
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
dof_tables.push_back(&getDOFTable(process_id));
}
GlobalExecutor::executeMemberOnDereferenced(
&LocalAssemblerInterface::postTimestep, _local_assemblers,
getDOFTable(process_id), *x[process_id], t, dt);
&LocalAssemblerInterface::postTimestep, _local_assemblers, dof_tables,
x, t, dt);
}
template <int DisplacementDim>
......
......@@ -254,7 +254,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/, double const /*dt*/) override
{
unsigned const n_integration_points =
......
......@@ -286,14 +286,24 @@ void ThermoMechanicalPhaseFieldProcess<DisplacementDim>::
double const dt,
int const process_id)
{
if (process_id != 0)
{
return;
}
DBUG("PostTimestep ThermoMechanicalPhaseFieldProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
auto const n_processes = x.size();
dof_tables.reserve(n_processes);
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
dof_tables.push_back(&getDOFTable(process_id));
}
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&ThermoMechanicalPhaseFieldLocalAssemblerInterface::postTimestep,
_local_assemblers, pv.getActiveElementIDs(), getDOFTable(process_id),
*x[process_id], t, dt);
_local_assemblers, pv.getActiveElementIDs(), dof_tables, x, t, dt);
}
template <int DisplacementDim>
......
......@@ -182,7 +182,7 @@ public:
}
}
void postTimestepConcrete(std::vector<double> const& /*local_x*/,
void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
double const /*t*/, double const /*dt*/) override
{
unsigned const n_integration_points =
......
......@@ -415,19 +415,24 @@ void ThermoMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
std::vector<GlobalVector*> const& x, double const t, double const dt,
int const process_id)
{
if (process_id != _process_data.mechanics_process_id)
if (process_id != 0)
{
return;
}
DBUG("PostTimestep ThermoMechanicsProcess.");
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
auto const n_processes = x.size();
dof_tables.reserve(n_processes);
for (std::size_t process_id = 0; process_id < n_processes; ++process_id)
{
dof_tables.push_back(&getDOFTable(process_id));
}
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::postTimestep, _local_assemblers,
pv.getActiveElementIDs(), *_local_to_global_index_map, *x[process_id],
t, dt);
pv.getActiveElementIDs(), dof_tables, x, t, dt);
}
template <int DisplacementDim>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment