Skip to content
Snippets Groups Projects
Commit bc2e5060 authored by wenqing's avatar wenqing
Browse files

[Coupling] Implemented the computation of the secondary variables with

 coupled processes.
parent a2cdbbc4
No related branches found
No related tags found
No related merge requests found
Showing
with 114 additions and 30 deletions
......@@ -104,13 +104,14 @@ void GroundwaterFlowProcess::assembleWithJacobianConcreteProcess(
}
void GroundwaterFlowProcess::computeSecondaryVariableConcrete(const double t,
GlobalVector const& x)
void GroundwaterFlowProcess::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term)
{
DBUG("Compute the velocity for GroundwaterFlowProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&GroundwaterFlowLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x);
_local_assemblers, *_local_to_global_index_map, t, x, coupled_term);
}
} // namespace GroundwaterFlow
......
......@@ -88,7 +88,9 @@ public:
}
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
GlobalVector const& x,
StaggeredCouplingTerm const&
coupled_term) override;
private:
void initializeConcreteProcess(
......
......@@ -115,13 +115,14 @@ void HeatConductionProcess::assembleWithJacobianConcreteProcess(
dx_dx, M, K, b, Jac, coupling_term);
}
void HeatConductionProcess::computeSecondaryVariableConcrete(const double t,
GlobalVector const& x)
void HeatConductionProcess::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term)
{
DBUG("Compute heat flux for HeatConductionProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&HeatConductionLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x);
_local_assemblers, *_local_to_global_index_map, t, x, coupled_term);
}
} // namespace HeatConduction
......
......@@ -38,8 +38,9 @@ public:
bool isLinear() const override { return true; }
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
void computeSecondaryVariableConcrete(
double const t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term) override;
void preTimestepConcreteProcess(GlobalVector const& x, const double t,
const double delta_t) override;
......
......@@ -349,12 +349,13 @@ void HydroMechanicsProcess<GlobalDim>::initializeConcreteProcess(
template <unsigned GlobalDim>
void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x)
const double t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term)
{
DBUG("Compute the secondary variables for HydroMechanicsProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&HydroMechanicsLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x);
_local_assemblers, *_local_to_global_index_map, t, x, coupled_term);
}
// ------------------------------------------------------------------------------------
......
......@@ -53,7 +53,9 @@ public:
//! @}
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
GlobalVector const& x,
StaggeredCouplingTerm const&
coupled_term) override;
private:
using LocalAssemblerInterface = HydroMechanicsLocalAssemblerInterface;
......
......@@ -306,6 +306,35 @@ void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>::
}
}
template <typename ShapeFunction, typename IntegrationMethod,
unsigned GlobalDim>
void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>::
computeSecondaryVariableWithCoupledProcessConcrete(
double const t, std::vector<double> const& local_x,
std::unordered_map<std::type_index, const std::vector<double>> const&
coupled_local_solutions)
{
SpatialPosition pos;
pos.setElementID(_element.getID());
const int material_id = _material_properties.getMaterialID(pos);
const Eigen::MatrixXd& perm = _material_properties.getPermeability(
material_id, t, pos, _element.getDimension());
const auto local_T = coupled_local_solutions.at(std::type_index(
typeid(ProcessLib::HeatConduction::HeatConductionProcess)));
// Note: For Inclined 1D in 2D/3D or 2D element in 3D, the first item in
// the assert must be changed to perm.rows() == _element->getDimension()
assert(perm.rows() == GlobalDim || perm.rows() == 1);
if (perm.size() == 1) // isotropic or 1D problem.
computeSecondaryVariableCoupledWithHeatTransportLocal<
IsotropicCalculator>(t, local_x, local_T, pos, perm);
else
computeSecondaryVariableCoupledWithHeatTransportLocal<
AnisotropicCalculator>(t, local_x, local_T, pos, perm);
}
template <typename ShapeFunction, typename IntegrationMethod,
unsigned GlobalDim>
template <typename LaplacianGravityVelocityCalculator>
......
......@@ -12,8 +12,10 @@
#pragma once
#include <map>
#include <unordered_map>
#include <vector>
#include <memory>
#include <typeindex>
#include "MathLib/LinAlg/Eigen/EigenMapTools.h"
#include "NumLib/Extrapolation/ExtrapolatableElement.h"
......@@ -95,6 +97,11 @@ public:
void computeSecondaryVariableConcrete(
double const /*t*/, std::vector<double> const& local_x) override;
void computeSecondaryVariableWithCoupledProcessConcrete(
double const t, std::vector<double> const& local_x,
std::unordered_map<std::type_index, const std::vector<double>> const&
coupled_local_solutions) override;
Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
const unsigned integration_point) const override
{
......
......@@ -115,13 +115,15 @@ void LiquidFlowProcess::assembleWithJacobianConcreteProcess(
dx_dx, M, K, b, Jac, coupling_term);
}
void LiquidFlowProcess::computeSecondaryVariableConcrete(const double t,
GlobalVector const& x)
void LiquidFlowProcess::computeSecondaryVariableConcrete(
const double t,
GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term)
{
DBUG("Compute the velocity for LiquidFlowProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&LiquidFlowLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x);
_local_assemblers, *_local_to_global_index_map, t, x, coupled_term);
}
} // end of namespace
......
......@@ -72,8 +72,10 @@ public:
double const gravitational_acceleration,
BaseLib::ConfigTree const& config);
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
void computeSecondaryVariableConcrete(
double const t,
GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term) override;
bool isLinear() const override { return true; }
int getGravitationalAxisID() const { return _gravitational_axis_id; }
......
......@@ -56,11 +56,24 @@ void LocalAssemblerInterface::assembleWithJacobianAndCouping(
void LocalAssemblerInterface::computeSecondaryVariable(
std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
double const t, GlobalVector const& x)
double const t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term)
{
auto const indices = NumLib::getIndices(mesh_item_id, dof_table);
auto const local_x = x.get(indices);
computeSecondaryVariableConcrete(t, local_x);
if (coupled_term.empty)
{
computeSecondaryVariableConcrete(t, local_x);
}
else
{
auto const local_coupled_xs
= getCurrentLocalSolutionsOfCoupledProcesses(
coupled_term.coupled_xs, indices);
computeSecondaryVariableWithCoupledProcessConcrete(t, local_x,
local_coupled_xs);
}
}
void LocalAssemblerInterface::preTimestep(
......
......@@ -9,6 +9,10 @@
#pragma once
#include <unordered_map>
#include <typeindex>
#include "NumLib/NumericsConfig.h"
#include "MathLib/Point3d.h"
#include "StaggeredCouplingTerm.h"
......@@ -64,7 +68,8 @@ public:
virtual void computeSecondaryVariable(std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
const double t, GlobalVector const& x);
const double t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term);
virtual void preTimestep(std::size_t const mesh_item_id,
NumLib::LocalToGlobalIndexMap const& dof_table,
......@@ -94,6 +99,12 @@ private:
virtual void computeSecondaryVariableConcrete
(double const /*t*/, std::vector<double> const& /*local_x*/) {}
virtual void computeSecondaryVariableWithCoupledProcessConcrete
(double const /*t*/, std::vector<double> const& /*local_x*/,
std::unordered_map<std::type_index,
const std::vector<double>> const&
/*coupled_local_solutions*/) {}
};
} // namespace ProcessLib
......@@ -246,9 +246,11 @@ void Process::postTimestep(GlobalVector const& x)
postTimestepConcreteProcess(x);
}
void Process::computeSecondaryVariable( const double t, GlobalVector const& x)
void Process::computeSecondaryVariable(const double t, GlobalVector const& x,
StaggeredCouplingTerm const&
coupled_term)
{
computeSecondaryVariableConcrete(t, x);
computeSecondaryVariableConcrete(t, x, coupled_term);
}
void Process::preIteration(const unsigned iter, const GlobalVector &x)
......
......@@ -60,7 +60,8 @@ public:
GlobalVector const& x) override final;
/// compute secondary variables for the coupled equations or for output.
void computeSecondaryVariable(const double t, GlobalVector const& x);
void computeSecondaryVariable(const double t, GlobalVector const& x,
StaggeredCouplingTerm const& coupled_term);
NumLib::IterationResult postIteration(GlobalVector const& x) override final;
......@@ -165,7 +166,9 @@ private:
GlobalVector const& /*x*/){}
virtual void computeSecondaryVariableConcrete(const double /*t*/,
GlobalVector const& /*x*/) {}
GlobalVector const& /*x*/,
StaggeredCouplingTerm
const& /*coupled_term*/) {}
virtual NumLib::IterationResult postIterationConcreteProcess(
GlobalVector const& /*x*/)
......
......@@ -659,11 +659,14 @@ bool UncoupledProcessesTimeLoop::solveUncoupledEquationSystems(
auto& x = *_process_solutions[pcs_idx];
pcs.preTimestep(x, t, dt);
const auto nonlinear_solver_succeeded = solveOneTimeStepOneProcess(
x, timestep_id, t, dt, *spd,
ProcessLib::createVoidStaggeredCouplingTerm(), *_output);
const auto void_staggered_coupling_term =
ProcessLib::createVoidStaggeredCouplingTerm();
const auto nonlinear_solver_succeeded =
solveOneTimeStepOneProcess(x, timestep_id, t, dt, *spd,
void_staggered_coupling_term, *_output);
pcs.postTimestep(x);
pcs.computeSecondaryVariable(t, x);
pcs.computeSecondaryVariable(t, x, void_staggered_coupling_term);
INFO("[time] Solving process #%u took %g s in time step #%u ", pcs_idx,
time_timestep_process.elapsed(), timestep_id);
......@@ -791,7 +794,11 @@ bool UncoupledProcessesTimeLoop::solveCoupledEquationSystemsByStaggeredScheme(
auto& pcs = spd->process;
auto& x = *_process_solutions[pcs_idx];
pcs.postTimestep(x);
pcs.computeSecondaryVariable(t, x);
StaggeredCouplingTerm coupled_term(
spd->coupled_processes, _solutions_of_coupled_processes[pcs_idx],
0.0);
pcs.computeSecondaryVariable(t, x, coupled_term);
_output->doOutput(pcs, spd->process_output, timestep_id, t, x);
++pcs_idx;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment