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 
51 namespace 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 SpT,
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,SpT>::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 SpT, 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 
143  // initialize tags
144  {
145  // Basis-dependent intializations
146  const ordinal_type tagSize = 4; // size of DoF tag, i.e., number of fields in the tag
147  const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
148  const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
149  const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
150 
151  // An array with local DoF tags assigned to the basis functions, in the order of their local enumeration
152  ordinal_type tags[4] = { spaceDim, 0, 0, 1 };
153 
154  ordinal_type_array_1d_host tagView(&tags[0], 4);
155 
156  this->setOrdinalTagData(this->tagToOrdinal_,
157  this->ordinalToTag_,
158  tagView,
159  this->basisCardinality_,
160  tagSize,
161  posScDim,
162  posScOrd,
163  posDfOrd);
164  }
165 
166  // dofCoords on host and create its mirror view to device
167  Kokkos::DynRankView<typename scalarViewType::value_type,typename SpT::array_layout,Kokkos::HostSpace>
168  dofCoords("dofCoordsHost", this->basisCardinality_, spaceDim), cellVerts("cellVerts", spaceDim);
169 
170  CellTools<SpT>::getReferenceCellCenter(Kokkos::subview(dofCoords, 0, Kokkos::ALL()),
171  cellVerts,
172  cellTopo);
173 
174  this->dofCoords_ = Kokkos::create_mirror_view(typename SpT::memory_space(), dofCoords);
175  Kokkos::deep_copy(this->dofCoords_, dofCoords);
176  }
177 
178 }
179 #endif
Kokkos::View< ordinal_type *,typename ExecSpaceType::array_layout, Kokkos::HostSpace > ordinal_type_array_1d_host
View type for 1d host array.
Basis_HVOL_C0_FEM()=delete
Constructor.
static void getReferenceCellCenter(Kokkos::DynRankView< cellCenterValueType, cellCenterProperties...> cellCenter, Kokkos::DynRankView< cellVertexValueType, cellVertexProperties...> cellVertex, const shards::CellTopology cell)
Computes the Cartesian coordinates of reference cell center.