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 override
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 override
82  {
84  intrepid_basis = createIntrepid2Basis<PHX::Device::execution_space,double,double>(_basis_type,_basis_order,topo);
85  return intrepid_basis->getCardinality();
86  }
87 
88  virtual bool hasPoints(const shards::CellTopology & topo) const override
89  {
90  return true;
91  }
92 
93 protected:
94  std::string _basis_type;
96 
97 private:
98  // hidden
99  BasisCoordsGenerator();
100  BasisCoordsGenerator(const BasisCoordsGenerator &);
101 };
102 
103 } // end namespace <anonymous>
104 
105 
107  _basis_type("none"),
108  _basis_order(-1)
109 {
110  _key = std::hash<BasisDescriptor>{}(*this);
111 }
112 
113 BasisDescriptor::BasisDescriptor(const int basis_order, const std::string & basis_type):
114  _basis_type(basis_type),
115  _basis_order(basis_order)
116 {
117  _key = std::hash<BasisDescriptor>{}(*this);
118 }
119 
123 {
124  using Teuchos::RCP;
125  using Teuchos::rcp;
126 
127  std::stringstream ss;
128  ss << "cell_ref:" << _basis_type << "-" << _basis_order;
129 
130  RCP<PointGenerator> generator = rcp(new BasisCoordsGenerator(_basis_order,_basis_type));
131 
132  PointDescriptor pd(ss.str(),generator);
133 
134  return pd;
135 }
136 
138  const panzer::BasisDescriptor& right)
139 {
140  return ( (left.getType() == right.getType()) &&
141  (left.getOrder() == right.getOrder()) );
142 }
143 
144 } // end namespace panzer
145 
146 std::size_t
148 {
149  std::size_t seed = 0;
150 
151  panzer::hash_combine(seed,desc.getType());
152  panzer::hash_combine(seed,desc.getOrder());
153 
154  return seed;
155 }
156 
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.