Intrepid
Intrepid_HGRAD_LINE_C1_FEMDef.hpp
Go to the documentation of this file.
1 #ifndef INTREPID_HGRAD_LINE_C1_FEMDEF_HPP
2 #define INTREPID_HGRAD_LINE_C1_FEMDEF_HPP
3 // @HEADER
4 // ************************************************************************
5 //
6 // Intrepid Package
7 // Copyright (2007) Sandia Corporation
8 //
9 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10 // license for use of this work by or on behalf of the U.S. Government.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Pavel Bochev (pbboche@sandia.gov)
40 // Denis Ridzal (dridzal@sandia.gov), or
41 // Kara Peterson (kjpeter@sandia.gov)
42 //
43 // ************************************************************************
44 // @HEADER
45 
51 namespace Intrepid {
52 
53 
54 template<class Scalar, class ArrayScalar>
56  this -> basisCardinality_ = 2;
57  this -> basisDegree_ = 1;
58  this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Line<2> >() );
59  this -> basisType_ = BASIS_FEM_DEFAULT;
60  this -> basisCoordinates_ = COORDINATES_CARTESIAN;
61  this -> basisTagsAreSet_ = false;
62 }
63 
64 
65 
66 template<class Scalar, class ArrayScalar>
68  const ArrayScalar & inputPoints,
69  const EOperator operatorType) const {
70 
71  // Verify arguments
72 #ifdef HAVE_INTREPID_DEBUG
73  Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues,
74  inputPoints,
75  operatorType,
76  this -> getBaseCellTopology(),
77  this -> getCardinality() );
78 #endif
79  // Number of evaluation points = dim 0 of inputPoints
80  int dim0 = inputPoints.dimension(0);
81 
82  // Temporaries: (x,y) coordinates of the evaluation point
83  Scalar x = 0.0;
84 
85  switch (operatorType) {
86 
87  case OPERATOR_VALUE:
88  for (int i0 = 0; i0 < dim0; i0++) {
89  x = inputPoints(i0, 0);
90 
91  // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
92  outputValues(0, i0) = (1.0 - x)/2.0;
93  outputValues(1, i0) = (1.0 + x)/2.0;
94  }
95  break;
96 
97  case OPERATOR_GRAD:
98  case OPERATOR_DIV:
99  case OPERATOR_CURL:
100  case OPERATOR_D1:
101  for (int i0 = 0; i0 < dim0; i0++) {
102  x = inputPoints(i0,0);
103 
104  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
105  outputValues(0, i0, 0) = -0.5;
106  outputValues(1, i0, 0) = 0.5;
107  }
108  break;
109 
110  case OPERATOR_D2:
111  for (int i0 = 0; i0 < dim0; i0++) {
112 
113  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, D2Cardinality=3)
114  outputValues(0, i0, 0) = 0.0;
115  outputValues(1, i0, 0) = 0.0;
116  }
117  break;
118 
119  case OPERATOR_D3:
120  case OPERATOR_D4:
121  case OPERATOR_D5:
122  case OPERATOR_D6:
123  case OPERATOR_D7:
124  case OPERATOR_D8:
125  case OPERATOR_D9:
126  case OPERATOR_D10:
127  {
128  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality)
129  int DkCardinality = Intrepid::getDkCardinality(operatorType,
130  this -> basisCellTopology_.getDimension() );
131  for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) {
132  for (int i0 = 0; i0 < dim0; i0++) {
133  for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){
134  outputValues(dofOrd, i0, dkOrd) = 0.0;
135  }
136  }
137  }
138  }
139  break;
140 
141  default:
142  TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument,
143  ">>> ERROR (Basis_HGRAD_LINE_C1_FEM): Invalid operator type");
144  }
145 }
146 
147 template<class Scalar, class ArrayScalar>
149 
150  // Basis-dependent intializations
151  int tagSize = 4; // size of DoF tag, i.e., number of fields in the tag
152  int posScDim = 0; // position in the tag, counting from 0, of the subcell dim
153  int posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
154  int 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 basis functions, in the order of their local enumeration
157  int tags[] = { 0, 0, 0, 1,
158  0, 1, 0, 1};
159 
160  // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
161  Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
162  this -> ordinalToTag_,
163  tags,
164  this -> basisCardinality_,
165  tagSize,
166  posScDim,
167  posScOrd,
168  posDfOrd);
169 }
170 
171 template<class Scalar, class ArrayScalar>
173  const ArrayScalar & inputPoints,
174  const ArrayScalar & cellVertices,
175  const EOperator operatorType) const {
176  TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error,
177  ">>> ERROR (Basis_HGRAD_LINE_C1_FEM): FEM Basis calling an FVD member function");
178 }
179 
180 }// namespace Intrepid
181 #endif
void setOrdinalTagData(std::vector< std::vector< std::vector< int > > > &tagToOrdinal, std::vector< std::vector< int > > &ordinalToTag, const int *tags, const int basisCard, const int tagSize, const int posScDim, const int posScOrd, const int posDfOrd)
Fills ordinalToTag_ and tagToOrdinal_ by basis-specific tag data.
EOperator
Enumeration of primitive operators available in Intrepid. Primitive operators act on reconstructed fu...
void initializeTags()
Initializes tagToOrdinal_ and ordinalToTag_ lookup arrays.
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
Evaluation of a FEM basis on a reference Line cell.
int getDkCardinality(const EOperator operatorType, const int spaceDim)
Returns cardinality of Dk, i.e., the number of all derivatives of order k.
int isValidOperator(const EOperator operatorType)
Verifies validity of an operator enum.