12#ifndef DUMUX_KIRCHHOFF_LOVE_PLATE_COUPLINGMANAGER_HH
13#define DUMUX_KIRCHHOFF_LOVE_PLATE_COUPLINGMANAGER_HH
21#include <dune/common/indices.hh>
22#include <dune/common/exceptions.hh>
36template<
class MDTraits>
41 using Scalar =
typename MDTraits::Scalar;
42 using SolutionVector =
typename MDTraits::SolutionVector;
45 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
48 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
49 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
50 template<std::
size_t id>
using ElementSeed =
typename GridView<id>::Grid::template Codim<0>::EntitySeed;
52 template<std::
size_t id>
using Indices
55 template<std::
size_t id>
using CouplingStencil = std::vector<GridIndex<id>>;
57 using GlobalPosition =
typename Element<0>::Geometry::GlobalCoordinate;
62 static constexpr auto rotationIdx =
typename MDTraits::template SubDomain<0>::Index();
63 static constexpr auto deformationIdx =
typename MDTraits::template SubDomain<1>::Index();
72 std::shared_ptr<GridGeometry<deformationIdx>> deformationGG)
81 void computeStencils(std::shared_ptr<GridGeometry<rotationIdx>> rotationsGG,
82 std::shared_ptr<GridGeometry<deformationIdx>> deformationGG)
84 const auto& rotationsGridGeometry = *rotationsGG;
85 const auto& deformationGridGeometry = *deformationGG;
86 auto rotGeo =
localView(rotationsGridGeometry);
87 auto defGeo =
localView(deformationGridGeometry);
89 defToRotStencils_.clear();
90 defToRotStencils_.resize(deformationGridGeometry.gridView().size(0));
92 rotToDefStencils_.clear();
93 rotToDefStencils_.resize(rotationsGridGeometry.gridView().size(0));
95 assert(defToRotStencils_.size() == rotToDefStencils_.size());
97 for (
const auto& element : elements(rotationsGridGeometry.gridView()))
99 rotGeo.bindElement(element);
100 defGeo.bindElement(element);
101 const auto eIdx = rotGeo.elementIndex();
103 for (
const auto& localDof :
localDofs(rotGeo))
104 defToRotStencils_[eIdx].push_back(localDof.dofIndex());
106 for (
const auto& localDof :
localDofs(defGeo))
107 rotToDefStencils_[eIdx].push_back(localDof.dofIndex());
111 void init(std::shared_ptr<Problem<rotationIdx>> momentumProblem,
112 std::shared_ptr<Problem<deformationIdx>> massProblem,
113 const SolutionVector&
curSol)
116 this->
setSubProblems(std::make_tuple(momentumProblem, massProblem));
124 void init(std::shared_ptr<Problem<rotationIdx>> momentumProblem,
125 std::shared_ptr<Problem<deformationIdx>> massProblem,
129 this->
setSubProblems(std::make_tuple(momentumProblem, massProblem));
132 template<std::
size_t i, std::
size_t j>
133 const CouplingStencil<j>&
couplingStencil(Dune::index_constant<i> domainI,
134 const Element<i>& element,
135 Dune::index_constant<j> domainJ)
const
137 static_assert(i != j,
"A domain cannot be coupled to itself!");
139 const auto eIdx = this->
problem(domainI).gridGeometry().elementMapper().index(element);
141 return rotToDefStencils_[eIdx];
143 return defToRotStencils_[eIdx];
146 auto rotation(
typename GridGeometry<deformationIdx>::LocalView
const& fvGeometry,
147 typename GridGeometry<deformationIdx>::SubControlVolumeFace
const& scvf)
const
152 fvGeometry.element(),
153 fvGeometry.element().geometry(),
160 typename GridGeometry<rotationIdx>::SubControlVolumeFace
const& scvf)
const
165 fvGeometry.element(),
166 fvGeometry.element().geometry(),
173 {
return Indices<deformationIdx>::shearCurlPotentialIdx; }
176 {
return Indices<deformationIdx>::shearGradPotentialIdx; }
183 template<std::
size_t i>
184 auto&
curSol(Dune::index_constant<i> domainIdx)
192 template<std::
size_t i>
193 const auto&
curSol(Dune::index_constant<i> domainIdx)
const
208 template<std::
size_t i,
class AssembleElementFunc>
209 void assembleMultithreaded(Dune::index_constant<i> domainId, AssembleElementFunc&& assembleElement)
const
211 if (elementSets_.empty())
212 DUNE_THROW(Dune::InvalidStateException,
213 "Call computeColorsForAssembly before assembling in parallel!");
219 const auto& grid = this->
problem(domainId).gridGeometry().gridView().grid();
220 for (
const auto& elements : elementSets_)
224 const auto element = grid.entity(elements[n]);
225 assembleElement(element);
232 std::deque<std::vector<ElementSeed<deformationIdx>>> elementSets_;
234 std::vector<CouplingStencil<deformationIdx>> rotToDefStencils_;
235 std::vector<CouplingStencil<rotationIdx>> defToRotStencils_;
239template<
class MDTraits>
241:
public std::true_type {};
Traits shared by the multi-domain assemblers.
void attachSolution(const SolutionVectorStorage &curSol)
Definition multidomain/couplingmanager.hh:331
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
typename MDTraits::template TupleOfSharedPtr< SubSolutionVector > SolutionVectorStorage
Definition multidomain/couplingmanager.hh:59
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:39
void computeStencils(std::shared_ptr< GridGeometry< rotationIdx > > rotationsGG, std::shared_ptr< GridGeometry< deformationIdx > > deformationGG)
(Re-)compute the DOF stencils on the shared mesh of rotationsGG and deformationGG.
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:80
void assembleMultithreaded(Dune::index_constant< i > domainId, AssembleElementFunc &&assembleElement) const
Execute assembly kernel in parallel.
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:208
KirchhoffLovePlateCouplingManager()=default
MDTraits MultiDomainTraits
export traits
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:65
auto & curSol(Dune::index_constant< i > domainIdx)
the solution vector of the subproblem
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:183
void computeColorsForAssembly()
Compute colors for multithreaded assembly.
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:198
typename ParentType::SolutionVectorStorage SolutionVectorStorage
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:66
static constexpr auto deformationIdx
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:62
auto rotation(typename GridGeometry< deformationIdx >::LocalView const &fvGeometry, typename GridGeometry< deformationIdx >::SubControlVolumeFace const &scvf) const
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:145
auto shearCurlPotentialIdx() const
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:171
const CouplingStencil< j > & couplingStencil(Dune::index_constant< i > domainI, const Element< i > &element, Dune::index_constant< j > domainJ) const
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:132
void init(std::shared_ptr< Problem< rotationIdx > > momentumProblem, std::shared_ptr< Problem< deformationIdx > > massProblem, const SolutionVector &curSol)
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:110
auto deformationAndPotentials(typename GridGeometry< rotationIdx >::LocalView const &fvGeometry, typename GridGeometry< rotationIdx >::SubControlVolumeFace const &scvf) const
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:158
static constexpr auto rotationIdx
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:61
auto shearGradPotentialIdx() const
Definition solidmechanics/plate/kirchhoff_love/couplingmanager.hh:174
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
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
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
Structure to define the index types used for grid and local indices.
Definition indextraits.hh:26