Skip to content

Commit

Permalink
Merge branch 'dof_arg_type_ref_to_pointer' into 'master'
Browse files Browse the repository at this point in the history
[ProcessLib] Make consistency of the type of  dof_tables argument

See merge request ogs/ogs!4968
  • Loading branch information
endJunction committed Apr 15, 2024
2 parents 06c4053 + 65938c6 commit 443a4fd
Show file tree
Hide file tree
Showing 34 changed files with 184 additions and 227 deletions.
21 changes: 9 additions & 12 deletions ProcessLib/Assembly/AssembledMatrixCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ struct AssembledMatrixCache final
bool const use_monolithic_scheme);

template <typename VectorOfLocalAssemblers>
void assemble(const double t, double const dt,
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev,
int const process_id, GlobalMatrix& M, GlobalMatrix& K,
GlobalVector& b,
std::vector<std::reference_wrapper<
NumLib::LocalToGlobalIndexMap>> const& dof_tables,
VectorMatrixAssembler& global_assembler,
VectorOfLocalAssemblers const& local_assemblers,
std::vector<std::size_t> const& active_element_ids);
void assemble(
const double t, double const dt, std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
VectorMatrixAssembler& global_assembler,
VectorOfLocalAssemblers const& local_assemblers,
std::vector<std::size_t> const& active_element_ids);

bool isLinear() const { return is_linear_; }

Expand All @@ -56,8 +54,7 @@ void AssembledMatrixCache::assemble(
const double t, double const dt, std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b,
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
VectorMatrixAssembler& global_assembler,
VectorOfLocalAssemblers const& local_assemblers,
std::vector<std::size_t> const& active_element_ids)
Expand Down
5 changes: 2 additions & 3 deletions ProcessLib/Assembly/ParallelVectorMatrixAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
BaseLib::PolymorphicRandomAccessContainerView<
LocalAssemblerInterface> const& local_assemblers,
std::vector<std::size_t> const& active_elements,
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
const double t, double const dt, std::vector<GlobalVector*> const& xs,
std::vector<GlobalVector*> const& x_prevs, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac)
Expand All @@ -134,7 +133,7 @@ void ParallelVectorMatrixAssembler::assembleWithJacobian(
{
OGS_FATAL("More than 1 dof table");
}
auto const& dof_table = dof_tables.front().get();
auto const& dof_table = *(dof_tables.front());

if (xs.size() != 1)
{
Expand Down
4 changes: 1 addition & 3 deletions ProcessLib/Assembly/ParallelVectorMatrixAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class ParallelVectorMatrixAssembler
BaseLib::PolymorphicRandomAccessContainerView<
LocalAssemblerInterface> const& local_assemblers,
std::vector<std::size_t> const& active_elements,
std::vector<
std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_tables,
const double t, double const dt, std::vector<GlobalVector*> const& xs,
std::vector<GlobalVector*> const& x_prevs, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac);
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/AssemblyMixin.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class AssemblyMixin : private AssemblyMixinBase
GlobalVector& b, Jac&... jac_or_not_jac)
{
// TODO why not getDOFTables(x.size()); ?
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const
dof_tables{*derived()._local_to_global_index_map};
std::vector<NumLib::LocalToGlobalIndexMap const*> const dof_tables{
derived()._local_to_global_index_map.get()};

auto const& loc_asms = derived().local_assemblers_;

Expand All @@ -211,7 +211,7 @@ class AssemblyMixin : private AssemblyMixinBase
MathLib::LinAlg::axpy(b, 1.0, b_submesh);

AssemblyMixinBase::copyResiduumVectorsToSubmesh(
b_submesh, dof_tables.front().get(), sad);
b_submesh, *(dof_tables.front()), sad);
}

NumLib::GlobalVectorProvider::provider.releaseVector(b_submesh);
Expand All @@ -229,7 +229,7 @@ class AssemblyMixin : private AssemblyMixinBase
}

AssemblyMixinBase::copyResiduumVectorsToBulkMesh(
b, dof_tables.front().get(), residuum_vectors_bulk_);
b, *(dof_tables.front()), residuum_vectors_bulk_);
}
};

Expand Down
31 changes: 14 additions & 17 deletions ProcessLib/ComponentTransport/ComponentTransportProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,16 @@ void ComponentTransportProcess::assembleConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_tables;
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
if (_use_monolithic_scheme)
{
dof_tables.push_back(std::ref(*_local_to_global_index_map));
dof_tables.push_back(_local_to_global_index_map.get());
}
else
{
std::generate_n(
std::back_inserter(dof_tables), _process_variables.size(),
[&]() { return std::ref(*_local_to_global_index_map); });
std::generate_n(std::back_inserter(dof_tables),
_process_variables.size(),
[&]() { return _local_to_global_index_map.get(); });
}

_asm_mat_cache.assemble(t, dt, x, x_prev, process_id, M, K, b, dof_tables,
Expand Down Expand Up @@ -274,11 +273,10 @@ void ComponentTransportProcess::assembleWithJacobianConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_tables;
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;

std::generate_n(std::back_inserter(dof_tables), _process_variables.size(),
[&]() { return std::ref(*_local_to_global_index_map); });
[&]() { return _local_to_global_index_map.get(); });

// Call global assembler for each local assembly item.
GlobalExecutor::executeSelectedMemberDereferenced(
Expand Down Expand Up @@ -511,17 +509,16 @@ void ComponentTransportProcess::preOutputConcreteProcess(

assembleConcreteProcess(t, dt, x, x_prev, process_id, *M, *K, *b);

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_tables;
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
if (_use_monolithic_scheme)
{
dof_tables.push_back(std::ref(*_local_to_global_index_map));
dof_tables.push_back(_local_to_global_index_map.get());
}
else
{
std::generate_n(
std::back_inserter(dof_tables), _process_variables.size(),
[&]() { return std::ref(*_local_to_global_index_map); });
std::generate_n(std::back_inserter(dof_tables),
_process_variables.size(),
[&]() { return _local_to_global_index_map.get(); });
}

BaseLib::RunTime time_residuum;
Expand All @@ -535,15 +532,15 @@ void ComponentTransportProcess::preOutputConcreteProcess(
++variable_id)
{
transformVariableFromGlobalVector(
residuum, variable_id, dof_tables[0], *_residua[variable_id],
residuum, variable_id, *dof_tables[0], *_residua[variable_id],
std::negate<double>());
}
}
else
{
auto const residuum = computeResiduum(dt, *x[process_id],
*x_prev[process_id], *M, *K, *b);
transformVariableFromGlobalVector(residuum, 0, dof_tables[process_id],
transformVariableFromGlobalVector(residuum, 0, *dof_tables[process_id],
*_residua[process_id],
std::negate<double>());
}
Expand Down
18 changes: 8 additions & 10 deletions ProcessLib/HT/HTProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ void HTProcess::assembleConcreteProcess(
std::vector<GlobalVector*> const& x_prev, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b)
{
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_tables;
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
if (_use_monolithic_scheme)
{
DBUG("Assemble HTProcess.");
dof_tables.emplace_back(*_local_to_global_index_map);
dof_tables.emplace_back(_local_to_global_index_map.get());
}
else
{
Expand All @@ -99,8 +98,8 @@ void HTProcess::assembleConcreteProcess(
"Assemble the equations of single phase fully saturated "
"fluid flow process within HTProcess.");
}
dof_tables.emplace_back(*_local_to_global_index_map);
dof_tables.emplace_back(*_local_to_global_index_map);
dof_tables.emplace_back(_local_to_global_index_map.get());
dof_tables.emplace_back(_local_to_global_index_map.get());
}

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
Expand All @@ -118,16 +117,15 @@ void HTProcess::assembleWithJacobianConcreteProcess(
{
DBUG("AssembleWithJacobian HTProcess.");

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_tables;
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
if (!_use_monolithic_scheme)
{
dof_tables.emplace_back(std::ref(*_local_to_global_index_map));
dof_tables.emplace_back(_local_to_global_index_map.get());
}
else
{
dof_tables.emplace_back(std::ref(*_local_to_global_index_map));
dof_tables.emplace_back(std::ref(*_local_to_global_index_map));
dof_tables.emplace_back(_local_to_global_index_map.get());
dof_tables.emplace_back(_local_to_global_index_map.get());
}

// Call global assembler for each local assembly item.
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/HeatConduction/HeatConductionProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void HeatConductionProcess::assembleConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};

_asm_mat_cache.assemble(t, dt, x, x_prev, process_id, M, K, b, dof_table,
_global_assembler, _local_assemblers,
Expand All @@ -119,8 +119,8 @@ void HeatConductionProcess::assembleWithJacobianConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
// Call global assembler for each local assembly item.
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/HeatTransportBHE/HeatTransportBHEProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ void HeatTransportBHEProcess::assembleConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
// Call global assembler for each local assembly item.
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
Expand All @@ -183,8 +183,8 @@ void HeatTransportBHEProcess::assembleWithJacobianConcreteProcess(
{
DBUG("AssembleWithJacobian HeatTransportBHE process.");

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

// Call global assembler for each local assembly item.
Expand Down
14 changes: 5 additions & 9 deletions ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ void HydroMechanicsProcess<DisplacementDim>::assembleConcreteProcess(
// only the Newton-Raphson method is employed to simulate coupled HM
// processes in this class, this function is actually not used so far.

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};

GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
Expand All @@ -310,16 +310,13 @@ void HydroMechanicsProcess<DisplacementDim>::
std::vector<GlobalVector*> const& x_prev, int const process_id,
GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac)
{
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_tables;
// For the monolithic scheme
bool const use_monolithic_scheme = _process_data.isMonolithicSchemeUsed();
if (use_monolithic_scheme)
{
DBUG(
"Assemble the Jacobian of HydroMechanics for the monolithic "
"scheme.");
dof_tables.emplace_back(*_local_to_global_index_map);
}
else
{
Expand All @@ -336,10 +333,9 @@ void HydroMechanicsProcess<DisplacementDim>::
"Assemble the Jacobian equations of mechanical process in "
"HydroMechanics for the staggered scheme.");
}
dof_tables.emplace_back(*_local_to_global_index_map_with_base_nodes);
dof_tables.emplace_back(*_local_to_global_index_map);
}

auto const dof_tables = getDOFTables(x.size());
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
_local_assemblers, getActiveElementIDs(), dof_tables, t, dt, x, x_prev,
Expand All @@ -349,13 +345,13 @@ void HydroMechanicsProcess<DisplacementDim>::
{
if (use_monolithic_scheme)
{
transformVariableFromGlobalVector(b, variable_id, dof_tables[0],
transformVariableFromGlobalVector(b, variable_id, *dof_tables[0],
output_vector,
std::negate<double>());
}
else
{
transformVariableFromGlobalVector(b, 0, dof_tables[process_id],
transformVariableFromGlobalVector(b, 0, *dof_tables[process_id],
output_vector,
std::negate<double>());
}
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ void HydroMechanicsProcess<GlobalDim>::assembleConcreteProcess(
{
DBUG("Assemble HydroMechanicsProcess.");

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
Expand All @@ -470,8 +470,8 @@ void HydroMechanicsProcess<GlobalDim>::assembleWithJacobianConcreteProcess(
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

// Call global assembler for each local assembly item.
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
_local_assemblers, pv.getActiveElementIDs(), dof_table, t, dt, x,
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/LIE/SmallDeformation/SmallDeformationProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ void SmallDeformationProcess<DisplacementDim>::assembleConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
// Call global assembler for each local assembly item.
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
Expand All @@ -439,8 +439,8 @@ void SmallDeformationProcess<DisplacementDim>::
// Call global assembler for each local assembly item.
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
_local_assemblers, pv.getActiveElementIDs(), dof_table, t, dt, x,
Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/LargeDeformation/LargeDeformationProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ void LargeDeformationProcess<DisplacementDim>::assembleConcreteProcess(

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
// Call global assembler for each local assembly item.
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
Expand All @@ -160,8 +160,8 @@ void LargeDeformationProcess<DisplacementDim>::

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];

std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
_local_to_global_index_map.get()};
// Call global assembler for each local assembly item.
GlobalExecutor::executeSelectedMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
Expand Down
Loading

0 comments on commit 443a4fd

Please sign in to comment.