Skip to content

Commit

Permalink
Merge branch 'remove-coupled-solutions' into 'master'
Browse files Browse the repository at this point in the history
Remove CoupledSolutionsForStaggeredScheme

Closes #3432

See merge request ogs/ogs!4784
  • Loading branch information
endJunction committed Nov 6, 2023
2 parents 8b0e75f + 8d9e3fe commit fd732ac
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 236 deletions.
1 change: 0 additions & 1 deletion ProcessLib/AbstractJacobianAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
namespace ProcessLib
{
class LocalAssemblerInterface;
struct LocalCoupledSolutions;

//! Base class for Jacobian assemblers.
class AbstractJacobianAssembler
Expand Down
1 change: 0 additions & 1 deletion ProcessLib/AnalyticalJacobianAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "AnalyticalJacobianAssembler.h"

#include "CoupledSolutionsForStaggeredScheme.h"
#include "LocalAssemblerInterface.h"

namespace ProcessLib
Expand Down
2 changes: 0 additions & 2 deletions ProcessLib/AnalyticalJacobianAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class ConfigTree;
namespace ProcessLib
{

struct LocalCoupledSolutions;

//! Assembles the Jacobian matrix using a provided "analytical" method from the
//! local assembler.
class AnalyticalJacobianAssembler final : public AbstractJacobianAssembler
Expand Down
1 change: 0 additions & 1 deletion ProcessLib/ComponentTransport/ComponentTransportFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "NumLib/NumericalStability/AdvectionMatrixAssembler.h"
#include "NumLib/NumericalStability/HydrodynamicDispersion.h"
#include "ParameterLib/Parameter.h"
#include "ProcessLib/CoupledSolutionsForStaggeredScheme.h"
#include "ProcessLib/LocalAssemblerInterface.h"
#include "ProcessLib/ProcessVariable.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "MeshLib/Utils/getOrCreateMeshProperty.h"
#include "NumLib/DOF/ComputeSparsityPattern.h"
#include "NumLib/ODESolver/NonlinearSystem.h"
#include "ProcessLib/CoupledSolutionsForStaggeredScheme.h"
#include "ProcessLib/SurfaceFlux/SurfaceFlux.h"
#include "ProcessLib/SurfaceFlux/SurfaceFluxData.h"
#include "ProcessLib/Utils/ComputeResiduum.h"
Expand Down
10 changes: 0 additions & 10 deletions ProcessLib/CoupledSolutionsForStaggeredScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@

namespace ProcessLib
{
CoupledSolutionsForStaggeredScheme::CoupledSolutionsForStaggeredScheme(
std::vector<GlobalVector*> const& coupled_xs_)
: coupled_xs(coupled_xs_)
{
for (auto const* coupled_x : coupled_xs)
{
MathLib::LinAlg::setLocalAccessibleVector(*coupled_x);
}
}

std::vector<double> getCoupledLocalSolutions(
std::vector<GlobalVector*> const& global_solutions,
std::vector<std::vector<GlobalIndexType>> const& indices)
Expand Down
39 changes: 0 additions & 39 deletions ProcessLib/CoupledSolutionsForStaggeredScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,6 @@

namespace ProcessLib
{
/**
* A struct to keep the references of the current solutions of the equations of
* the coupled processes.
*
* During staggered coupling iteration, an instance of this struct is created
* and passed through interfaces to global and local assemblers for each
* process.
*/
struct CoupledSolutionsForStaggeredScheme
{
explicit CoupledSolutionsForStaggeredScheme(
std::vector<GlobalVector*> const& coupled_xs_);

/// References to the current solutions of the coupled processes.
std::vector<GlobalVector*> const& coupled_xs;

/// Pointers to the vector of the solutions of the previous time step.
std::vector<GlobalVector*> coupled_xs_t0;
};

/**
* A struct to keep the references to the local element solutions of the
* current and previous time step solutions of the equations of the coupled
* processes.
*
* During the global assembly loop, an instance of this struct is created for
* each element and it is then passed to local assemblers.
*/
struct LocalCoupledSolutions
{
explicit LocalCoupledSolutions(std::vector<double>&& local_coupled_xs0_)
: local_coupled_xs0(std::move(local_coupled_xs0_))
{
}

/// Local solutions of the previous time step.
std::vector<double> const local_coupled_xs0;
};

/**
* Fetch the nodal solutions of all coupled processes from the given vector of
* global solutions for each process into a flat vector.
Expand Down
19 changes: 0 additions & 19 deletions ProcessLib/HT/HTLocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

namespace ProcessLib
{
struct CoupledSolutionsForStaggeredScheme;

namespace HT
{
Expand Down Expand Up @@ -46,12 +45,6 @@ class HTLocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
{
public:
HTLocalAssemblerInterface() = default;
void setStaggeredCoupledSolutions(
std::size_t const /*mesh_item_id*/,
CoupledSolutionsForStaggeredScheme* const coupling_term)
{
_coupled_solutions = coupling_term;
}

virtual std::vector<double> const& getIntPtDarcyVelocity(
const double /*t*/,
Expand All @@ -63,18 +56,6 @@ class HTLocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
double const t,
std::vector<double> const& local_x) const override =
0;

protected:
// TODO: remove _coupled_solutions or move integration point data from
// local assembler class to a new class to make local assembler unique
// for each process.
/** Pointer to CoupledSolutionsForStaggeredScheme that is set in a
* member of Process class,
* setCoupledTermForTheStaggeredSchemeToLocalAssemblers. It is used for
* calculate the secondary variables like velocity for coupled
* processes.
*/
CoupledSolutionsForStaggeredScheme* _coupled_solutions{nullptr};
};

} // namespace HT
Expand Down
12 changes: 1 addition & 11 deletions ProcessLib/HT/HTProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "MonolithicHTFEM.h"
#include "NumLib/DOF/DOFTableUtil.h"
#include "NumLib/DOF/LocalToGlobalIndexMap.h"
#include "ProcessLib/CoupledSolutionsForStaggeredScheme.h"
#include "ProcessLib/SurfaceFlux/SurfaceFluxData.h"
#include "ProcessLib/Utils/CreateLocalAssemblers.h"
#include "StaggeredHTFEM.h"
Expand Down Expand Up @@ -137,17 +138,6 @@ void HTProcess::assembleWithJacobianConcreteProcess(
x_prev, process_id, M, K, b, Jac);
}

void HTProcess::setCoupledTermForTheStaggeredSchemeToLocalAssemblers(
int const process_id)
{
DBUG("Set the coupled term for the staggered scheme to local assemblers.");

ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&HTLocalAssemblerInterface::setStaggeredCoupledSolutions,
_local_assemblers, pv.getActiveElementIDs(), _coupled_solutions);
}

std::tuple<NumLib::LocalToGlobalIndexMap*, bool>
HTProcess::getDOFTableForExtrapolatorData() const
{
Expand Down
3 changes: 0 additions & 3 deletions ProcessLib/HT/HTProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ class HTProcess final : public Process
double const t,
std::vector<GlobalVector*> const& x) const override;

void setCoupledTermForTheStaggeredSchemeToLocalAssemblers(
int const process_id) override;

void postTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev,
const double t,
Expand Down
1 change: 0 additions & 1 deletion ProcessLib/HT/StaggeredHTFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace ProcessLib
{
struct LocalCoupledSolutions;

namespace HT
{
Expand Down
1 change: 0 additions & 1 deletion ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "MaterialLib/SolidModels/SelectSolidConstitutiveRelation.h"
#include "MathLib/KelvinVector.h"
#include "NumLib/Function/Interpolation.h"
#include "ProcessLib/CoupledSolutionsForStaggeredScheme.h"
#include "ProcessLib/Utils/SetOrGetIntegrationPointData.h"

namespace ProcessLib
Expand Down
5 changes: 3 additions & 2 deletions ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,9 @@ void HydroMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(

template <int DisplacementDim>
void HydroMechanicsProcess<DisplacementDim>::postNonLinearSolverConcreteProcess(
GlobalVector const& x, GlobalVector const& x_prev, const double t,
double const dt, const int process_id)
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev, const double t, double const dt,
const int process_id)
{
DBUG("PostNonLinearSolver HydroMechanicsProcess.");

Expand Down
8 changes: 4 additions & 4 deletions ProcessLib/HydroMechanics/HydroMechanicsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ class HydroMechanicsProcess final : public Process
const double t, const double dt,
int const process_id) override;

void postNonLinearSolverConcreteProcess(GlobalVector const& x,
GlobalVector const& x_prev,
const double t, double const dt,
int const process_id) override;
void postNonLinearSolverConcreteProcess(
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev, const double t,
double const dt, int const process_id) override;

void setInitialConditionsConcreteProcess(std::vector<GlobalVector*>& x,
double const t,
Expand Down
10 changes: 5 additions & 5 deletions ProcessLib/LocalAssemblerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <cassert>

#include "CoupledSolutionsForStaggeredScheme.h"
#include "MathLib/LinAlg/Eigen/EigenMapTools.h"
#include "NumLib/DOF/DOFTableUtil.h"

Expand Down Expand Up @@ -162,13 +161,14 @@ void LocalAssemblerInterface::postTimestep(

void LocalAssemblerInterface::postNonLinearSolver(
std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table, GlobalVector const& x,
GlobalVector const& x_prev, double const t, double const dt,
NumLib::LocalToGlobalIndexMap const& dof_table,
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev, double const t, double const dt,
bool const use_monolithic_scheme, int const process_id)
{
auto const indices = NumLib::getIndices(mesh_item_id, dof_table);
auto const local_x = x.get(indices);
auto const local_x_prev = x_prev.get(indices);
auto const local_x = x[process_id]->get(indices);
auto const local_x_prev = x_prev[process_id]->get(indices);

postNonLinearSolverConcrete(local_x, local_x_prev, t, dt,
use_monolithic_scheme, process_id);
Expand Down
5 changes: 2 additions & 3 deletions ProcessLib/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class LocalToGlobalIndexMap;

namespace ProcessLib
{
struct CoupledSolutionsForStaggeredScheme;
struct LocalCoupledSolutions;

/*! Common interface for local assemblers
* NumLib::ODESystemTag::FirstOrderImplicitQuasilinear ODE systems.
Expand Down Expand Up @@ -97,7 +95,8 @@ class LocalAssemblerInterface

void postNonLinearSolver(std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
GlobalVector const& x, GlobalVector const& x_prev,
std::vector<GlobalVector*> const& x,
std::vector<GlobalVector*> const& x_prev,
double const t, double const dt,
bool const use_monolithic_scheme,
int const process_id);
Expand Down
10 changes: 5 additions & 5 deletions ProcessLib/PhaseField/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ struct PhaseFieldLocalAssemblerInterface
std::vector<
std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
GlobalVector const& x, double const t, double& crack_volume,
CoupledSolutionsForStaggeredScheme const* const cpl_xs) = 0;
std::vector<GlobalVector*> const& x, double const t,
double& crack_volume) = 0;

virtual void computeEnergy(
std::size_t mesh_item_id,
std::vector<
std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
GlobalVector const& x, double const t, double& elastic_energy,
double& surface_energy, double& pressure_work,
CoupledSolutionsForStaggeredScheme const* const cpl_xs) = 0;
std::vector<GlobalVector*> const& x, double const t,
double& elastic_energy, double& surface_energy,
double& pressure_work) = 0;
};

} // namespace PhaseField
Expand Down
19 changes: 6 additions & 13 deletions ProcessLib/PhaseField/PhaseFieldFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,17 @@ void PhaseFieldLocalAssembler<ShapeFunction, DisplacementDim>::
computeCrackIntegral(std::size_t mesh_item_id,
std::vector<std::reference_wrapper<
NumLib::LocalToGlobalIndexMap>> const& dof_tables,
GlobalVector const& /*x*/, double const /*t*/,
double& crack_volume,
CoupledSolutionsForStaggeredScheme const* const cpl_xs)
std::vector<GlobalVector*> const& x,
double const /*t*/, double& crack_volume)
{
assert(cpl_xs != nullptr);

std::vector<std::vector<GlobalIndexType>> indices_of_processes;
indices_of_processes.reserve(dof_tables.size());
std::transform(dof_tables.begin(), dof_tables.end(),
std::back_inserter(indices_of_processes),
[&](NumLib::LocalToGlobalIndexMap const& dof_table)
{ return NumLib::getIndices(mesh_item_id, dof_table); });

auto local_coupled_xs =
getCoupledLocalSolutions(cpl_xs->coupled_xs, indices_of_processes);
auto local_coupled_xs = getCoupledLocalSolutions(x, indices_of_processes);
assert(local_coupled_xs.size() == displacement_size + phasefield_size);

auto const d = Eigen::Map<PhaseFieldVector const>(
Expand Down Expand Up @@ -314,12 +310,9 @@ void PhaseFieldLocalAssembler<ShapeFunction, DisplacementDim>::computeEnergy(
std::size_t mesh_item_id,
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
GlobalVector const& /*x*/, double const t, double& elastic_energy,
double& surface_energy, double& pressure_work,
CoupledSolutionsForStaggeredScheme const* const cpl_xs)
std::vector<GlobalVector*> const& x, double const t, double& elastic_energy,
double& surface_energy, double& pressure_work)
{
assert(cpl_xs != nullptr);

std::vector<std::vector<GlobalIndexType>> indices_of_processes;
indices_of_processes.reserve(dof_tables.size());
std::transform(dof_tables.begin(), dof_tables.end(),
Expand All @@ -328,7 +321,7 @@ void PhaseFieldLocalAssembler<ShapeFunction, DisplacementDim>::computeEnergy(
{ return NumLib::getIndices(mesh_item_id, dof_table); });

auto const local_coupled_xs =
getCoupledLocalSolutions(cpl_xs->coupled_xs, indices_of_processes);
getCoupledLocalSolutions(x, indices_of_processes);
assert(local_coupled_xs.size() == displacement_size + phasefield_size);

auto const d = Eigen::Map<PhaseFieldVector const>(
Expand Down
20 changes: 9 additions & 11 deletions ProcessLib/PhaseField/PhaseFieldFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,15 @@ class PhaseFieldLocalAssembler : public PhaseFieldLocalAssemblerInterface
std::vector<
std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
GlobalVector const& x, double const t, double& crack_volume,
CoupledSolutionsForStaggeredScheme const* const cpl_xs) override;

void computeEnergy(
std::size_t mesh_item_id,
std::vector<
std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const&
dof_tables,
GlobalVector const& x, double const t, double& elastic_energy,
double& surface_energy, double& pressure_work,
CoupledSolutionsForStaggeredScheme const* const cpl_xs) override;
std::vector<GlobalVector*> const& x, double const t,
double& crack_volume) override;

void computeEnergy(std::size_t mesh_item_id,
std::vector<std::reference_wrapper<
NumLib::LocalToGlobalIndexMap>> const& dof_tables,
std::vector<GlobalVector*> const& x, double const t,
double& elastic_energy, double& surface_energy,
double& pressure_work) override;

Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
const unsigned integration_point) const override
Expand Down
Loading

0 comments on commit fd732ac

Please sign in to comment.