Intrepid
http://trilinos.sandia.gov/packages/docs/r10.12/packages/intrepid/src/Shared/Intrepid_PointTools.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ************************************************************************
00003 //
00004 //                           Intrepid Package
00005 //                 Copyright (2007) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Pavel Bochev  (pbboche@sandia.gov)
00038 //                    Denis Ridzal  (dridzal@sandia.gov), or
00039 //                    Kara Peterson (kjpeter@sandia.gov)
00040 //
00041 // ************************************************************************
00042 // @HEADER
00043 
00051 #ifndef INTREPID_POINTTOOLS_HPP
00052 #define INTREPID_POINTTOOLS_HPP
00053 
00054 #include "Shards_CellTopology.hpp"
00055 #include "Teuchos_Assert.hpp"
00056 #include "Intrepid_Polylib.hpp"
00057 #include "Intrepid_FieldContainer.hpp"
00058 #include "Intrepid_CellTools.hpp"
00059 #include <stdexcept>
00060 
00061 namespace Intrepid {
00062   
00195   class PointTools {
00196   public:
00214    static inline int getLatticeSize( const shards::CellTopology& cellType ,
00215                                      const int order ,
00216                                      const int offset = 0 )
00217     {
00218       switch( cellType.getKey() ) {
00219       case shards::Tetrahedron<4>::key:
00220       case shards::Tetrahedron<8>::key:
00221       case shards::Tetrahedron<10>::key:
00222         {
00223           const int effectiveOrder = order - 4 * offset;
00224           if (effectiveOrder < 0) return 0;
00225           else return (effectiveOrder+1)*(effectiveOrder+2)*(effectiveOrder+3)/6;
00226         }
00227         break;
00228       case shards::Triangle<3>::key:
00229       case shards::Triangle<4>::key:
00230       case shards::Triangle<6>::key: 
00231         {
00232           const int effectiveOrder = order - 3 * offset;
00233           if (effectiveOrder < 0) return 0;
00234           else return (effectiveOrder+1)*(effectiveOrder+2)/2;
00235         }
00236         break;
00237       case shards::Line<2>::key:
00238       case shards::Line<3>::key:
00239         {
00240           const int effectiveOrder = order - 2 * offset;
00241           if (effectiveOrder < 0) return 0;
00242           else return (effectiveOrder+1);
00243         }
00244         break;
00245       default:
00246         TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
00247                             ">>> ERROR (Intrepid::PointTools::getLatticeSize): Illegal cell type" );
00248       }
00249     }
00250 
00251 
00268     template<class Scalar, class ArrayType>
00269     static void getLattice( ArrayType &pts ,
00270                             const shards::CellTopology& cellType ,
00271                             const int order ,
00272                             const int offset = 0 ,
00273                             const EPointType pointType = POINTTYPE_EQUISPACED );
00274 
00281     template<class Scalar, class ArrayType>
00282     static void getGaussPoints( ArrayType &pts ,
00283                                 const int order );
00284 
00285 
00286   private:
00302     template<class Scalar, class ArrayTypeOut, class ArrayTypeIn1, class ArrayTypeIn2>
00303     static void cartToBaryTriangle( ArrayTypeOut & baryValues ,
00304                                     const ArrayTypeIn1 & cartValues ,
00305                                     const ArrayTypeIn2 & vertices );
00306 
00307 
00324     template<class Scalar, class ArrayTypeOut, class ArrayTypeIn1, class ArrayTypeIn2>
00325     static void baryToCartTriangle( ArrayTypeOut & cartValues ,
00326                                     const ArrayTypeIn1 & baryValues ,
00327                                     const ArrayTypeIn2 & vertices );
00328 
00329 
00346     template<class Scalar, class ArrayTypeOut, class ArrayTypeIn1, class ArrayTypeIn2>
00347     static void cartToBaryTetrahedron( ArrayTypeOut & baryValues ,
00348                                       const ArrayTypeIn1 & cartValues ,
00349                                       const ArrayTypeIn2 & vertices );
00350 
00367     template<class Scalar, class ArrayTypeOut, class ArrayTypeIn1, class ArrayTypeIn2>
00368     static void baryToCartTetrahedron( ArrayTypeOut & cartValues ,
00369                                       const ArrayTypeIn1 & baryValues ,
00370                                       const ArrayTypeIn2 & vertices );
00371 
00372 
00388   template<class Scalar, class ArrayType>
00389   static void getEquispacedLattice( const shards::CellTopology& cellType ,
00390                                     ArrayType &points ,
00391                                     const int order ,
00392                                     const int offset = 0 );
00393 
00394 
00410     template<class Scalar, class ArrayType>
00411     static void getWarpBlendLattice( const shards::CellTopology& cellType ,
00412                                     ArrayType &points ,
00413                                     const int order ,
00414                                     const int offset = 0);
00415     
00416 
00431     template<class Scalar, class ArrayType>
00432     static void getEquispacedLatticeLine( ArrayType &points ,
00433                                           const int order ,
00434                                           const int offset = 0 );
00435 
00450     template<class Scalar, class ArrayType>
00451     static void getEquispacedLatticeTriangle( ArrayType &points ,
00452                                               const int order ,
00453                                               const int offset = 0 );
00454 
00469     template<class Scalar, class ArrayType>
00470     static void getEquispacedLatticeTetrahedron( ArrayType &points ,
00471                                                 const int order ,
00472                                                 const int offset = 0 );
00473 
00488     template<class Scalar, class ArrayType>
00489     static void getWarpBlendLatticeLine( ArrayType &points ,
00490                                         const int order ,
00491                                         const int offset = 0 );
00492 
00499     template<class Scalar, class ArrayType>
00500     static void warpFactor( const int order ,
00501                             const ArrayType &xnodes ,
00502                             const ArrayType &xout ,
00503                             ArrayType &warp );
00504 
00519     template<class Scalar, class ArrayType>
00520     static void getWarpBlendLatticeTriangle(ArrayType &points ,
00521                                             const int order ,
00522                                             const int offset = 0 );
00523 
00537     template<class Scalar, class ArrayType>
00538     static void getWarpBlendLatticeTetrahedron( ArrayType &points ,
00539                                                 const int order ,
00540                                                 const int offset = 0 );
00541 
00542 
00553   template<class Scalar, class ArrayType>
00554   static void warpShiftFace3D( const int order ,
00555                         const Scalar pval ,
00556                         const ArrayType &L1,
00557                         const ArrayType &L2,
00558                         const ArrayType &L3,
00559                         const ArrayType &L4,
00560                         ArrayType &dxy);
00561 
00571   template<class Scalar, class ArrayType>
00572   static void evalshift( const int order ,
00573                   const Scalar pval ,
00574                   const ArrayType &L1 ,
00575                   const ArrayType &L2 ,
00576                   const ArrayType &L3 ,
00577                   ArrayType &dxy );
00578 
00585   template<class Scalar, class ArrayType>
00586   static void evalwarp( ArrayType &warp ,
00587                 const int order ,
00588                 const ArrayType &xnodes ,
00589                 const ArrayType &xout );
00590 
00591 
00592   }; // end class PointTools
00593 
00594 } // end namespace Intrepid
00595 
00596 // include templated definitions
00597 #include <Intrepid_PointToolsDef.hpp>
00598 
00599 #endif