Namespace GooseFEM::Mesh::Quad4#
-
namespace Quad4
Simple meshes of 4-noded quadrilateral elements in 2d (ElementType::Quad4).
-
class FineLayer : public GooseFEM::Mesh::RegularBase2d<FineLayer>
- #include <GooseFEM/MeshQuad4.h>
Mesh with fine middle layer, and coarser elements towards the top and bottom.
Public Functions
-
inline FineLayer(size_t nelx, size_t nely, double h = 1.0, size_t nfine = 1)
Constructor.
- Parameters:
nelx – Number of elements (along the middle layer) in horizontal (x) direction.
nely – Approximate equivalent number of elements in vertical (y) direction.
h – Edge size (width == height) of elements along the weak layer.
nfine – Extra number of fine layers around the middle layer. By default the element size is kept smaller than the distance to the middle layer.
-
template<class C, class E, std::enable_if_t<xt::is_xexpression<C>::value, bool> = true>
inline FineLayer(const C &coor, const E &conn) Reconstruct class for given coordinates / connectivity.
- Template Parameters:
C – e.g.
array_type::tensor<double, 2>
E – e.g.
array_type::tensor<size_t, 2>
- Parameters:
coor – Nodal coordinates
[nnode, ndim]
withndim == 2
.conn – Connectivity
[nne, nne]
withnne == 4
.
-
inline const array_type::tensor<size_t, 1> &elemrow_nhx() const
Edge size in x-direction of a block, in units of h, per row of blocks.
Note that a block is equal to an element except in refinement layers where it contains three elements.
- Returns:
List of size equal to the number of rows of blocks.
-
inline const array_type::tensor<size_t, 1> &elemrow_nhy() const
Edge size in y-direction of a block, in units of h, per row of blocks.
Note that a block is equal to an element except in refinement layers where it contains three elements.
- Returns:
List of size equal to the number of rows of blocks.
-
inline const array_type::tensor<int, 1> &elemrow_type() const
Per row of blocks:
-1
: normal layer0
: transition layer to match coarse and finer element on the previous/next row.- Returns:
List of size equal to the number of rows of blocks.
-
inline const array_type::tensor<size_t, 1> &elemrow_nelem() const
Number of elements per row of blocks.
Note that a block is equal to an element except in refinement layers where it contains three elements.
- Returns:
List of size equal to the number of rows of blocks.
-
inline array_type::tensor<size_t, 1> elementsMiddleLayer() const
Elements in the middle (fine) layer.
- Returns:
List of element numbers.
-
inline array_type::tensor<size_t, 1> elementsLayer(size_t layer) const
Elements along a layer.
- Returns:
List of element numbers.
-
inline array_type::tensor<size_t, 1> elementgrid_ravel(std::vector<size_t> start_stop_rows, std::vector<size_t> start_stop_cols) const
Select region of elements from ‘matrix’ of element numbers.
- Returns:
List of element numbers.
-
inline array_type::tensor<size_t, 1> elementgrid_around_ravel(size_t e, size_t size, bool periodic = true)
Select region of elements from ‘matrix’ of element numbers around an element: square box with edge-size
(2 * size + 1) * h
, aroundelement
.- Parameters:
e – The element around which to select elements.
size – Edge size of the square box encapsulating the selected element.
periodic – Assume the mesh periodic.
- Returns:
List of elements.
-
inline array_type::tensor<size_t, 1> elementgrid_leftright(size_t e, size_t left, size_t right, bool periodic = true)
Select region of elements from ‘matrix’ of element numbers around an element: left/right from
element
(on the same layer).- Parameters:
e – The element around which to select elements.
left – Number of elements to select to the left.
right – Number of elements to select to the right.
periodic – Assume the mesh periodic.
- Returns:
List of elements.
-
inline array_type::tensor<size_t, 1> roll(size_t n)
Mapping to ‘roll’ periodically in the x-direction,.
- Returns:
element mapping, such that: new_elemvar = elemvar[elem_map]
-
inline FineLayer(size_t nelx, size_t nely, double h = 1.0, size_t nfine = 1)
-
class Regular : public GooseFEM::Mesh::RegularBase2d<Regular>
- #include <GooseFEM/MeshQuad4.h>
Regular mesh: equi-sized elements.
Public Functions
-
inline Regular(size_t nelx, size_t nely, double h = 1.0)
Constructor.
- Parameters:
nelx – Number of elements in horizontal (x) direction.
nely – Number of elements in vertical (y) direction.
h – Edge size (width == height).
-
inline array_type::tensor<size_t, 2> elementgrid() const
Element numbers as ‘matrix’.
-
inline Regular(size_t nelx, size_t nely, double h = 1.0)
-
namespace Map
Mesh mappings.
-
class FineLayer2Regular
- #include <GooseFEM/MeshQuad4.h>
Map a FineLayer mesh to a Regular mesh.
The element size of the Regular corresponds to the smallest elements of the FineLayer mesh (along the middle layer).
Public Functions
-
inline FineLayer2Regular(const GooseFEM::Mesh::Quad4::FineLayer &mesh)
Constructors.
- Parameters:
mesh – The FineLayer mesh.
-
inline GooseFEM::Mesh::Quad4::FineLayer fineLayerMesh() const
Obtain the FineLayer mesh (copy of the mesh passed to the constructor).
- Returns:
mesh.
-
inline std::vector<std::vector<size_t>> map() const
Get element-mapping: elements of the Regular mesh per element of the FineLayer mesh.
The number of Regular elements varies between elements of the FineLayer mesh.
- Returns:
[nelem_finelayer, ?]
-
inline std::vector<std::vector<double>> mapFraction() const
To overlap fraction for each item in the mapping in map().
- Returns:
[nelem_finelayer, ?]
-
inline GooseFEM::Mesh::Quad4::Regular getRegularMesh() const
Obtain the Regular mesh.
- Returns:
mesh.
-
inline GooseFEM::Mesh::Quad4::FineLayer getFineLayerMesh() const
Obtain the FineLayer mesh (copy of the mesh passed to the constructor).
- Returns:
mesh.
-
inline std::vector<std::vector<size_t>> getMap() const
Get element-mapping: elements of the Regular mesh per element of the FineLayer mesh.
The number of Regular elements varies between elements of the FineLayer mesh.
- Returns:
[nelem_finelayer, ?]
-
inline std::vector<std::vector<double>> getMapFraction() const
To overlap fraction for each item in the mapping in getMap().
- Returns:
[nelem_finelayer, ?]
-
template<class T, size_t rank>
inline array_type::tensor<T, rank> mapToRegular(const array_type::tensor<T, rank> &data) const Map element quantities to Regular.
The mapping is a bit simplistic: no interpolation is involved, the function just accounts the fraction of overlap between the FineLayer element and the Regular element. The mapping is such that::
ret[e_regular, ...] <- arg[e_finelayer, ...]
- Template Parameters:
T – type of the data (e.g.
double
).rank – rank of the data.
- Parameters:
data – data.
- Returns:
mapped data.
-
inline FineLayer2Regular(const GooseFEM::Mesh::Quad4::FineLayer &mesh)
-
class RefineRegular
- #include <GooseFEM/MeshQuad4.h>
Refine a Regular mesh: subdivide elements in several smaller elements.
Public Functions
-
inline RefineRegular(const GooseFEM::Mesh::Quad4::Regular &mesh, size_t nx, size_t ny)
Constructor.
- Parameters:
mesh – the coarse mesh.
nx – for each coarse element: number of fine elements in x-direction.
ny – for each coarse element: number of fine elements in y-direction.
-
inline size_t nx() const
For each coarse element: number of fine elements in x-direction.
- Returns:
unsigned int (same as used in constructor)
-
inline size_t ny() const
For each coarse element: number of fine elements in y-direction.
- Returns:
unsigned int (same as used in constructor)
-
inline GooseFEM::Mesh::Quad4::Regular coarseMesh() const
Obtain the coarse mesh (copy of the mesh passed to the constructor).
- Returns:
mesh
-
inline const array_type::tensor<size_t, 2> &map() const
Get element-mapping: elements of the fine mesh per element of the coarse mesh.
-
inline GooseFEM::Mesh::Quad4::Regular getCoarseMesh() const
Obtain the coarse mesh (copy of the mesh passed to the constructor).
- Returns:
mesh
-
inline const array_type::tensor<size_t, 2> &getMap() const
Get element-mapping: elements of the fine mesh per element of the coarse mesh.
-
template<class T, size_t rank>
inline array_type::tensor<T, rank> meanToCoarse(const array_type::tensor<T, rank> &data) const Compute the mean of the quantity define on the fine mesh when mapped on the coarse mesh.
- Template Parameters:
T – type of the data (e.g.
double
).rank – rank of the data.
- Parameters:
data – the data [nelem_fine, …]
- Returns:
the average data of the coarse mesh [nelem_coarse, …]
-
template<class T, size_t rank, class S>
inline array_type::tensor<T, rank> averageToCoarse(const array_type::tensor<T, rank> &data, const array_type::tensor<S, rank> &weights) const Compute the average of the quantity define on the fine mesh when mapped on the coarse mesh.
- Template Parameters:
T – type of the data (e.g.
double
).rank – rank of the data.
S – type of the weights (e.g.
double
).
- Parameters:
data – the data [nelem_fine, …]
weights – the weights [nelem_fine, …]
- Returns:
the average data of the coarse mesh [nelem_coarse, …]
-
template<class T, size_t rank>
inline array_type::tensor<T, rank> mapToFine(const array_type::tensor<T, rank> &data) const Map element quantities to the fine mesh.
The mapping is a bit simplistic: no interpolation is involved. The mapping is such that::
ret[e_fine, ...] <- data[e_coarse, ...]
- Template Parameters:
T – type of the data (e.g.
double
).rank – rank of the data.
- Parameters:
data – the data.
- Returns:
mapped data.
-
inline RefineRegular(const GooseFEM::Mesh::Quad4::Regular &mesh, size_t nx, size_t ny)
-
class FineLayer2Regular
-
class FineLayer : public GooseFEM::Mesh::RegularBase2d<FineLayer>