13#ifndef DEFORMINGGRIDMANAGER_HH_
14#define DEFORMINGGRIDMANAGER_HH_
16#include "dune/common/fvector.hh"
17#include "dune/grid/geometrygrid/coordfunction.hh"
18#include "dune/grid/geometrygrid/grid.hh"
19#include "dune/grid/uggrid.hh"
28 namespace DeformingGridManagerDetail
31 class Deformation:
public Dune::DiscreteCoordFunction<typename Grid::ctype,
35 using ctype =
typename Grid::ctype;
36 constexpr static int dim = Grid::dimension;
38 using LevelView =
typename Grid::LevelGridView;
39 using Index =
typename LevelView::IndexSet::IndexType;
51 Deformation(Grid
const& grid_, ctype featureEdgeAngle=0.5, ctype featureCurveAngle=1.0)
57 Deformation(Grid
const& grid_, GeometricFeatureDetector<Index,ctype,dim>
const& featureDetector)
59 , tangents_(grid,featureDetector)
69 void setFeatureAngles(ctype featureCurveAngle=1.0, ctype featureEdgeAngle=0.5)
71 GridAngleFeatureDetector<LevelView> features(featureCurveAngle,featureEdgeAngle);
72 tangents_ = GridBoundaryTangents<LevelView>(grid,features);
76 void evaluate(
typename Grid::template Codim<dim>::Entity
const& vertex,
unsigned int ,
79 y = vertexPositions_[grid.leafGridView().indexSet().index(vertex)];
82 void evaluate(
typename Grid::template Codim<0>::Entity
const& cell,
unsigned int corner,
85 y = vertexPositions_[grid.leafGridView().indexSet().subIndex(cell,corner,dim)];
88 GridBoundaryTangents<typename Grid::LevelGridView>
const& tangents()
const
93 std::vector<Vector>
const& vertexPositions()
const
95 return vertexPositions_;
100 GridBoundaryTangents<typename Grid::LevelGridView> tangents_;
101 std::vector<Vector> vertexPositions_;
116 template <
class Gr
id>
118 :
public GridManagerBase<Dune::GeometryGrid<Grid,DeformingGridManagerDetail::Deformation<Grid>>>
120 using Deformation = DeformingGridManagerDetail::Deformation<Grid>;
121 using DeformedGrid = Dune::GeometryGrid<Grid,Deformation>;
123 using ctype =
typename Grid::ctype;
124 constexpr static int dim = Grid::dimension;
126 using LevelView =
typename Grid::LevelGridView;
127 using Index =
typename LevelView::IndexSet::IndexType;
142 ctype featureCurveAngle=1.0, ctype featureEdgeAngle=0.5,
144 :
Base(new DeformedGrid(std::shared_ptr<
Grid>(
grid.release())),
147 this->
gridptr->coordFunction().setFeatureAngles(featureCurveAngle,featureEdgeAngle);
153 :
Base(makeDeformedGrid(std::move(
grid),featureDetector),
163 this->
gridptr->globalRefine(refCount);
180 template <
class Scalar>
183 if(&correction.space().gridManager() !=
this)
184 throw DetailedException(
"Correction has wrong underlying gridManager.",__FILE__,__LINE__);
187 if (correction.space().mapper().maxOrder()==1)
189 correction =
static_cast<Scalar
>(0.0);
194 this->gridptr->coordFunction().tangents());
206 vertexAdjustment = correction;
210 correction -= vertexAdjustment;
214 static DeformedGrid* makeDeformedGrid(std::unique_ptr<Grid>&&
grid,
217 std::shared_ptr<Deformation> deformation (
new Deformation(*
grid,featureDetector));
218 std::shared_ptr<Grid> g (
grid.release());
219 return new DeformedGrid(g,deformation);
The BoundaryInterpolationDisplacement class provides a Kaskade WeakFunctionView on the displacement f...
A wrapper class for conveniently providing exceptions with context information.
A representation of a finite element function space defined over a domain covered by a grid.
A class for representing finite element functions.
The interface for specifying feature edges and feature vertices.
Basic functionality for managing grids and their refinement.
std::shared_ptr< Grid > gridptr
The grid itself.
Grid const & grid() const
Returns a const reference on the owned grid.
Dune::GeometryGrid< Grid, DeformingGridManagerDetail::Deformation< Grid > > Grid
the type of managed grid
Self & enforceConcurrentReads(bool enforceConcurrentReads)
Tells the grid manager that concurrent reads of the grid are safe.
void interpolateGloballyWeak(Target &target, Source const &fu)
Interpolates WeakFunctionViews to FunctionSpaceElement.
std::vector< Dune::FieldVector< typename GridView::ctype, GridView::dimension > > interpolateVertexPositions(GridView const &gv, GridBoundaryTangents< GridView > const &tangents, bool computeDisplacements=false)
Computes a new position for each grid vertex based on boundary interpolation.
Dune::FieldVector< Scalar, dim > Vector
AngleFeatureDetector< typename GridView::IndexSet::IndexType, typename GridView::ctype, GridView::dimension > GridAngleFeatureDetector
Convenience typedefs and creation functions for common function spaces.