Skip to content

Commit

Permalink
[PL/SD] Moved methods to local assembler interface
Browse files Browse the repository at this point in the history
  • Loading branch information
chleh committed Jun 17, 2024
1 parent 3c1b794 commit 30608a9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 88 deletions.
49 changes: 43 additions & 6 deletions ProcessLib/RichardsMechanics/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,38 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
name, values, current_states_);
}

virtual std::vector<double> getMaterialStateVariableInternalState(
std::vector<double> getMaterialStateVariableInternalState(
std::function<std::span<double>(
typename MaterialLib::Solids::MechanicsBase<DisplacementDim>::
MaterialStateVariables&)> const& get_values_span,
int const& n_components) const = 0;
int const& n_components) const
{
return ProcessLib::getIntegrationPointDataMaterialStateVariables(
material_states_,
&ProcessLib::ThermoRichardsMechanics::MaterialStateData<
DisplacementDim>::material_state_variables,
get_values_span, n_components);
}

// TODO move to NumLib::ExtrapolatableElement
virtual unsigned getNumberOfIntegrationPoints() const = 0;
unsigned getNumberOfIntegrationPoints() const
{
return integration_method_.getNumberOfPoints();
}

virtual int getMaterialID() const = 0;
int getMaterialID() const
{
return process_data_.material_ids == nullptr
? 0
: (*process_data_.material_ids)[element_.getID()];
}

virtual typename MaterialLib::Solids::MechanicsBase<
typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
getMaterialStateVariablesAt(unsigned /*integration_point*/) const = 0;
getMaterialStateVariablesAt(unsigned integration_point) const
{
return *material_states_[integration_point].material_state_variables;
}

static auto getReflectionDataForOutput()
{
Expand All @@ -137,6 +155,25 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
&Self::current_states_, &Self::output_data_);
}

void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
Eigen::VectorXd const& /*local_x_prev*/,
double const /*t*/, double const /*dt*/,
int const /*process_id*/) override final
{
unsigned const n_integration_points =
integration_method_.getNumberOfPoints();

for (auto& s : material_states_)
{
s.pushBackState();
}

for (unsigned ip = 0; ip < n_integration_points; ip++)
{
prev_states_[ip] = current_states_[ip];
}
}

protected:
RichardsMechanicsProcessData<DisplacementDim>& process_data_;
NumLib::GenericIntegrationMethod const& integration_method_;
Expand Down
48 changes: 0 additions & 48 deletions ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1443,34 +1443,6 @@ void RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
.noalias() += Kup * p_L;
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
int RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
ShapeFunctionPressure,
DisplacementDim>::getMaterialID() const
{
return this->process_data_.material_ids == nullptr
? 0
: (*this->process_data_.material_ids)[this->element_.getID()];
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
std::vector<double> RichardsMechanicsLocalAssembler<
ShapeFunctionDisplacement, ShapeFunctionPressure, DisplacementDim>::
getMaterialStateVariableInternalState(
std::function<std::span<double>(
typename MaterialLib::Solids::MechanicsBase<DisplacementDim>::
MaterialStateVariables&)> const& get_values_span,
int const& n_components) const
{
return ProcessLib::getIntegrationPointDataMaterialStateVariables(
this->material_states_,
&ProcessLib::ThermoRichardsMechanics::MaterialStateData<
DisplacementDim>::material_state_variables,
get_values_span, n_components);
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
void RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
Expand Down Expand Up @@ -1858,25 +1830,5 @@ void RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
DisplacementDim>(this->element_, this->is_axially_symmetric_, p_L,
*this->process_data_.pressure_interpolated);
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
unsigned RichardsMechanicsLocalAssembler<
ShapeFunctionDisplacement, ShapeFunctionPressure,
DisplacementDim>::getNumberOfIntegrationPoints() const
{
return this->integration_method_.getNumberOfPoints();
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
int DisplacementDim>
typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
ShapeFunctionPressure, DisplacementDim>::
getMaterialStateVariablesAt(unsigned integration_point) const
{
return *this->material_states_[integration_point].material_state_variables;
}
} // namespace RichardsMechanics
} // namespace ProcessLib
34 changes: 0 additions & 34 deletions ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,6 @@ class RichardsMechanicsLocalAssembler
}
}

void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
Eigen::VectorXd const& /*local_x_prev*/,
double const /*t*/, double const /*dt*/,
int const /*process_id*/) override
{
unsigned const n_integration_points =
this->integration_method_.getNumberOfPoints();

for (auto& s : this->material_states_)
{
s.pushBackState();
}

// TODO move to the local assembler interface
for (unsigned ip = 0; ip < n_integration_points; ip++)
{
this->prev_states_[ip] = this->current_states_[ip];
}
}

void computeSecondaryVariableConcrete(
double const t, double const dt, Eigen::VectorXd const& local_x,
Eigen::VectorXd const& local_x_prev) override;
Expand All @@ -191,14 +171,6 @@ class RichardsMechanicsLocalAssembler
return Eigen::Map<const Eigen::RowVectorXd>(N_u.data(), N_u.size());
}

int getMaterialID() const override;

std::vector<double> getMaterialStateVariableInternalState(
std::function<std::span<double>(
typename MaterialLib::Solids::MechanicsBase<DisplacementDim>::
MaterialStateVariables&)> const& get_values_span,
int const& n_components) const override;

private:
/**
* Assemble local matrices and vectors arise from the linearized discretized
Expand Down Expand Up @@ -261,12 +233,6 @@ class RichardsMechanicsLocalAssembler
std::vector<double>& local_K_data, std::vector<double>& local_b_data,
std::vector<double>& local_Jac_data);

unsigned getNumberOfIntegrationPoints() const override;

typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
getMaterialStateVariablesAt(unsigned integration_point) const override;

private:
static void assembleWithJacobianEvalConstitutiveSetting(
double const t, double const dt,
Expand Down

0 comments on commit 30608a9

Please sign in to comment.