Permalink
Browse files

Merge pull request #2286 from endJunction/SecondaryVariablesStaggeredFix

Secondary variables staggered fix
  • Loading branch information...
endJunction committed Dec 6, 2018
2 parents 651493d + f86f5e1 commit cb4411e564b99958fac0a891072e1782c78df1ab
@@ -103,12 +103,12 @@ void HeatConductionProcess::assembleWithJacobianConcreteProcess(
}
void HeatConductionProcess::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x)
const double t, GlobalVector const& x, int const process_id)
{
DBUG("Compute heat flux for HeatConductionProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&HeatConductionLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x,
_local_assemblers, getDOFTable(process_id), t, x,
_coupled_solutions);
}
@@ -39,7 +39,7 @@ class HeatConductionProcess final : public Process
bool isLinear() const override { return true; }
void computeSecondaryVariableConcrete(
double const t, GlobalVector const& x) override;
double const t, GlobalVector const& x, int const process_id) override;
private:
void initializeConcreteProcess(
@@ -182,12 +182,12 @@ void HeatTransportBHEProcess::assembleWithJacobianConcreteProcess(
}
void HeatTransportBHEProcess::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x)
const double t, GlobalVector const& x, int const process_id)
{
DBUG("Compute heat flux for HeatTransportBHE process.");
GlobalExecutor::executeMemberOnDereferenced(
&HeatTransportBHELocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x,
_local_assemblers, getDOFTable(process_id), t, x,
_coupled_solutions);
}
@@ -40,7 +40,8 @@ class HeatTransportBHEProcess final : public Process
bool isLinear() const override { return false; }
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
GlobalVector const& x,
int const process_id) override;
private:
void constructDofTable() override;
@@ -387,12 +387,12 @@ void HydroMechanicsProcess<DisplacementDim>::postNonLinearSolverConcreteProcess(
template <int DisplacementDim>
void HydroMechanicsProcess<DisplacementDim>::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x)
const double t, GlobalVector const& x, const int process_id)
{
DBUG("Compute the secondary variables for HydroMechanicsProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&LocalAssemblerInterface::computeSecondaryVariable, _local_assemblers,
*_local_to_global_index_map, t, x, _coupled_solutions);
getDOFTable(process_id), t, x, _coupled_solutions);
}
template <int DisplacementDim>
@@ -55,7 +55,7 @@ class HydroMechanicsProcess final : public Process
* process_id = 0. For the staggered scheme,
* process_id = 0 represents the
* hydraulic (H) process, while process_id = 1
* represents the mechanical (M) process.
* represents the mechanical (M) process.
* @return Matrix specifications including size and sparse pattern.
*/
MathLib::MatrixSpecifications getMatrixSpecifications(
@@ -116,8 +116,8 @@ class HydroMechanicsProcess final : public Process
/// Solutions of the previous time step
std::array<std::unique_ptr<GlobalVector>, 2> _xs_previous_timestep;
void computeSecondaryVariableConcrete(const double t,
GlobalVector const& x) override;
void computeSecondaryVariableConcrete(const double t, GlobalVector const& x,
const int process_id) override;
/**
* @copydoc ProcessLib::Process::getDOFTableForExtrapolatorData()
*/
@@ -427,12 +427,13 @@ void HydroMechanicsProcess<GlobalDim>::initializeConcreteProcess(
template <int GlobalDim>
void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x)
const double t, GlobalVector const& x, int const process_id)
{
const auto& dof_table = getDOFTable(process_id);
DBUG("Compute the secondary variables for HydroMechanicsProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&HydroMechanicsLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x,
_local_assemblers, dof_table, t, x,
_coupled_solutions);
// Copy displacement jumps in a solution vector to mesh property
@@ -465,7 +466,7 @@ void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
auto const num_comp = pv_g.getNumberOfComponents();
for (int component_id = 0; component_id < num_comp; ++component_id)
{
auto const& mesh_subset = _local_to_global_index_map->getMeshSubset(
auto const& mesh_subset = dof_table.getMeshSubset(
g_variable_id, component_id);
auto const mesh_id = mesh_subset.getMeshID();
for (auto const* node : mesh_subset.getNodes())
@@ -474,8 +475,7 @@ void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
node->getID());
auto const global_index =
_local_to_global_index_map->getGlobalIndex(l, g_variable_id,
component_id);
dof_table.getGlobalIndex(l, g_variable_id, component_id);
mesh_prop_g[node->getID() * num_comp + component_id] =
x[global_index];
}
@@ -49,7 +49,8 @@ class HydroMechanicsProcess final : public Process
//! @}
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
GlobalVector const& x,
int const process_id) override;
private:
using LocalAssemblerInterface = HydroMechanicsLocalAssemblerInterface;
@@ -411,13 +411,13 @@ void SmallDeformationProcess<DisplacementDim>::initializeConcreteProcess(
template <int DisplacementDim>
void SmallDeformationProcess<DisplacementDim>::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x)
const double t, GlobalVector const& x, int const process_id)
{
DBUG("Compute the secondary variables for SmallDeformationProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&SmallDeformationLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x,
_local_assemblers, getDOFTable(process_id), t, x,
_coupled_solutions);
}
@@ -45,7 +45,8 @@ class SmallDeformationProcess final : public Process
//! @}
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
GlobalVector const& x,
int const process_id) override;
private:
using LocalAssemblerInterface = SmallDeformationLocalAssemblerInterface;
@@ -86,7 +86,7 @@ void LiquidFlowProcess::assembleConcreteProcess(const double t,
DBUG("Assemble LiquidFlowProcess.");
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
dof_table = {std::ref(*_local_to_global_index_map)};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assemble, _local_assemblers,
@@ -101,21 +101,22 @@ void LiquidFlowProcess::assembleWithJacobianConcreteProcess(
DBUG("AssembleWithJacobian LiquidFlowProcess.");
std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>>
dof_table = {std::ref(*_local_to_global_index_map)};
dof_table = {std::ref(*_local_to_global_index_map)};
// Call global assembler for each local assembly item.
GlobalExecutor::executeMemberDereferenced(
_global_assembler, &VectorMatrixAssembler::assembleWithJacobian,
_local_assemblers, dof_table, t, x, xdot, dxdot_dx,
dx_dx, M, K, b, Jac, _coupled_solutions);
_local_assemblers, dof_table, t, x, xdot, dxdot_dx, dx_dx, M, K, b, Jac,
_coupled_solutions);
}
void LiquidFlowProcess::computeSecondaryVariableConcrete(const double t,
GlobalVector const& x)
GlobalVector const& x,
int const process_id)
{
DBUG("Compute the velocity for LiquidFlowProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&LiquidFlowLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, *_local_to_global_index_map, t, x,
_local_assemblers, getDOFTable(process_id), t, x,
_coupled_solutions);
}
@@ -73,7 +73,8 @@ class LiquidFlowProcess final : public Process
BaseLib::ConfigTree const& config);
void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x) override;
GlobalVector const& x,
int const process_id) override;
bool isLinear() const override { return true; }
int getGravitationalAxisID() const { return _gravitational_axis_id; }
@@ -356,11 +356,12 @@ void Process::postNonLinearSolver(GlobalVector const& x, const double t,
postNonLinearSolverConcreteProcess(x, t, process_id);
}
void Process::computeSecondaryVariable(const double t, GlobalVector const& x)
void Process::computeSecondaryVariable(const double t, GlobalVector const& x,
int const process_id)
{
MathLib::LinAlg::setLocalAccessibleVector(x);
computeSecondaryVariableConcrete(t, x);
computeSecondaryVariableConcrete(t, x, process_id);
}
void Process::preIteration(const unsigned iter, const GlobalVector& x)
@@ -71,7 +71,8 @@ class Process
void preIteration(const unsigned iter, GlobalVector const& x) 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,
int const process_id);
NumLib::IterationResult postIteration(GlobalVector const& x) final;
@@ -213,7 +214,8 @@ class Process
}
virtual void computeSecondaryVariableConcrete(const double /*t*/,
GlobalVector const& /*x*/)
GlobalVector const& /*x*/,
int const /*process_id*/)
{
}
@@ -348,12 +348,13 @@ void RichardsMechanicsProcess<
template <int DisplacementDim>
void RichardsMechanicsProcess<
DisplacementDim>::computeSecondaryVariableConcrete(const double t,
GlobalVector const& x)
GlobalVector const& x,
int const process_id)
{
DBUG("Compute the secondary variables for RichardsMechanicsProcess.");
GlobalExecutor::executeMemberOnDereferenced(
&LocalAssemblerInterface::computeSecondaryVariable, _local_assemblers,
*_local_to_global_index_map, t, x, _coupled_solutions);
getDOFTable(process_id), t, x, _coupled_solutions);
}
template <int DisplacementDim>
@@ -114,7 +114,8 @@ class RichardsMechanicsProcess final : public Process
std::array<std::unique_ptr<GlobalVector>, 2> _xs_previous_timestep;
void computeSecondaryVariableConcrete(const double t,
GlobalVector const& x) override;
GlobalVector const& x,
int const process_id) override;
/**
* @copydoc ProcessLib::Process::getDOFTableForExtrapolatorData()
*/
@@ -648,7 +648,7 @@ bool UncoupledProcessesTimeLoop::solveUncoupledEquationSystems(
process_id, x, timestep_id, t, dt, *process_data, *_output);
process_data->nonlinear_solver_converged = nonlinear_solver_succeeded;
pcs.postTimestep(x, t, dt, process_id);
pcs.computeSecondaryVariable(t, x);
pcs.computeSecondaryVariable(t, x, process_id);
INFO("[time] Solving process #%u took %g s in time step #%u ",
process_id, time_timestep_process.elapsed(), timestep_id);
@@ -822,7 +822,7 @@ bool UncoupledProcessesTimeLoop::solveCoupledEquationSystemsByStaggeredScheme(
auto& pcs = process_data->process;
auto& x = *_process_solutions[process_id];
pcs.postTimestep(x, t, dt, process_id);
pcs.computeSecondaryVariable(t, x);
pcs.computeSecondaryVariable(t, x, process_id);
++process_id;
}
@@ -858,7 +858,7 @@ void UncoupledProcessesTimeLoop::outputSolutions(
process_id);
// Update secondary variables, which might be uninitialized, before
// output.
pcs.computeSecondaryVariable(_start_time, x);
pcs.computeSecondaryVariable(_start_time, x, process_id);
}
if (is_staggered_coupling)
{

0 comments on commit cb4411e

Please sign in to comment.