Jive reference manual
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
jive::geom::StdShape Class Referenceabstract

Encapsulates the geometrical properties of a finite element in its local coordinate system. More...

Inheritance diagram for jive::geom::StdShape:
Inheritance graph

Public Types

typedef jem::String String
 A string type. More...
 
typedef util::Vector Vector
 A vector type. More...
 
typedef util::Matrix Matrix
 A matrix type. More...
 
typedef util::Cubix Cubix
 A three-dimensional array of doubles. More...
 

Public Member Functions

virtual String name () const =0
 Returns the name of this shape. More...
 
virtual int rank () const =0
 Returns the rank of this shape. More...
 
virtual int nodeCount () const =0
 Returns the number of nodes attached to this shape. More...
 
virtual Matrix getNodeCoords () const =0
 Returns the local node coordinates. More...
 
virtual bool containsPoint (const Vector &u) const =0
 Tests whether a point is located within this shape. More...
 
virtual void evalShapeFunctions (const Vector &h, const Vector &u) const =0
 Computes the shape functions in a given point. More...
 
virtual void evalShapeFunctions (const Matrix &h, const Matrix &u) const
 Computes the shape functions in multiple points within this shape. More...
 
virtual void evalShapeGradients (const Matrix &g, const Vector &u) const =0
 Computes the gradients of the shape functions in a specific point within this shape. More...
 
virtual void evalShapeGradients (const Cubix &g, const Matrix &u) const
 Computes the gradients of the shape functions in multiple points within this shape. More...
 

Static Public Member Functions

static void registerShape (StdShape *shape)
 Registers a standard shape. More...
 
static StdShapefindShape (const String &name)
 Searches for a standard shape with a given name. More...
 
static void encodeShape (jem::io::DataOutput &out, StdShape *shape)
 Writes a standard shape to a data output stream. More...
 
static StdShapedecodeShape (jem::io::DataInput &in)
 Reads a standard shape from a data input stream. More...
 

Protected Member Functions

 StdShape ()
 Constructs an empty shape object. More...
 
virtual ~StdShape ()
 Protected destructor to invalidate delete expressions. More...
 

Detailed Description

#include <jive/geom/StdShape.h>

The abstract base class StdShape encapsulates the properties of a finite element in its local coordinate system. It can be used to get the local node coordinates of an element; to evaluate the shape functions of an element; and to evaluate the gradients of the shape functions in the local coordinate system.

In addition to a set of nodes and shape functions, a StdShape object has a name and a rank. The former is a string that may have any value as long as it is unique for each StdShape object. The latter is an integer number that equals the number of dimensions of the local coordinate system.

The StdShape class implements the Singleton pattern. This means that there exists only one StdShape object for each type of element. For instance, there is one StdShape object that captures the local geometrical properties of a triangle element with linear shape functions. This particular object can be obtained by calling the static member function getShape of the class StdLinearTriangle. The shape object representing other element types can be obtained in a similar way. You can use the helper class StdShapeInstance to create a single instance of a class derived from the StdShape class in a thread-safe way.

Since the number of StdShape objects in a program is limited to the number of element types that are used, there is no need to destroy and deallocate StdShape objects when they are no longer needed. In fact, they can not be destroyed because the destructor of the StdShape class is a protected member. This design eliminates the possibility that a program accidentaly accesses an invalid pointer to a StdShape object.

The StdShape class encapsulates a static table containing pointers to the StdShape objects that are used in a program. Access to this table is provided by the static member functions findShape() and registerShape(). The the first function returns a pointer to a shape object given its name, while the second function registers a standard shape object by inserting it into the table. You can use the helper class StdShapeRegisterAgent to automate the registration of shape objects.

The static shape table is used – among others – by the serialization functions encodeShape() and decodeShape(). The first writes the name of a StdShape object to a data output stream. The second reads the name of a StdShape object from a data input stream and then calls the function findShape() to obtain a pointer to that shape object.

See also
StdShapeInstance, StdShapeRegisterAgent, Shape

Member Typedef Documentation

The String type encapsulates the name of a StdShape object. It is just a convenient alias for jem::String.

The Vector type represents a one-dimensional array of doubles. It is just a convenient alias for jive::util::Vector.

The Matrix type represents a two-dimensional array of double. It is just an alias for jive::util::Matrix.

The Cubix type is a three-dimensional array of doubles. It is simply an alias for jive::util::Cubix.

Constructor & Destructor Documentation

jive::geom::StdShape::StdShape ( )
protected

The default constructor does nothing; it simply creates an empty StdShape object.

virtual jive::geom::StdShape::~StdShape ( )
protectedvirtual

The destructor of the StdShape class is a protected member to ensure that a StdShape object can not be created on the stack and that a StdShape object can not be deleted. All classes derived from the StdShape class should also declare their destructor protected.

The destructor of the StdShape class does nothing.

Member Function Documentation

virtual String jive::geom::StdShape::name ( ) const
pure virtual

Returns the name of this StdShape object. The name can be any string as long as it is unique for each StdShape object. To avoid name conflicts, it is strongly recommended that the name of a StdShape is similar to the name of the element type represented by that shape object. For instance, if this shape object represents a triangle element with linear shape functions, then this function should return the string "LinearTriangle", or something similar.

Returns
The name of this shape.
virtual int jive::geom::StdShape::rank ( ) const
pure virtual
virtual int jive::geom::StdShape::nodeCount ( ) const
pure virtual

Returns the number of nodes attached to this shape.

Returns
The number of nodes.
virtual Matrix jive::geom::StdShape::getNodeCoords ( ) const
pure virtual

Returns a matrix containing the local coordinates of the nodes attached to this shape. If c denotes the returned matrix, then c(i,j) equals the i-th coordinate of the j-th node.

Returns
The local node coordinates.
virtual bool jive::geom::StdShape::containsPoint ( const Vector u) const
pure virtual

Returns true if the point specified by the local coordinate vector u lies within this shape, and false otherwise.

Parameters
u- a local coordinate vector.
Precondition
u.size() == this->rank()
Returns
true if the specified point lies within this shape, and false otherwise.

Implemented in jive::geom::StdBezierShape, jive::geom::StdBoundary, jive::geom::StdPrism, jive::geom::StdPumShape, jive::geom::StdHyperCube, jive::geom::StdCube, jive::geom::StdLine, jive::geom::StdSquare, jive::geom::StdTetrahedron, jive::geom::StdTriangle, and jive::geom::StdWedge.

virtual void jive::geom::StdShape::evalShapeFunctions ( const Vector h,
const Vector u 
) const
pure virtual

Fills the vector h with the values of the shape functions in a specific point within this shape: h[i] is set to the i-th shape function in that point. The vector u should contain the local coordinates of the point: u[i] should be equal to the i-th local coordinate.

Parameters
h- a vector that will be filled with the values of the shape functions in a specific point within this shape.
u- a vector containing the local coordinates of the specified point.
Precondition
h.size() == this->nodeCount() &&
u.size() == this->rank() && this->containsPoint ( u )

Implemented in jive::geom::StdSquare6Bx3B, jive::geom::StdSquare5Bx3B, jive::geom::StdSquare5Bx2, jive::geom::StdSquare4Bx3B, jive::geom::StdSquare4Bx2, jive::geom::StdSquare3Bx2, jive::geom::StdSquare25B, jive::geom::StdLine6B, jive::geom::StdSquare16B, jive::geom::StdLine5B, jive::geom::StdSquare9B, jive::geom::StdLine4B, jive::geom::StdSquare12, jive::geom::StdLine3B, jive::geom::StdCube3Bx2x2, jive::geom::StdLine4, jive::geom::StdSquare9, jive::geom::StdCube27B, jive::geom::StdLine3, jive::geom::StdCube20, jive::geom::StdSquare8, jive::geom::StdLine2C1, jive::geom::StdCube16, jive::geom::StdSquare6, jive::geom::StdTriangle6, jive::geom::StdWedge18, jive::geom::StdTetrahedron10, jive::geom::StdLine2, jive::geom::StdHyperCube16, jive::geom::StdCube8, jive::geom::StdSquare4, jive::geom::StdTriangle3, jive::geom::StdWedge6, jive::geom::StdTetrahedron4, jive::geom::StdBezierShape, jive::geom::StdBoundary, jive::geom::StdPrism, jive::geom::StdPumShape, and jive::geom::StdEdge.

virtual void jive::geom::StdShape::evalShapeFunctions ( const Matrix h,
const Matrix u 
) const
virtual

Fills the matrix h with the values of the shape functions in a set of points within this shape: h(i,j) is set to the i-th shape function in the j-th point. The matrix u should contain the local coordinates of the points: u(i,j) should be equal to the i-th local coordinate of the j-th point.

The implementation of this function provided by the StdShape class simply executes:

int j;
for ( j = 0; j < u.size(1); j++ ) {
evalShapeFunctions ( h( slice(ALL), j ), u( slice(ALL), j ) );
}
Parameters
h- a matrix that will be filled with the values of the shape functions in a specific set of points within this shape.
u- a matrix containing the local coordinates of the specified points.
Precondition
h.size(0) == this->nodeCount() &&
u.size(0) == this->rank() &&
h.size(1) == u.size(1)
virtual void jive::geom::StdShape::evalShapeGradients ( const Matrix g,
const Vector u 
) const
pure virtual

Fills the matrix g with the spatial derivatives of the shape functions in a specific point in this shape: g(i,j) is set to the i-th derivative of the j-th shape function in that point. The vector u should contain the local coordinates of that point: u[i] should be equal to the i-th local coordinate.

Note that the derivatives are computed in the local coordinate system.

Parameters
g- a matrix that will be filled with the gradients of the shape functions.
u- a local coordinate vector.
Precondition
g.size(0) == this->rank() &&
g.size(1) == this->nodeCount() &&
u.size() == this->rank()
virtual void jive::geom::StdShape::evalShapeGradients ( const Cubix g,
const Matrix u 
) const
virtual

Fills the three-dimensional array g with the spatial derivatives of the shape functions in a specified set of points in this shape: g(i,j,k) is set to the i-th derivative of the j-th shape function in the k-th point. The matrix u should contain the local coordinates of the points: u(i,k) should be equal to the i-th local coordinate of the k-th point.

Note that the derivatives are computed in the local coordinate system.

The implementation of this function provided by the StdShape class basically executes the following code:

int k;
for ( k = 0; k < u.size(1); k++ ) {
evalShapeGradients ( g( slice(ALL), slice(ALL), k ),
u( slice(ALL), k ) );
}
Parameters
g- a three-dimensional array that will be filled with the gradients of the shape functions in a specific set of points.
u- a matrix containing the local coordinates of the specified points.
Precondition
g.size(0) == this->rank() &&
g.size(1) == this->nodeCount() &&
u.size(0) == this->rank() &&
u.size(1) == g.size(2)
static void jive::geom::StdShape::registerShape ( StdShape shape)
static

Registers the standard shape shape by inserting it into the static shape table that is encapsulated by the StdShape class. If the table already contains a shape with the same name as shape, then shape replaces the current object in the table. You can use the helper class StdShapeRegisterAgent to automate the registration of standard shapes.

This function is thread safe.

Parameters
shape- a pointer to a StdShape object.
Precondition
shape != NULL
Postcondition
findShape( shape->name() ) == shape
static StdShape* jive::geom::StdShape::findShape ( const String name)
static

Returns a pointer to the shape object with name name. If no shape with that name has been registered – with the registerShape() function – then NULL is returned.

This function is thread safe.

Parameters
name- the name of a standard shape.
Returns
A pointer to StdShape object with name name, or NULL if there is no shape with that name.
static void jive::geom::StdShape::encodeShape ( jem::io::DataOutput out,
StdShape shape 
)
static

Writes the name of the StdShape object shape to the data output stream out. The member function decodeShape() can be used to reverse this procedure.

Parameters
out- a data output stream.
shape- a pointer to a StdShape object.
Precondition
shape != NULL
Exceptions
jem::io::IOException- if an I/O error occurs.
static StdShape* jive::geom::StdShape::decodeShape ( jem::io::DataInput in)
static

Reads the name of a standard shape from the input stream in, and returns a pointer to the StdShape object with that name.

Parameters
in- a data input stream.
Exceptions
jem::io::SerializationException- if there is no StdShape object with the extracted name.