Intrepid2
Intrepid2_CubatureControlVolumeSide.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Intrepid2 Package
5// Copyright (2007) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Kyungjoo Kim (kyukim@sandia.gov), or
38// Mauro Perego (mperego@sandia.gov)
39//
40// ************************************************************************
41// @HEADER
42
49#ifndef __INTREPID2_CUBATURE_CONTROLVOLUME_SIDE_HPP__
50#define __INTREPID2_CUBATURE_CONTROLVOLUME_SIDE_HPP__
51
52#include "Intrepid2_ConfigDefs.hpp"
54
55#include "Shards_CellTopology.hpp"
57
58namespace Intrepid2{
59
63 template<typename DeviceType = void,
64 typename pointValueType = double,
65 typename weightValueType = double>
67 : public Cubature<DeviceType,pointValueType,weightValueType> {
68 public:
69
70 template<typename cubPointViewType,
71 typename cubWeightViewType,
72 typename subcvCoordViewType,
73 typename subcvSideNormalViewType,
74 typename mapViewType>
75 struct Functor {
76 cubPointViewType _cubPoints;
77 cubWeightViewType _cubWeights;
78 const subcvCoordViewType _subcvCoords;
79 const subcvSideNormalViewType _subcvSideNormals;
80 const mapViewType _sideMap;
81
82 KOKKOS_INLINE_FUNCTION
83 Functor( cubPointViewType cubPoints_,
84 cubWeightViewType cubWeights_,
85 subcvCoordViewType subcvCoords_,
86 subcvSideNormalViewType subcvSideNormals_,
87 mapViewType sideMap_ )
88 : _cubPoints(cubPoints_), _cubWeights(cubWeights_),
89 _subcvCoords(subcvCoords_), _subcvSideNormals(subcvSideNormals_), _sideMap(sideMap_) {}
90
91 KOKKOS_INLINE_FUNCTION
92 void operator()(const ordinal_type cell) const {
93 const ordinal_type numNodesPerCell = _cubPoints.extent(1);
94 const ordinal_type spaceDim = _cubPoints.extent(2);
95
96 const ordinal_type numNodesPerSide = _sideMap(0);
97 const ordinal_type numSubcvPoints = _subcvSideNormals.extent(2);
98
99 const ordinal_type sideDim = spaceDim - 1;
100
101 // compute side centers
102 for (ordinal_type node=0;node<numNodesPerCell;++node) {
103 typename cubPointViewType::value_type val[3] = {};
104 for (ordinal_type j=0;j<numNodesPerSide;++j) {
105 for (ordinal_type i=0;i<spaceDim;++i)
106 val[i] += _subcvCoords(cell, node, _sideMap(j+1), i);
107 }
108 for (ordinal_type i=0;i<spaceDim;++i)
109 _cubPoints(cell, node, i) = (val[i]/numNodesPerSide);
110 }
111
112 // compute weights (area or volume)
113 for (ordinal_type node=0;node<numNodesPerCell;++node) {
114 for (ordinal_type i=0;i<spaceDim;++i) {
115 typename cubWeightViewType::value_type val = 0;
116 for (ordinal_type pt=0;pt<numSubcvPoints;++pt)
117 val += _subcvSideNormals(cell, node, pt, i)*pow(2,sideDim);
118 _cubWeights(cell, node, i) = val;
119 }
120 }
121 }
122 };
123
124 protected:
125
128 shards::CellTopology primaryCellTopo_;
129
132 shards::CellTopology subcvCellTopo_;
133
136 ordinal_type degree_;
137
138 // cubature points and weights associated with sub-control volume.
139 Kokkos::View<ordinal_type**,Kokkos::LayoutRight,DeviceType> sideNodeMap_;
140 Kokkos::DynRankView<pointValueType, DeviceType> sidePoints_;
141
142 public:
143 typedef typename Cubature<DeviceType,pointValueType,weightValueType>::PointViewType PointViewType;
144 typedef typename Cubature<DeviceType,pointValueType,weightValueType>::weightViewType weightViewType;
145
146 using Cubature<DeviceType,pointValueType,weightValueType>::getCubature;
147
155 virtual
156 void
157 getCubature( PointViewType cubPoints,
158 weightViewType cubWeights,
159 PointViewType cellCoords) const override;
160
163 virtual
164 ordinal_type
165 getNumPoints() const override {
166 return primaryCellTopo_.getEdgeCount();
167 }
168
171 virtual
172 ordinal_type
173 getDimension() const override {
174 return primaryCellTopo_.getDimension();
175 }
176
179 virtual
180 const char*
181 getName() const override {
182 return "CubatureControlVolumeSide";
183 }
184
188 CubatureControlVolumeSide(const shards::CellTopology cellTopology);
189 virtual ~CubatureControlVolumeSide() {}
190
191 }; // end class CubatureControlVolume
192
193} // end namespace Intrepid2
194
196
197#endif
198
Header file for the Intrepid2::CellTools class.
Header file for the Intrepid2::CubatureControlVolume class.
Header file for the Intrepid2::Cubature class.
Defines cubature (integration) rules over control volumes.
shards::CellTopology subcvCellTopo_
The topology of the sub-control volume.
virtual ordinal_type getDimension() const override
Returns dimension of integration domain.
ordinal_type degree_
The degree of the polynomials that are integrated exactly.
CubatureControlVolumeSide(const shards::CellTopology cellTopology)
virtual ordinal_type getNumPoints() const override
Returns the number of cubature points.
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights, PointViewType cellCoords) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
shards::CellTopology primaryCellTopo_
The topology of the primary cell.
virtual const char * getName() const override
Returns cubature name.
Defines the base class for cubature (integration) rules in Intrepid.