Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal variables for TM/RM/HM #2732

Merged
merged 3 commits into from
Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ProcessLib/HydroMechanics/HydroMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,5 +796,25 @@ void HydroMechanicsLocalAssembler<ShapeFunctionDisplacement,
}
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int DisplacementDim>
unsigned HydroMechanicsLocalAssembler<
ShapeFunctionDisplacement, ShapeFunctionPressure, IntegrationMethod,
DisplacementDim>::getNumberOfIntegrationPoints() const
{
return _integration_method.getNumberOfPoints();
}

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int DisplacementDim>
typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
HydroMechanicsLocalAssembler<ShapeFunctionDisplacement, ShapeFunctionPressure,
IntegrationMethod, DisplacementDim>::
getMaterialStateVariablesAt(unsigned integration_point) const
{
return *_ip_data[integration_point].material_state_variables;
}

} // namespace HydroMechanics
} // namespace ProcessLib
9 changes: 8 additions & 1 deletion ProcessLib/HydroMechanics/HydroMechanicsFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ struct SecondaryData

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int DisplacementDim>
class HydroMechanicsLocalAssembler : public LocalAssemblerInterface
class HydroMechanicsLocalAssembler
: public LocalAssemblerInterface<DisplacementDim>
{
public:
using ShapeMatricesTypeDisplacement =
Expand Down Expand Up @@ -436,6 +437,12 @@ class HydroMechanicsLocalAssembler : public LocalAssemblerInterface
std::vector<double>& local_b_data, std::vector<double>& local_Jac_data,
LocalCoupledSolutions const& local_coupled_solutions);

unsigned getNumberOfIntegrationPoints() const override;

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

private:
HydroMechanicsProcessData<DisplacementDim>& _process_data;

Expand Down
114 changes: 52 additions & 62 deletions ProcessLib/HydroMechanics/HydroMechanicsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@

#include <cassert>

#include "HydroMechanicsFEM.h"
#include "HydroMechanicsProcessData.h"
#include "MeshLib/Elements/Utils.h"
#include "NumLib/DOF/ComputeSparsityPattern.h"
#include "ProcessLib/Deformation/SolidMaterialInternalToSecondaryVariables.h"
#include "ProcessLib/HydroMechanics/CreateLocalAssemblers.h"
#include "ProcessLib/Process.h"

#include "HydroMechanicsFEM.h"
#include "HydroMechanicsProcessData.h"

namespace ProcessLib
{
namespace HydroMechanics
Expand Down Expand Up @@ -208,77 +207,68 @@ void HydroMechanicsProcess<DisplacementDim>::initializeConcreteProcess(
_local_assemblers, mesh.isAxiallySymmetric(), integration_order,
_process_data);

_secondary_variables.addSecondaryVariable(
"sigma_xx",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtSigmaXX));
auto add_secondary_variable = [&](std::string const& name,
int const num_components,
auto get_ip_values_function) {
_secondary_variables.addSecondaryVariable(
name,
makeExtrapolator(num_components, getExtrapolator(),
_local_assemblers,
std::move(get_ip_values_function)));
};

add_secondary_variable(
"sigma_xx", 1, &LocalAssemblerIF::getIntPtSigmaXX);

_secondary_variables.addSecondaryVariable(
"sigma_yy",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtSigmaYY));
add_secondary_variable(
"sigma_yy", 1, &LocalAssemblerIF::getIntPtSigmaYY);

_secondary_variables.addSecondaryVariable(
"sigma_zz",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtSigmaZZ));
add_secondary_variable(
"sigma_zz", 1, &LocalAssemblerIF::getIntPtSigmaZZ);

_secondary_variables.addSecondaryVariable(
"sigma_xy",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtSigmaXY));
add_secondary_variable(
"sigma_xy", 1, &LocalAssemblerIF::getIntPtSigmaXY);

if (DisplacementDim == 3)
{
_secondary_variables.addSecondaryVariable(
"sigma_xz",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtSigmaXZ));
add_secondary_variable(
"sigma_xz", 1, &LocalAssemblerIF::getIntPtSigmaXZ);

_secondary_variables.addSecondaryVariable(
"sigma_yz",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtSigmaYZ));
add_secondary_variable(
"sigma_yz", 1, &LocalAssemblerIF::getIntPtSigmaYZ);
}

_secondary_variables.addSecondaryVariable(
"epsilon_xx",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtEpsilonXX));
add_secondary_variable(
"epsilon_xx", 1, &LocalAssemblerIF::getIntPtEpsilonXX);

_secondary_variables.addSecondaryVariable(
"epsilon_yy",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtEpsilonYY));
add_secondary_variable(
"epsilon_yy", 1, &LocalAssemblerIF::getIntPtEpsilonYY);

_secondary_variables.addSecondaryVariable(
"epsilon_zz",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtEpsilonZZ));
add_secondary_variable(
"epsilon_zz", 1, &LocalAssemblerIF::getIntPtEpsilonZZ);

_secondary_variables.addSecondaryVariable(
"epsilon_xy",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtEpsilonXY));
add_secondary_variable(
"epsilon_xy", 1, &LocalAssemblerIF::getIntPtEpsilonXY);

if (DisplacementDim == 3)
{
_secondary_variables.addSecondaryVariable(
"epsilon_xz",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtEpsilonXZ));
add_secondary_variable(
"epsilon_xz", 1, &LocalAssemblerIF::getIntPtEpsilonXZ);

_secondary_variables.addSecondaryVariable(
"epsilon_yz",
makeExtrapolator(1, getExtrapolator(), _local_assemblers,
&LocalAssemblerInterface::getIntPtEpsilonYZ));
add_secondary_variable(
"epsilon_yz", 1, &LocalAssemblerIF::getIntPtEpsilonYZ);
}

_secondary_variables.addSecondaryVariable(
"velocity",
makeExtrapolator(mesh.getDimension(), getExtrapolator(),
_local_assemblers,
&LocalAssemblerInterface::getIntPtDarcyVelocity));
add_secondary_variable("velocity",
DisplacementDim,
&LocalAssemblerIF::getIntPtDarcyVelocity);

//
// enable output of internal variables defined by material models
//
ProcessLib::Deformation::solidMaterialInternalToSecondaryVariables<
LocalAssemblerIF>(_process_data.solid_materials,
add_secondary_variable);

_process_data.pressure_interpolated =
MeshLib::getOrCreateMeshProperty<double>(
Expand Down Expand Up @@ -357,7 +347,7 @@ void HydroMechanicsProcess<DisplacementDim>::initializeConcreteProcess(

// Initialize local assemblers after all variables have been set.
GlobalExecutor::executeMemberOnDereferenced(
&LocalAssemblerInterface::initialize, _local_assemblers,
&LocalAssemblerIF::initialize, _local_assemblers,
*_local_to_global_index_map);
}

Expand Down Expand Up @@ -483,7 +473,7 @@ void HydroMechanicsProcess<DisplacementDim>::preTimestepConcreteProcess(
ProcessLib::ProcessVariable const& pv =
getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::preTimestep, _local_assemblers,
&LocalAssemblerIF::preTimestep, _local_assemblers,
pv.getActiveElementIDs(), *_local_to_global_index_map,
*x[process_id], t, dt);
}
Expand All @@ -497,7 +487,7 @@ void HydroMechanicsProcess<DisplacementDim>::postTimestepConcreteProcess(
DBUG("PostTimestep HydroMechanicsProcess.");
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::postTimestep, _local_assemblers,
&LocalAssemblerIF::postTimestep, _local_assemblers,
pv.getActiveElementIDs(), getDOFTable(process_id), *x[process_id], t,
dt);
}
Expand All @@ -516,7 +506,7 @@ void HydroMechanicsProcess<DisplacementDim>::postNonLinearSolverConcreteProcess(
// Calculate strain, stress or other internal variables of mechanics.
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::postNonLinearSolver, _local_assemblers,
&LocalAssemblerIF::postNonLinearSolver, _local_assemblers,
pv.getActiveElementIDs(), getDOFTable(process_id), x, t, dt,
_use_monolithic_scheme);
}
Expand All @@ -528,7 +518,7 @@ void HydroMechanicsProcess<DisplacementDim>::computeSecondaryVariableConcrete(
DBUG("Compute the secondary variables for HydroMechanicsProcess.");
ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
GlobalExecutor::executeSelectedMemberOnDereferenced(
&LocalAssemblerInterface::computeSecondaryVariable, _local_assemblers,
&LocalAssemblerIF::computeSecondaryVariable, _local_assemblers,
pv.getActiveElementIDs(), getDOFTable(process_id), t, x,
_coupled_solutions);
}
Expand Down
4 changes: 3 additions & 1 deletion ProcessLib/HydroMechanics/HydroMechanicsProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class HydroMechanicsProcess final : public Process
const int process_id) const override;

private:
using LocalAssemblerIF = LocalAssemblerInterface<DisplacementDim>;

void constructDofTable() override;

void initializeConcreteProcess(
Expand Down Expand Up @@ -103,7 +105,7 @@ class HydroMechanicsProcess final : public Process
std::unique_ptr<MeshLib::MeshSubset const> _mesh_subset_base_nodes;
HydroMechanicsProcessData<DisplacementDim> _process_data;

std::vector<std::unique_ptr<LocalAssemblerInterface>> _local_assemblers;
std::vector<std::unique_ptr<LocalAssemblerIF>> _local_assemblers;

std::unique_ptr<NumLib::LocalToGlobalIndexMap>
_local_to_global_index_map_single_component;
Expand Down
14 changes: 11 additions & 3 deletions ProcessLib/HydroMechanics/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@

#pragma once

#include "MaterialLib/SolidModels/MechanicsBase.h"
#include "NumLib/Extrapolation/ExtrapolatableElement.h"
#include "ProcessLib/LocalAssemblerInterface.h"

namespace ProcessLib
{
namespace HydroMechanics
{
struct LocalAssemblerInterface
: public ProcessLib::LocalAssemblerInterface,
public NumLib::ExtrapolatableElement
template <int DisplacementDim>
struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
public NumLib::ExtrapolatableElement
{
virtual std::size_t setIPDataInitialConditions(
std::string const& name, double const* values,
Expand Down Expand Up @@ -106,6 +107,13 @@ struct LocalAssemblerInterface
std::vector<GlobalVector*> const& x,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
std::vector<double>& cache) const = 0;

// TODO move to NumLib::ExtrapolatableElement
virtual unsigned getNumberOfIntegrationPoints() const = 0;

virtual typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
getMaterialStateVariablesAt(unsigned /*integration_point*/) const = 0;
};

} // namespace HydroMechanics
Expand Down
9 changes: 9 additions & 0 deletions ProcessLib/RichardsMechanics/LocalAssemblerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

#pragma once

#include "MaterialLib/SolidModels/MechanicsBase.h"
#include "NumLib/Extrapolation/ExtrapolatableElement.h"
#include "ProcessLib/LocalAssemblerInterface.h"

namespace ProcessLib
{
namespace RichardsMechanics
{
template <int DisplacementDim>
struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
public NumLib::ExtrapolatableElement
{
Expand All @@ -43,6 +45,13 @@ struct LocalAssemblerInterface : public ProcessLib::LocalAssemblerInterface,
std::vector<GlobalVector*> const& x,
std::vector<NumLib::LocalToGlobalIndexMap const*> const& dof_table,
std::vector<double>& cache) const = 0;

// TODO move to NumLib::ExtrapolatableElement
virtual unsigned getNumberOfIntegrationPoints() const = 0;

virtual typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
getMaterialStateVariablesAt(unsigned /*integration_point*/) const = 0;
};

} // namespace RichardsMechanics
Expand Down
20 changes: 20 additions & 0 deletions ProcessLib/RichardsMechanics/RichardsMechanicsFEM-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -886,5 +886,25 @@ void RichardsMechanicsLocalAssembler<ShapeFunctionDisplacement,
*_process_data.pressure_interpolated);
}

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

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int DisplacementDim>
typename MaterialLib::Solids::MechanicsBase<
DisplacementDim>::MaterialStateVariables const&
RichardsMechanicsLocalAssembler<
ShapeFunctionDisplacement, ShapeFunctionPressure, IntegrationMethod,
DisplacementDim>::getMaterialStateVariablesAt(unsigned integration_point)
const
{
return *_ip_data[integration_point].material_state_variables;
}
} // namespace RichardsMechanics
} // namespace ProcessLib
9 changes: 8 additions & 1 deletion ProcessLib/RichardsMechanics/RichardsMechanicsFEM.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ struct SecondaryData

template <typename ShapeFunctionDisplacement, typename ShapeFunctionPressure,
typename IntegrationMethod, int DisplacementDim>
class RichardsMechanicsLocalAssembler : public LocalAssemblerInterface
class RichardsMechanicsLocalAssembler
: public LocalAssemblerInterface<DisplacementDim>
{
public:
using ShapeMatricesTypeDisplacement =
Expand Down Expand Up @@ -244,6 +245,12 @@ class RichardsMechanicsLocalAssembler : public LocalAssemblerInterface
std::vector<double>& local_b_data, std::vector<double>& local_Jac_data,
LocalCoupledSolutions const& local_coupled_solutions);

unsigned getNumberOfIntegrationPoints() const override;

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

private:
RichardsMechanicsProcessData<DisplacementDim>& _process_data;

Expand Down
Loading