Intrepid2
Intrepid2_HVOL_C0_FEMDef.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
48#ifndef __INTREPID2_HVOL_C0_FEM_DEF_HPP__
49#define __INTREPID2_HVOL_C0_FEM_DEF_HPP__
50
51namespace Intrepid2 {
52
53 namespace Impl {
54
55 template<EOperator opType>
56 template<typename OutputViewType,
57 typename inputViewType>
58 KOKKOS_INLINE_FUNCTION
59 void
60 Basis_HVOL_C0_FEM::Serial<opType>::
61 getValues( OutputViewType output,
62 const inputViewType /* input */ ) {
63 switch (opType) {
64 case OPERATOR_VALUE : {
65 output.access(0) = 1.0;
66 break;
67 }
68 case OPERATOR_MAX : {
69 const ordinal_type jend = output.extent(1);
70 const ordinal_type iend = output.extent(0);
71
72 for (ordinal_type j=0;j<jend;++j)
73 for (ordinal_type i=0;i<iend;++i)
74 output.access(i, j) = 0.0;
75 break;
76 }
77 default: {
78 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
79 opType != OPERATOR_MAX,
80 ">>> ERROR: (Intrepid2::Basis_HVOL_C0_FEM::Serial::getValues) operator is not supported");
81 }
82 }
83 }
84
85 template<typename DT,
86 typename outputValueValueType, class ...outputValueProperties,
87 typename inputPointValueType, class ...inputPointProperties>
88 void
89 Basis_HVOL_C0_FEM::
90 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
91 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
92 const EOperator operatorType ) {
93 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
94 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
95 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
96
97 // Number of evaluation points = dim 0 of inputPoints
98 const auto loopSize = inputPoints.extent(0);
99 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
100
101 switch (operatorType) {
102 case OPERATOR_VALUE: {
103 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
104 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
105 break;
106 }
107 case OPERATOR_GRAD:
108 case OPERATOR_CURL:
109 case OPERATOR_DIV:
110 case OPERATOR_D1:
111 case OPERATOR_D2:
112 case OPERATOR_D3:
113 case OPERATOR_D4:
114 case OPERATOR_D5:
115 case OPERATOR_D6:
116 case OPERATOR_D7:
117 case OPERATOR_D8:
118 case OPERATOR_D9:
119 case OPERATOR_D10: {
120 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
121 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
122 break;
123 }
124 default: {
125 INTREPID2_TEST_FOR_EXCEPTION( !Intrepid2::isValidOperator(operatorType), std::invalid_argument,
126 ">>> ERROR (Basis_HVOL_C0_FEM): Invalid operator type");
127 }
128 }
129 }
130 }
131
132 template<typename DT, typename OT, typename PT>
134 Basis_HVOL_C0_FEM(const shards::CellTopology cellTopo) {
135 const ordinal_type spaceDim = cellTopo.getDimension();
136
137 this->basisCardinality_ = 1;
138 this->basisDegree_ = 0;
139 this->basisCellTopology_ = cellTopo;
140 this->basisType_ = Intrepid2::BASIS_FEM_DEFAULT;
141 this->basisCoordinates_ = Intrepid2::COORDINATES_CARTESIAN;
142 this->functionSpace_ = FUNCTION_SPACE_HVOL;
143
144 basisName_ = "Intrepid2_HVOL_";
145 basisName_ += cellTopo.getName();
146 basisName_ += "_C0_FEM";
147
148 // initialize tags
149 {
150 // Basis-dependent intializations
151 const ordinal_type tagSize = 4; // size of DoF tag, i.e., number of fields in the tag
152 const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
153 const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
154 const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
155
156 // An array with local DoF tags assigned to the basis functions, in the order of their local enumeration
157 ordinal_type tags[4] = { spaceDim, 0, 0, 1 };
158
159 OrdinalTypeArray1DHost tagView(&tags[0], 4);
160
161 this->setOrdinalTagData(this->tagToOrdinal_,
162 this->ordinalToTag_,
163 tagView,
164 this->basisCardinality_,
165 tagSize,
166 posScDim,
167 posScOrd,
168 posDfOrd);
169 }
170
171 // dofCoords on host and create its mirror view to device
172 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
173 dofCoords("dofCoordsHost", this->basisCardinality_, spaceDim);
174
175 CellTools<Kokkos::HostSpace>::getReferenceCellCenter(Kokkos::subview(dofCoords, 0, Kokkos::ALL()), cellTopo);
176
177 this->dofCoords_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoords);
178 Kokkos::deep_copy(this->dofCoords_, dofCoords);
179 }
180
181}
182#endif
Basis_HVOL_C0_FEM()=delete
Constructor.
static void getReferenceCellCenter(Kokkos::DynRankView< cellCenterValueType, cellCenterProperties... > cellCenter, const shards::CellTopology cell)
Computes the Cartesian coordinates of reference cell barycenter.