Skip to content

Commit

Permalink
[PL] LIE/HM; rename computeSec. to postTimestep.
Browse files Browse the repository at this point in the history
This saves passing dt to all the computeSecondaryVariable
functions. Having the dt finally removes the dt member
from the ProcessData.
Calling postTimestep is equivalent to the call of compute
secondary; see TimeLoop.cpp; those are called one after
each other.
  • Loading branch information
endJunction committed Sep 20, 2019
1 parent 56180c3 commit 33905fd
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 42 deletions.
12 changes: 5 additions & 7 deletions ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp
Expand Up @@ -454,8 +454,9 @@ void HydroMechanicsProcess<GlobalDim>::initializeConcreteProcess(
}

template <int GlobalDim>
void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
const double t, GlobalVector const& x, int const process_id)
void HydroMechanicsProcess<GlobalDim>::postTimestepConcreteProcess(
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);
Expand All @@ -465,9 +466,8 @@ void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete(
getProcessVariables(process_id)[0];

GlobalExecutor::executeSelectedMemberOnDereferenced(
&HydroMechanicsLocalAssemblerInterface::computeSecondaryVariable,
_local_assemblers, pv.getActiveElementIDs(),
dof_table, t, x, _coupled_solutions);
&HydroMechanicsLocalAssemblerInterface::postTimestep,
_local_assemblers, pv.getActiveElementIDs(), dof_table, x, t, dt);
}

// Copy displacement jumps in a solution vector to mesh property
Expand Down Expand Up @@ -616,8 +616,6 @@ void HydroMechanicsProcess<GlobalDim>::preTimestepConcreteProcess(
{
DBUG("PreTimestep HydroMechanicsProcess.");

_process_data.dt = dt;

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

GlobalExecutor::executeSelectedMemberOnDereferenced(
Expand Down
6 changes: 3 additions & 3 deletions ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.h
Expand Up @@ -51,9 +51,9 @@ class HydroMechanicsProcess final : public Process
bool isLinear() const override;
//! @}

void computeSecondaryVariableConcrete(double const t,
GlobalVector const& x,
int const process_id) override;
void postTimestepConcreteProcess(GlobalVector const& x, double const t,
double const dt,
int const process_id) override;

private:
using LocalAssemblerInterface = HydroMechanicsLocalAssemblerInterface;
Expand Down
2 changes: 0 additions & 2 deletions ProcessLib/LIE/HydroMechanics/HydroMechanicsProcessData.h
Expand Up @@ -111,8 +111,6 @@ struct HydroMechanicsProcessData
std::unique_ptr<MeshLib::ElementStatus> p_element_status;
ParameterLib::Parameter<double> const* p0 = nullptr;

double dt = 0.0;

// mesh properties for output
MeshLib::PropertyVector<double>* mesh_prop_stress_xx = nullptr;
MeshLib::PropertyVector<double>* mesh_prop_stress_yy = nullptr;
Expand Down
Expand Up @@ -328,10 +328,10 @@ void HydroMechanicsLocalAssemblerFracture<ShapeFunctionDisplacement,

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int GlobalDim>
void HydroMechanicsLocalAssemblerFracture<ShapeFunctionDisplacement,
ShapeFunctionPressure,
IntegrationMethod, GlobalDim>::
computeSecondaryVariableConcreteWithVector(const double t,
void HydroMechanicsLocalAssemblerFracture<
ShapeFunctionDisplacement, ShapeFunctionPressure, IntegrationMethod,
GlobalDim>::postTimestepConcreteWithVector(const double t,
double const /*dt*/,
Eigen::VectorXd const& local_x)
{
auto const nodal_g = local_x.segment(displacement_index, displacement_size);
Expand Down
Expand Up @@ -57,8 +57,9 @@ class HydroMechanicsLocalAssemblerFracture
}
}

void computeSecondaryVariableConcreteWithVector(
const double t, Eigen::VectorXd const& local_x) override;
void postTimestepConcreteWithVector(
const double t, double const dt,
Eigen::VectorXd const& local_x) override;

Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix(
const unsigned integration_point) const override
Expand Down
Expand Up @@ -101,8 +101,8 @@ class HydroMechanicsLocalAssemblerInterface
}
}

void computeSecondaryVariableConcrete(
const double t, std::vector<double> const& local_x_) override
void postTimestepConcrete(std::vector<double> const& local_x_,
const double t, double const dt) override
{
auto const local_dof_size = local_x_.size();

Expand All @@ -112,7 +112,7 @@ class HydroMechanicsLocalAssemblerInterface
_local_u[_dofIndex_to_localIndex[i]] = local_x_[i];
}

computeSecondaryVariableConcreteWithVector(t, _local_u);
postTimestepConcreteWithVector(t, dt, _local_u);
}

protected:
Expand All @@ -122,8 +122,8 @@ class HydroMechanicsLocalAssemblerInterface
Eigen::VectorXd& local_b,
Eigen::MatrixXd& local_J) = 0;

virtual void computeSecondaryVariableConcreteWithVector(
double const t, Eigen::VectorXd const& local_u) = 0;
virtual void postTimestepConcreteWithVector(
double const t, double const dt, Eigen::VectorXd const& local_u) = 0;

MeshLib::Element const& _element;
bool const _is_axially_symmetric;
Expand Down
Expand Up @@ -294,10 +294,9 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int GlobalDim>
void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
ShapeFunctionPressure,
IntegrationMethod, GlobalDim>::
computeSecondaryVariableConcreteWithVector(double const t,
void HydroMechanicsLocalAssemblerMatrix<
ShapeFunctionDisplacement, ShapeFunctionPressure, IntegrationMethod,
GlobalDim>::postTimestepConcreteWithVector(double const t, double const dt,
Eigen::VectorXd const& local_x)
{
auto p = const_cast<Eigen::VectorXd&>(local_x).segment(pressure_index,
Expand All @@ -308,16 +307,16 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
}
auto u = local_x.segment(displacement_index, displacement_size);

computeSecondaryVariableConcreteWithBlockVectors(t, p, u);
postTimestepConcreteWithBlockVectors(t, dt, p, u);
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int GlobalDim>
void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
ShapeFunctionPressure,
IntegrationMethod, GlobalDim>::
computeSecondaryVariableConcreteWithBlockVectors(
double const t,
postTimestepConcreteWithBlockVectors(
double const t, double const dt,
Eigen::Ref<const Eigen::VectorXd> const& p,
Eigen::Ref<const Eigen::VectorXd> const& u)
{
Expand Down Expand Up @@ -354,8 +353,8 @@ void HydroMechanicsLocalAssemblerMatrix<ShapeFunctionDisplacement,
eps.noalias() = B * u;

auto&& solution = _ip_data[ip].solid_material.integrateStress(
t, x_position, _process_data.dt, eps_prev, eps, sigma_eff_prev,
*state, _process_data.reference_temperature);
t, x_position, dt, eps_prev, eps, sigma_eff_prev, *state,
_process_data.reference_temperature);

if (!solution)
{
Expand Down
Expand Up @@ -84,11 +84,12 @@ class HydroMechanicsLocalAssemblerMatrix
Eigen::Ref<Eigen::MatrixXd> J_pp, Eigen::Ref<Eigen::MatrixXd> J_pu,
Eigen::Ref<Eigen::MatrixXd> J_uu, Eigen::Ref<Eigen::MatrixXd> J_up);

void computeSecondaryVariableConcreteWithVector(
double const t, Eigen::VectorXd const& local_x) override;
void postTimestepConcreteWithVector(
double const t, double const dt,
Eigen::VectorXd const& local_x) override;

void computeSecondaryVariableConcreteWithBlockVectors(
double const t,
void postTimestepConcreteWithBlockVectors(
double const t, double const dt,
Eigen::Ref<const Eigen::VectorXd> const& p,
Eigen::Ref<const Eigen::VectorXd> const& u);

Expand Down
Expand Up @@ -131,8 +131,7 @@ template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int GlobalDim>
void HydroMechanicsLocalAssemblerMatrixNearFracture<
ShapeFunctionDisplacement, ShapeFunctionPressure, IntegrationMethod,
GlobalDim>::
computeSecondaryVariableConcreteWithVector(double const t,
GlobalDim>::postTimestepConcreteWithVector(double const t, double const dt,
Eigen::VectorXd const& local_x)
{
auto p = const_cast<Eigen::VectorXd&>(local_x).segment(pressure_index,
Expand All @@ -152,7 +151,7 @@ void HydroMechanicsLocalAssemblerMatrixNearFracture<
if (ele_levelset == 0)
{
// no DoF exists for displacement jumps. do the normal assembly
Base::computeSecondaryVariableConcreteWithBlockVectors(t, p, u);
Base::postTimestepConcreteWithBlockVectors(t, dt, p, u);
return;
}

Expand All @@ -163,7 +162,7 @@ void HydroMechanicsLocalAssemblerMatrixNearFracture<
Eigen::VectorXd const total_u = u + ele_levelset * g;

// evaluate residuals and Jacobians for pressure and displacements
Base::computeSecondaryVariableConcreteWithBlockVectors(t, p, total_u);
Base::postTimestepConcreteWithBlockVectors(t, dt, p, total_u);
}

} // namespace HydroMechanics
Expand Down
Expand Up @@ -71,8 +71,9 @@ class HydroMechanicsLocalAssemblerMatrixNearFracture
}
}

void computeSecondaryVariableConcreteWithVector(
double const t, Eigen::VectorXd const& local_x) override;
void postTimestepConcreteWithVector(
double const t, double const dt,
Eigen::VectorXd const& local_x) override;

using Base::_element;
using Base::_ip_data;
Expand Down

0 comments on commit 33905fd

Please sign in to comment.