<commit_before>#include "fe_test.h" // For linear_test(), headers, FETestBase, etc

// Helper functions for restricting normal components
namespace {

RealTensor tangential_hessian (RealTensor hess,
                               const RealVectorValue normal)
{
  const RealVectorValue full_hess_n = hess*normal;

  const RealTensor n_n = outer_product(normal, normal);
  for (unsigned int k=0; k != 3; ++k)
    {
      RealVectorValue ek {0};
      ek(k) = 1;
      const Real Hkn = ek * full_hess_n;
      RealVectorValue Hkn_ek = Hkn*ek;
      hess -= outer_product(Hkn_ek, normal);
      hess -= outer_product(normal, Hkn_ek);
      hess += 2*(Hkn_ek*normal) * n_n;
    }
  hess -= normal*(full_hess_n) * n_n;

  return hess;
}

} // anonymous namespace

#define SIDEFETEST                              \
  CPPUNIT_TEST( testU );                        \
  CPPUNIT_TEST( testGradU );                    \
  CPPUNIT_TEST( testGradUComp );                \
  CPPUNIT_TEST( testHessU );                    \
  CPPUNIT_TEST( testHessUComp );

template <Order order, FEFamily family, ElemType elem_type>
class FESideTest : public FETestBase<order, family, elem_type, 2> {

private:
  FEBase * _fe_side;
  QGauss * _qrule_side;

public:
  void setUp()
  {
    FETestBase<order,family,elem_type,2>::setUp();

    FEType fe_type = this->_sys->variable_type(0);
    _fe_side = FEBase::build(this->_dim, fe_type).release();

    _qrule_side = new QGauss(this->_dim-1, fe_type.default_quadrature_order());
    _fe_side->attach_quadrature_rule(this->_qrule_side);

    _fe_side->get_xyz();
    _fe_side->get_normals();
    _fe_side->get_phi();
    _fe_side->get_dphi();
    _fe_side->get_dphidx();
#if LIBMESH_DIM > 1
    _fe_side->get_dphidy();
#endif
#if LIBMESH_DIM > 2
    _fe_side->get_dphidz();
#endif

#if LIBMESH_ENABLE_SECOND_DERIVATIVES

    // Clough-Tocher elements still don't work multithreaded
    if (family == CLOUGH && libMesh::n_threads() > 1)
      return;

    // Szabab elements don't have second derivatives yet
    if (family == SZABAB)
      return;

    _fe_side->get_d2phi();
    _fe_side->get_d2phidx2();
#if LIBMESH_DIM > 1
    _fe_side->get_d2phidxdy();
    _fe_side->get_d2phidy2();
#endif
#if LIBMESH_DIM > 2
    _fe_side->get_d2phidxdz();
    _fe_side->get_d2phidydz();
    _fe_side->get_d2phidz2();
#endif

#endif
  }

  void tearDown()
  {
    delete _fe_side;
    delete _qrule_side;
    FETestBase<order,family,elem_type,2>::tearDown();
  }

  template <typename Functor>
  void testSideLoop(Functor f)
  {
    // Clough-Tocher elements still don't work multithreaded
    if (family == CLOUGH && libMesh::n_threads() > 1)
      return;

    for (auto e : this->_mesh->active_element_ptr_range())
      {
        this->_elem = e;

        this->_sys->get_dof_map().dof_indices(this->_elem, this->_dof_indices);

        for (unsigned int s=0; s != this->_elem->n_sides(); ++s)
          {
            _fe_side->reinit(this->_elem, s);

            f();
          }<commit_msg>Refactor mesh size in fe_side_test<commit_after>#include "fe_test.h" // For linear_test(), headers, FETestBase, etc

// Helper functions for restricting normal components
namespace {

RealTensor tangential_hessian (RealTensor hess,
                               const RealVectorValue normal)
{
  const RealVectorValue full_hess_n = hess*normal;

  const RealTensor n_n = outer_product(normal, normal);
  for (unsigned int k=0; k != 3; ++k)
    {
      RealVectorValue ek {0};
      ek(k) = 1;
      const Real Hkn = ek * full_hess_n;
      RealVectorValue Hkn_ek = Hkn*ek;
      hess -= outer_product(Hkn_ek, normal);
      hess -= outer_product(normal, Hkn_ek);
      hess += 2*(Hkn_ek*normal) * n_n;
    }
  hess -= normal*(full_hess_n) * n_n;

  return hess;
}

} // anonymous namespace

#define SIDEFETEST                              \
  CPPUNIT_TEST( testU );                        \
  CPPUNIT_TEST( testGradU );                    \
  CPPUNIT_TEST( testGradUComp );                \
  CPPUNIT_TEST( testHessU );                    \
  CPPUNIT_TEST( testHessUComp );

const unsigned int N_x=2;

template <Order order, FEFamily family, ElemType elem_type>
class FESideTest : public FETestBase<order, family, elem_type, N_x> {

private:
  FEBase * _fe_side;
  QGauss * _qrule_side;

public:
  void setUp()
  {
    FETestBase<order,family,elem_type,N_x>::setUp();

    FEType fe_type = this->_sys->variable_type(0);
    _fe_side = FEBase::build(this->_dim, fe_type).release();

    _qrule_side = new QGauss(this->_dim-1, fe_type.default_quadrature_order());
    _fe_side->attach_quadrature_rule(this->_qrule_side);

    _fe_side->get_xyz();
    _fe_side->get_normals();
    _fe_side->get_phi();
    _fe_side->get_dphi();
    _fe_side->get_dphidx();
#if LIBMESH_DIM > 1
    _fe_side->get_dphidy();
#endif
#if LIBMESH_DIM > 2
    _fe_side->get_dphidz();
#endif

#if LIBMESH_ENABLE_SECOND_DERIVATIVES

    // Clough-Tocher elements still don't work multithreaded
    if (family == CLOUGH && libMesh::n_threads() > 1)
      return;

    // Szabab elements don't have second derivatives yet
    if (family == SZABAB)
      return;

    _fe_side->get_d2phi();
    _fe_side->get_d2phidx2();
#if LIBMESH_DIM > 1
    _fe_side->get_d2phidxdy();
    _fe_side->get_d2phidy2();
#endif
#if LIBMESH_DIM > 2
    _fe_side->get_d2phidxdz();
    _fe_side->get_d2phidydz();
    _fe_side->get_d2phidz2();
#endif

#endif
  }

  void tearDown()
  {
    delete _fe_side;
    delete _qrule_side;
    FETestBase<order,family,elem_type,N_x>::tearDown();
  }

  template <typename Functor>
  void testSideLoop(Functor f)
  {
    // Clough-Tocher elements still don't work multithreaded
    if (family == CLOUGH && libMesh::n_threads() > 1)
      return;

    for (auto e : this->_mesh->active_element_ptr_range())
      {
        this->_elem = e;

        this->_sys->get_dof_map().dof_indices(this->_elem, this->_dof_indices);

        for (unsigned int s=0; s != this->_elem->n_sides(); ++s)
          {
            _fe_side->reinit(this->_elem, s);

            f();
          }
{'fraction_non_alphanumeric': 0.12471131639722864, 'fraction_numerical': 0.008578027053777632, 'mean_word_length': 2.8084170854271355, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4298028', 'n_tokens_mistral': 2306, 'n_tokens_neox': 2201, 'n_words': 430}