22#ifndef DUMUX_SOLIDMECHANICS_HYPERELASTIC_VOLISO_COUPLING_MANAGER_HH
23#define DUMUX_SOLIDMECHANICS_HYPERELASTIC_VOLISO_COUPLING_MANAGER_HH
31#include <dune/common/exceptions.hh>
32#include <dune/common/fmatrix.hh>
33#include <dune/common/indices.hh>
36#include <dumux/common/concepts/ipdata_.hh>
52template<
class MDTraits>
57 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
59 template<std::
size_t id>
using ElementDiscretization =
typename GridDiscretization<id>::LocalView;
60 template<std::
size_t id>
using GridView =
typename GridDiscretization<id>::GridView;
61 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
62 template<std::
size_t id>
using ElementSeed =
typename GridView<id>::Grid::template Codim<0>::EntitySeed;
64 using Scalar =
typename MDTraits::Scalar;
65 using SolutionVector =
typename MDTraits::SolutionVector;
67 static constexpr std::size_t momIdx_ = 0;
68 static constexpr std::size_t presIdx_ = 1;
70 using GlobalPosition =
typename Element<0>::Geometry::GlobalCoordinate;
71 using LocalPosition =
typename Element<0>::Geometry::LocalCoordinate;
72 using Tensor = Dune::FieldMatrix<Scalar, GridView<0>::dimension, GridView<0>::dimension>;
73 static constexpr int dim = GridView<0>::dimension;
76 static constexpr auto momentumIdx = Dune::index_constant<momIdx_>();
77 static constexpr auto pressureIdx = Dune::index_constant<presIdx_>();
82 std::shared_ptr<GridDiscretization<momIdx_>> momGridDisc,
83 std::shared_ptr<GridDiscretization<presIdx_>> presGridDisc)
85 buildStencils_(*momGridDisc, *presGridDisc);
88 void init(std::shared_ptr<
GetPropType<SubDomainTypeTag<momIdx_>, Properties::Problem>> momProblem,
89 std::shared_ptr<
GetPropType<SubDomainTypeTag<presIdx_>, Properties::Problem>> presProblem,
90 const SolutionVector&
curSol)
96 template<std::
size_t i, std::
size_t j>
98 const Element<j>& element,
99 Dune::index_constant<j>)
const
101 static_assert(i != j);
102 const auto eIdx = this->
problem(Dune::index_constant<j>{})
104 if constexpr (i == momIdx_)
return stencilsMomToPres_[eIdx];
105 else return stencilsPresTOMom_[eIdx];
108 template<Concept::IpData IpData>
109 Scalar
pressure(
const ElementDiscretization<momIdx_>& elemDisc,
110 const IpData& ipData)
const
115 gridDisc, elemSol, ipData.local())[0];
118 template<Concept::IpData IpData>
120 const IpData& ipData)
const
123 const auto elemDiscMom =
localView(gridDisc).bindElement(elemDisc.element());
124 return computeF_(elemDisc.element(), ipData.local(), elemDiscMom);
133 template<std::
size_t i,
class AssembleElementFunc>
136 if (elementSets_.empty())
137 DUNE_THROW(Dune::InvalidStateException,
138 "Call computeColorsForAssembly before parallel assembly!");
139 const auto& grid = this->
problem(Dune::index_constant<i>{})
141 for (
const auto& elems : elementSets_)
143 { f(grid.entity(elems[n])); });
146 template<std::
size_t i>
148 template<std::
size_t i>
152 Tensor computeF_(
const Element<presIdx_>& element,
153 const LocalPosition& ipLocal,
154 const ElementDiscretization<momIdx_>& elemDiscMom)
const
156 const auto& geom = element.geometry();
157 const auto& localBasis = elemDiscMom.feLocalBasis();
158 using ShapeJac =
typename std::decay_t<
decltype(localBasis)>::Traits::JacobianType;
159 std::vector<ShapeJac> shapeJac;
160 localBasis.evaluateJacobian(ipLocal, shapeJac);
161 const auto jacInvT = geom.jacobianInverseTransposed(ipLocal);
164 for (
const auto& localDof :
localDofs(elemDiscMom))
166 GlobalPosition gradN;
167 jacInvT.mv(shapeJac[localDof.index()][0], gradN);
168 for (
int d = 0; d < dim; ++d)
171 for (
int d = 0; d < dim; ++d) F[d][d] += 1.0;
175 void buildStencils_(
const GridDiscretization<momIdx_>& momGridDisc,
176 const GridDiscretization<presIdx_>& presGridDisc)
178 const std::size_t n = presGridDisc.gridView().size(0);
179 stencilsMomToPres_.resize(n);
180 stencilsPresTOMom_.resize(n);
182 auto elemDiscMom =
localView(momGridDisc);
183 auto elemDiscPres =
localView(presGridDisc);
185 for (
const auto& element : elements(presGridDisc.gridView()))
187 elemDiscMom.bindElement(element);
188 elemDiscPres.bindElement(element);
189 const std::size_t eIdx = presGridDisc.elementMapper().index(element);
191 for (
const auto& localDof :
localDofs(elemDiscPres))
192 stencilsMomToPres_[eIdx].push_back(localDof.dofIndex());
194 for (
const auto& localDof :
localDofs(elemDiscMom))
195 stencilsPresTOMom_[eIdx].push_back(localDof.dofIndex());
199 std::deque<std::vector<ElementSeed<momIdx_>>> elementSets_;
200 std::vector<CouplingStencilType> stencilsMomToPres_, stencilsPresTOMom_;
203template<
class MDTraits>
205:
public std::true_type {};
Traits shared by the multi-domain assemblers.
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 – hyperelastic model.
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:54
static constexpr auto momentumIdx
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:76
auto & curSol(Dune::index_constant< i > id)
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:147
std::vector< std::size_t > CouplingStencilType
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:79
HyperelasticVolIsoCouplingManager(std::shared_ptr< GridDiscretization< momIdx_ > > momGridDisc, std::shared_ptr< GridDiscretization< presIdx_ > > presGridDisc)
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:81
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:88
Scalar pressure(const ElementDiscretization< momIdx_ > &elemDisc, const IpData &ipData) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:109
const auto & curSol(Dune::index_constant< i > id) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:149
void computeColorsForAssembly()
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:127
Tensor deformationGradient(const ElementDiscretization< presIdx_ > &elemDisc, const IpData &ipData) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:119
static constexpr auto pressureIdx
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:77
void assembleMultithreaded(Dune::index_constant< i >, AssembleElementFunc &&f) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:134
const CouplingStencilType & couplingStencil(Dune::index_constant< i >, const Element< j > &element, Dune::index_constant< j >) const
Definition solidmechanics/hyperelastic_voliso/couplingmanager.hh:97
Coloring schemes for shared-memory-parallel assembly.
Defines all properties used in Dumux.
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
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
PrimaryVariables evalSolutionAtLocalPos(const Element &element, const typename Element::Geometry &geometry, const typename FVElementGeometry::GridGeometry &gridGeometry, const CVFEElementSolution< FVElementGeometry, PrimaryVariables > &elemSol, const typename Element::Geometry::LocalCoordinate &localPos, bool ignoreState=false)
Interpolates a given cvfe element solution at a given local position. Uses the finite element cache o...
Definition evalsolution.hh:172
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
Parallel for loop (multithreading).
Type trait that is specialized for coupling manager supporting multithreaded assembly.
Definition assemblytraits.hh:43