IFEM 90A354
ElementBlock.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
12//==============================================================================
13
14#ifndef _ELEMENT_BLOCK_H
15#define _ELEMENT_BLOCK_H
16
17#include "Point.h"
18#include "MatVec.h"
19#include <array>
20
21
27{
28public:
30 explicit ElementBlock(size_t nenod = 8);
32 virtual ~ElementBlock() = default;
33
38 void resize(size_t nI, size_t nJ = 1, size_t nK = 1);
39
44 void unStructResize(size_t nEl, size_t nPts, size_t nMNPC = 0);
45
47 bool setCoor(size_t i, size_t j, Real x);
49 bool setCoor(size_t i, const Vec3& X);
51 bool setCoor(size_t i, Real x, Real y, Real z)
52 { return this->setCoor(i,Vec3(x,y,z)); }
54 bool setParams(size_t i, Real u, Real v, Real w = Real(0));
55
57 bool setNode(size_t i, int nodeNumb);
59 bool endOfElm(size_t& i);
60
62 bool addLine(Real x1, Real y1, Real z1, Real x2, Real y2, Real z2);
67 size_t addLine(size_t i1, const Vec3& X2, int elmId = -1);
68
70 void setElmId(size_t i, int iel) { MINEX[i-1] = iel; }
72 int getElmId(size_t i) const { return MINEX[i-1]; }
74 size_t getElmIndex(size_t i) const { return i < elmIdx.size() ? elmIdx[i]:i; }
75
77 size_t getNoNodes() const { return coord.size(); }
79 size_t getNoElms() const { return MINEX.size(); }
81 size_t getNoElmNodes() const { return nen; }
83 void setNoElmNodes(size_t nenod) { nen = nenod; }
84
86 void merge(const ElementBlock* other,
87 std::vector<int>& nodeNums, bool uniqNodes = true);
89 void merge(const ElementBlock& other, bool uniqNodes = true);
90
92 void transform(const Matrix& Tlg);
93
95 std::vector<Vec3>::const_iterator begin_XYZ() const { return coord.begin(); }
97 std::vector<Vec3>::const_iterator end_XYZ() const { return coord.end(); }
98
100 const Vec3& getCoord(size_t i) const { return coord[i]; }
102 const Real* getParam(size_t i) const;
103
105 const int* getElements() const { return MMNPC.data(); }
107 bool getElements(std::vector<int>& mnpc, size_t nenod) const;
108
110 utl::Point getCenter(size_t i) const;
112 void removeElement(int iel);
113
114protected:
115 using Prm3 = std::array<Real,3>;
116
117 std::vector<Vec3> coord;
118 std::vector<Prm3> param;
119 std::vector<int> MMNPC;
120 std::vector<int> MINEX;
121 size_t nen;
122
123private:
124 std::vector<size_t> elmIdx;
125
126public:
127 static double eps;
128};
129
130
137{
138public:
143 PlaneBlock(const Vec3& X0, const Vec3& X1, const Vec3& X2);
144};
145
146
154{
155public:
159 CubeBlock(const Vec3& X0, double dX);
160};
161
162
170{
171public:
177 SphereBlock(const Vec3& X0, double R, size_t nTheta = 180, size_t nPhi = 60);
178};
179
180
188{
189public:
195 CylinderBlock(const Vec3& X0, const Vec3& X1,
196 double R, size_t nTheta = 180);
197};
198
199#endif
#define Real
The floating point type to use.
Definition ImmersedBoundaries.h:18
Global algebraic operations on index 1-based matrices and vectors.
Representation of points in 3D space with coordinates and parameters.
Class for single-element cube geometries.
Definition ElementBlock.h:154
Class for cylinder geometries.
Definition ElementBlock.h:188
Class for storage of a standard FE grid block.
Definition ElementBlock.h:27
void resize(size_t nI, size_t nJ=1, size_t nK=1)
Reallocates the internal arrays to fit a structured grid.
Definition ElementBlock.C:43
bool setParams(size_t i, Real u, Real v, Real w=Real(0))
Defines the parameter values for node i.
Definition ElementBlock.C:104
std::vector< Vec3 >::const_iterator begin_XYZ() const
Returns the beginning of the coordinate array.
Definition ElementBlock.h:95
size_t getNoNodes() const
Returns the total number of nodes in the block.
Definition ElementBlock.h:77
const Real * getParam(size_t i) const
Returns a pointer to the parameter values of a given node.
Definition ElementBlock.C:233
bool setCoor(size_t i, size_t j, Real x)
Defines the j'th coordinate of node i.
Definition ElementBlock.C:86
size_t nen
Number of Element Nodes.
Definition ElementBlock.h:121
std::array< Real, 3 > Prm3
Convenience type.
Definition ElementBlock.h:115
size_t getNoElmNodes() const
Returns the number of nodes per element.
Definition ElementBlock.h:81
void transform(const Matrix &Tlg)
Applies a transformation matrix from local to global system.
Definition ElementBlock.C:225
int getElmId(size_t i) const
Returns the external ID of an element.
Definition ElementBlock.h:72
std::vector< Vec3 > coord
Vector of nodal coordinates.
Definition ElementBlock.h:117
std::vector< Prm3 > param
Vector of parameter values of the nodal points.
Definition ElementBlock.h:118
bool endOfElm(size_t &i)
Marks the end of current element for unstructured grids.
Definition ElementBlock.C:124
static double eps
Element shrinkage factor.
Definition ElementBlock.h:127
void unStructResize(size_t nEl, size_t nPts, size_t nMNPC=0)
Reallocates the internal arrays to fit an unstructured grid.
Definition ElementBlock.C:67
void removeElement(int iel)
Removes all elements with the specified external ID.
Definition ElementBlock.C:313
void setNoElmNodes(size_t nenod)
Sets the number of nodes per element.
Definition ElementBlock.h:83
const int * getElements() const
Returns a pointer to the element connectivity array.
Definition ElementBlock.h:105
bool setNode(size_t i, int nodeNumb)
Defines the global number of element node i.
Definition ElementBlock.C:115
std::vector< int > MINEX
Matrix of Internal to External element numbers.
Definition ElementBlock.h:120
void merge(const ElementBlock *other, std::vector< int > &nodeNums, bool uniqNodes=true)
Merges another element block into this one.
Definition ElementBlock.C:188
const Vec3 & getCoord(size_t i) const
Returns the coordinate of a given node.
Definition ElementBlock.h:100
virtual ~ElementBlock()=default
Empty destructor.
bool addLine(Real x1, Real y1, Real z1, Real x2, Real y2, Real z2)
Adds a line element to the grid, assuming nen is equal to two.
Definition ElementBlock.C:162
std::vector< Vec3 >::const_iterator end_XYZ() const
Returns the end of the coordinate array.
Definition ElementBlock.h:97
utl::Point getCenter(size_t i) const
Returns the coordinates of the center of the given element.
Definition ElementBlock.C:268
size_t getNoElms() const
Returns the total number of elements in the block.
Definition ElementBlock.h:79
void setElmId(size_t i, int iel)
Assigns an external ID to an element.
Definition ElementBlock.h:70
std::vector< size_t > elmIdx
Internal element order in case of mixed types.
Definition ElementBlock.h:124
bool setCoor(size_t i, Real x, Real y, Real z)
Defines the coordinates of node i.
Definition ElementBlock.h:51
std::vector< int > MMNPC
Matrix of Matrices of Nodal Point Correspondance.
Definition ElementBlock.h:119
size_t getElmIndex(size_t i) const
Returns the internal index of an element in case of mixed types.
Definition ElementBlock.h:74
Class for single-element plane geometries.
Definition ElementBlock.h:137
Class for sphere geometries.
Definition ElementBlock.h:170
Simple class for representing a point in 3D space.
Definition Vec3.h:27
Class for representing points in 3D space.
Definition Point.h:29