19 template <
typename DisplacementBasedElement,
typename Traits>
24 static constexpr int worldDim = Traits::worlddim;
33 template <
typename VolumeLoad>
34 explicit Volume(VolumeLoad p_volumeLoad = {}) {
35 if constexpr (!std::is_same_v<VolumeLoad, utils::LoadDefault>) volumeLoad = p_volumeLoad;
56 calculateVectorImpl<double>(req, force);
66 calculateMatrixImpl<double>(req, K);
70 template <
typename ScalarType>
72 = std::nullopt)
const -> ScalarType {
73 if (not volumeLoad)
return 0.0;
74 ScalarType energy = 0.0;
75 const auto uFunction = dbElement().displacementFunction(par, dx);
76 const auto geo = dbElement().geometry();
79 for (
const auto& [gpIndex, gp] : uFunction.viewOverIntegrationPoints()) {
80 const auto uVal = uFunction.evaluate(gpIndex);
81 Eigen::Vector<double, worldDim> fext = volumeLoad(geo.global(gp.position()), lambda);
82 energy -= uVal.dot(fext) * geo.integrationElement(gp.position()) * gp.weight();
87 template <
typename ScalarType>
89 const std::optional<
const Eigen::VectorX<ScalarType>>& dx = std::nullopt)
const {
90 if (not volumeLoad)
return;
91 using namespace Dune::DerivativeDirections;
93 const auto uFunction = dbElement().displacementFunction(par, dx);
94 const auto geo = dbElement().geometry();
97 for (
const auto& [gpIndex, gp] : uFunction.viewOverIntegrationPoints()) {
98 const Eigen::Vector<double, worldDim> fext = volumeLoad(geo.global(gp.position()), lambda);
99 const double intElement = geo.integrationElement(gp.position()) * gp.weight();
100 for (
size_t i = 0; i < dbElement().numberOfNodes(); ++i) {
101 const auto udCi = uFunction.evaluateDerivative(gpIndex, wrt(coeff(i)));
102 force.template segment<worldDim>(
worldDim * i) -= udCi * fext * intElement;
107 template <
typename ScalarType>
109 const std::optional<
const Eigen::VectorX<ScalarType>>& dx = std::nullopt)
const {}
120 constexpr const DisplacementBasedElement& dbElement()
const {
121 return static_cast<DisplacementBasedElement const&
>(*this);
Collection of fallback default functions.
Definition of the LinearElastic class for finite element mechanics computations.
Definition: simpleassemblers.hh:21
Definition: resultevaluators.hh:17
Volume class represents distributed volume load that can be applied.
Definition: volume.hh:20
typename Traits::FERequirementType FERequirementType
Definition: volume.hh:22
typename Traits::LocalView LocalView
Definition: volume.hh:23
double calculateScalar(const FERequirementType &req) const
Calculate the scalar value.
Definition: volume.hh:46
auto calculateScalarImpl(const FERequirementType &par, const std::optional< const Eigen::VectorX< ScalarType > > &dx=std::nullopt) const -> ScalarType
Definition: volume.hh:71
Volume(VolumeLoad p_volumeLoad={})
Constructor for the Loads class.
Definition: volume.hh:34
void calculateMatrixImpl(const FERequirementType &par, typename Traits::template MatrixType<> K, const std::optional< const Eigen::VectorX< ScalarType > > &dx=std::nullopt) const
Definition: volume.hh:108
static constexpr int worldDim
Definition: volume.hh:24
void calculateMatrix(const FERequirementType &req, typename Traits::template MatrixType<> K) const
Calculate the matrix associated with the given FERequirementType.
Definition: volume.hh:65
void calculateVector(const FERequirementType &req, typename Traits::template VectorType<> force) const
Calculate the vector associated with the given FERequirementType.
Definition: volume.hh:55
void calculateVectorImpl(const FERequirementType &par, typename Traits::template VectorType< ScalarType > force, const std::optional< const Eigen::VectorX< ScalarType > > &dx=std::nullopt) const
Definition: volume.hh:88
Definition: resultevaluators.hh:20