Intrepid2
Intrepid2_CubatureControlVolume.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Intrepid2 Package
4 //
5 // Copyright 2007 NTESS and the Intrepid2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
16 #ifndef __INTREPID2_CUBATURE_CONTROLVOLUME_HPP__
17 #define __INTREPID2_CUBATURE_CONTROLVOLUME_HPP__
18 
19 #include "Intrepid2_ConfigDefs.hpp"
20 #include "Intrepid2_Cubature.hpp"
21 
22 #include "Shards_CellTopology.hpp"
23 #include "Intrepid2_CellTools.hpp"
25 
26 namespace Intrepid2{
27 
34  template<typename DeviceType = void,
35  typename pointValueType = double,
36  typename weightValueType = double>
38  : public Cubature<DeviceType,pointValueType,weightValueType> {
39  public:
40 
41  template<typename cubPointViewType,
42  typename cubWeightViewType,
43  typename subcvCoordViewType,
44  typename subcvWeightViewType,
45  typename jacDetViewType>
46  struct Functor {
47  cubPointViewType _cubPoints;
48  cubWeightViewType _cubWeights;
49  const subcvCoordViewType _subcvCoords;
50  const subcvWeightViewType _subcvWeights;
51  const jacDetViewType _jacDets;
52 
53  KOKKOS_INLINE_FUNCTION
54  Functor( cubPointViewType cubPoints_,
55  cubWeightViewType cubWeights_,
56  subcvCoordViewType subcvCoords_,
57  subcvWeightViewType subcvWeights_,
58  jacDetViewType jacDets_ )
59  : _cubPoints(cubPoints_), _cubWeights(cubWeights_),
60  _subcvCoords(subcvCoords_), _subcvWeights(subcvWeights_), _jacDets(jacDets_) {}
61 
62  KOKKOS_INLINE_FUNCTION
63  void operator()(const ordinal_type cell) const {
64  const ordinal_type numNodesPerCell = _subcvCoords.extent(1);
65  const ordinal_type numNodesPerSubcv = _subcvCoords.extent(2);
66  const ordinal_type spaceDim = _subcvCoords.extent(3);
67  const ordinal_type numSubcvPoints = _subcvWeights.extent(0);
68 
69  // compute subcv centers
70  for (ordinal_type node=0;node<numNodesPerCell;++node) {
71  typename cubPointViewType::value_type val[3] = {};
72  for (ordinal_type subcv=0;subcv<numNodesPerSubcv;++subcv) {
73  for (ordinal_type i=0;i<spaceDim;++i)
74  val[i] += _subcvCoords(cell, node, subcv, i);
75  }
76  for (ordinal_type i=0;i<spaceDim;++i)
77  _cubPoints(cell, node, i) = (val[i]/numNodesPerSubcv);
78  }
79 
80  // compute weights (area or volume)
81  for (ordinal_type node=0;node<numNodesPerCell;++node) {
82  typename cubWeightViewType::value_type val = 0;
83  for (ordinal_type pt=0;pt<numSubcvPoints;++pt)
84  val += _subcvWeights(pt)*_jacDets(cell, node, pt);
85  _cubWeights(cell, node) = val;
86  }
87  }
88  };
89 
90  protected:
91 
94  shards::CellTopology primaryCellTopo_;
95 
98  shards::CellTopology subcvCellTopo_;
99 
102  ordinal_type degree_;
103 
104  // cubature points and weights associated with sub-control volume.
105  Kokkos::DynRankView<pointValueType, DeviceType> subcvCubaturePoints_;
106  Kokkos::DynRankView<weightValueType,DeviceType> subcvCubatureWeights_;
107 
108  public:
109  typedef typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewType PointViewType;
110  typedef typename Cubature<DeviceType,pointValueType,weightValueType>::weightViewType weightViewType;
111 
113 
121  virtual
122  void
123  getCubature( PointViewType cubPoints,
124  weightViewType cubWeights,
125  PointViewType cellCoords) const override;
126 
129  virtual
130  ordinal_type
131  getNumPoints() const override {
132  return primaryCellTopo_.getNodeCount();
133  }
134 
137  virtual
138  ordinal_type
139  getDimension() const override {
140  return primaryCellTopo_.getDimension();
141  }
142 
145  virtual
146  const char*
147  getName() const override {
148  return "CubatureControlVolume";
149  }
150 
154  CubatureControlVolume(const shards::CellTopology cellTopology);
155  virtual ~CubatureControlVolume() {}
156 
157  }; // end class CubatureControlVolume
158 
159 } // end namespace Intrepid2
160 
162 
163 #endif
164 
Header file for the abstract base class Intrepid2::DefaultCubatureFactory.
Defines the base class for cubature (integration) rules in Intrepid.
virtual const char * getName() const override
Returns cubature name.
Header file for the Intrepid2::CubatureControlVolume class.
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights, PointViewType cellCoords) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
virtual ordinal_type getDimension() const override
Returns dimension of integration domain.
Header file for the Intrepid2::Cubature class.
ordinal_type degree_
The degree of the polynomials that are integrated exactly.
shards::CellTopology primaryCellTopo_
The topology of the primary cell.
CubatureControlVolume(const shards::CellTopology cellTopology)
shards::CellTopology subcvCellTopo_
The topology of the sub-control volume.
Defines cubature (integration) rules over control volumes.
virtual ordinal_type getNumPoints() const override
Returns the number of cubature points.
Header file for the Intrepid2::CellTools class.