14#include <dune/localfefunctions/eigenDuneTransformations.hh>
21template <
typename PreFE,
typename FE>
32 template <
typename PreFE,
typename FE>
44template <
typename PreFE,
typename FE>
46 :
public ResultTypeBase<ResultTypes::cauchyAxialForce, ResultTypes::PK2AxialForce, ResultTypes::linearAxialForce>
62 static_assert(
myDim == 1,
"Truss elements should have myDim == 1");
72 template <
typename ST>
99 template <
typename ST =
double>
101 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ST>>>& dx = std::nullopt)
const {
103 auto disp = Ikarus::FEHelper::localSolutionBlockVector<Traits>(d, underlying().localView(), dx);
116 template <
class ST =
double>
119 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ST>>>& dx = std::nullopt)
const {
121 const auto& localView = underlying().localView();
122 const auto& tree = localView.tree();
123 const auto numberOfNodes = tree.child(0).finiteElement().size();
124 auto& ele = localView.element();
125 const auto X1 = Dune::toEigen(ele.geometry().corner(0));
126 const auto X2 = Dune::toEigen(ele.geometry().corner(1));
128 const auto A1 = X2 - X1;
129 const auto ud1 = u.col(1) - u.col(0);
131 const Eigen::Vector<ST, worldDim> x1 = X1 + u.col(0);
132 const Eigen::Vector<ST, worldDim> x2 = X2 + u.col(1);
134 const double Lsquared = A1.squaredNorm();
135 const ST lsquared = (x2 - x1).squaredNorm();
137 kin.
L = sqrt(Lsquared);
138 kin.
l = sqrt(lsquared);
141 kin.
Elin = (kin.
l - kin.
L) / kin.
L;
144 kin.
Egl = 0.5 * (lsquared - Lsquared) / Lsquared;
148 kin.
dEdu << -A1 - ud1, A1 + ud1;
149 kin.
dEdu /= Lsquared;
153 kin.
ddEddu.template topRightCorner<worldDim, worldDim>() = -Eigen::Matrix<ST, worldDim, worldDim>::Identity();
154 kin.
ddEddu.template bottomLeftCorner<worldDim, worldDim>() = -Eigen::Matrix<ST, worldDim, worldDim>::Identity();
171 template <
template <
typename,
int,
int>
class RT>
172 requires(supportsResultType<RT>())
174 Dune::PriorityTag<0>)
const {
176 const auto [L, l, Elin, Egl, dEdu, ddEddu] =
computeStrain(req);
177 if constexpr (isSameResultType<RT, ResultTypes::cauchyAxialForce>) {
178 auto N = Eigen::Vector<double, 1>{E * A * Egl * l / L};
181 if constexpr (isSameResultType<RT, ResultTypes::PK2AxialForce>) {
182 auto N = Eigen::Vector<double, 1>{E * A * Egl};
185 if constexpr (isSameResultType<RT, ResultTypes::linearAxialForce>) {
186 auto N = Eigen::Vector<double, 1>{E * A * Elin};
193 const auto& underlying()
const {
return static_cast<const FE&
>(*this); }
194 auto& underlying() {
return static_cast<FE&
>(*this); }
200 template <
typename ScalarType>
203 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ScalarType>>>& dx = std::nullopt)
const {
204 const auto [L, l, Elin, Egl, dEdu, ddEddu] =
computeStrain(par, dx);
205 K += E * A * L * (dEdu * dEdu.transpose() + ddEddu * Egl);
208 template <
typename ScalarType>
210 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ScalarType>>>& dx =
211 std::nullopt)
const -> ScalarType {
212 const auto [L, l, Elin, Egl, dEdu, ddEddu] =
computeStrain(par, dx);
213 return 0.5 * E * A * L * Egl * Egl;
216 template <
typename ScalarType>
219 const std::optional<std::reference_wrapper<
const Eigen::VectorX<ScalarType>>>& dx = std::nullopt)
const {
220 const auto [L, l, Elin, Egl, dEdu, ddEddu] =
computeStrain(par, dx);
221 force += E * A * Egl * L * dEdu;
231inline auto truss(
const double E,
const double A) {
Definition of the LinearElastic class for finite element mechanics computations.
auto viewAsEigenMatrixAsDynFixed(Dune::BlockVector< ValueType > &blockedVector)
View Dune::BlockVector as an Eigen::Matrix with dynamic rows and fixed columns depending on the size ...
Definition: linearalgebrahelper.hh:88
Definition: assemblermanipulatorbuildingblocks.hh:22
auto truss(const double E, const double A)
A helper function to create a truss pre finite element.
Definition: truss.hh:231
MatrixAffordance
A strongly typed enum class representing the matrix affordance.
Definition: ferequirements.hh:63
VectorAffordance
A strongly typed enum class representing the vector affordance.
Definition: ferequirements.hh:48
ScalarAffordance
A strongly typed enum class representing the scalar affordance.
Definition: ferequirements.hh:37
FE class is a base class for all finite elements.
Definition: febase.hh:79
FETraits< BH, useEigenRef, useFlat > Traits
Definition: febase.hh:38
Class representing the requirements for finite element calculations.
Definition: ferequirements.hh:252
SolutionVectorReturnType globalSolution()
Get the global solution vector.
Definition: ferequirements.hh:308
Container that is used for FE Results. It gives access to the stored value, but can also be used to a...
Definition: feresulttypes.hh:159
Base class for element definitions that provides common functionality for ResultTypes.
Definition: feresulttypes.hh:272
Traits for handling finite elements.
Definition: fetraits.hh:25
typename Basis::LocalView LocalView
Type of the local view.
Definition: fetraits.hh:42
typename Element::Geometry Geometry
Type of the element geometry.
Definition: fetraits.hh:51
BH BasisHandler
Type of the basis of the finite element.
Definition: fetraits.hh:27
typename Basis::GridView GridView
Type of the grid view.
Definition: fetraits.hh:45
static constexpr int worlddim
Dimension of the world space.
Definition: fetraits.hh:60
typename BasisHandler::FlatBasis FlatBasis
Type of the flat basis.
Definition: fetraits.hh:33
typename LocalView::Element Element
Type of the grid element.
Definition: fetraits.hh:48
static constexpr int mydim
Dimension of the geometry.
Definition: fetraits.hh:63
Truss class represents a truss finite element.
Definition: truss.hh:47
void calculateVectorImpl(const Requirement &par, VectorAffordance affordance, typename Traits::template VectorType< ScalarType > force, const std::optional< std::reference_wrapper< const Eigen::VectorX< ScalarType > > > &dx=std::nullopt) const
Definition: truss.hh:217
auto calculateAtImpl(const Requirement &req, const Dune::FieldVector< double, Traits::mydim > &local, Dune::PriorityTag< 0 >) const
Calculates a requested result at a specific local position.
Definition: truss.hh:173
typename Traits::LocalView LocalView
Definition: truss.hh:54
Truss(const Pre &pre)
Constructor for the Truss class.
Definition: truss.hh:87
static constexpr int worldDim
Definition: truss.hh:61
void calculateMatrixImpl(const Requirement &par, const MatrixAffordance &affordance, typename Traits::template MatrixType<> K, const std::optional< std::reference_wrapper< const Eigen::VectorX< ScalarType > > > &dx=std::nullopt) const
Definition: truss.hh:201
typename Traits::Geometry Geometry
Definition: truss.hh:55
typename Traits::FlatBasis FlatBasis
Definition: truss.hh:51
typename Traits::GridView GridView
Definition: truss.hh:56
typename Traits::BasisHandler BasisHandler
Definition: truss.hh:50
static constexpr int myDim
Definition: truss.hh:60
auto calculateScalarImpl(const Requirement &par, ScalarAffordance affordance, const std::optional< std::reference_wrapper< const Eigen::VectorX< ScalarType > > > &dx=std::nullopt) const -> ScalarType
Definition: truss.hh:209
typename Traits::Element Element
Definition: truss.hh:57
KinematicVariables< ST > computeStrain(const Requirement &par, const std::optional< std::reference_wrapper< const Eigen::VectorX< ST > > > &dx=std::nullopt) const
Gets the strain for the given Requirement and optional displacement vector.
Definition: truss.hh:117
auto displacement(const Requirement &par, const std::optional< std::reference_wrapper< const Eigen::VectorX< ST > > > &dx=std::nullopt) const
Gets the displacement for the given Requirement and optional displacement vector.
Definition: truss.hh:100
A PreFE struct for truss elements.
Definition: truss.hh:28
double E
Definition: truss.hh:29
double A
Definition: truss.hh:30
A structure representing kinematic variables.
Definition: truss.hh:74
double L
Length of the reference geometry.
Definition: truss.hh:75
Eigen::MatrixX< ST > ddEddu
second derivative of Egl w.r.t displacements
Definition: truss.hh:80
ST l
Length of the deformed geometry.
Definition: truss.hh:76
ST Egl
Green-Lagrange strain.
Definition: truss.hh:78
ST Elin
Linear strain.
Definition: truss.hh:77
Eigen::VectorX< ST > dEdu
first derivative of Egl w.r.t displacements
Definition: truss.hh:79
Definition: utils/dirichletvalues.hh:32