MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Lagrange shape function for triangle elements. More...
#include <TriLagrangeShape.hpp>
Public Member Functions | |
virtual EntityTopology | element_topology () const |
Get MBMesquite::EntityTopology handled by this mapping function. | |
virtual int | num_nodes () const |
Get number of nodes in the element type. | |
virtual NodeSet | sample_points (NodeSet higher_order_nodes) const |
Get sample points at which to evaluate mapping function. | |
virtual void | coefficients (Sample location, NodeSet nodeset, double *coeff_out, size_t *indices_out, size_t &num_coeff_out, MsqError &err) const |
Mapping Function Coefficients. | |
virtual void | derivatives (Sample location, NodeSet nodeset, size_t *vertex_indices_out, MsqVector< 2 > *d_coeff_d_xi_out, size_t &num_vtx, MsqError &err) const |
Mapping Function Derivatives. | |
virtual void | ideal (Sample location, MsqMatrix< 3, 2 > &jacobian_out, MsqError &err) const |
Get ideal Jacobian matrix. |
Lagrange shape function for triangle elements.
This class implements the MappingFunction interface, providing a Lagrange shape function for 6-node triangle.
\(\vec{x}(r,s) = sum_{i=0}^{n-1} N_i(r,s) \vec{x_i}\)
\(N_1 = t(2t - 1)\)
\(N_2 = r(2r - 1)\)
\(N_3 = s(2s - 1)\)
\(N_4 = 4rt\)
\(N_5 = 4rs\)
\(N_6 = 4st\)
\(t = 1 - r - s\)
Definition at line 62 of file TriLagrangeShape.hpp.
void MBMesquite::TriLagrangeShape::coefficients | ( | Sample | location, |
NodeSet | nodeset, | ||
double * | coeff_out, | ||
size_t * | indices_out, | ||
size_t & | num_coeff_out, | ||
MsqError & | err | ||
) | const [virtual] |
Mapping Function Coefficients.
This function returns the list of scalar values ( \(N_i\)'s) resulting from the evaluation of the mapping function coefficient terms \(N_1(\vec{\xi}), N_2(\vec{\xi}), \ldots, N_n(\vec{\xi})\) for a given \(\vec{\xi}\).
location | Where within the element at which to evaluate the coefficients. |
nodeset | List of which nodes are present in the element. |
coefficients_out | The coefficients ( \(N_i(\vec{\xi})\)) for each vertex in the element. |
indices_out | The index ($i$ in $N_i$) for each term in 'coeffs_out'. The assumption is that mapping function implementations will not return zero coefficients. This is not required, but for element types with large numbers of nodes it may have a significant impact on performance. |
Implements MBMesquite::MappingFunction.
Definition at line 64 of file TriLagrangeShape.cpp.
References MBMesquite::Sample::dimension, MBMesquite::NodeSet::have_any_mid_face_node(), MBMesquite::NodeSet::mid_edge_node(), MSQ_SETERR, MBMesquite::Sample::number, and MBMesquite::MsqError::UNSUPPORTED_ELEMENT.
{ if( nodeset.have_any_mid_face_node() ) { MSQ_SETERR( err ) ( "TriLagrangeShape does not support mid-element nodes", MsqError::UNSUPPORTED_ELEMENT ); return; } switch( loc.dimension ) { case 0: num_coeff = 1; indices_out[0] = loc.number; coeff_out[0] = 1.0; break; case 1: if( nodeset.mid_edge_node( loc.number ) ) { // if mid-edge node is present num_coeff = 1; indices_out[0] = 3 + loc.number; coeff_out[0] = 1.0; } else { // no mid node on edge num_coeff = 2; indices_out[0] = loc.number; indices_out[1] = ( loc.number + 1 ) % 3; coeff_out[0] = 0.5; coeff_out[1] = 0.5; } break; case 2: num_coeff = 3; indices_out[0] = 0; indices_out[1] = 1; indices_out[2] = 2; coeff_out[0] = 1.0 / 3.0; coeff_out[1] = 1.0 / 3.0; coeff_out[2] = 1.0 / 3.0; for( int i = 0; i < 3; ++i ) { // for each mid-edge node if( nodeset.mid_edge_node( i ) ) { // if node is present indices_out[num_coeff] = i + 3; // coeff for mid-edge node coeff_out[num_coeff] = 4.0 / 9.0; // adjust coeff for adj corner nodes coeff_out[i] -= 2.0 / 9.0; coeff_out[( i + 1 ) % 3] -= 2.0 / 9.0; // update count ++num_coeff; } } break; default: MSQ_SETERR( err ) ( MsqError::UNSUPPORTED_ELEMENT, "Request for dimension %d mapping function value" "for a triangular element", loc.dimension ); } }
void MBMesquite::TriLagrangeShape::derivatives | ( | Sample | location, |
NodeSet | nodeset, | ||
size_t * | vertex_indices_out, | ||
MsqVector< 2 > * | d_coeff_d_xi_out, | ||
size_t & | num_vtx, | ||
MsqError & | err | ||
) | const [virtual] |
Mapping Function Derivatives.
This function returns the partial derivatives of the mapping function coefficient terms \(\nabla N_1(\vec{\xi}), \nabla N_2(\vec{\xi}), \ldots, \nabla N_n(\vec{\xi})\) evaluated for a given \(\vec{\xi}\), where \(\vec{x_i}\) is a point in \(\mathbf{R}^3\) (i.e. \(x_i,y_i,z_i\)). \(\vec{\xi_i} = \left\{\begin{array}{c}\xi_i\\ \eta_i\\ \end{array}\right\}\) for surface elements and \(\vec{\xi_i} = \left\{\begin{array}{c}\xi_i\\ \eta_i\\ \zeta_i\\ \end{array}\right\}\) for volume elements.
The list of returned partial derivatives may be considered list of elements of a matrix \(\mathbf{D}\) in row major order. For surface elements, \(\mathbf{D}\) is a \(n\times 2\) matrix and for volume elements it is a \(n \times 3\) matrix. Each row of \(\mathbf{D}\) corresponds to one of the coefficient functions \(N_i(\vec{\xi})\) and each column corresponds to one of the components of \(\vec{\xi}\) that the corresponding coefficient function is differentiated with respect to.
\( \mathbf{D} = \left[ \begin{array}{ccc} \frac{\delta N_1}{\delta \xi} & \frac{\delta N_1}{\delta \eta} & \ldots \\ \frac{\delta N_2}{\delta \xi} & \frac{\delta N_2}{\delta \eta} & \ldots \\ \vdots & \vdots & \ddots \end{array} \right]\)
The Jacobian matrix ( \(\mathbf{J}\)) of the mapping function can be calculated as follows. Define a matrix \(\mathbf{X}\) such that each column contains the coordinates of the element nodes.
\( \mathbf{X} = \left[ \begin{array}{ccc} x_1 & x_2 & \ldots \\ y_1 & y_2 & \ldots \\ z_1 & z_2 & \ldots \end{array}\right]\)
The Jacobian matrix is then:
\(\mathbf{J} = \mathbf{X} \times \mathbf{D}\)
\(\mathbf{X}\) is always \(3\times n\), so \(\mathbf{J}\) is either \(3\times 2\) (surface elements) or \(3\times 3\) (volume elements) depending on the dimensions of \(\mathbf{D}\).
If the Jacobian matrix of the mapping function is considered as a function of the element vertex coordinates \(\mathbf{J}(\vec{x_1},\vec{x_2},\ldots)\) with \(\vec{\xi}\) constant, then the gradient of that Jacobian matrix function (with respect to the vertex coordinates) can be obtained from the same output list of partial deravitves.
\(\frac{\delta \mathbf{J}}{\delta x_i} = \left[ \begin{array}{ccc} \frac{\delta N_i}{\delta \xi} & \frac{\delta N_i}{\delta \eta} & \ldots \\ 0 & 0 & \ldots \\ 0 & 0 & \ldots \end{array} \right]\) \(\frac{\delta \mathbf{J}}{\delta y_i} = \left[ \begin{array}{ccc} 0 & 0 & \ldots \\ \frac{\delta N_i}{\delta \xi} & \frac{\delta N_i}{\delta \eta} & \ldots \\ 0 & 0 & \ldots \end{array} \right]\) \(\frac{\delta \mathbf{J}}{\delta z_i} = \left[ \begin{array}{ccc} 0 & 0 & \ldots \\ 0 & 0 & \ldots \\ \frac{\delta N_i}{\delta \xi} & \frac{\delta N_i}{\delta \eta} & \ldots \end{array} \right]\)
location | Where within the element at which to evaluate the derivatives. |
nodeset | List of which nodes are present in the element. |
vertices_out | The list of vertices for which the corresponding coefficient in the mapping function is non-zero. The vertices are specified by their index in the canonical ordering for an element with all mid-nodes present (i.e. first all the corner nodes, then the mid-edge nodes, ...). |
d_coeff_d_xi_out | The mapping function is composed of a series of coefficient functions \(N_i(\vec{\xi})\), one correspoding to the position \(\vec{x_i}\) of each node in the element such that the mapping function is of the form: \(\vec{x}(\vec{\xi})=\sum_{i=1}^n N_i(\vec{\xi})\vec{x_i}\). For each vertex indicated in vertex_indices_out, this list contains the partial derivatives of the cooresponding coefficient function \(N_i\) with respect to each component of \(\vec{\xi}\) in the same order as the corresponding nodes in vertex_indices_out. |
num_vtx | Output: The number of vertex indices and derivitive tuples returned in vertices_out and d_coeff_d_xi_out, respectively. |
Implements MBMesquite::MappingFunction2D.
Definition at line 310 of file TriLagrangeShape.cpp.
References MBMesquite::derivatives_at_corner(), MBMesquite::derivatives_at_mid_edge(), MBMesquite::derivatives_at_mid_elem(), MBMesquite::Sample::dimension, MBMesquite::get_linear_derivatives(), MBMesquite::NodeSet::have_any_mid_face_node(), MBMesquite::NodeSet::have_any_mid_node(), MBMesquite::MsqError::INVALID_ARG, MSQ_SETERR, MBMesquite::Sample::number, and MBMesquite::MsqError::UNSUPPORTED_ELEMENT.
{ if( !nodeset.have_any_mid_node() ) { num_vtx = 3; get_linear_derivatives( vertex_indices_out, d_coeff_d_xi_out ); return; } if( nodeset.have_any_mid_face_node() ) { MSQ_SETERR( err ) ( "TriLagrangeShape does not support mid-element nodes", MsqError::UNSUPPORTED_ELEMENT ); return; } switch( loc.dimension ) { case 0: derivatives_at_corner( loc.number, nodeset, vertex_indices_out, d_coeff_d_xi_out, num_vtx ); break; case 1: derivatives_at_mid_edge( loc.number, nodeset, vertex_indices_out, d_coeff_d_xi_out, num_vtx ); break; case 2: derivatives_at_mid_elem( nodeset, vertex_indices_out, d_coeff_d_xi_out, num_vtx ); break; default: MSQ_SETERR( err )( "Invalid/unsupported logical dimension", MsqError::INVALID_ARG ); } }
EntityTopology MBMesquite::TriLagrangeShape::element_topology | ( | ) | const [virtual] |
Get MBMesquite::EntityTopology handled by this mapping function.
Implements MBMesquite::MappingFunction.
Definition at line 40 of file TriLagrangeShape.cpp.
References MBMesquite::TRIANGLE.
{ return TRIANGLE; }
void MBMesquite::TriLagrangeShape::ideal | ( | Sample | location, |
MsqMatrix< 3, 2 > & | jacobian_out, | ||
MsqError & | err | ||
) | const [virtual] |
Get ideal Jacobian matrix.
Returns the Jacobian matrix of an ideal element. The orientation of element or corresponding matrix is arbitrary. The "ideal" element should be scaled such the Jacobian (determinant of the Jacobian matrix) is 1.0.
location | Where within the element at which to evaluate the Jacobian. Typically doesn't matter except for degenerate elements (e.g. pyramid as degenerate hex.) |
jacobian_out | The Jacobian of the mapping function at the specified logical location. |
Reimplemented from MBMesquite::MappingFunction2D.
Definition at line 347 of file TriLagrangeShape.cpp.
References b.
{ // const double g = 1.074569931823542; // sqrt(2/sqrt(3)); // J(0,0) = g; J(0,1) = 0.5*g; // J(1,0) = 0.0; J(1,1) = 1.0/g; // J(2,0) = 0.0; J(2,1) = 0.0; const double a = 0.70710678118654746; // 1/sqrt(2) const double b = 1.3160740129524924; // 4th root of 3 J( 0, 0 ) = -a / b; J( 0, 1 ) = a / b; J( 1, 0 ) = -a * b; J( 1, 1 ) = -a * b; J( 2, 0 ) = 0.0; J( 2, 1 ) = 0.0; }
int MBMesquite::TriLagrangeShape::num_nodes | ( | ) | const [virtual] |
Get number of nodes in the element type.
Get the number of nodes in the element type that the mapping function implements. It is assumed that the result of this function, in combination with the element topology, is sufficient to determine the element type.
Implements MBMesquite::MappingFunction.
Definition at line 45 of file TriLagrangeShape.cpp.
{
return 6;
}
NodeSet MBMesquite::TriLagrangeShape::sample_points | ( | NodeSet | higher_order_nodes | ) | const [virtual] |
Get sample points at which to evaluate mapping function.
Get the points within the element at which TMP quality metrics that are a function of the mapping function Jacobian should be evaluated. The default (which may be overridden by individual mapping functions) is to evaluate at all nodes.
Reimplemented from MBMesquite::MappingFunction.
Definition at line 50 of file TriLagrangeShape.cpp.
References MBMesquite::NodeSet::clear(), MBMesquite::NodeSet::have_any_mid_node(), MBMesquite::NodeSet::set_all_corner_nodes(), MBMesquite::NodeSet::set_mid_face_node(), and MBMesquite::TRIANGLE.
{ if( ns.have_any_mid_node() ) { ns.set_all_corner_nodes( TRIANGLE ); } else { ns.clear(); ns.set_mid_face_node( 0 ); } return ns; }