#include <SimplexJac.h>
Public Types | |
typedef T | Number |
The number type. | |
typedef ads::FixedArray< N, Number > | Vertex |
The class for a vertex. | |
typedef Simplex< N, Vertex, Number > | Simplex |
The simplex type. | |
typedef ads::SquareMatrix< N, Number > | Matrix |
An NxN matrix. | |
Public Member Functions | |
Constructors etc. | |
SimplexJac () | |
Default constructor. Un-initialized memory. | |
SimplexJac (const SimplexJac &other) | |
Copy constructor. | |
SimplexJac (const Simplex &s) | |
Construct from a simplex. | |
SimplexJac & | operator= (const SimplexJac &other) |
Assignment operator. | |
~SimplexJac () | |
Trivial destructor. | |
Accessors | |
const Matrix & | getMatrix () const |
Return a const reference to the Jacobian matrix. | |
const ads::FixedArray< N, Matrix > & | getGradientMatrix () const |
Return a const reference to the gradient of the Jacobian matrix. | |
Number | getDeterminant () const |
Return the determinant of the Jacobian matrix. | |
const Vertex & | getGradientDeterminant () const |
Return a const reference to the gradient of the determinant of the Jacobian matrix. | |
Number | computeContent () const |
Return the content (hypervolume) of the simplex. | |
void | computeGradientContent (Vertex *grad) const |
Calculate the gradient of the content (hypervolume) of the simplex. | |
Vertex | computeGradientContent () const |
Return the gradient of the content (hypervolume) of the simplex. | |
Manipulators | |
void | setFunction (const Simplex &s) |
Set the vertices. Calculate the Jacobian matrix and determinant. | |
void | set (const Simplex &s) |
Set the vertices. Calculate the Jacobian matrix and the determinant and its gradient. | |
void | setFunction (const geom::Simplex< N, ads::FixedArray< N+1, Number >, Number > &s) |
Set the vertices. Calculate the Jacobian matrix and determinant. | |
void | set (const geom::Simplex< N, ads::FixedArray< N+1, Number >, Number > &s) |
Set the vertices. Calculate the Jacobian matrix and the determinant and its gradient. |
N | is the dimension. | |
T | is the number type. By default it is double. |
Consider a simplex with vertices
. We call this the physical simplex. The identity simplex
may be mapped to the physical simplex
by an affine transformation and a translation.
is the Jacobian matrix of the transformation.
In 2-D, the identity triangle has vertices: ,
and
. In 3-D, the identity tetrahedron has vertices:
,
,
and
.
The logical simplex, is the simplex whose vertices are the origin and unit displacements in each coordinate direction. In 2-D, the logical triangle has vertices:
,
and
. In 3-D, the logical tetrahedron has vertices:
,
,
,
. It is easy to map the logical simplex to the physical simplex.
The columns of are the displacements of the vertices from the first vertex
. In 3-D, this is
It is also easy to map the logical simplex to the identity simplex.
The columns of are the vertices of
. In 3-D, this is
By combining the former transformation with the inverse of the latter, we can map the identity simplex to the physical simplex.
The Jacobian matrix of the transformation is .
Usage
Construct a SimplexJac
with the default constructor or from a SimplexJac::Simplex
.
typedef geom::SimplexJac<3> TetJac; typedef TetJac::Vertex Vertex; typedef TetJac::Simplex Tetrahedron; // Default constructor. TetJac tet;
// The identity tetrahedron. Tetrahedron t(Vertex(0, 0, 0), Vertex(1, 0, 0), Vertex(1./2, std::sqrt(3.)/2, 0), Vertex(1./2, std::sqrt(3.)/6, std::sqrt(2./3.))); TetJac tet(t);
Simplex
constructor calls set()
to enable evaluation of the determinant, the content and their gradients.
To evaluate the determinant or the content of the simplex, first call setFunction()
to set the Jacobian matrix and then use the getDeterminant() and computeContent() member functions.
tet.setFunction(t); std::cout << "Identity tetrahedron:\n" << "determinant = " << tet.getDeterminant() << "\nvolume = " << tet.computeContent() << '\n';
set()
to set the Jacobian matrix and its gradient. Then use the member functions to access the appropriate qantities. tet.set(t); std::cout << "Identity tetrahedron:\n" << "determinant = " << tet.getDeterminant() << "\ngrad determinant = " << tet.getGradientDeterminant() << "\nvolume = " << tet.computeContent() << "\ngrad volume = " << tet.computeGradientContent() << '\n';
void geom::SimplexJac< N, T >::set | ( | const geom::Simplex< N, ads::FixedArray< N+1, Number >, Number > & | s | ) |
Set the vertices. Calculate the Jacobian matrix and the determinant and its gradient.
This first projects the simplex to N-D and then call the above set().
void geom::SimplexJac< N, T >::setFunction | ( | const geom::Simplex< N, ads::FixedArray< N+1, Number >, Number > & | s | ) |
Set the vertices. Calculate the Jacobian matrix and determinant.
This first projects the simplex to N-D and then call the above setFunction().