Intrepid2
Intrepid2_HDIV_WEDGE_I1_FEMDef.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_HDIV_WEDGE_I1_FEM_DEF_HPP__
17 #define __INTREPID2_HDIV_WEDGE_I1_FEM_DEF_HPP__
18 
19 namespace Intrepid2 {
20 
21  // -------------------------------------------------------------------------------------
22  namespace Impl {
23 
24  template<EOperator opType>
25  template<typename OutputViewType,
26  typename inputViewType>
27  KOKKOS_INLINE_FUNCTION
28  void
29  Basis_HDIV_WEDGE_I1_FEM::Serial<opType>::
30  getValues( OutputViewType output,
31  const inputViewType input ) {
32  switch (opType) {
33  case OPERATOR_VALUE: {
34  const auto x = input(0);
35  const auto y = input(1);
36  const auto z = input(2);
37 
38  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
39  output.access(0, 0) = x*2.0;
40  output.access(0, 1) = (y - 1.0)*2.0;
41  output.access(0, 2) = 0.0;
42 
43  output.access(1, 0) = x*2.0;
44  output.access(1, 1) = y*2.0;
45  output.access(1, 2) = 0.0;
46 
47  output.access(2, 0) = (x - 1.0)*2.0;
48  output.access(2, 1) = y*2.0;
49  output.access(2, 2) = 0.0;
50 
51  output.access(3, 0) = 0.0;
52  output.access(3, 1) = 0.0;
53  output.access(3, 2) = (z - 1.0)/2.0;
54 
55  output.access(4, 0) = 0.0;
56  output.access(4, 1) = 0.0;
57  output.access(4, 2) = (1.0 + z)/2.0;
58  break;
59  }
60  case OPERATOR_DIV: {
61 
62  // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
63  output.access(0) = 4.0;
64  output.access(1) = 4.0;
65  output.access(2) = 4.0;
66  output.access(3) = 0.5;
67  output.access(4) = 0.5;
68  break;
69  }
70  default: {
71  INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
72  opType != OPERATOR_DIV,
73  ">>> ERROR: (Intrepid2::Basis_HDIV_WEDGE_I1_FEM::Serial::getValues) operator is not supported");
74 
75  }
76  }
77  }
78 
79  template<typename DT,
80  typename outputValueValueType, class ...outputValueProperties,
81  typename inputPointValueType, class ...inputPointProperties>
82  void
83  Basis_HDIV_WEDGE_I1_FEM::
84  getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
85  const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
86  const EOperator operatorType ) {
87  typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
88  typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
89  typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
90 
91  // Number of evaluation points = dim 0 of inputPoints
92  const auto loopSize = inputPoints.extent(0);
93  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
94 
95  switch (operatorType) {
96 
97  case OPERATOR_VALUE: {
98  typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
99  Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
100  break;
101  }
102  case OPERATOR_DIV: {
103  typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_DIV> FunctorType;
104  Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
105  break;
106  }
107  default: {
108  INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
109  ">>> ERROR (Basis_HDIV_WEDGE_I1_FEM): Invalid operator type");
110  }
111  }
112  }
113 
114 
115  }
116  // -------------------------------------------------------------------------------------
117 
118  template<typename DT, typename OT, typename PT>
121  const ordinal_type spaceDim = 3;
122  this->basisCardinality_ = 5;
123  this->basisDegree_ = 1;
124  this->basisCellTopologyKey_ = shards::Wedge<6>::key;
125  this->basisType_ = BASIS_FEM_DEFAULT;
126  this->basisCoordinates_ = COORDINATES_CARTESIAN;
127  this->functionSpace_ = FUNCTION_SPACE_HDIV;
128 
129  // initialize tags
130  {
131  // Basis-dependent intializations
132  const ordinal_type tagSize = 4; // size of DoF tag
133  const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
134  const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
135  const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
136 
137  // An array with local DoF tags assigned to basis functions, in the order of their local enumeration
138  ordinal_type tags[20] = { 2, 0, 0, 1,
139  2, 1, 0, 1,
140  2, 2, 0, 1,
141  2, 3, 0, 1,
142  2, 4, 0, 1 };
143 
144  // host tags
145  OrdinalTypeArray1DHost tagView(&tags[0], 20);
146 
147  // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
148  //OrdinalTypeArray2DHost ordinalToTag;
149  //OrdinalTypeArray3DHost tagToOrdinal;
150  this->setOrdinalTagData(this->tagToOrdinal_,
151  this->ordinalToTag_,
152  tagView,
153  this->basisCardinality_,
154  tagSize,
155  posScDim,
156  posScOrd,
157  posDfOrd);
158  }
159 
160  // dofCoords on host and create its mirror view to device
161  Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
162  dofCoords("dofCoordsHost", this->basisCardinality_,spaceDim);
163 
164  dofCoords(0,0) = 0.5; dofCoords(0,1) = 0.0; dofCoords(0,2) = 0.0;
165  dofCoords(1,0) = 0.5; dofCoords(1,1) = 0.5; dofCoords(1,2) = 0.0;
166  dofCoords(2,0) = 0.0; dofCoords(2,1) = 0.5; dofCoords(2,2) = 0.0;
167  dofCoords(3,0) = 1.0/3.0; dofCoords(3,1) = 1.0/3.0; dofCoords(3,2) = -1.0;
168  dofCoords(4,0) = 1.0/3.0; dofCoords(4,1) = 1.0/3.0; dofCoords(4,2) = 1.0;
169 
170  this->dofCoords_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoords);
171  Kokkos::deep_copy(this->dofCoords_, dofCoords);
172 
173  // dofCoords on host and create its mirror view to device
174  Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
175  dofCoeffs("dofCoeffsHost", this->basisCardinality_,spaceDim);
176 
177  // dofCoeffs are normals to edges
178  dofCoeffs(0,0) = 0.0; dofCoeffs(0,1) = -0.5; dofCoeffs(0,2) = 0.0;
179  dofCoeffs(1,0) = 0.5; dofCoeffs(1,1) = 0.5; dofCoeffs(1,2) = 0.0;
180  dofCoeffs(2,0) = -0.5; dofCoeffs(2,1) = 0.0; dofCoeffs(2,2) = 0.0;
181  dofCoeffs(3,0) = 0.0; dofCoeffs(3,1) = 0.0; dofCoeffs(3,2) = -1.0;
182  dofCoeffs(4,0) = 0.0; dofCoeffs(4,1) = 0.0; dofCoeffs(4,2) = 1.0;
183 
184  this->dofCoeffs_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoeffs);
185  Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
186 
187  }
188 
189  template<typename DT, typename OT, typename PT>
190  void
192  ordinal_type& perTeamSpaceSize,
193  ordinal_type& perThreadSpaceSize,
194  const PointViewType inputPoints,
195  const EOperator operatorType) const {
196  perTeamSpaceSize = 0;
197  perThreadSpaceSize = 0;
198  }
199 
200  template<typename DT, typename OT, typename PT>
201  KOKKOS_INLINE_FUNCTION
202  void
203  Basis_HDIV_WEDGE_I1_FEM<DT,OT,PT>::getValues(
204  OutputViewType outputValues,
205  const PointViewType inputPoints,
206  const EOperator operatorType,
207  const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
208  const typename DT::execution_space::scratch_memory_space & scratchStorage,
209  const ordinal_type subcellDim,
210  const ordinal_type subcellOrdinal) const {
211 
212  INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
213  ">>> ERROR: (Intrepid2::Basis_HDIV_WEDGE_I1_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
214 
215  (void) scratchStorage; //avoid unused variable warning
216 
217  const int numPoints = inputPoints.extent(0);
218 
219  switch(operatorType) {
220  case OPERATOR_VALUE:
221  Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
222  auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
223  const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
224  Impl::Basis_HDIV_WEDGE_I1_FEM::Serial<OPERATOR_VALUE>::getValues( output, input);
225  });
226  break;
227  case OPERATOR_DIV:
228  Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
229  auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
230  const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
231  Impl::Basis_HDIV_WEDGE_I1_FEM::Serial<OPERATOR_DIV>::getValues( output, input);
232  });
233  break;
234  default: {
235  INTREPID2_TEST_FOR_ABORT( true, ">>> ERROR: (Intrepid2::Basis_HDIV_WEDGE_I1_FEM::getValues), Operator Type not supported.");
236  }
237  }
238  }
239 
240 }// namespace Intrepid2
241 
242 #endif
Implementation of the default H(grad)-compatible FEM basis of degree 1 on Wedge cell.