22#ifndef DUMUX_SOLIDMECHANICS_HYPERELASTIC_VOLISO_COUPLING_MANAGER_HH
23#define DUMUX_SOLIDMECHANICS_HYPERELASTIC_VOLISO_COUPLING_MANAGER_HH
26#include <dune/common/fmatrix.hh>
39template<
class MDTraits>
44 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
46 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
47 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
48 template<std::
size_t id>
using ElementSeed =
typename GridView<id>::Grid::template Codim<0>::EntitySeed;
50 using Scalar =
typename MDTraits::Scalar;
51 using SolutionVector =
typename MDTraits::SolutionVector;
53 static constexpr std::size_t momIdx_ = 0;
54 static constexpr std::size_t presIdx_ = 1;
56 using GlobalPosition =
typename Element<0>::Geometry::GlobalCoordinate;
57 using Tensor = Dune::FieldMatrix<Scalar, GridView<0>::dimension, GridView<0>::dimension>;
58 static constexpr int dim = GridView<0>::dimension;
61 static constexpr auto momentumIdx = Dune::index_constant<momIdx_>();
62 static constexpr auto pressureIdx = Dune::index_constant<presIdx_>();
67 std::shared_ptr<GridGeometry<momIdx_>> momGG,
68 std::shared_ptr<GridGeometry<presIdx_>> presGG)
70 buildStencils_(*momGG, *presGG);
73 void init(std::shared_ptr<
GetPropType<SubDomainTypeTag<momIdx_>, Properties::Problem>> momProblem,
74 std::shared_ptr<
GetPropType<SubDomainTypeTag<presIdx_>, Properties::Problem>> presProblem,
75 const SolutionVector&
curSol)
81 template<std::
size_t i, std::
size_t j>
83 const Element<j>& element,
84 Dune::index_constant<j>)
const
86 static_assert(i != j);
87 const auto eIdx = this->
problem(Dune::index_constant<j>{})
89 if constexpr (i == momIdx_)
return stencilsMomToPres_[eIdx];
90 else return stencilsPresTOMom_[eIdx];
95 const GlobalPosition& ip)
const
99 return evalSolution(fvGeom.element(), fvGeom.element().geometry(),
105 const GlobalPosition& ip)
const
108 const auto fvGeomMom =
localView(gg).bindElement(fvGeom.element());
109 return computeF_(fvGeom.element(), ip, fvGeomMom);
118 template<std::
size_t i,
class AssembleElementFunc>
121 if (elementSets_.empty())
122 DUNE_THROW(Dune::InvalidStateException,
123 "Call computeColorsForAssembly before parallel assembly!");
124 const auto& grid = this->
problem(Dune::index_constant<i>{})
126 for (
const auto& elems : elementSets_)
128 { f(grid.entity(elems[n])); });
131 template<std::
size_t i>
133 template<std::
size_t i>
137 Tensor computeF_(
const Element<presIdx_>& element,
138 const GlobalPosition& ip,
139 const typename GridGeometry<momIdx_>::LocalView& fvGeomMom)
const
141 const auto& geom = element.geometry();
142 const auto ipLocal = geom.local(ip);
143 const auto& localBasis = fvGeomMom.feLocalBasis();
144 using ShapeJac =
typename std::decay_t<
decltype(localBasis)>::Traits::JacobianType;
145 std::vector<ShapeJac> shapeJac;
146 localBasis.evaluateJacobian(ipLocal, shapeJac);
147 const auto jacInvT = geom.jacobianInverseTransposed(ipLocal);
150 for (
const auto& localDof :
localDofs(fvGeomMom))
152 GlobalPosition gradN;
153 jacInvT.mv(shapeJac[localDof.index()][0], gradN);
154 for (
int d = 0; d < dim; ++d)
157 for (
int d = 0; d < dim; ++d) F[d][d] += 1.0;
161 void buildStencils_(
const GridGeometry<momIdx_>& momGG,
const GridGeometry<presIdx_>& presGG)
163 const std::size_t n = presGG.gridView().size(0);
164 stencilsMomToPres_.resize(n);
165 stencilsPresTOMom_.resize(n);
170 for (
const auto& element : elements(presGG.gridView()))
172 fvMom.bindElement(element);
173 fvPres.bindElement(element);
174 const std::size_t eIdx = presGG.elementMapper().index(element);
176 for (
const auto& localDof :
localDofs(fvPres))
177 stencilsMomToPres_[eIdx].push_back(localDof.dofIndex());
179 for (
const auto& localDof :
localDofs(fvMom))
180 stencilsPresTOMom_[eIdx].push_back(localDof.dofIndex());
184 std::deque<std::vector<ElementSeed<momIdx_>>> elementSets_;
185 std::vector<CouplingStencilType> stencilsMomToPres_, stencilsPresTOMom_;
188template<
class MDTraits>
190:
public std::true_type {};
void setSubProblems(const std::tuple< std::shared_ptr< SubProblems >... > &problems)
Definition multidomain/couplingmanager.hh:296
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Definition multidomain/couplingmanager.hh:318
SubSolutionVector< i > & curSol(Dune::index_constant< i > domainIdx)
Definition multidomain/couplingmanager.hh:347
void updateSolution(const SolutionVector &curSol)
Definition multidomain/couplingmanager.hh:228
CouplingManager()
Definition multidomain/couplingmanager.hh:70
Coupling manager for the mixed u–p hyperelastic model.
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:41
static constexpr auto momentumIdx
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:61
Tensor deformationGradientAtPoint(const typename GridGeometry< presIdx_ >::LocalView &fvGeom, const GlobalPosition &ip) const
Evaluate at a global position (displacement shape functions).
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:104
auto & curSol(Dune::index_constant< i > id)
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:132
std::vector< std::size_t > CouplingStencilType
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:64
void init(std::shared_ptr< GetPropType< SubDomainTypeTag< momIdx_ >, Properties::Problem > > momProblem, std::shared_ptr< GetPropType< SubDomainTypeTag< presIdx_ >, Properties::Problem > > presProblem, const SolutionVector &curSol)
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:73
const auto & curSol(Dune::index_constant< i > id) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:134
void computeColorsForAssembly()
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:112
static constexpr auto pressureIdx
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:62
void assembleMultithreaded(Dune::index_constant< i >, AssembleElementFunc &&f) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:119
const CouplingStencilType & couplingStencil(Dune::index_constant< i >, const Element< j > &element, Dune::index_constant< j >) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:82
Scalar pressureAtPoint(const typename GridGeometry< momIdx_ >::LocalView &fvGeom, const GlobalPosition &ip) const
Evaluate at a global position (P1 interpolation from pressure solution).
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:94
HyperelasticVolIsoCouplingManager(std::shared_ptr< GridGeometry< momIdx_ > > momGG, std::shared_ptr< GridGeometry< presIdx_ > > presGG)
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:66
Element solution classes and factory functions.
free functions for the evaluation of primary variables inside elements.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition localview.hh:26
PrimaryVariables evalSolution(const Element &element, const typename Element::Geometry &geometry, const typename FVElementGeometry::GridGeometry &gridGeometry, const CVFEElementSolution< FVElementGeometry, PrimaryVariables > &elemSol, const typename Element::Geometry::GlobalCoordinate &globalPos, bool ignoreState=false)
Interpolates a given box element solution at a given global position. Uses the finite element cache o...
Definition evalsolution.hh:197
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition cellcentered/elementsolution.hh:101
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading).
Definition parallel_for.hh:160
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
decltype(auto) gridDiscretization(const T &t, Args &&... args)
The grid discretization.
Definition griddiscretization.hh:65
The interface of the coupling manager for multi domain problems.
auto computeColoring(const GridGeometry &gg, int verbosity=1)
Compute iterable lists of element seeds partitioned by color.
Definition coloring.hh:243
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition localdof.hh:50
Type trait that is specialized for coupling manager supporting multithreaded assembly.
Definition assemblytraits.hh:43