Panzer Version of the Day
Loading...
Searching...
No Matches
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
19namespace 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.
25namespace {
26
29class BasisCoordsGenerator :
30 public PointGenerator {
31public:
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,PHX::Device>
38 getPoints(const shards::CellTopology & topo) const override
39 {
40 Teuchos::RCP<Intrepid2::Basis<PHX::Device,double,double> >
41 intrepid_basis = createIntrepid2Basis<PHX::Device,double,double>(_basis_type,_basis_order,topo);
42
43 Kokkos::DynRankView<double,PHX::Device> view(_basis_type+"_ref_coords",intrepid_basis->getCardinality(),topo.getDimension());
44
45 intrepid_basis->getDofCoords(view);
46
47 return view;
48 }
49
50 virtual int numPoints(const shards::CellTopology & topo) const override
51 {
52 Teuchos::RCP<Intrepid2::Basis<PHX::Device,double,double> >
53 intrepid_basis = createIntrepid2Basis<PHX::Device,double,double>(_basis_type,_basis_order,topo);
54 return intrepid_basis->getCardinality();
55 }
56
57 virtual bool hasPoints(const shards::CellTopology & topo) const override
58 {
59 return true;
60 }
61
62protected:
63 std::string _basis_type;
64 int _basis_order;
65
66private:
67 // hidden
68 BasisCoordsGenerator();
69 BasisCoordsGenerator(const BasisCoordsGenerator &);
70};
71
72} // end namespace <anonymous>
73
74
76 _basis_type("none"),
77 _basis_order(-1)
78{
79 _key = std::hash<BasisDescriptor>{}(*this);
80}
81
82BasisDescriptor::BasisDescriptor(const int basis_order, const std::string & basis_type):
83 _basis_type(basis_type),
84 _basis_order(basis_order)
85{
86 _key = std::hash<BasisDescriptor>{}(*this);
87}
88
92{
93 using Teuchos::RCP;
94 using Teuchos::rcp;
95
96 std::stringstream ss;
97 ss << "cell_ref:" << _basis_type << "-" << _basis_order;
98
99 RCP<PointGenerator> generator = rcp(new BasisCoordsGenerator(_basis_order,_basis_type));
100
101 PointDescriptor pd(ss.str(),generator);
102
103 return pd;
104}
105
107 const panzer::BasisDescriptor& right)
108{
109 return ( (left.getType() == right.getType()) &&
110 (left.getOrder() == right.getOrder()) );
111}
112
113} // end namespace panzer
114
115std::size_t
117{
118 std::size_t seed = 0;
119
120 panzer::hash_combine(seed,desc.getType());
121 panzer::hash_combine(seed,desc.getOrder());
122
123 return seed;
124}
125
int getOrder() const
Get order of basis.
std::string _basis_type
Basis type (HGrad, HDiv, HCurl, HVol).
const std::string & getType() const
Get type of basis.
PointDescriptor getPointDescriptor() const
Build a point descriptor that builds reference points for the DOF locations. This method throws if no...
BasisDescriptor()
Constructor for empty basis.
bool operator==(const panzer::BasisDescriptor &left, const panzer::BasisDescriptor &right)
void hash_combine(std::size_t &seed, const T &v)
Mixes the hash of v into seed, in place. Used to build a combined hash from multiple values.
Teuchos::RCP< Intrepid2::Basis< DeviceType, OutputValueType, PointValueType > > createIntrepid2Basis(const std::string basis_type, int basis_order, const shards::CellTopology &cell_topology)
Creates an Intrepid2::Basis object given the basis, order and cell topology.
std::size_t operator()(const panzer::BasisDescriptor &desc) const