Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_BasisDescriptor.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
44 
45 #include "Phalanx_KokkosDeviceTypes.hpp"
46 
47 #include "Panzer_HashUtils.hpp"
49 #include "Panzer_PointGenerator.hpp" // includes Kokkos::DynRankView
50 
51 namespace panzer
52 {
53 
54 // Anonymous namespace that holds the coordinate generator,
55 // this hides any details about the generator from an external
56 // user and hopefully hides Kokkos from any file that doesn't need it.
57 namespace {
58 
61 class BasisCoordsGenerator :
62  public PointGenerator {
63 public:
64  BasisCoordsGenerator(const int basis_order, const std::string & basis_type)
65  : _basis_type(basis_type), _basis_order(basis_order) {}
66 
67  virtual ~BasisCoordsGenerator() = default;
68 
69  virtual Kokkos::DynRankView<double> getPoints(const shards::CellTopology & topo) const
70  {
72  intrepid_basis = createIntrepid2Basis<PHX::Device::execution_space,double,double>(_basis_type,_basis_order,topo);
73 
74  Kokkos::DynRankView<double> view(_basis_type+"_ref_coords",intrepid_basis->getCardinality(),topo.getDimension());
75 
76  intrepid_basis->getDofCoords(view);
77 
78  return view;
79  }
80 
81  virtual int numPoints(const shards::CellTopology & topo) const
82  {
84  intrepid_basis = createIntrepid2Basis<PHX::Device::execution_space,double,double>(_basis_type,_basis_order,topo);
85  return intrepid_basis->getCardinality();
86  }
87 
88 protected:
89  std::string _basis_type;
91 
92 private:
93  // hidden
94  BasisCoordsGenerator();
95  BasisCoordsGenerator(const BasisCoordsGenerator &);
96 };
97 
98 } // end namespace <anonymous>
99 
100 
102  _basis_type("none"),
103  _basis_order(-1)
104 {
105  _key = std::hash<BasisDescriptor>{}(*this);
106 }
107 
108 BasisDescriptor::BasisDescriptor(const int basis_order, const std::string & basis_type):
109  _basis_type(basis_type),
110  _basis_order(basis_order)
111 {
112  _key = std::hash<BasisDescriptor>{}(*this);
113 }
114 
118 {
119  using Teuchos::RCP;
120  using Teuchos::rcp;
121 
122  std::stringstream ss;
123  ss << "cell_ref:" << _basis_type << "-" << _basis_order;
124 
125  RCP<PointGenerator> generator = rcp(new BasisCoordsGenerator(_basis_order,_basis_type));
126 
127  PointDescriptor pd(ss.str(),generator);
128 
129  return pd;
130 }
131 
132 } // end namespace panzer
133 
134 std::size_t
136 {
137  std::size_t seed = 0;
138 
139  panzer::hash_combine(seed,desc.getType());
140  panzer::hash_combine(seed,desc.getOrder());
141 
142  return seed;
143 }
144 
PointDescriptor getPointDescriptor() const
Build a point descriptor that builds reference points for the DOF locations. This method throws if no...
std::size_t operator()(const panzer::BasisDescriptor &desc) const
int numPoints
int _basis_order
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const std::string & getType() const
Get type of basis.
int getOrder() const
Get order of basis.
void hash_combine(std::size_t &seed, const T &v)
std::string _basis_type
BasisDescriptor()
Constructor for empty basis.