$extrastylesheet
fe_scalar.C
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 // Local includes
00021 #include "libmesh/dof_map.h"
00022 #include "libmesh/fe.h"
00023 #include "libmesh/elem.h"
00024 
00025 namespace libMesh
00026 {
00027 
00028 // ------------------------------------------------------------
00029 // SCALAR-specific implementations
00030 
00031 // Anonymous namespace for local helper functions
00032 namespace {
00033 
00034 void scalar_nodal_soln(const Elem* elem,
00035                        const Order order,
00036                        const std::vector<Number>& elem_soln,
00037                        std::vector<Number>&       nodal_soln)
00038 {
00039   const unsigned int n_nodes = elem->n_nodes();
00040   nodal_soln.resize(n_nodes);
00041 
00042   // If the SCALAR order is CONSTANT, just set the nodal values
00043   // to zero, otherwise, set to the value of the first SCALAR dof
00044   for(unsigned int i=0; i<n_nodes; i++)
00045     nodal_soln[i] = (order == CONSTANT) ? 0. : elem_soln[0];
00046 } // scalar_nodal_soln()
00047 
00048 } // anonymous namespace
00049 
00050 
00051 
00052 
00053   // Do full-specialization of nodal_soln() function for every
00054   // dimension, instead of explicit instantiation at the end of this
00055   // file.
00056   // This could be macro-ified so that it fits on one line...
00057 template <>
00058 void FE<0,SCALAR>::nodal_soln(const Elem* elem,
00059                               const Order order,
00060                               const std::vector<Number>& elem_soln,
00061                               std::vector<Number>& nodal_soln)
00062 { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }
00063 
00064 template <>
00065 void FE<1,SCALAR>::nodal_soln(const Elem* elem,
00066                               const Order order,
00067                               const std::vector<Number>& elem_soln,
00068                               std::vector<Number>& nodal_soln)
00069 { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }
00070 
00071 template <>
00072 void FE<2,SCALAR>::nodal_soln(const Elem* elem,
00073                               const Order order,
00074                               const std::vector<Number>& elem_soln,
00075                               std::vector<Number>& nodal_soln)
00076 { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }
00077 
00078 template <>
00079 void FE<3,SCALAR>::nodal_soln(const Elem* elem,
00080                               const Order order,
00081                               const std::vector<Number>& elem_soln,
00082                               std::vector<Number>& nodal_soln)
00083 { scalar_nodal_soln(elem, order, elem_soln, nodal_soln); }
00084 
00085 // Full specialization of n_dofs() function for every dimension
00086 // The Order indicates the number of SCALAR dofs
00087 template <> unsigned int FE<0,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
00088 template <> unsigned int FE<1,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
00089 template <> unsigned int FE<2,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
00090 template <> unsigned int FE<3,SCALAR>::n_dofs(const ElemType, const Order o) { return o; }
00091 
00092 // Full specialization of n_dofs_at_node() function for every dimension.
00093 // SCALARs have no dofs at nodes
00094 template <> unsigned int FE<0,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
00095 template <> unsigned int FE<1,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
00096 template <> unsigned int FE<2,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
00097 template <> unsigned int FE<3,SCALAR>::n_dofs_at_node(const ElemType, const Order, const unsigned int) { return 0; }
00098 
00099 // Full specialization of n_dofs_per_elem() function for every dimension.
00100 // SCALARs have no dofs per element
00101 template <> unsigned int FE<0,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
00102 template <> unsigned int FE<1,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
00103 template <> unsigned int FE<2,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
00104 template <> unsigned int FE<3,SCALAR>::n_dofs_per_elem(const ElemType, const Order) { return 0; }
00105 
00106 // Scalar FEMs are discontinuous
00107 template <> FEContinuity FE<0,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
00108 template <> FEContinuity FE<1,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
00109 template <> FEContinuity FE<2,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
00110 template <> FEContinuity FE<3,SCALAR>::get_continuity() const { return DISCONTINUOUS; }
00111 
00112 // Scalar FEMs are not hierarchic
00113 template <> bool FE<0,SCALAR>::is_hierarchic() const { return false; }
00114 template <> bool FE<1,SCALAR>::is_hierarchic() const { return false; }
00115 template <> bool FE<2,SCALAR>::is_hierarchic() const { return false; }
00116 template <> bool FE<3,SCALAR>::is_hierarchic() const { return false; }
00117 
00118 
00119 #ifdef LIBMESH_ENABLE_AMR
00120 // compute_constraints() just returns for SCALAR FEMs
00121 template <>
00122 void FE<2,SCALAR>::compute_constraints (DofConstraints&,
00123                                         DofMap&,
00124                                         const unsigned int,
00125                                         const Elem*)
00126 { }
00127 
00128 template <>
00129 void FE<3,SCALAR>::compute_constraints (DofConstraints&,
00130                                         DofMap&,
00131                                         const unsigned int,
00132                                         const Elem*)
00133 { }
00134 #endif // #ifdef LIBMESH_ENABLE_AMR
00135 
00136 // Scalar FEM shapes do not need reinit
00137 template <> bool FE<0,SCALAR>::shapes_need_reinit() const { return false; }
00138 template <> bool FE<1,SCALAR>::shapes_need_reinit() const { return false; }
00139 template <> bool FE<2,SCALAR>::shapes_need_reinit() const { return false; }
00140 template <> bool FE<3,SCALAR>::shapes_need_reinit() const { return false; }
00141 
00142 } // namespace libMesh