Skip to content
Snippets Groups Projects
Commit 8a18a5d6 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

make lagrange grid-creator a grid-function by implementing entitySet and operator()

parent 1fc42aa7
No related branches found
No related tags found
No related merge requests found
......@@ -21,14 +21,14 @@ namespace Dune
{
// \brief Create a grid from data that represents higher (lagrange) cells.
/**
* The grid is created from the first nodes of a cell parametrization, representing
* the corner vertices. Thus a piecewise "flat" grid is constructed. The parametrization
* is 1. passed as a local element parametrization to the `insertElement()` function of a
* gridFactory to allow the grid itself to handle the parametrization and 2. is stored
* The grid is created from the first nodes of a cell parametrization, representing
* the corner vertices. Thus a piecewise "flat" grid is constructed. The parametrization
* is 1. passed as a local element parametrization to the `insertElement()` function of a
* gridFactory to allow the grid itself to handle the parametrization and 2. is stored
* internally that can be accessed by using this GridCreator object as a grid function,
* or by extracting locally the parametrization on each existing grid element after
* or by extracting locally the parametrization on each existing grid element after
* creation of the grid.
*
*
* So, the LagrangeGridCreator models both, a `GridCreator` and a `GridFunction`.
**/
template <class Grid>
......@@ -43,7 +43,7 @@ namespace Dune
struct ElementParametrization
{
GeometryType type; //< Geometry type of the element
GeometryType type; //< Geometry type of the element
std::vector<std::int64_t> nodes; //< Indices of the w.r.t. `nodes_` vector
std::vector<unsigned int> corners; //< Insertion-indices of the element corner nodes
};
......@@ -71,7 +71,7 @@ namespace Dune
}
template <class F>
using HasParametrizedElements = decltype(std::declval<F>().insertElement(std::declval<GeometryType>(),
using HasParametrizedElements = decltype(std::declval<F>().insertElement(std::declval<GeometryType>(),
std::declval<std::vector<unsigned int> const&>(), std::declval<std::function<GlobalCoordinate(LocalCoordinate)>>()));
/// Implementation of the interface function `insertElements()`
......@@ -144,11 +144,11 @@ namespace Dune
/// \brief Construct an element parametrization
/**
* The returned LocalParametrization is a mapping `GlobalCoordinate(LocalCoordinate)`
* where `LocalCoordinate is w.r.t. the local coordinate system in an element with
* given `insertionIndex` (defined by the inserted corner vertices) and
* where `LocalCoordinate is w.r.t. the local coordinate system in an element with
* given `insertionIndex` (defined by the inserted corner vertices) and
* `GlobalCoordinate` a world coordinate in the parametrized grid.
**/
LocalParametrization localParametrization (unsigned int insertionIndex) const
LocalParametrization localParametrization (unsigned int insertionIndex) const
{
assert(!nodes_.empty() && !parametrization_.empty());
auto const& localParam = parametrization_.at(insertionIndex);
......@@ -158,13 +158,13 @@ namespace Dune
/// \brief Construct an element parametrization
/**
* The returned LocalParametrization is a mapping `GlobalCoordinate(LocalCoordinate)`
* where `LocalCoordinate is w.r.t. the local coordinate system in the passed element
* where `LocalCoordinate is w.r.t. the local coordinate system in the passed element
* and `GlobalCoordinate` a world coordinate in the parametrized grid.
*
*
* Note, when an element is passed, it might have a different local coordinate system
* than the coordinate system used to defined the element parametrization. Thus coordinate
* transform is internally chained to the evaluation of the local parametrization. This
* local geometry transform is obtained by figuring out the permutation of corners in the
* transform is internally chained to the evaluation of the local parametrization. This
* local geometry transform is obtained by figuring out the permutation of corners in the
* element corresponding to the inserted corner vertices.
**/
LocalParametrization localParametrization (Element const& element) const
......@@ -191,25 +191,6 @@ namespace Dune
return LocalParametrization{nodes_, localParam, order(localParam), permutation};
}
/// \brief Local function representing the parametrization of the grid.
/**
* The returned LocalFunction object models a Functions::Concept::LocalFunction
* and can thus be bound to an element of the created grid and evaluated in the
* local coordinates of the bound element.
*
* It is implemented in terms of the \ref LocalParametrization function returned by
* the method \ref localParametrization(element). See comments there for furhter
* details.
*
* Note, this methods requires the GridCreator to be bassed by lvalue-reference. This
* is necessary, since we want to guarantee that all internal storage is preserved while
* evaluating the local function.
**/
friend LocalFunction localFunction (LagrangeGridCreator& gridCreator)
{
return LocalFunction{gridCreator};
}
/// Determine lagrange order from number of points
template <class LocalParam>
unsigned int order (LocalParam const& localParam) const
......@@ -224,12 +205,51 @@ namespace Dune
}
/// Determine lagrange order from number of points from the first element parametrization
unsigned int order () const
unsigned int order () const
{
assert(!parametrization_.empty());
return order(parametrization_.front());
}
public:
/// \brief Local function representing the parametrization of the grid.
/**
* The returned object models Functions::Concept::LocalFunction
* and can thus be bound to an element of the created grid and evaluated in
* the local coordinates of the bound element.
*
* It is implemented in terms of the \ref LocalParametrization function
* returned by the method \ref localParametrization(element). See comments
* there for further details.
*
* Note, this methods requires the GridCreator to be based by
* lvalue-reference. This is necessary, since we want to guarantee that all
* internal storage is preserved while evaluating the local function.
**/
friend LocalFunction localFunction (LagrangeGridCreator& gridCreator)
{
return LocalFunction{gridCreator};
}
struct EntitySet
{
using Grid = typename Self::Grid;
};
/// Dummy function returning a placeholder entityset
EntitySet entitySet () const
{
assert(false && "Should not be used!");
return EntitySet{};
}
/// Dummy function returning a placeholder entityset
GlobalCoordinate operator() (GlobalCoordinate const&) const
{
assert(false && "Should not be used!");
return GlobalCoordinate{};
}
private:
/// All point coordinates inclusing the higher-order lagrange points
Nodes nodes_;
......@@ -243,7 +263,7 @@ namespace Dune
class LagrangeGridCreator<Grid>::LocalParametrization
{
using ctype = typename Grid::ctype;
using GlobalCoordinate = typename Grid::template Codim<0>::Entity::Geometry::GlobalCoordinate;
using LocalCoordinate = typename Grid::template Codim<0>::Entity::Geometry::LocalCoordinate;
using LocalGeometry = MultiLinearGeometry<ctype,Grid::dimension,Grid::dimension>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment