Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
boundarypatchprolongator.hh
Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set ts=8 sw=4 et sts=4:
3
4// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
5// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
6
7#ifndef DUNE_FUFEM_BOUNDARY_PATCH_PROLONGATOR_HH
8#define DUNE_FUFEM_BOUNDARY_PATCH_PROLONGATOR_HH
9
15#include <vector>
16
17
18
22
23
24
28template <class GridType>
30public:
31
43 {
45 patchPointers.resize(patches.size());
46 for(size_t i=0; i<patches.size(); ++i)
47 patchPointers[i] = &(patches[i]);
48 prolong(patchPointers);
49 }
50
61 template<class BoundaryPatchPointerType>
63 {
64 typedef typename GridType::template Codim<0>::Entity::Entity Element;
65
66 if (not(patches[0]->isInitialized()))
67 DUNE_THROW(Dune::Exception, "Coarse boundary patch has not been set up correctly!");
68
69 const GridType& grid = patches[0]->gridView().grid();
70
71 int maxLevel = std::min((size_t)grid.maxLevel(), patches.size()-1);
72 // Set array sizes correctly
73 for (int i=1; i<=maxLevel; i++)
74 patches[i]->setup(grid.levelGridView(i));
75
76 for (const auto& pIt : *patches[0])
77 {
78 const Element& inside = pIt.inside();
79
80 if (not(inside.isLeaf()) and (inside.level()<maxLevel))
81 {
82 Face<GridType> face(grid, inside, pIt.indexInInside());
83
86
87 for(; it!=end; ++it)
88 patches[it->level()]->addFace(it->element(), it->index());
89 }
90 }
91 }
92
93
105 {
106
107 if (not(coarsePatch.isInitialized()))
108 DUNE_THROW(Dune::Exception, "Coarse boundary patch has not been set up correctly!");
109
110 const GridType& grid = coarsePatch.gridView().grid();
111
112 // Set array sizes correctly
113 finePatch.setup(grid.leafGridView());
114
115 for (const auto& pIt : coarsePatch)
116 {
117 const auto& inside = pIt.inside();
118
119 if (inside.isLeaf())
120 finePatch.addFace(inside, pIt.indexInInside());
121 else
122 {
123 Face<GridType> face(grid, inside, pIt.indexInInside());
124
125 typename Face<GridType>::HierarchicIterator it = face.hbegin(grid.maxLevel());
126 typename Face<GridType>::HierarchicIterator end = face.hend(grid.maxLevel());
127
128 for(; it!=end; ++it)
129 {
130 if (it->element().isLeaf())
131 finePatch.addFace(it->element(), it->index());
132 }
133 }
134 }
135 }
136
137};
138
139
140#endif
141
int maxLevel() const
iterator end()
#define DUNE_THROW(E,...)
LeafGridView leafGridView() const
int maxLevel() const
LevelGridView levelGridView(int level) const
Encapsulate a part of a grid boundary.
Definition boundarypatch.hh:218
void addFace(const IntersectionIterator &nIt)
Add a boundary face to the patch.
Definition boundarypatch.hh:326
void setup(const GridView &gridView, bool insertAllBoundaryFaces=false)
Setup for a given grid view.
Definition boundarypatch.hh:282
Contains methods which prolong coarse a boundary patch to finer ones.
Definition boundarypatchprolongator.hh:29
static void prolong(std::vector< BoundaryPatchPointerType > &patches)
Prolong coarse BoundaryPatch to all levels.
Definition boundarypatchprolongator.hh:62
static void prolong(std::vector< BoundaryPatch< typename GridType::LevelGridView > > &patches)
Prolong coarse BoundaryPatch to all levels.
Definition boundarypatchprolongator.hh:42
static void prolong(const BoundaryPatch< typename GridType::LevelGridView > &coarsePatch, BoundaryPatch< typename GridType::LeafGridView > &finePatch)
Prolong coarse BoundaryPatch to leaf level.
Definition boundarypatchprolongator.hh:103
const GridView & gridView() const
Return reference to the carrier grid view.
Definition domains/boundarypatch.hh:197
bool isInitialized() const
Check if BoundaryPatch is initialized.
Definition domains/boundarypatch.hh:205
Class representing a face.
Definition facehierarchy.hh:120
HierarchicIterator hend(int maxLevel) const
Return end of HierarchicIterator to subfaces.
Definition facehierarchy.hh:206
HierarchicIterator hbegin(int maxLevel) const
Return HierarchicIterator to subfaces.
Definition facehierarchy.hh:197
A hierarchical iterator for faces.
Definition facehierarchy.hh:338
const Element element() const
Get element of current face.
Definition facehierarchy.hh:389
int index() const
Get index of current face within element.
Definition facehierarchy.hh:396
T min(T... args)
T resize(T... args)
T size(T... args)