📄 fe_hierarchic.c
字号:
// $Id: fe_hierarchic.C 2789 2008-04-13 02:24:40Z roystgnr $// The libMesh Finite Element Library.// Copyright (C) 2002-2007 Benjamin S. Kirk, John W. Peterson // 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 "elem.h"#include "fe.h"#include "fe_macro.h"// ------------------------------------------------------------// Hierarchic-specific implementationstemplate <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(); const ElemType type = elem->type(); nodal_soln.resize(n_nodes); const Order totalorder = static_cast<Order>(order + elem->p_level()); switch (totalorder) { // Constant shape functions case CONSTANT: { libmesh_assert (elem_soln.size() == 1); const Number val = elem_soln[0]; for (unsigned int n=0; n<n_nodes; n++) nodal_soln[n] = val; return; } // For other bases do interpolation at the nodes // explicitly. default: { const unsigned int n_sf = FE<Dim,T>::n_shape_functions(type, totalorder); for (unsigned int n=0; n<n_nodes; n++) { const Point mapped_point = FE<Dim,T>::inverse_map(elem, elem->point(n)); libmesh_assert (elem_soln.size() == n_sf); // Zero before summation nodal_soln[n] = 0; // u_i = Sum (alpha_i phi_i) for (unsigned int i=0; i<n_sf; i++) nodal_soln[n] += elem_soln[i]*FE<Dim,T>::shape(elem, order, i, mapped_point); } return; } }}template <unsigned int Dim, FEFamily T>unsigned int FE<Dim,T>::n_dofs(const ElemType t, const Order o){ libmesh_assert (o > 0); switch (t) { case EDGE2: case EDGE3: return (o+1); case QUAD4: libmesh_assert(o < 2); case QUAD8: case QUAD9: return ((o+1)*(o+1)); case HEX8: libmesh_assert(o < 2); case HEX20: libmesh_assert(o < 2); case HEX27: return ((o+1)*(o+1)*(o+1)); case TRI6: return ((o+1)*(o+2)/2); default: libmesh_error(); } libmesh_error(); return 0;}template <unsigned int Dim, FEFamily T>unsigned int FE<Dim,T>::n_dofs_at_node(const ElemType t, const Order o, const unsigned int n){ libmesh_assert (o > 0); switch (t) { case EDGE2: case EDGE3: switch (n) { case 0: case 1: return 1; // Internal DoFs are associated with the elem, not its nodes case 2: return 0; default: libmesh_error(); } case TRI6: switch (n) { case 0: case 1: case 2: return 1; case 3: case 4: case 5: return (o-1); // Internal DoFs are associated with the elem, not its nodes default: libmesh_error(); } case QUAD4: libmesh_assert (n < 4); libmesh_assert (o < 2); case QUAD8: case QUAD9: switch (n) { case 0: case 1: case 2: case 3: return 1; case 4: case 5: case 6: case 7: return (o-1); // Internal DoFs are associated with the elem, not its nodes case 8: return 0; default: libmesh_error(); } case HEX8: libmesh_assert (n < 8); libmesh_assert (o < 2); case HEX20: libmesh_assert (n < 20); libmesh_assert (o < 2); case HEX27: switch (n) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: return 1; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: return (o-1); case 20: case 21: case 22: case 23: case 24: case 25: return ((o-1)*(o-1)); // Internal DoFs are associated with the elem, not its nodes case 26: return 0; default: libmesh_error(); } default:#ifdef DEBUG std::cerr << "ERROR: Bad ElemType = " << t << std::endl;#endif libmesh_error(); } libmesh_error(); return 0;}template <unsigned int Dim, FEFamily T>unsigned int FE<Dim,T>::n_dofs_per_elem(const ElemType t, const Order o){ libmesh_assert (o > 0); switch (t) { case EDGE2: case EDGE3: return (o-1); case TRI3: case QUAD4: return 0; case TRI6: return ((o-1)*(o-2)/2); case QUAD8: case QUAD9: return ((o-1)*(o-1)); case HEX8: case HEX20: libmesh_assert(o < 2); return 0; case HEX27: return ((o-1)*(o-1)*(o-1)); default:#ifdef DEBUG std::cerr << "ERROR: Bad ElemType = " << t << std::endl;#endif libmesh_error(); } // Will never get here... libmesh_error(); return 0;}template <unsigned int Dim, FEFamily T>FEContinuity FE<Dim,T>::get_continuity() const{ return C_ZERO;}template <unsigned int Dim, FEFamily T>bool FE<Dim,T>::is_hierarchic() const{ return true;}#ifdef ENABLE_AMRtemplate <unsigned int Dim, FEFamily T>void FE<Dim,T>::compute_constraints (DofConstraints &constraints, DofMap &dof_map, const unsigned int variable_number, const Elem* elem){ compute_proj_constraints(constraints, dof_map, variable_number, elem);}#endif // #ifdef ENABLE_AMRtemplate <unsigned int Dim, FEFamily T>bool FE<Dim,T>::shapes_need_reinit() const{ return true;}//--------------------------------------------------------------// Explicit instantiation of member functionsINSTANTIATE_MBRF(1,HIERARCHIC);INSTANTIATE_MBRF(2,HIERARCHIC);INSTANTIATE_MBRF(3,HIERARCHIC);#ifdef ENABLE_AMRtemplate void FE<2,HIERARCHIC>::compute_constraints(DofConstraints&, DofMap&, const unsigned int, const Elem*);template void FE<3,HIERARCHIC>::compute_constraints(DofConstraints&, DofMap&, const unsigned int, const Elem*);#endif // #ifdef ENABLE_AMR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -