fe_base.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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 #ifndef LIBMESH_FE_BASE_H 00021 #define LIBMESH_FE_BASE_H 00022 00023 // Local includes 00024 #include "libmesh/reference_counted_object.h" 00025 #include "libmesh/fe_abstract.h" 00026 #include "libmesh/point.h" 00027 #include "libmesh/vector_value.h" 00028 #include "libmesh/enum_elem_type.h" 00029 #include "libmesh/fe_type.h" 00030 #include "libmesh/auto_ptr.h" 00031 #include "libmesh/fe_transformation_base.h" 00032 #include "libmesh/tensor_tools.h" 00033 #include "libmesh/type_n_tensor.h" 00034 00035 // C++ includes 00036 #include <cstddef> 00037 #include <vector> 00038 00039 00040 namespace libMesh 00041 { 00042 00043 00044 // forward declarations 00045 template <typename T> class DenseMatrix; 00046 template <typename T> class DenseVector; 00047 class BoundaryInfo; 00048 class DofConstraints; 00049 class DofMap; 00050 class Elem; 00051 class MeshBase; 00052 template <typename T> class NumericVector; 00053 class QBase; 00054 template <typename T> class FETransformationBase; 00055 00056 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS 00057 class NodeConstraints; 00058 #endif 00059 00060 #ifdef LIBMESH_ENABLE_PERIODIC 00061 class PeriodicBoundaries; 00062 class PointLocatorBase; 00063 #endif 00064 00065 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00066 template <unsigned int Dim, FEFamily T_radial, InfMapType T_map> 00067 class InfFE; 00068 #endif 00069 00070 // TypesEqual takes two types as parameters. 00071 // If they are the exact same type, then TypesEqual::value is the boolean true, 00072 // otherwise TypesEqual::value is the boolean false. 00073 // FIXME: Need to put this in a common place 00074 template <typename T1, typename T2> 00075 struct TypesEqual { 00076 static const bool value = false; 00077 }; 00078 00079 template <typename T> 00080 struct TypesEqual<T,T> { 00081 static const bool value = true; 00082 }; 00083 00111 // ------------------------------------------------------------ 00112 // FEBase class definition 00113 template <typename OutputType> 00114 class FEGenericBase : public FEAbstract 00115 { 00116 protected: 00117 00123 FEGenericBase (const unsigned int dim, 00124 const FEType& fet); 00125 00126 public: 00127 00131 virtual ~FEGenericBase(); 00132 00141 static AutoPtr<FEGenericBase> build (const unsigned int dim, 00142 const FEType& type); 00143 00148 typedef OutputType OutputShape; 00149 typedef typename TensorTools::IncrementRank<OutputShape>::type OutputGradient; 00150 typedef typename TensorTools::IncrementRank<OutputGradient>::type OutputTensor; 00151 typedef typename TensorTools::DecrementRank<OutputShape>::type OutputDivergence; 00152 typedef typename TensorTools::MakeNumber<OutputShape>::type OutputNumber; 00153 typedef typename TensorTools::IncrementRank<OutputNumber>::type OutputNumberGradient; 00154 typedef typename TensorTools::IncrementRank<OutputNumberGradient>::type OutputNumberTensor; 00155 typedef typename TensorTools::DecrementRank<OutputNumber>::type OutputNumberDivergence; 00156 00157 00158 00159 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00160 00169 static AutoPtr<FEGenericBase> build_InfFE (const unsigned int dim, 00170 const FEType& type); 00171 00172 #endif 00173 00174 #ifdef LIBMESH_ENABLE_AMR 00175 00182 static void compute_proj_constraints (DofConstraints &constraints, 00183 DofMap &dof_map, 00184 const unsigned int variable_number, 00185 const Elem* elem); 00186 00192 static void coarsened_dof_values(const NumericVector<Number> &global_vector, 00193 const DofMap &dof_map, 00194 const Elem *coarse_elem, 00195 DenseVector<Number> &coarse_dofs, 00196 const unsigned int var, 00197 const bool use_old_dof_indices = false); 00198 00199 #endif // #ifdef LIBMESH_ENABLE_AMR 00200 00201 #ifdef LIBMESH_ENABLE_PERIODIC 00202 00208 static void compute_periodic_constraints (DofConstraints &constraints, 00209 DofMap &dof_map, 00210 const PeriodicBoundaries &boundaries, 00211 const MeshBase& mesh, 00212 const PointLocatorBase* point_locator, 00213 const unsigned int variable_number, 00214 const Elem* elem); 00215 00216 #endif // LIBMESH_ENABLE_PERIODIC 00217 00222 const std::vector<std::vector<OutputShape> >& get_phi() const 00223 { libmesh_assert(!calculations_started || calculate_phi); 00224 calculate_phi = true; return phi; } 00225 00230 const std::vector<std::vector<OutputGradient> >& get_dphi() const 00231 { libmesh_assert(!calculations_started || calculate_dphi); 00232 calculate_dphi = calculate_dphiref = true; return dphi; } 00233 00238 const std::vector<std::vector<OutputShape> >& get_curl_phi() const 00239 { libmesh_assert(!calculations_started || calculate_curl_phi); 00240 calculate_curl_phi = calculate_dphiref = true; return curl_phi; } 00241 00246 const std::vector<std::vector<OutputDivergence> >& get_div_phi() const 00247 { libmesh_assert(!calculations_started || calculate_div_phi); 00248 calculate_div_phi = calculate_dphiref = true; return div_phi; } 00249 00254 const std::vector<std::vector<OutputShape> >& get_dphidx() const 00255 { libmesh_assert(!calculations_started || calculate_dphi); 00256 calculate_dphi = calculate_dphiref = true; return dphidx; } 00257 00262 const std::vector<std::vector<OutputShape> >& get_dphidy() const 00263 { libmesh_assert(!calculations_started || calculate_dphi); 00264 calculate_dphi = calculate_dphiref = true; return dphidy; } 00265 00270 const std::vector<std::vector<OutputShape> >& get_dphidz() const 00271 { libmesh_assert(!calculations_started || calculate_dphi); 00272 calculate_dphi = calculate_dphiref = true; return dphidz; } 00273 00278 const std::vector<std::vector<OutputShape> >& get_dphidxi() const 00279 { libmesh_assert(!calculations_started || calculate_dphiref); 00280 calculate_dphiref = true; return dphidxi; } 00281 00286 const std::vector<std::vector<OutputShape> >& get_dphideta() const 00287 { libmesh_assert(!calculations_started || calculate_dphiref); 00288 calculate_dphiref = true; return dphideta; } 00289 00294 const std::vector<std::vector<OutputShape> >& get_dphidzeta() const 00295 { libmesh_assert(!calculations_started || calculate_dphiref); 00296 calculate_dphiref = true; return dphidzeta; } 00297 00298 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 00299 00304 const std::vector<std::vector<OutputTensor> >& get_d2phi() const 00305 { libmesh_assert(!calculations_started || calculate_d2phi); 00306 calculate_d2phi = calculate_dphiref = true; return d2phi; } 00307 00312 const std::vector<std::vector<OutputShape> >& get_d2phidx2() const 00313 { libmesh_assert(!calculations_started || calculate_d2phi); 00314 calculate_d2phi = calculate_dphiref = true; return d2phidx2; } 00315 00320 const std::vector<std::vector<OutputShape> >& get_d2phidxdy() const 00321 { libmesh_assert(!calculations_started || calculate_d2phi); 00322 calculate_d2phi = calculate_dphiref = true; return d2phidxdy; } 00323 00328 const std::vector<std::vector<OutputShape> >& get_d2phidxdz() const 00329 { libmesh_assert(!calculations_started || calculate_d2phi); 00330 calculate_d2phi = calculate_dphiref = true; return d2phidxdz; } 00331 00336 const std::vector<std::vector<OutputShape> >& get_d2phidy2() const 00337 { libmesh_assert(!calculations_started || calculate_d2phi); 00338 calculate_d2phi = calculate_dphiref = true; return d2phidy2; } 00339 00344 const std::vector<std::vector<OutputShape> >& get_d2phidydz() const 00345 { libmesh_assert(!calculations_started || calculate_d2phi); 00346 calculate_d2phi = calculate_dphiref = true; return d2phidydz; } 00347 00352 const std::vector<std::vector<OutputShape> >& get_d2phidz2() const 00353 { libmesh_assert(!calculations_started || calculate_d2phi); 00354 calculate_d2phi = calculate_dphiref = true; return d2phidz2; } 00355 00360 const std::vector<std::vector<OutputShape> >& get_d2phidxi2() const 00361 { libmesh_assert(!calculations_started || calculate_d2phi); 00362 calculate_d2phi = calculate_dphiref = true; return d2phidxi2; } 00363 00368 const std::vector<std::vector<OutputShape> >& get_d2phidxideta() const 00369 { libmesh_assert(!calculations_started || calculate_d2phi); 00370 calculate_d2phi = calculate_dphiref = true; return d2phidxideta; } 00371 00376 const std::vector<std::vector<OutputShape> >& get_d2phidxidzeta() const 00377 { libmesh_assert(!calculations_started || calculate_d2phi); 00378 calculate_d2phi = calculate_dphiref = true; return d2phidxidzeta; } 00379 00384 const std::vector<std::vector<OutputShape> >& get_d2phideta2() const 00385 { libmesh_assert(!calculations_started || calculate_d2phi); 00386 calculate_d2phi = calculate_dphiref = true; return d2phideta2; } 00387 00392 const std::vector<std::vector<OutputShape> >& get_d2phidetadzeta() const 00393 { libmesh_assert(!calculations_started || calculate_d2phi); 00394 calculate_d2phi = calculate_dphiref = true; return d2phidetadzeta; } 00395 00400 const std::vector<std::vector<OutputShape> >& get_d2phidzeta2() const 00401 { libmesh_assert(!calculations_started || calculate_d2phi); 00402 calculate_d2phi = calculate_dphiref = true; return d2phidzeta2; } 00403 00404 #endif //LIBMESH_ENABLE_SECOND_DERIVATIVES 00405 00406 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00407 00418 const std::vector<OutputGradient>& get_dphase() const 00419 { return dphase; } 00420 00421 00434 const std::vector<Real>& get_Sobolev_weight() const 00435 { return weight; } 00436 00442 const std::vector<RealGradient>& get_Sobolev_dweight() const 00443 { return dweight; } 00444 00445 #endif 00446 00447 00451 void print_phi(std::ostream& os) const; 00452 00457 void print_dphi(std::ostream& os) const; 00458 00459 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 00460 00465 void print_d2phi(std::ostream& os) const; 00466 00467 #endif 00468 00469 00470 protected: 00471 00472 00473 00474 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00475 00481 virtual void init_base_shape_functions(const std::vector<Point>& qp, 00482 const Elem* e) = 0; 00483 00484 #endif 00485 00496 virtual void compute_shape_functions(const Elem* elem, const std::vector<Point>& qp); 00497 00502 AutoPtr<FETransformationBase<OutputType> > _fe_trans; 00503 00507 std::vector<std::vector<OutputShape> > phi; 00508 00512 std::vector<std::vector<OutputGradient> > dphi; 00513 00517 std::vector<std::vector<OutputShape> > curl_phi; 00518 00522 std::vector<std::vector<OutputDivergence> > div_phi; 00523 00527 std::vector<std::vector<OutputShape> > dphidxi; 00528 00532 std::vector<std::vector<OutputShape> > dphideta; 00533 00537 std::vector<std::vector<OutputShape> > dphidzeta; 00538 00542 std::vector<std::vector<OutputShape> > dphidx; 00543 00547 std::vector<std::vector<OutputShape> > dphidy; 00548 00552 std::vector<std::vector<OutputShape> > dphidz; 00553 00554 00555 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 00556 00560 std::vector<std::vector<OutputTensor> > d2phi; 00561 00565 std::vector<std::vector<OutputShape> > d2phidxi2; 00566 00570 std::vector<std::vector<OutputShape> > d2phidxideta; 00571 00575 std::vector<std::vector<OutputShape> > d2phidxidzeta; 00576 00580 std::vector<std::vector<OutputShape> > d2phideta2; 00581 00585 std::vector<std::vector<OutputShape> > d2phidetadzeta; 00586 00590 std::vector<std::vector<OutputShape> > d2phidzeta2; 00591 00595 std::vector<std::vector<OutputShape> > d2phidx2; 00596 00600 std::vector<std::vector<OutputShape> > d2phidxdy; 00601 00605 std::vector<std::vector<OutputShape> > d2phidxdz; 00606 00610 std::vector<std::vector<OutputShape> > d2phidy2; 00611 00615 std::vector<std::vector<OutputShape> > d2phidydz; 00616 00620 std::vector<std::vector<OutputShape> > d2phidz2; 00621 00622 #endif 00623 00624 00625 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00626 00627 //-------------------------------------------------------------- 00628 /* protected members for infinite elements, which are accessed 00629 * from the outside through some inline functions 00630 */ 00631 00632 00638 std::vector<OutputGradient> dphase; 00639 00645 std::vector<RealGradient> dweight; 00646 00652 std::vector<Real> weight; 00653 00654 #endif 00655 00656 private: 00657 00658 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00659 00665 template <unsigned int friend_Dim, FEFamily friend_T_radial, InfMapType friend_T_map> 00666 friend class InfFE; 00667 00668 #endif 00669 00670 00671 }; 00672 00673 00674 // Typedefs for convenience and backwards compatibility 00675 typedef FEGenericBase<Real> FEBase; 00676 typedef FEGenericBase<RealGradient> FEVectorBase; 00677 00678 00679 00680 00681 // ------------------------------------------------------------ 00682 // FEGenericBase class inline members 00683 template <typename OutputType> 00684 inline 00685 FEGenericBase<OutputType>::FEGenericBase(const unsigned int d, 00686 const FEType& fet) : 00687 FEAbstract(d,fet), 00688 _fe_trans( FETransformationBase<OutputType>::build(fet) ), 00689 phi(), 00690 dphi(), 00691 curl_phi(), 00692 div_phi(), 00693 dphidxi(), 00694 dphideta(), 00695 dphidzeta(), 00696 dphidx(), 00697 dphidy(), 00698 dphidz() 00699 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 00700 ,d2phi(), 00701 d2phidxi2(), 00702 d2phidxideta(), 00703 d2phidxidzeta(), 00704 d2phideta2(), 00705 d2phidetadzeta(), 00706 d2phidzeta2(), 00707 d2phidx2(), 00708 d2phidxdy(), 00709 d2phidxdz(), 00710 d2phidy2(), 00711 d2phidydz(), 00712 d2phidz2() 00713 #endif 00714 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS 00715 ,dphase(), 00716 dweight(), 00717 weight() 00718 #endif 00719 { 00720 } 00721 00722 00723 00724 template <typename OutputType> 00725 inline 00726 FEGenericBase<OutputType>::~FEGenericBase() 00727 { 00728 } 00729 00730 } // namespace libMesh 00731 00732 #endif // LIBMESH_FE_BASE_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:46 UTC
Hosted By: