Intrepid2
Intrepid2_HVOL_C0_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
15#ifndef __INTREPID2_HVOL_C0_FEM_DEF_HPP__
16#define __INTREPID2_HVOL_C0_FEM_DEF_HPP__
17
18namespace Intrepid2 {
19
20 namespace Impl {
21
22 template<EOperator opType>
23 template<typename OutputViewType,
24 typename inputViewType>
25 KOKKOS_INLINE_FUNCTION
26 void
27 Basis_HVOL_C0_FEM::Serial<opType>::
28 getValues( OutputViewType output,
29 const inputViewType /* input */ ) {
30 switch (opType) {
31 case OPERATOR_VALUE : {
32 output.access(0) = 1.0;
33 break;
34 }
35 case OPERATOR_MAX : {
36 const ordinal_type jend = output.extent(1);
37 const ordinal_type iend = output.extent(0);
38
39 for (ordinal_type j=0;j<jend;++j)
40 for (ordinal_type i=0;i<iend;++i)
41 output.access(i, j) = 0.0;
42 break;
43 }
44 default: {
45 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
46 opType != OPERATOR_MAX,
47 ">>> ERROR: (Intrepid2::Basis_HVOL_C0_FEM::Serial::getValues) operator is not supported");
48 }
49 }
50 }
51
52 template<typename DT,
53 typename outputValueValueType, class ...outputValueProperties,
54 typename inputPointValueType, class ...inputPointProperties>
55 void
56 Basis_HVOL_C0_FEM::
57 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
58 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
59 const EOperator operatorType ) {
60 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
61 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
62 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
63
64 // Number of evaluation points = dim 0 of inputPoints
65 const auto loopSize = inputPoints.extent(0);
66 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
67
68 switch (operatorType) {
69 case OPERATOR_VALUE: {
70 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
71 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
72 break;
73 }
74 case OPERATOR_GRAD:
75 case OPERATOR_CURL:
76 case OPERATOR_DIV:
77 case OPERATOR_D1:
78 case OPERATOR_D2:
79 case OPERATOR_D3:
80 case OPERATOR_D4:
81 case OPERATOR_D5:
82 case OPERATOR_D6:
83 case OPERATOR_D7:
84 case OPERATOR_D8:
85 case OPERATOR_D9:
86 case OPERATOR_D10: {
87 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
88 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
89 break;
90 }
91 default: {
92 INTREPID2_TEST_FOR_EXCEPTION( !Intrepid2::isValidOperator(operatorType), std::invalid_argument,
93 ">>> ERROR (Basis_HVOL_C0_FEM): Invalid operator type");
94 }
95 }
96 }
97 }
98
99 template<typename DT, typename OT, typename PT>
101 Basis_HVOL_C0_FEM(const shards::CellTopology& cellTopo) {
102 const ordinal_type spaceDim = cellTopo.getDimension();
103
104 this->basisCardinality_ = 1;
105 this->basisDegree_ = 0;
106 this->basisCellTopologyKey_ = cellTopo.getKey();
107 this->basisType_ = Intrepid2::BASIS_FEM_DEFAULT;
108 this->basisCoordinates_ = Intrepid2::COORDINATES_CARTESIAN;
109 this->functionSpace_ = FUNCTION_SPACE_HVOL;
110
111 basisName_ = "Intrepid2_HVOL_";
112 basisName_ += cellTopo.getName();
113 basisName_ += "_C0_FEM";
114
115 // initialize tags
116 {
117 // Basis-dependent intializations
118 const ordinal_type tagSize = 4; // size of DoF tag, i.e., number of fields in the tag
119 const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
120 const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
121 const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
122
123 // An array with local DoF tags assigned to the basis functions, in the order of their local enumeration
124 ordinal_type tags[4] = { spaceDim, 0, 0, 1 };
125
126 OrdinalTypeArray1DHost tagView(&tags[0], 4);
127
128 this->setOrdinalTagData(this->tagToOrdinal_,
129 this->ordinalToTag_,
130 tagView,
131 this->basisCardinality_,
132 tagSize,
133 posScDim,
134 posScOrd,
135 posDfOrd);
136 }
137
138 // dofCoords on host and create its mirror view to device
139 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
140 dofCoords("dofCoordsHost", this->basisCardinality_, spaceDim);
141
142 CellTools<Kokkos::HostSpace>::getReferenceCellCenter(Kokkos::subview(dofCoords, 0, Kokkos::ALL()), cellTopo);
143
144 this->dofCoords_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoords);
145 Kokkos::deep_copy(this->dofCoords_, dofCoords);
146 }
147
148}
149#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.