version 3.11-dev
Loading...
Searching...
No Matches
solidmechanics/hyperelastic_voliso/localresidual.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
24#ifndef DUMUX_SOLIDMECHANICS_HYPERELASTIC_VOLISO_LOCAL_RESIDUAL_HH
25#define DUMUX_SOLIDMECHANICS_HYPERELASTIC_VOLISO_LOCAL_RESIDUAL_HH
26
27#include <vector>
28
29#include <dune/common/fmatrix.hh>
30#include <dune/common/fvector.hh>
31
34#include <dumux/common/typetraits/localdofs_.hh>
37
38namespace Dumux {
39
52template<class TypeTag>
54{
59 using GridDiscretization = GetPropType<TypeTag, Properties::GridGeometry>;
60 using ElementDiscretization = typename GridDiscretization::LocalView;
61 using GridView = typename GridDiscretization::GridView;
63 using Tensor = Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension>;
64 static constexpr int dim = GridView::dimension;
65
67 using ElementVariables = typename GridVariables::GridVariablesCache::LocalView;
68
69public:
70 using ParentType::ParentType;
71 using ElementResidualVector = typename ParentType::ElementResidualVector;
72
73 NumEqVector storageIntegral(const ElementDiscretization&, const ElementVariables&,
74 const auto&, bool) const
75 { return NumEqVector(0.0); }
76
79 const Problem& problem,
80 const auto& element,
81 const ElementDiscretization& elemDisc,
82 const ElementVariables& elemVars) const
83 {
84 if constexpr (Dumux::Detail::LocalDofs::hasNonCVLocalDofsInterface<ElementDiscretization>())
85 {
86 if (nonCVLocalDofs(elemDisc).empty())
87 return;
88
89 for (const auto& qpData : CVFE::quadratureRule(elemDisc, element))
90 {
91 const auto& ipCache = cache(elemVars, qpData.ipData());
92
93 const auto F = deformationGradient_(elemDisc, elemVars, ipCache);
94 const auto P = firstPiolaKirchhoffStressTensor_(problem, F, elemDisc, qpData.ipData());
95 const auto f = problem.source(elemDisc, elemVars, qpData.ipData());
96 const auto& shapeValues = ipCache.shapeValues();
97
98 for (const auto& nonCVdof : nonCVLocalDofs(elemDisc))
99 {
100 const auto idx = nonCVdof.index();
101 for (int i = 0; i < dim; ++i)
102 {
103 for (int j = 0; j < dim; ++j)
104 residual[idx][Indices::momentum(i)] += P[i][j] * ipCache.gradN(idx)[j] * qpData.weight();
105 residual[idx][Indices::momentum(i)] -= f[Indices::momentum(i)] * shapeValues[idx][0] * qpData.weight();
106 }
107 }
108 }
109 }
110 }
111
113 template<class SubControlVolumeFace>
114 NumEqVector fluxIntegral(const ElementDiscretization& elemDisc,
115 const ElementVariables& elemVars,
116 const SubControlVolumeFace& scvf) const
117 {
118 const auto& problem = this->asImp().problem();
119 const auto& n = scvf.unitOuterNormal();
120 NumEqVector f(0.0);
121
122 for (const auto& qpData : CVFE::quadratureRule(elemDisc, scvf))
123 {
124 const auto& ipCache = cache(elemVars, qpData.ipData());
125 const auto F = deformationGradient_(elemDisc, elemVars, ipCache);
126 const auto P = firstPiolaKirchhoffStressTensor_(problem, F, elemDisc, qpData.ipData());
127
128 for (int i = 0; i < dim; ++i)
129 for (int j = 0; j < dim; ++j)
130 f[Indices::momentum(i)] -= P[i][j] * n[j] * qpData.weight();
131 }
132 return f;
133 }
134
136 template<class IpData>
137 Scalar volumetricStressPressure(const Problem& problem,
138 const ElementDiscretization& elemDisc,
139 const IpData& ipData) const
140 { return problem.couplingManager().pressure(elemDisc, ipData); }
141
142private:
143 template<class IpCache>
144 Tensor deformationGradient_(const ElementDiscretization& elemDisc,
145 const ElementVariables& elemVars,
146 const IpCache& ipCache) const
147 {
148 Tensor F(0.0);
149 for (const auto& localDof : localDofs(elemDisc))
150 for (int d = 0; d < dim; ++d)
151 F[d].axpy(elemVars[localDof].displacement(d), ipCache.gradN(localDof.index()));
152 for (int d = 0; d < dim; ++d)
153 F[d][d] += 1.0;
154 return F;
155 }
156
157 template<class IpData>
158 Tensor firstPiolaKirchhoffStressTensor_(const Problem& problem,
159 const Tensor& F,
160 const ElementDiscretization& elemDisc,
161 const IpData& ipData) const
162 {
163 auto P = problem.isochoricFirstPiolaKirchhoffStressTensor(F, elemDisc, ipData.global());
164
165 Tensor Finv(F);
166 Finv.invert();
167 const Scalar pJ = this->asImp().volumetricStressPressure(problem, elemDisc, ipData)*F.determinant();
168 for (int i = 0; i < dim; ++i)
169 for (int j = 0; j < dim; ++j)
170 P[i][j] += pJ*Finv[j][i];
171
172 return P;
173 }
174};
175
185template<class TypeTag>
187{
192 using GridDiscretization = GetPropType<TypeTag, Properties::GridGeometry>;
193 using ElementDiscretization = typename GridDiscretization::LocalView;
194 using GridView = typename GridDiscretization::GridView;
195 using Tensor = Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension>;
196
198 using ElementVariables = typename GridVariables::GridVariablesCache::LocalView;
199
200public:
201 using ParentType::ParentType;
202 using ElementResidualVector = typename ParentType::ElementResidualVector;
203
204 NumEqVector storageIntegral(const ElementDiscretization&, const ElementVariables&,
205 const auto&, bool) const
206 { return NumEqVector(0.0); }
207
208 NumEqVector fluxIntegral(const ElementDiscretization&, const ElementVariables&,
209 const auto&) const
210 { return NumEqVector(0.0); }
211
219 NumEqVector sourceIntegral(const ElementDiscretization& elemDisc,
220 const ElementVariables& elemVars,
221 const auto& scv) const
222 {
223 NumEqVector source(0.0);
224
225 const auto& problem = this->asImp().problem();
226 const auto& localBasis = elemDisc.gridDiscretization().feCache().get(elemDisc.element().type()).localBasis();
227 std::vector< Dune::FieldVector<Scalar, 1> > shapeValues;
228
229 for (const auto& qpData : CVFE::quadratureRule(elemDisc, scv, QuadratureRules::DuneQuadrature<3>{}))
230 {
231 const Tensor F = problem.couplingManager().deformationGradient(elemDisc, qpData.ipData());
232 const Scalar J = F.determinant();
233 const Scalar psEq = problem.volumetricPressure(J);
234
235 localBasis.evaluateFunction(qpData.ipData().local(), shapeValues);
236 Scalar ps = 0.0;
237 for (const auto& localDof : localDofs(elemDisc))
238 ps += elemVars[localDof].pressure() * shapeValues[localDof.index()][0];
239
240 source[0] -= (psEq - ps) * qpData.weight();
241 }
242
243 return source;
244 }
245
250 const Problem& problem,
251 const auto& element,
252 const ElementDiscretization& elemDisc,
253 const ElementVariables& elemVars) const
254 {
255 if constexpr (Dumux::Detail::LocalDofs::hasNonCVLocalDofsInterface<ElementDiscretization>())
256 {
257 if (nonCVLocalDofs(elemDisc).empty())
258 return;
259
260 const auto& problem = this->asImp().problem();
261 const auto& localBasis = elemDisc.gridDiscretization().feCache().get(elemDisc.element().type()).localBasis();
262 std::vector< Dune::FieldVector<Scalar, 1> > shapeValues;
263
264 for (const auto& qpData : CVFE::quadratureRule(elemDisc, element, QuadratureRules::DuneQuadrature<3>{}))
265 {
266 const Tensor F = problem.couplingManager().deformationGradient(elemDisc, qpData.ipData());
267 const Scalar J = F.determinant();
268 const Scalar psEq = problem.volumetricPressure(J);
269
270 localBasis.evaluateFunction(qpData.ipData().local(), shapeValues);
271 Scalar ps = 0.0;
272 for (const auto& localDof : localDofs(elemDisc))
273 ps += elemVars[localDof].pressure() * shapeValues[localDof.index()][0];
274
275 for (const auto& nonCVdof : nonCVLocalDofs(elemDisc))
276 {
277 const auto idx = nonCVdof.index();
278 residual[idx][0] -= (psEq - ps) * shapeValues[idx][0] * qpData.weight();
279 }
280 }
281
282 }
283 }
284
285};
286
287} // end namespace Dumux
288#endif
Momentum local residual for the mixed – hyperelastic model.
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:54
Scalar volumetricStressPressure(const Problem &problem, const ElementDiscretization &elemDisc, const IpData &ipData) const
The scalar of the volumetric stress .
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:137
void addToElementFluxAndSourceResidual(ElementResidualVector &residual, const Problem &problem, const auto &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars) const
FE contributions of stress divergence and body force for non-CV dofs (e.g. PQ2 hybrid).
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:78
NumEqVector storageIntegral(const ElementDiscretization &, const ElementVariables &, const auto &, bool) const
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:73
NumEqVector fluxIntegral(const ElementDiscretization &elemDisc, const ElementVariables &elemVars, const SubControlVolumeFace &scvf) const
Interior flux integral: .
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:114
typename ParentType::ElementResidualVector ElementResidualVector
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:71
Pressure local residual for the mixed – hyperelastic model.
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:187
void addToElementFluxAndSourceResidual(ElementResidualVector &residual, const Problem &problem, const auto &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars) const
FE contributions for non-CV DOFs.
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:249
NumEqVector sourceIntegral(const ElementDiscretization &elemDisc, const ElementVariables &elemVars, const auto &scv) const
Pressure constraint integrated over an SCV.
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:219
NumEqVector fluxIntegral(const ElementDiscretization &, const ElementVariables &, const auto &) const
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:208
typename ParentType::ElementResidualVector ElementResidualVector
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:202
NumEqVector storageIntegral(const ElementDiscretization &, const ElementVariables &, const auto &, bool) const
Definition solidmechanics/hyperelastic_voliso/localresidual.hh:204
Defines all properties used in Dumux.
The default local operator than can be specialized for each discretization scheme.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition numeqvector.hh:34
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition quadraturerules.hh:160
Definition adapt.hh:17
typename Detail::DiscretizationDefaultLocalOperator< TypeTag >::type DiscretizationDefaultLocalOperator
Definition defaultlocaloperator.hh:26
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition localdof.hh:50
A helper to deduce a vector with the same size as numbers of equations.
Quadrature rules over sub-control volumes and sub-control volume faces.
Dune-based quadrature rule with specified order.
Definition quadraturerules.hh:67