<commit_before>// $Id$

// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 <NAME>, <NAME>, <NAME>
  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
  
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



// Local includes
#include "dof_map.h"
#include "fe.h"
#include "fe_macro.h"
#include "elem.h"

namespace libMesh
{




// ------------------------------------------------------------
// SCALAR-specific implementations

template <unsigned int Dim, FEFamily T>
void FE<Dim,T>::nodal_soln(const Elem* elem,
			   const Order order,
			   const std::vector<Number>& elem_soln,
			   std::vector<Number>&       nodal_soln)
{
  const unsigned int n_nodes = elem->n_nodes();
  nodal_soln.resize(n_nodes);

  // If the SCALAR order is CONSTANT, just set the nodal values
  // to zero, otherwise, set to the value of the first SCALAR dof
  for(unsigned int i=0; i<n_nodes; i++)
  {
    nodal_soln[i] = (order == CONSTANT) ? 0. : elem_soln[0];
  }
}

template <unsigned int Dim, FEFamily T>
unsigned int FE<Dim,T>::n_dofs(const ElemType, const Order o)
{
  // The Order indicates the number of SCALAR dofs
  return o;
}

template <unsigned int Dim, FEFamily T>
unsigned int FE<Dim,T>::n_dofs_at_node(const ElemType,
				       const Order,
				       const unsigned int)
{
  // SCALARs have no dofs at nodes

  return 0;
}

template <unsigned int Dim, FEFamily T>
unsigned int FE<Dim,T>::n_dofs_per_elem(const ElemType,
					const Order)
{
  // SCALARs have no dofs per element

  return 0;
}

template <unsigned int Dim, FEFamily T>
FEContinuity FE<Dim,T>::get_continuity() const
{
  // This ensures that SCALARs are not constrained
  // by periodic boundary conditions (they are
  // necessarily periodic already)
  return DISCONTINUOUS;
}



template <unsigned int Dim, FEFamily T>
bool FE<Dim,T>::is_hierarchic() const
{
  return false;
}

#ifdef LIBMESH_ENABLE_AMR
template <unsigned int Dim, FEFamily T>
void FE<Dim,T>::compute_constraints (DofConstraints &constraints,
				     DofMap &dof_map,
				     const unsigned int variable_number,
				     const Elem* elem)
{
  return;
}
#endif // #ifdef LIBMESH_ENABLE_AMR

template <unsigned int Dim, FEFamily T>
bool FE<Dim,T>::shapes_need_reinit() const
{
  return false;
}

//--------------------------------------------------------------
// Explicit instantiation of member functions
INSTANTIATE_MBRF(0,SCALAR);
INSTANTIATE_MBRF(1,SCALAR);
INSTANTIATE_MBRF(2,SCALAR);
INSTANTIATE_MBRF(3,SCALAR);

} // namespace libMesh<commit_msg>Refactoring fe_scalar.C functions to use specialization instead of instantiation.<commit_after>// $Id$

// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 <NAME>, <NAME>, <NAME>

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



// Local includes
#include "dof_map.h"
#include "fe.h"
#include "fe_macro.h"
#include "elem.h"

namespace libMesh
{

  // ------------------------------------------------------------
  // SCALAR-specific implementations

  // Anonymous namespace for local helper functions
  namespace {

    void scalar_nodal_soln(const Elem* elem,
			   const Order order,
			   const std::vector<Number>& elem_soln,
			   std::vector<Number>&       nodal_soln)
    {
      const unsigned int n_nodes = elem->n_nodes();
      nodal_soln.resize(n_nodes);

      // If the SCALAR order is CONSTANT, just set the nodal values
      // to zero, otherwise, set to the value of the first SCALAR dof
      for(unsigned int i=0; i<n_nodes; i++)
	nodal_soln[i] = (order == CONSTANT) ? 0. : elem_soln[0];
    } // scalar_nodal_soln()

  } // anonymous namespace




  // Do full-specialization of nodal_soln() function for every
  // dimension, instead of explicit instantiation at the end of this
  // file.
  // This could be macro-ified so that it fits on one line...
  template <>
  void FE<0,SCALAR>::nodal_soln(const Elem* elem,
				const Order order,
				const std::vector<Number>& elem_soln,
				std::vector<Number>& nodal_soln)
  { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }

  template <>
  void FE<1,SCALAR>::nodal_soln(const Elem* elem,
				const Order order,
				const std::vector<Number>& elem_soln,
				std::vector<Number>& nodal_soln)
  { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }

  template <>
  void FE<2,SCALAR>::nodal_soln(const Elem* elem,
				const Order order,
				const std::vector<Number>& elem_soln,
				std::vector<Number>& nodal_soln)
  { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }

  template <>
  void FE<3,SCALAR>::nodal_soln(const Elem* elem,
				const Order order,
				const std::vector<Number>& elem_soln,
				std::vector<Number>& nodal_soln)
  { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }

  // Full specialization of n_dofs() function for every dimension
  // The Order indicates the number of SCALAR dofs
  template <> unsigned int FE<0,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
  template <> unsigned int FE<1,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
  template <> unsigned int FE<2,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
  template <> unsigned int FE<3,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }

  // Full specialization of n_dofs_at_node() function for every dimension.
  // SCALARs have no dofs at nodes
  template <> unsigned int FE<0,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
  template <> unsigned int FE<1,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
  template <> unsigned int FE<2,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
  template <> unsigned int FE<3,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }

  // Full specialization of n_dofs_per_elem() function for every dimension.
  // SCALARs have no dofs per element
  template <> unsigned int FE<0,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
  template <> unsigned int FE<1,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
  template <> unsigned int FE<2,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
  template <> unsigned int FE<3,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }

  // Scalar FEMs are discontinuous
  template <> FEContinuity FE<0,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
  template <> FEContinuity FE<1,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
  template <> FEContinuity FE<2,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
  template <> FEContinuity FE<3,SCALAR>::get_continuity() const { return DISCONTINUOUS; }

  // Scalar FEMs are not hierarchic
  template <> bool FE<0,SCALAR>::is_hierarchic() const { return false; }
  template <> bool FE<1,SCALAR>::is_hierarchic() const { return false; }
  template <> bool FE<2,SCALAR>::is_hierarchic() const { return false; }
  template <> bool FE<3,SCALAR>::is_hierarchic() const { return false; }


#ifdef LIBMESH_ENABLE_AMR
  // compute_constraints() just returns for SCALAR FEMs
  template <>
  void FE<2,SCALAR>::compute_constraints (DofConstraints&,
					  DofMap&,
					  const unsigned int,
					  const Elem*)
  { }

  template <>
  void FE<3,SCALAR>::compute_constraints (DofConstraints&,
					  DofMap&,
					  const unsigned int,
					  const Elem*)
  { }
#endif // #ifdef LIBMESH_ENABLE_AMR

  // Scalar FEM shapes do not need reinit
  template <> bool FE<0,SCALAR>::shapes_need_reinit() const { return false; }
  template <> bool FE<1,SCALAR>::shapes_need_reinit() const { return false; }
  template <> bool FE<2,SCALAR>::shapes_need_reinit() const { return false; }
  template <> bool FE<3,SCALAR>::shapes_need_reinit() const { return false; }

} // namespace libMesh
{'fraction_non_alphanumeric': 0.12676828599627152, 'fraction_numerical': 0.010746792411448623, 'mean_word_length': 3.6270928462709286, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, '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': '5067260', 'n_tokens_mistral': 3163, 'n_tokens_neox': 2916, 'n_words': 948}