Intrepid2
Intrepid2_HDIV_WEDGE_I1_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 
49 #ifndef __INTREPID2_HDIV_WEDGE_I1_FEM_DEF_HPP__
50 #define __INTREPID2_HDIV_WEDGE_I1_FEM_DEF_HPP__
51 
52 namespace Intrepid2 {
53 
54  // -------------------------------------------------------------------------------------
55  namespace Impl {
56 
57  template<EOperator opType>
58  template<typename OutputViewType,
59  typename inputViewType>
60  KOKKOS_INLINE_FUNCTION
61  void
62  Basis_HDIV_WEDGE_I1_FEM::Serial<opType>::
63  getValues( OutputViewType output,
64  const inputViewType input ) {
65  switch (opType) {
66  case OPERATOR_VALUE: {
67  const auto x = input(0);
68  const auto y = input(1);
69  const auto z = input(2);
70 
71  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
72  output.access(0, 0) = x/2.0;
73  output.access(0, 1) = (y - 1.0)/2.0;
74  output.access(0, 2) = 0.0;
75 
76  output.access(1, 0) = x/2.0;
77  output.access(1, 1) = y/2.0;
78  output.access(1, 2) = 0.0;
79 
80  output.access(2, 0) = (x - 1.0)/2.0;
81  output.access(2, 1) = y/2.0;
82  output.access(2, 2) = 0.0;
83 
84  output.access(3, 0) = 0.0;
85  output.access(3, 1) = 0.0;
86  output.access(3, 2) = z - 1.0;
87 
88  output.access(4, 0) = 0.0;
89  output.access(4, 1) = 0.0;
90  output.access(4, 2) = 1.0 + z;
91  break;
92  }
93  case OPERATOR_DIV: {
94 
95  // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
96  output.access(0) = 1.0;
97  output.access(1) = 1.0;
98  output.access(2) = 1.0;
99  output.access(3) = 1.0;
100  output.access(4) = 1.0;
101  break;
102  }
103  default: {
104  INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
105  opType != OPERATOR_DIV,
106  ">>> ERROR: (Intrepid2::Basis_HDIV_WEDGE_I1_FEM::Serial::getValues) operator is not supported");
107 
108  }
109  }
110  }
111 
112  template<typename SpT,
113  typename outputValueValueType, class ...outputValueProperties,
114  typename inputPointValueType, class ...inputPointProperties>
115  void
116  Basis_HDIV_WEDGE_I1_FEM::
117  getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
118  const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
119  const EOperator operatorType ) {
120  typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
121  typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
122  typedef typename ExecSpace<typename inputPointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
123 
124  // Number of evaluation points = dim 0 of inputPoints
125  const auto loopSize = inputPoints.extent(0);
126  Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
127 
128  switch (operatorType) {
129 
130  case OPERATOR_VALUE: {
131  typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
132  Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
133  break;
134  }
135  case OPERATOR_DIV: {
136  typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_DIV> FunctorType;
137  Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
138  break;
139  }
140  default: {
141  INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
142  ">>> ERROR (Basis_HDIV_WEDGE_I1_FEM): Invalid operator type");
143  }
144  }
145  }
146 
147 
148  }
149  // -------------------------------------------------------------------------------------
150 
151  template<typename SpT, typename OT, typename PT>
154  this->basisCardinality_ = 5;
155  this->basisDegree_ = 1;
156  this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Wedge<6> >() );
157  this->basisType_ = BASIS_FEM_DEFAULT;
158  this->basisCoordinates_ = COORDINATES_CARTESIAN;
159  this->functionSpace_ = FUNCTION_SPACE_HDIV;
160 
161  // initialize tags
162  {
163  // Basis-dependent intializations
164  const ordinal_type tagSize = 4; // size of DoF tag
165  const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
166  const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
167  const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
168 
169  // An array with local DoF tags assigned to basis functions, in the order of their local enumeration
170  ordinal_type tags[20] = { 2, 0, 0, 1,
171  2, 1, 0, 1,
172  2, 2, 0, 1,
173  2, 3, 0, 1,
174  2, 4, 0, 1 };
175 
176  // host tags
177  OrdinalTypeArray1DHost tagView(&tags[0], 20);
178 
179  // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
180  //OrdinalTypeArray2DHost ordinalToTag;
181  //OrdinalTypeArray3DHost tagToOrdinal;
182  this->setOrdinalTagData(this->tagToOrdinal_,
183  this->ordinalToTag_,
184  tagView,
185  this->basisCardinality_,
186  tagSize,
187  posScDim,
188  posScOrd,
189  posDfOrd);
190  }
191 
192  // dofCoords on host and create its mirror view to device
193  Kokkos::DynRankView<typename ScalarViewType::value_type,typename SpT::array_layout,Kokkos::HostSpace>
194  dofCoords("dofCoordsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
195 
196  dofCoords(0,0) = 0.5; dofCoords(0,1) = 0.0; dofCoords(0,2) = 0.0;
197  dofCoords(1,0) = 0.5; dofCoords(1,1) = 0.5; dofCoords(1,2) = 0.0;
198  dofCoords(2,0) = 0.0; dofCoords(2,1) = 0.5; dofCoords(2,2) = 0.0;
199  dofCoords(3,0) = 1.0/3.0; dofCoords(3,1) = 1.0/3.0; dofCoords(3,2) = -1.0;
200  dofCoords(4,0) = 1.0/3.0; dofCoords(4,1) = 1.0/3.0; dofCoords(4,2) = 1.0;
201 
202  this->dofCoords_ = Kokkos::create_mirror_view(typename SpT::memory_space(), dofCoords);
203  Kokkos::deep_copy(this->dofCoords_, dofCoords);
204  }
205 
206 }// namespace Intrepid2
207 #endif
Kokkos::View< ordinal_type *, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.