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>
35template<
class MDTraits>
40 using Scalar =
typename MDTraits::Scalar;
41 using SolutionVector =
typename MDTraits::SolutionVector;
44 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
47 template<std::
size_t id>
using GridView =
typename GridGeometry<id>::GridView;
48 template<std::
size_t id>
using Element =
typename GridView<id>::template Codim<0>::Entity;
49 template<std::
size_t id>
using ElementSeed =
typename GridView<id>::Grid::template Codim<0>::EntitySeed;
51 template<std::
size_t id>
using Indices
54 template<std::
size_t id>
using CouplingStencil = std::vector<GridIndex<id>>;
56 using GlobalPosition =
typename Element<0>::Geometry::GlobalCoordinate;
61 static constexpr auto rotationIdx =
typename MDTraits::template SubDomain<0>::Index();
62 static constexpr auto deformationIdx =
typename MDTraits::template SubDomain<1>::Index();
70 std::shared_ptr<GridGeometry<deformationIdx>> deformationGG)
72 const auto& rotationsGridGeometry = *rotationsGG;
73 const auto& deformationGridGeometry = *deformationGG;
74 auto rotGeo =
localView(rotationsGridGeometry);
75 auto defGeo =
localView(deformationGridGeometry);
77 defToRotStencils_.clear();
78 defToRotStencils_.resize(deformationGridGeometry.gridView().size(0));
80 rotToDefStencils_.clear();
81 rotToDefStencils_.resize(rotationsGridGeometry.gridView().size(0));
83 assert(defToRotStencils_.size() == rotToDefStencils_.size());
85 for (
const auto& element : elements(rotationsGridGeometry.gridView()))
87 rotGeo.bindElement(element);
88 defGeo.bindElement(element);
89 const auto eIdx = rotGeo.elementIndex();
91 for (
const auto& localDof :
localDofs(rotGeo))
92 defToRotStencils_[eIdx].push_back(localDof.dofIndex());
94 for (
const auto& localDof :
localDofs(defGeo))
95 rotToDefStencils_[eIdx].push_back(localDof.dofIndex());
99 void init(std::shared_ptr<Problem<rotationIdx>> momentumProblem,
100 std::shared_ptr<Problem<deformationIdx>> massProblem,
101 const SolutionVector&
curSol)
104 this->
setSubProblems(std::make_tuple(momentumProblem, massProblem));
107 template<std::
size_t i, std::
size_t j>
109 const Element<i>& element,
110 Dune::index_constant<j> domainJ)
const
112 static_assert(i != j,
"A domain cannot be coupled to itself!");
114 const auto eIdx = this->
problem(domainI).gridGeometry().elementMapper().index(element);
116 return rotToDefStencils_[eIdx];
118 return defToRotStencils_[eIdx];
121 auto rotation(
typename GridGeometry<deformationIdx>::LocalView
const& fvGeometry,
122 typename GridGeometry<deformationIdx>::SubControlVolumeFace
const& scvf)
const
127 fvGeometry.element(),
128 fvGeometry.element().geometry(),
135 typename GridGeometry<rotationIdx>::SubControlVolumeFace
const& scvf)
const
140 fvGeometry.element(),
141 fvGeometry.element().geometry(),
148 {
return Indices<deformationIdx>::shearCurlPotentialIdx; }
151 {
return Indices<deformationIdx>::shearGradPotentialIdx; }
158 template<std::
size_t i>
159 auto&
curSol(Dune::index_constant<i> domainIdx)
167 template<std::
size_t i>
168 const auto&
curSol(Dune::index_constant<i> domainIdx)
const
183 template<std::
size_t i,
class AssembleElementFunc>
186 if (elementSets_.empty())
187 DUNE_THROW(Dune::InvalidStateException,
188 "Call computeColorsForAssembly before assembling in parallel!");
194 const auto& grid = this->
problem(domainId).gridGeometry().gridView().grid();
195 for (
const auto& elements : elementSets_)
199 const auto element = grid.entity(elements[n]);
200 assembleElement(element);
210 std::deque<std::vector<ElementSeed<deformationIdx>>> elementSets_;
212 std::vector<CouplingStencil<deformationIdx>> rotToDefStencils_;
213 std::vector<CouplingStencil<rotationIdx>> defToRotStencils_;
217template<
class MDTraits>
219:
public std::true_type {};
The interface of the coupling manager for multi domain problems.
Definition: multidomain/couplingmanager.hh:37
void setSubProblems(const std::tuple< std::shared_ptr< SubProblems >... > &problems)
set the pointers to the sub problems
Definition: multidomain/couplingmanager.hh:297
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:319
SubSolutionVector< i > & curSol(Dune::index_constant< i > domainIdx)
the solution vector of the subproblem
Definition: multidomain/couplingmanager.hh:348
void updateSolution(const SolutionVector &curSol)
Updates the entire solution vector, e.g. before assembly or after grid adaption Overload might want t...
Definition: multidomain/couplingmanager.hh:229
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:38
void assembleMultithreaded(Dune::index_constant< i > domainId, AssembleElementFunc &&assembleElement) const
Execute assembly kernel in parallel.
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:184
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:159
const auto & curSol(Dune::index_constant< i > domainIdx) const
the solution vector of the subproblem
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:168
void computeColorsForAssembly()
Compute colors for multithreaded assembly.
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:174
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:121
auto shearCurlPotentialIdx() const
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:147
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:108
void init(std::shared_ptr< Problem< rotationIdx > > momentumProblem, std::shared_ptr< Problem< deformationIdx > > massProblem, const SolutionVector &curSol)
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:99
auto deformationAndPotentials(typename GridGeometry< rotationIdx >::LocalView const &fvGeometry, typename GridGeometry< rotationIdx >::SubControlVolumeFace const &scvf) const
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:134
static constexpr auto rotationIdx
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:61
KirchhoffLovePlateCouplingManager(std::shared_ptr< GridGeometry< rotationIdx > > rotationsGG, std::shared_ptr< GridGeometry< deformationIdx > > deformationGG)
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:69
auto shearGradPotentialIdx() const
Definition: solidmechanics/plate/kirchhoff_love/couplingmanager.hh:150
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:198
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:241
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: multistagemultidomainfvassembler.hh:78
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26