MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include "Mesquite.hpp"
#include "QuadLagrangeShape.hpp"
#include "TopologyInfo.hpp"
#include "MsqError.hpp"
#include "IdealElements.hpp"
#include "JacobianCalculator.hpp"
#include "UnitUtil.hpp"
#include <vector>
#include <algorithm>
#include <iostream>
#include <sstream>
Go to the source code of this file.
Classes | |
class | QuadLagrangeShapeTest |
Defines | |
#define | ASSERT_VALUES_EQUAL(v1, v2, location, bits) ASSERT_MESSAGE( value_message( ( location ), ( bits ), ( v1 ), ( v2 ) ), ( fabs( ( v1 ) - ( v2 ) ) < epsilon ) ) |
Typedefs | |
typedef double(* | N_t )(double, double) |
typedef double(* | f_t )(unsigned, double, double) |
Enumerations | |
enum | { XI = 0, ETA = 1 } |
Functions | |
static CppUnit::Message | value_message (unsigned location, NodeSet bits, double v1, double v2) |
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (QuadLagrangeShapeTest,"QuadLagrangeShapeTest") | |
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (QuadLagrangeShapeTest,"Unit") | |
static double | l11 (double xi) |
static double | l12 (double xi) |
static double | l22 (double xi) |
static double | dl11 (double) |
static double | dl12 (double) |
static double | dl22 (double xi) |
static double | N0 (double xi, double eta) |
static double | N1 (double xi, double eta) |
static double | N2 (double xi, double eta) |
static double | N3 (double xi, double eta) |
static double | N4 (double xi, double eta) |
static double | N5 (double xi, double eta) |
static double | N6 (double xi, double eta) |
static double | N7 (double xi, double eta) |
static double | N8 (double xi, double eta) |
static double | dN0dxi (double xi, double eta) |
static double | dN1dxi (double xi, double eta) |
static double | dN2dxi (double xi, double eta) |
static double | dN3dxi (double xi, double eta) |
static double | dN4dxi (double xi, double eta) |
static double | dN5dxi (double xi, double eta) |
static double | dN6dxi (double xi, double eta) |
static double | dN7dxi (double xi, double eta) |
static double | dN8dxi (double xi, double eta) |
static double | dN0deta (double xi, double eta) |
static double | dN1deta (double xi, double eta) |
static double | dN2deta (double xi, double eta) |
static double | dN3deta (double xi, double eta) |
static double | dN4deta (double xi, double eta) |
static double | dN5deta (double xi, double eta) |
static double | dN6deta (double xi, double eta) |
static double | dN7deta (double xi, double eta) |
static double | dN8deta (double xi, double eta) |
static double | N (unsigned i, double xi, double eta) |
static double | dNdxi (unsigned i, double xi, double eta) |
static double | dNdeta (unsigned i, double xi, double eta) |
static void | eval (f_t function, NodeSet nodeset, double xi, double eta, double results[9]) |
static void | get_coeffs (NodeSet nodebits, double xi, double eta, double coeffs_out[9]) |
static void | get_partial_wrt_xi (NodeSet nodebits, double xi, double eta, double derivs_out[9]) |
static void | get_partial_wrt_eta (NodeSet nodebits, double xi, double eta, double derivs_out[9]) |
static void | check_valid_indices (const size_t *vertices, size_t num_vtx, NodeSet nodeset) |
static void | check_no_zeros (const MsqVector< 2 > *derivs, size_t num_vtx) |
static void | compare_coefficients (const double *coeffs, const size_t *indices, size_t num_coeff, const double *expected_coeffs, unsigned loc, NodeSet bits) |
static void | compare_derivatives (const size_t *vertices, size_t num_vtx, const MsqVector< 2 > *derivs, const double *expected_dxi, const double *expected_deta, unsigned loc, NodeSet bits) |
static NodeSet | nodeset_from_bits (unsigned bits) |
Variables | |
const double | epsilon = 1e-6 |
const double | min_xi = 0 |
const double | max_xi = 1 |
const double | mid_xi = 0.5 * ( min_xi + max_xi ) |
static const N_t | N_a [9] = { &N0, &N1, &N2, &N3, &N4, &N5, &N6, &N7, &N8 } |
static const N_t | dNdxi_a [9] = { &dN0dxi, &dN1dxi, &dN2dxi, &dN3dxi, &dN4dxi, &dN5dxi, &dN6dxi, &dN7dxi, &dN8dxi } |
static const N_t | dNdeta_a [9] |
static const double | corners [4][2] = { { min_xi, min_xi }, { max_xi, min_xi }, { max_xi, max_xi }, { min_xi, max_xi } } |
static const double | midedge [4][2] = { { mid_xi, min_xi }, { max_xi, mid_xi }, { mid_xi, max_xi }, { min_xi, mid_xi } } |
static const double | midelem [2] = { mid_xi, mid_xi } |
Definition in file QuadLagrangeShapeTest.cpp.
#define ASSERT_VALUES_EQUAL | ( | v1, | |
v2, | |||
location, | |||
bits | |||
) | ASSERT_MESSAGE( value_message( ( location ), ( bits ), ( v1 ), ( v2 ) ), ( fabs( ( v1 ) - ( v2 ) ) < epsilon ) ) |
Definition at line 49 of file QuadLagrangeShapeTest.cpp.
Referenced by compare_coefficients(), and compare_derivatives().
typedef double( * f_t)(unsigned, double, double) |
Definition at line 315 of file QuadLagrangeShapeTest.cpp.
typedef double( * N_t)(double, double) |
Definition at line 292 of file QuadLagrangeShapeTest.cpp.
anonymous enum |
static void check_no_zeros | ( | const MsqVector< 2 > * | derivs, |
size_t | num_vtx | ||
) | [static] |
Definition at line 399 of file QuadLagrangeShapeTest.cpp.
References CPPUNIT_ASSERT.
Referenced by compare_derivatives().
{ for( unsigned i = 0; i < num_vtx; ++i ) { double dxi = derivs[i][0]; double deta = derivs[i][1]; CPPUNIT_ASSERT( fabs( dxi ) > 1e-6 || fabs( deta ) > 1e-6 ); } }
static void check_valid_indices | ( | const size_t * | vertices, |
size_t | num_vtx, | ||
NodeSet | nodeset | ||
) | [static] |
Definition at line 375 of file QuadLagrangeShapeTest.cpp.
References CPPUNIT_ASSERT, MBMesquite::NodeSet::mid_edge_node(), and MBMesquite::NodeSet::mid_face_node().
Referenced by compare_derivatives().
{ // check valid size of list (at least three, at most all nodes) CPPUNIT_ASSERT( num_vtx <= 9 ); CPPUNIT_ASSERT( num_vtx >= 3 ); // make sure vertex indices are valid (in [0,8]) size_t vertcopy[9]; std::copy( vertices, vertices + num_vtx, vertcopy ); std::sort( vertcopy, vertcopy + num_vtx ); CPPUNIT_ASSERT( vertcopy[num_vtx - 1] <= 8 ); // max value less than 9 // make sure there are no duplicates in the list const size_t* iter = std::unique( vertcopy, vertcopy + num_vtx ); CPPUNIT_ASSERT( iter == vertcopy + num_vtx ); // make all vertices are present in element for( unsigned i = 0; i < num_vtx; ++i ) { if( vertcopy[i] == 8 ) CPPUNIT_ASSERT( nodeset.mid_face_node( 0 ) ); else if( vertcopy[i] >= 4 ) CPPUNIT_ASSERT( nodeset.mid_edge_node( vertcopy[i] - 4 ) ); } }
static void compare_coefficients | ( | const double * | coeffs, |
const size_t * | indices, | ||
size_t | num_coeff, | ||
const double * | expected_coeffs, | ||
unsigned | loc, | ||
NodeSet | bits | ||
) | [static] |
Definition at line 409 of file QuadLagrangeShapeTest.cpp.
References ASSERT_VALUES_EQUAL, CPPUNIT_ASSERT, MBMesquite::NodeSet::mid_edge_node(), and MBMesquite::NodeSet::mid_face_node().
Referenced by QuadLagrangeShapeTest::test_corner_coeff(), QuadLagrangeShapeTest::test_edge_coeff(), and QuadLagrangeShapeTest::test_mid_coeff().
{ // find the location in the returned list for each node size_t revidx[9]; double test_vals[9]; for( size_t i = 0; i < 9; ++i ) { revidx[i] = std::find( indices, indices + num_coeff, i ) - indices; test_vals[i] = ( revidx[i] == num_coeff ) ? 0.0 : coeffs[revidx[i]]; } // Check that index list doesn't contain any nodes not actually // present in the element. CPPUNIT_ASSERT( bits.mid_edge_node( 0 ) || ( revidx[4] == num_coeff ) ); CPPUNIT_ASSERT( bits.mid_edge_node( 1 ) || ( revidx[5] == num_coeff ) ); CPPUNIT_ASSERT( bits.mid_edge_node( 2 ) || ( revidx[6] == num_coeff ) ); CPPUNIT_ASSERT( bits.mid_edge_node( 3 ) || ( revidx[7] == num_coeff ) ); CPPUNIT_ASSERT( bits.mid_face_node( 0 ) || ( revidx[8] == num_coeff ) ); // compare expected and actual coefficient values ASSERT_VALUES_EQUAL( expected_coeffs[0], test_vals[0], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[1], test_vals[1], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[2], test_vals[2], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[3], test_vals[3], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[4], test_vals[4], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[5], test_vals[5], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[6], test_vals[6], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[7], test_vals[7], loc, bits ); ASSERT_VALUES_EQUAL( expected_coeffs[8], test_vals[8], loc, bits ); }
static void compare_derivatives | ( | const size_t * | vertices, |
size_t | num_vtx, | ||
const MsqVector< 2 > * | derivs, | ||
const double * | expected_dxi, | ||
const double * | expected_deta, | ||
unsigned | loc, | ||
NodeSet | bits | ||
) | [static] |
Definition at line 445 of file QuadLagrangeShapeTest.cpp.
References ASSERT_VALUES_EQUAL, check_no_zeros(), check_valid_indices(), and CPPUNIT_ASSERT.
Referenced by QuadLagrangeShapeTest::test_corner_derivs(), QuadLagrangeShapeTest::test_edge_derivs(), and QuadLagrangeShapeTest::test_mid_derivs().
{ check_valid_indices( vertices, num_vtx, bits ); check_no_zeros( derivs, num_vtx ); // Input has values in dxi & deta only for nodes in 'vertices' // Convert to values for every possible node, with zero's for // nodes that are not present. CPPUNIT_ASSERT( num_vtx <= 9 ); double expanded_dxi[9], expanded_deta[9]; std::fill( expanded_dxi, expanded_dxi + 9, 0.0 ); std::fill( expanded_deta, expanded_deta + 9, 0.0 ); for( unsigned i = 0; i < num_vtx; ++i ) { CPPUNIT_ASSERT( vertices[i] <= 9 ); expanded_dxi[vertices[i]] = derivs[i][0]; expanded_deta[vertices[i]] = derivs[i][1]; } ASSERT_VALUES_EQUAL( expected_dxi[0], expanded_dxi[0], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[1], expanded_dxi[1], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[2], expanded_dxi[2], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[3], expanded_dxi[3], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[4], expanded_dxi[4], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[5], expanded_dxi[5], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[6], expanded_dxi[6], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[7], expanded_dxi[7], loc, bits ); ASSERT_VALUES_EQUAL( expected_dxi[8], expanded_dxi[8], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[0], expanded_deta[0], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[1], expanded_deta[1], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[2], expanded_deta[2], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[3], expanded_deta[3], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[4], expanded_deta[4], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[5], expanded_deta[5], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[6], expanded_deta[6], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[7], expanded_deta[7], loc, bits ); ASSERT_VALUES_EQUAL( expected_deta[8], expanded_deta[8], loc, bits ); }
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION | ( | QuadLagrangeShapeTest | , |
"QuadLagrangeShapeTest" | |||
) |
static double dl11 | ( | double | ) | [static] |
static double dl12 | ( | double | ) | [static] |
static double dl22 | ( | double | xi | ) | [static] |
Definition at line 168 of file QuadLagrangeShapeTest.cpp.
References MBMesquite::xi.
Referenced by dN4dxi(), dN5deta(), dN6dxi(), dN7deta(), dN8deta(), and dN8dxi().
{ return 4 - 8 * xi; }
static double dN0deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN0dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN1deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN1dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN2deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN2dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN3deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN3dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN4deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN4dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN5deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN5dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN6deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN6dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN7deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN7dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN8deta | ( | double | xi, |
double | eta | ||
) | [static] |
static double dN8dxi | ( | double | xi, |
double | eta | ||
) | [static] |
static double dNdeta | ( | unsigned | i, |
double | xi, | ||
double | eta | ||
) | [static] |
Definition at line 309 of file QuadLagrangeShapeTest.cpp.
References dNdeta_a, MBMesquite::eta, and MBMesquite::xi.
Referenced by get_partial_wrt_eta().
static double dNdxi | ( | unsigned | i, |
double | xi, | ||
double | eta | ||
) | [static] |
Definition at line 305 of file QuadLagrangeShapeTest.cpp.
References dNdxi_a, MBMesquite::eta, and MBMesquite::xi.
Referenced by get_partial_wrt_xi().
static void eval | ( | f_t | function, |
NodeSet | nodeset, | ||
double | xi, | ||
double | eta, | ||
double | results[9] | ||
) | [static] |
Definition at line 316 of file QuadLagrangeShapeTest.cpp.
References MBMesquite::NodeSet::mid_edge_node(), and MBMesquite::NodeSet::mid_face_node().
Referenced by moab::SpatialLocator::elem_eval(), moab::FileOptions::get_ints_option(), main(), moab::Tree::set_eval(), and TestMeshRefiner().
{ // Initial values are a) linear values for corners, // b) values for mid edges assuming no mid-face node, // and c) the mid-face value for a fully quadratic element. for( unsigned i = 0; i < 9; ++i ) results[i] = function( i, xi, eta ); // if center node is present, adjust mid-edge coefficients if( !nodeset.mid_face_node( 0 ) ) { results[8] = 0; } else { for( unsigned i = 0; i < 4; ++i ) results[i] -= 0.25 * results[8]; for( unsigned i = 4; i < 8; ++i ) results[i] -= 0.5 * results[8]; } // if mid-edge nodes are present, adjust values for adjacent corners for( unsigned i = 0; i < 4; ++i ) { if( !nodeset.mid_edge_node( i ) ) { results[i + 4] = 0.0; } else { results[i] -= 0.5 * results[i + 4]; // 1st adjacent corner results[( i + 1 ) % 4] -= 0.5 * results[i + 4]; // 2nd adjacent corner } } }
static void get_coeffs | ( | NodeSet | nodebits, |
double | xi, | ||
double | eta, | ||
double | coeffs_out[9] | ||
) | [static] |
Definition at line 355 of file QuadLagrangeShapeTest.cpp.
References MBMesquite::eval(), and N.
Referenced by QuadLagrangeShapeTest::test_corner_coeff(), QuadLagrangeShapeTest::test_edge_coeff(), and QuadLagrangeShapeTest::test_mid_coeff().
static void get_partial_wrt_eta | ( | NodeSet | nodebits, |
double | xi, | ||
double | eta, | ||
double | derivs_out[9] | ||
) | [static] |
Definition at line 365 of file QuadLagrangeShapeTest.cpp.
References dNdeta(), and MBMesquite::eval().
Referenced by QuadLagrangeShapeTest::test_corner_derivs(), QuadLagrangeShapeTest::test_edge_derivs(), and QuadLagrangeShapeTest::test_mid_derivs().
static void get_partial_wrt_xi | ( | NodeSet | nodebits, |
double | xi, | ||
double | eta, | ||
double | derivs_out[9] | ||
) | [static] |
Definition at line 360 of file QuadLagrangeShapeTest.cpp.
References dNdxi(), and MBMesquite::eval().
Referenced by QuadLagrangeShapeTest::test_corner_derivs(), QuadLagrangeShapeTest::test_edge_derivs(), and QuadLagrangeShapeTest::test_mid_derivs().
static double l11 | ( | double | xi | ) | [static] |
static double l12 | ( | double | xi | ) | [static] |
static double l22 | ( | double | xi | ) | [static] |
static double N | ( | unsigned | i, |
double | xi, | ||
double | eta | ||
) | [static] |
Definition at line 299 of file QuadLagrangeShapeTest.cpp.
References MBMesquite::eta, N_a, and MBMesquite::xi.
static double N0 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N1 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N2 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N3 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N4 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N5 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N6 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N7 | ( | double | xi, |
double | eta | ||
) | [static] |
static double N8 | ( | double | xi, |
double | eta | ||
) | [static] |
static NodeSet nodeset_from_bits | ( | unsigned | bits | ) | [static] |
Definition at line 584 of file QuadLagrangeShapeTest.cpp.
References MBMesquite::NodeSet::set_mid_edge_node(), and MBMesquite::NodeSet::set_mid_face_node().
Referenced by QuadLagrangeShapeTest::test_coeff_center(), QuadLagrangeShapeTest::test_coeff_corners(), QuadLagrangeShapeTest::test_coeff_edges(), QuadLagrangeShapeTest::test_deriv_center(), QuadLagrangeShapeTest::test_deriv_corners(), and QuadLagrangeShapeTest::test_deriv_edges().
{ NodeSet result; for( unsigned i = 0; i < 4; ++i ) if( bits & ( 1 << i ) ) result.set_mid_edge_node( i ); if( bits & ( 1 << 4 ) ) result.set_mid_face_node( 0 ); return result; }
static CppUnit::Message value_message | ( | unsigned | location, |
NodeSet | bits, | ||
double | v1, | ||
double | v2 | ||
) | [inline, static] |
Definition at line 52 of file QuadLagrangeShapeTest.cpp.
{ CppUnit::Message m( "equality assertion failed" ); std::ostringstream buffer1; buffer1 << "Expected : " << v1; m.addDetail( buffer1.str() ); std::ostringstream buffer2; buffer2 << "Actual : " << v2; m.addDetail( buffer2.str() ); std::ostringstream buffer3; buffer3 << "Location : "; if( location < 4 ) buffer3 << "Corner " << location; else if( location < 8 ) buffer3 << "Edge " << location - 4; else if( location == 8 ) buffer3 << "Mid-element"; else buffer3 << "INVALID!!"; m.addDetail( buffer3.str() ); std::ostringstream buffer4; buffer4 << "Node Bits: " << bits; m.addDetail( buffer4.str() ); return m; }
const double corners[4][2] = { { min_xi, min_xi }, { max_xi, min_xi }, { max_xi, max_xi }, { min_xi, max_xi } } [static] |
Definition at line 371 of file QuadLagrangeShapeTest.cpp.
const N_t dNdxi_a[9] = { &dN0dxi, &dN1dxi, &dN2dxi, &dN3dxi, &dN4dxi, &dN5dxi, &dN6dxi, &dN7dxi, &dN8dxi } [static] |
Definition at line 294 of file QuadLagrangeShapeTest.cpp.
Referenced by dNdxi().
const double epsilon = 1e-6 |
Definition at line 48 of file QuadLagrangeShapeTest.cpp.
const double max_xi = 1 |
Definition at line 135 of file QuadLagrangeShapeTest.cpp.
Definition at line 136 of file QuadLagrangeShapeTest.cpp.
const double midedge[4][2] = { { mid_xi, min_xi }, { max_xi, mid_xi }, { mid_xi, max_xi }, { min_xi, mid_xi } } [static] |
Definition at line 372 of file QuadLagrangeShapeTest.cpp.
Referenced by MBMesquite::get_nodeset(), MBMesquite::MeshImpl::set_skin_flags(), QuadLagrangeShapeTest::test_edge_coeff(), and QuadLagrangeShapeTest::test_edge_derivs().
Definition at line 373 of file QuadLagrangeShapeTest.cpp.
Referenced by QuadLagrangeShapeTest::test_mid_coeff(), and QuadLagrangeShapeTest::test_mid_derivs().
const double min_xi = 0 |
Definition at line 134 of file QuadLagrangeShapeTest.cpp.