KASKADE 7 development version
Loading...
Searching...
No Matches
Grid input

Grid creation or input. More...

Topics

 Platonian solids

Namespaces

namespace  Kaskade::AmiraMeshReader
 Reader for Amira meshes.

Classes

class  Kaskade::AnsysMeshReader
 Reader for Ansys *.inp grid files. More...
class  Kaskade::VTKReader
 A class to create a grid and load coefficients from a VTK file. More...

Functions

template<class Grid, class GridView>
std::unique_ptr< Grid > Kaskade::extrude (GridView const &gridView, double h)
 Extrude a (d-1)-dimensional simplicial surface grid to a d-dimensional simplicial grid.
std::unique_ptr< Dune::UGGrid< 2 > > readPolyData (std::string const &name, std::vector< int > *boundaryMarker=nullptr)
 Construct an unstructured UG grid from .node and .ele files (Triangle output).
template<class Grid, class Type, class Deformation = IdentityDeformation>
std::unique_ptr< Grid > Kaskade::createGrid (std::vector< Type > const &cubes, Deformation phi=Deformation())
 Extract simplicial grid from list of cubes.
template<class Grid, class Scalar, int dim, class EdgeLength>
std::unique_ptr< Grid > Kaskade::createCuboid (Dune::FieldVector< Scalar, dim > const &x0, Dune::FieldVector< Scalar, dim > const &dx, EdgeLength const &dh, bool symmetric=true)
 Creates a uniform simplicial grid on a rectangular or cuboid domain.
template<class Grid>
std::unique_ptr< Grid > Kaskade::createUnitSquare (double dh=1., bool symmetric=true)
 Creates a unit square, filled regularly.
template<class Grid>
std::unique_ptr< Grid > Kaskade::createUnitCube (double dh=1., bool symmetric=true)
 Creates a unit cube.
template<class Grid, class Scalar, class Dh, class Deformation = IdentityDeformation>
std::unique_ptr< Grid > Kaskade::createRectangle (Dune::FieldVector< Scalar, 2 > const &x0, Dune::FieldVector< Scalar, 2 > const &dx, Dh dh, bool symmetric=true, Deformation phi=Deformation())
 Cartesian structured triangulation of a rectangular domain.
template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createLShape (Dune::FieldVector< Scalar, dim > const &x0, Scalar dx, Scalar dy, Dune::FieldVector< Scalar, dim > const &thickness, Scalar dh, bool symmetric=true)
 Fill L-shaped domain with cubes.
template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createTShape (Dune::FieldVector< Scalar, dim > const &x0, Scalar dx, Scalar dy, Dune::FieldVector< Scalar, dim > const &thickness, Scalar dh, bool symmetric=true)
 Fill L-shaped domain with cubes.
template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createTwoLayerCuboid (Dune::FieldVector< Scalar, dim > const &x0, Dune::FieldVector< Scalar, dim > const &dx1, Dune::FieldVector< Scalar, dim > const &dx2, Dune::FieldVector< Scalar, dim > const &dh1, Scalar dh2, bool symmetric=true)
template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createTwoLayerCuboid (Dune::FieldVector< Scalar, dim > const &x0, Dune::FieldVector< Scalar, dim > const &dx1, Dune::FieldVector< Scalar, dim > const &dx2, Dune::FieldVector< Scalar, dim > const &dh1, Dune::FieldVector< Scalar, dim > const &dh2, bool symmetric=true)
template<class Grid>
std::unique_ptr< Grid > Kaskade::createCylinder (double radius, double height, int layers, int circumEdges=6)
 Creates a cylinder.
template<class Grid, class Deformation>
std::unique_ptr< Grid > Kaskade::createCylinder (double radius, double height, int layers, int circumEdges, Deformation const &deformation)
 Creates a deformed cylinder.
template<class Grid>
std::unique_ptr< Grid > Kaskade::createPentagon (double radius=1)
 Creates an regular pentagon consisting of five triangles, centered at the origin and with radius r.
template<class Grid>
std::unique_ptr< Grid > Kaskade::createUshape (double l, double d, double eps)
 Creates a U-shaped domain in \( \R^2 \).
template<class GridView, class ... GridViews>
auto Kaskade::unionGrid (GridView const &gv, GridViews const &...gvs)
 Creates a union grid from multiple given simplicial grid views.

Detailed Description

Grid creation or input.

Function Documentation

◆ createCuboid()

template<class Grid, class Scalar, int dim, class EdgeLength>
std::unique_ptr< Grid > Kaskade::createCuboid ( Dune::FieldVector< Scalar, dim > const & x0,
Dune::FieldVector< Scalar, dim > const & dx,
EdgeLength const & dh,
bool symmetric = true )

Creates a uniform simplicial grid on a rectangular or cuboid domain.

Template Parameters
Gridtype of grid to create
Scalarreal number type (usually double)
dimspatial dimension (usually 2 or 3)
EdgeLengtheither a scalar or a Dune::FieldVector<*,dim> type
Parameters
x0left, lower, front corner of the cuboid
dxdesired side lengths of the hexahedron to fill
dhside length(s) of hexahedra that are used to fill the cuboid
symmetrictrue: each cube provides a symmetric tetrahedal decomposition

If the edge length dh is a scalar, exact cubes are created. If it is a vector (of size dim), hexahedra with the given edge length are created.

Note that the desired size dx of the domain to be filled is just an indication - the resulting grid will approximately have this size. In contrast, the hexahedra used for filling the domain will always have the shape given by dh.

Definition at line 460 of file gridGeneration.hh.

Referenced by createCoverGrid(), createUnitCube(), and createUnitSquare().

◆ createCylinder() [1/2]

template<class Grid, class Deformation>
std::unique_ptr< Grid > Kaskade::createCylinder ( double radius,
double height,
int layers,
int circumEdges,
Deformation const & deformation )

Creates a deformed cylinder.

This creates a grid for the cyclinder domain \( \{ (x,y,z) \mid x^2 + y^2 \le r, 0\le z \le H \} \), and deforms it as specified. The grid consists of a series of prisms along the cylinder's axis.

Parameters
radiusthe cylinder's radius \( r \)
heightthe cylinder's height \( H \)
layersthe number of anti-prsimatic disks making up the grid
circumEdgesthe number of edges (or vertices) around the circumference
deformationa callable object Dune::FieldVector<double,3> deformation(Dune::FieldVector<double,3>)

Cell quality (in terms of aspect ratio) depends on the parameter values (and the deformation, of course). Reasonable cell quality is achieved for values approximately satisfying radius*layers = height and circumEdges = 6.

Definition at line 769 of file gridGeneration.hh.

◆ createCylinder() [2/2]

template<class Grid>
std::unique_ptr< Grid > Kaskade::createCylinder ( double radius,
double height,
int layers,
int circumEdges = 6 )

Creates a cylinder.

This creates a grid for the cyclinder domain \( \{ (x,y,z) \mid x^2 + y^2 \le r, 0\le z \le H \} \), i.e. the cylinder's axis is the z-axis. The grid consists of a series of prisms along the cylinder's axis.

Parameters
radiusthe cylinder's radius \( r \)
heightthe cylinder's height \( H \)
layersthe number of anti-prsimatic disks making up the grid
circumEdgesthe number of edges (or vertices) around the circumference
Cellquality (in terms of aspect ratio) depends on the parameter values. Reasonable cell quality is achieved for values approximately satisfying radius*layers = height and circumEdges = 6.

Definition at line 747 of file gridGeneration.hh.

Referenced by createCylinder().

◆ createGrid()

template<class Grid, class Type, class Deformation = IdentityDeformation>
std::unique_ptr< Grid > Kaskade::createGrid ( std::vector< Type > const & cubes,
Deformation phi = Deformation() )

Extract simplicial grid from list of cubes.

From a given list of (conforming) cubes or rectangles, this creates a simplicial grid. Optionally, the grid vertices can be warped by an invertible deformation of the space, such that piecewise planar meshes of curved domains can be created.

Template Parameters
Gridthe type of grid to create
Typetype of provided cuboids (cubes in 3D or rectangles in 2D)
Deformationa callable type mapping Dune::FieldVector to Dune::FieldVector
Parameters
cubesa sequence of cuboids making up the cartesian grid structure
phian invertible mapping from the grid domain to \( \R^d \)

Usage:

grid = createGrid<Grid>(GridGeneration_Detail::fillCuboid(x0,dx,dh,true));
std::unique_ptr< Grid > createGrid(std::vector< Type > const &cubes, Deformation phi=Deformation())
Extract simplicial grid from list of cubes.

Definition at line 414 of file gridGeneration.hh.

Referenced by createCuboid(), createLShape(), createRectangle(), createTShape(), createTwoLayerCuboid(), and createTwoLayerCuboid().

◆ createLShape()

template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createLShape ( Dune::FieldVector< Scalar, dim > const & x0,
Scalar dx,
Scalar dy,
Dune::FieldVector< Scalar, dim > const & thickness,
Scalar dh,
bool symmetric = true )

Fill L-shaped domain with cubes.

Parameters
x0left, lower, front corner of the L-shaped domain
dxlength of horizontal line
dylength of vertical line
thickness
dhside length of cubes that are used to fill the cuboid
symmetrictrue: each cube provides a symmetric tetrahedal decomposition

Definition at line 535 of file gridGeneration.hh.

◆ createPentagon()

template<class Grid>
std::unique_ptr< Grid > Kaskade::createPentagon ( double radius = 1)

Creates an regular pentagon consisting of five triangles, centered at the origin and with radius r.

Parameters
radiusof the circumcircle of the pentagon
Template Parameters
Gridthe type of grid to create

Definition at line 839 of file gridGeneration.hh.

◆ createRectangle()

template<class Grid, class Scalar, class Dh, class Deformation = IdentityDeformation>
std::unique_ptr< Grid > Kaskade::createRectangle ( Dune::FieldVector< Scalar, 2 > const & x0,
Dune::FieldVector< Scalar, 2 > const & dx,
Dh dh,
bool symmetric = true,
Deformation phi = Deformation() )

Cartesian structured triangulation of a rectangular domain.

Template Parameters
Dheither a scalar or a Dune::FieldVector<Scalar,2>
Deformationa callable type mapping Dune::FieldVector to Dune::FieldVector
Parameters
x0left, lower, front corner of the rectangle
dxside lengths
dhside length of squares that are used to fill the rectangle
symmetrictrue: each square provides a symmetric triangular decomposition

Definition at line 511 of file gridGeneration.hh.

◆ createTShape()

template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createTShape ( Dune::FieldVector< Scalar, dim > const & x0,
Scalar dx,
Scalar dy,
Dune::FieldVector< Scalar, dim > const & thickness,
Scalar dh,
bool symmetric = true )

Fill L-shaped domain with cubes.

Parameters
x0center on lower boundary of the T-shaped domain
dxlength of horizontal line
dylength of vertical line
thickness
dhside length of cubes that are used to fill the cuboid
symmetrictrue: each cube provides a symmetric tetrahedal decomposition

Definition at line 554 of file gridGeneration.hh.

◆ createTwoLayerCuboid() [1/2]

template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createTwoLayerCuboid ( Dune::FieldVector< Scalar, dim > const & x0,
Dune::FieldVector< Scalar, dim > const & dx1,
Dune::FieldVector< Scalar, dim > const & dx2,
Dune::FieldVector< Scalar, dim > const & dh1,
Dune::FieldVector< Scalar, dim > const & dh2,
bool symmetric = true )

Definition at line 577 of file gridGeneration.hh.

◆ createTwoLayerCuboid() [2/2]

template<class Grid, class Scalar, int dim>
std::unique_ptr< Grid > Kaskade::createTwoLayerCuboid ( Dune::FieldVector< Scalar, dim > const & x0,
Dune::FieldVector< Scalar, dim > const & dx1,
Dune::FieldVector< Scalar, dim > const & dx2,
Dune::FieldVector< Scalar, dim > const & dh1,
Scalar dh2,
bool symmetric = true )

Definition at line 566 of file gridGeneration.hh.

◆ createUnitCube()

template<class Grid>
std::unique_ptr< Grid > Kaskade::createUnitCube ( double dh = 1.,
bool symmetric = true )

Creates a unit cube.

Parameters
dhdesired side length of the subcubes.

Definition at line 491 of file gridGeneration.hh.

◆ createUnitSquare()

template<class Grid>
std::unique_ptr< Grid > Kaskade::createUnitSquare ( double dh = 1.,
bool symmetric = true )

Creates a unit square, filled regularly.

Parameters
dhside length of the subsquares.
symmetricif true, each subsquare is filled symmetrically with four triangles

Definition at line 479 of file gridGeneration.hh.

◆ createUshape()

template<class Grid>
std::unique_ptr< Grid > Kaskade::createUshape ( double l,
double d,
double eps )

Creates a U-shaped domain in \( \R^2 \).

xxxxx
x
xxxxx

Template Parameters
Gridthe type of grid to create
Parameters
lside length (horizontal extent, length of the legs of the U, \( l > d\))
dthickness of gemetry (vertical width of a single leg, \( d > 0 \))
epsslit width of geometry (distance between legs, \( \epsilon > 0 \))

Definition at line 892 of file gridGeneration.hh.

◆ extrude()

template<class Grid, class GridView>
std::unique_ptr< Grid > Kaskade::extrude ( GridView const & gridView,
double h )

Extrude a (d-1)-dimensional simplicial surface grid to a d-dimensional simplicial grid.

Given a simplicial grid of a (d-1)-dimensional manifold embedded in d-dimensional space (a surface mesh in 3D for d=3, a curve in 2D for d=2), this creates a d-dimensional simplicial grid that is a conforming prismatisation of the surface: a layer of prescribed thickness \( h \) around the surface, meshed with simplices.

The input grid is interpreted as the mid-surface of the extruded layer. The layer extends symmetrically by \( h/2 \) to both sides of the input surface. Consequently the absolute orientation of the input surface is irrelevant (reversing all normals yields the same grid) and there is no notion of an "outside" that would have to be determined. Only the relative orientation of neighbouring cells has to be consistent, which is achieved by a breadth-first propagation over the cell adjacency (see io/extrusion.hpp).

In every input node a normal direction is defined as the normalised average of the unit normals of the incident cells, and the layer vertices are placed along these directions. The number of sub-layers is chosen from the mean cell diameter \( s \) as \( n = \max(1, \mathrm{round}(h/s)) \), so that the sub-prisms are approximately isotropic; this assumes a roughly uniform local mesh size. For \( h \ll s \) one obtains flat simplices (usually intended), for \( h \sim s \) well-shaped ones.

Each sub-prism is decomposed into simplices. In 3D a triangular prism is split into three tetrahedra; the decomposition is selected by a purely local rule on the diagonals of the rectangular side faces which is provably conforming (shared faces get the same diagonal), see io/extrusion.hpp for the details and the proof.

Template Parameters
Gridthe type of grid to create, with Grid::dimension == Grid::dimensionworld == GridView::dimensionworld (e.g. Dune::UGGrid<3> for a surface mesh in 3D)
GridViewa leaf grid view of the input surface grid with GridView::dimension == GridView::dimensionworld - 1; only simplex cells are supported
Parameters
gridViewthe leaf grid view of the input surface grid
hthe thickness of the layer ( \( h \neq 0 \)); the layer spans \( [-h/2, +h/2] \) around the input surface
Returns
a std::unique_ptr owning the newly created grid
Exceptions
GridExceptionif the input contains non-simplex cells, if the node normals cannot be oriented consistently (non-orientable surface or a ~180 degree fold), or if the extrusion would produce inverted/self-intersecting cells (e.g. h too large for a strongly curved surface)

Example:

// a 2D surface grid (triangles) in 3D space
using SurfaceGrid = Dune::UGGrid<2>; // embedded in 3D via Dune::GeometryGrid, say
using VolumeGrid = Dune::UGGrid<3>;
auto grid = extrude<VolumeGrid>(surfaceLeafView, 0.1);
std::unique_ptr< Grid > extrude(GridView const &gridView, double h)
Extrude a (d-1)-dimensional simplicial surface grid to a d-dimensional simplicial grid.

A complete tutorial example is provided in tutorial/extrusion, demonstrating both a 2D curve-to-strip and a 3D surface-to-shell extrusion with VTK output and volume verification.

Note
The implementation is provided in extrusion.hpp. This header only declares the interface. For the template to be instantiated with your surface grid view type, include extrusion.hpp instead of (or in addition to) this file. Explicit instantiations for Dune::UGGrid<2> and Dune::UGGrid<3> with representative surface grid views are compiled into the library; other surface grid views require the template definition from extrusion.hpp.

◆ readPolyData()

std::unique_ptr< Dune::UGGrid< 2 > > readPolyData ( std::string const & name,
std::vector< int > * boundaryMarker = nullptr )

Construct an unstructured UG grid from .node and .ele files (Triangle output).

Parameters
namethe base name of the files (without the .node/.ele extension).
boundaryMarkera pointer to a vector of boundary markers. If not the nullpointer, the given vector is resized to the number of boundary segments (which is the number of boundary edges), and the corresponding markers are stored. These are stored in arbitrary order.

If the reading of boundary markers is requested, i.e. boundaryMarker != nullptr, a ".edge" file must exist. This can be generated by triangle using the -e option.

Warning
: triangle assigns the "boundary marker" 0 to interior edges in the *.edge file. These are ignored when reading the boundary information. Thus, don't ever use boundary marker 0 for any boundaries!

Dune boundary intersections have a method boundarySegmentIndex() returning the index of the coarse grid boundary segment on which the intersection resides. Use this index to look up the marker in the boundaryMarker array.

◆ unionGrid()

template<class GridView, class ... GridViews>
auto Kaskade::unionGrid ( GridView const & gv,
GridViews const &... gvs )

Creates a union grid from multiple given simplicial grid views.

Template Parameters
GridViewa Dune::GridView type for the first given grid view
GridViewsa template parameter pack of more Dune::GridView types

All the grid views need to contain only simplicial cells, have the same dimension, and a compatible coordinate scalar type ctype.

Parameters
gvthe first grid view
gva parameter pack of more grid views
Returns
a unique pointer to the union grid. The grid type is that of the last provided grid view.

The vertices and cells are just concatenated, shifting the vertex indices of later grid views by the total number of vertices in previous grid views.

Todo
: boundary segment indices are not yet handled

Definition at line 1012 of file gridGeneration.hh.