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 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
12 
13 #include "Phalanx_KokkosDeviceTypes.hpp"
14 
15 #include "Panzer_HashUtils.hpp"
17 #include "Panzer_PointGenerator.hpp" // includes Kokkos::DynRankView
18 
19 namespace panzer
20 {
21 
22 // Anonymous namespace that holds the coordinate generator,
23 // this hides any details about the generator from an external
24 // user and hopefully hides Kokkos from any file that doesn't need it.
25 namespace {
26 
29 class BasisCoordsGenerator :
30  public PointGenerator {
31 public:
32  BasisCoordsGenerator(const int basis_order, const std::string & basis_type)
33  : _basis_type(basis_type), _basis_order(basis_order) {}
34 
35  virtual ~BasisCoordsGenerator() = default;
36 
37  virtual Kokkos::DynRankView<double> getPoints(const shards::CellTopology & topo) const override
38  {
40  intrepid_basis = createIntrepid2Basis<PHX::Device::execution_space,double,double>(_basis_type,_basis_order,topo);
41 
42  Kokkos::DynRankView<double> view(_basis_type+"_ref_coords",intrepid_basis->getCardinality(),topo.getDimension());
43 
44  intrepid_basis->getDofCoords(view);
45 
46  return view;
47  }
48 
49  virtual int numPoints(const shards::CellTopology & topo) const override
50  {
52  intrepid_basis = createIntrepid2Basis<PHX::Device::execution_space,double,double>(_basis_type,_basis_order,topo);
53  return intrepid_basis->getCardinality();
54  }
55 
56  virtual bool hasPoints(const shards::CellTopology & topo) const override
57  {
58  return true;
59  }
60 
61 protected:
62  std::string _basis_type;
64 
65 private:
66  // hidden
67  BasisCoordsGenerator();
68  BasisCoordsGenerator(const BasisCoordsGenerator &);
69 };
70 
71 } // end namespace <anonymous>
72 
73 
75  _basis_type("none"),
76  _basis_order(-1)
77 {
78  _key = std::hash<BasisDescriptor>{}(*this);
79 }
80 
81 BasisDescriptor::BasisDescriptor(const int basis_order, const std::string & basis_type):
82  _basis_type(basis_type),
83  _basis_order(basis_order)
84 {
85  _key = std::hash<BasisDescriptor>{}(*this);
86 }
87 
91 {
92  using Teuchos::RCP;
93  using Teuchos::rcp;
94 
95  std::stringstream ss;
96  ss << "cell_ref:" << _basis_type << "-" << _basis_order;
97 
98  RCP<PointGenerator> generator = rcp(new BasisCoordsGenerator(_basis_order,_basis_type));
99 
100  PointDescriptor pd(ss.str(),generator);
101 
102  return pd;
103 }
104 
106  const panzer::BasisDescriptor& right)
107 {
108  return ( (left.getType() == right.getType()) &&
109  (left.getOrder() == right.getOrder()) );
110 }
111 
112 } // end namespace panzer
113 
114 std::size_t
116 {
117  std::size_t seed = 0;
118 
119  panzer::hash_combine(seed,desc.getType());
120  panzer::hash_combine(seed,desc.getOrder());
121 
122  return seed;
123 }
124 
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.
bool operator==(const panzer::BasisDescriptor &left, const panzer::BasisDescriptor &right)
void hash_combine(std::size_t &seed, const T &v)
std::string _basis_type
BasisDescriptor()
Constructor for empty basis.