2#include "libmesh/libmesh.h"
3#include "libmesh/dense_matrix.h"
4#include "libmesh/edge_edge2.h"
6#include "libmesh/quadrature_gauss.h"
7#include "libmesh/mesh_generation.h"
8#include "libmesh/mesh.h"
34 std::unique_ptr<FEBase>
_fe;
49 CPPUNIT_ASSERT_EQUAL(dual_coeff.
m(),
unsigned(2));
50 CPPUNIT_ASSERT_EQUAL(dual_coeff.
n(),
unsigned(2));
55 LIBMESH_ASSERT_FP_EQUAL(2, dual_coeff(0,0), my_tol);
56 LIBMESH_ASSERT_FP_EQUAL(-1, dual_coeff(0,1), my_tol);
57 LIBMESH_ASSERT_FP_EQUAL(-1, dual_coeff(1,0), my_tol);
58 LIBMESH_ASSERT_FP_EQUAL(2, dual_coeff(1,1), my_tol);
60 const auto & dual_phi =
_fe->get_dual_phi();
62 CPPUNIT_ASSERT_EQUAL(std::size_t(2), dual_phi.size());
64 const auto & qpoints =
_qrule->get_points();
66 CPPUNIT_ASSERT_EQUAL(qpoints.size(), dual_phi[0].size());
69 LIBMESH_ASSERT_FP_EQUAL(1./2. * (1. - 3.*qpoints[qp](0)), dual_phi[0][qp],
72 CPPUNIT_ASSERT_EQUAL(qpoints.size(), dual_phi[1].size());
75 LIBMESH_ASSERT_FP_EQUAL(1./2. * (1. + 3.*qpoints[qp](0)), dual_phi[1][qp],
91 auto rng =
mesh.active_local_element_ptr_range();
92 if (rng.begin() == rng.end())
94 const Elem * elem = *(rng.begin());
98 const auto & JxW = fe->get_JxW();
99 const auto & phi = fe->get_phi();
100 const auto & dual_phi = fe->get_dual_phi();
102 fe->attach_quadrature_rule(&qrule);
105 CPPUNIT_ASSERT_EQUAL(std::size_t(n), phi.size());
106 CPPUNIT_ASSERT_EQUAL(std::size_t(n), dual_phi.size());
112 std::vector<Real> dtilde(n, 0);
115 dtilde[j] += JxW[qp]*dual_phi[j][qp];
117 Real sum_dtilde = 0, volume = 0;
120 CPPUNIT_ASSERT(dtilde[j] > 0);
121 sum_dtilde += dtilde[j];
127 LIBMESH_ASSERT_FP_EQUAL(volume, sum_dtilde, my_tol);
132 sum += dual_phi[j][qp];
133 LIBMESH_ASSERT_FP_EQUAL(1., sum, my_tol);
137 LIBMESH_ASSERT_FP_EQUAL(vertex_over_mid,
138 dtilde[0]/dtilde[elem->
n_vertices()], my_tol);
147 T(m,m) = 1. - 2.*alpha;
160 ntilde_k += T(k,l)*phi[l][qp];
161 integral += JxW[qp]*dual_phi[j][qp]*ntilde_k;
163 LIBMESH_ASSERT_FP_EQUAL(k == j ? dtilde[j] : 0., integral, my_tol);
208 auto rng =
_mesh->active_local_element_ptr_range();
209 _elem = rng.begin() == rng.end() ? nullptr : *(rng.begin());
212 _fe->attach_quadrature_rule(
_qrule.get());
This class is for unit testing dual coefficient and shape function values.
LIBMESH_CPPUNIT_TEST_SUITE(DualShapeTest)
std::unique_ptr< FEBase > _fe
CPPUNIT_TEST(testTri6Lagrange)
std::unique_ptr< QGauss > _qrule
CPPUNIT_TEST(testQuad8Lagrange)
std::unique_ptr< Mesh > _mesh
void testTransformedDual(const ElemType elem_type, const unsigned int n, const Real vertex_over_mid, const FEFamily family=LAGRANGE)
Check what the transformed dual basis on QUAD8/TRI6/TRI7 guarantees, none of which the untransformed ...
CPPUNIT_TEST(testL2Lagrange)
CPPUNIT_TEST(testEdge2Lagrange)
CPPUNIT_TEST(testTri7Lagrange)
Defines a dense matrix for use in Finite Element-type computations.
This is the base class from which all geometric element types are derived.
virtual unsigned int n_vertices() const =0
virtual unsigned int n_second_order_adjacent_vertices(const unsigned int n) const
virtual unsigned short int second_order_adjacent_vertex(const unsigned int n, const unsigned int v) const
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Order default_quadrature_order() const
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
This class implements specific orders of Gauss quadrature.
Communicator * TestCommWorld
CPPUNIT_TEST_SUITE_REGISTRATION(DualShapeTest)
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
ElemType
Defines an enum for geometric element types.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...