Intrepid2
Intrepid2_ProjectionToolsDefHDIV.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_PROJECTIONTOOLSDEFHDIV_HPP__
50 #define __INTREPID2_PROJECTIONTOOLSDEFHDIV_HPP__
51 
53 #include "Intrepid2_ArrayTools.hpp"
55 
56 
57 namespace Intrepid2 {
58 
59 namespace FunctorsProjectionTools {
60 
61 template<typename ViewType1, typename ViewType2, typename ViewType3>
63  ViewType1 basisNormalAtBasisEPoints_;
64  ViewType1 wBasisNormalAtBasisEPoints_;
65  const ViewType1 basisAtBasisEPoints_;
66  const ViewType2 basisEWeights_;
67  const ViewType1 refSideNormal_;
68  const ViewType3 tagToOrdinal_;
69  ordinal_type sideDim_;
70  ordinal_type iside_;
71  ordinal_type offsetBasis_;
72 
73  ComputeWBasisSide_HDiv(ViewType1 basisNormalAtBasisEPoints, ViewType1 wBasisNormalAtBasisEPoints,
74  ViewType1 basisAtBasisEPoints, ViewType2 basisEWeights, ViewType1 refSideNormal, ViewType3 tagToOrdinal,
75  ordinal_type sideDim, ordinal_type iside, ordinal_type offsetBasis) :
76  basisNormalAtBasisEPoints_(basisNormalAtBasisEPoints), wBasisNormalAtBasisEPoints_(wBasisNormalAtBasisEPoints), basisAtBasisEPoints_(basisAtBasisEPoints),
77  basisEWeights_(basisEWeights), refSideNormal_(refSideNormal), tagToOrdinal_(tagToOrdinal),
78  sideDim_(sideDim), iside_(iside), offsetBasis_(offsetBasis) {}
79 
80  void
81  KOKKOS_INLINE_FUNCTION
82  operator()(const ordinal_type j, const ordinal_type iq) const {
83  ordinal_type jdof = tagToOrdinal_(sideDim_, iside_, j);
84  for(ordinal_type d=0; d <ordinal_type(refSideNormal_.extent(0)); ++d)
85  basisNormalAtBasisEPoints_(0,j,iq) += refSideNormal_(d)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
86  wBasisNormalAtBasisEPoints_(0,j,iq) = basisNormalAtBasisEPoints_(0,j,iq)*basisEWeights_(iq);
87  }
88 };
89 
90 template<typename ViewType1, typename ViewType2, typename ViewType3, typename ViewType4>
92  const ViewType2 targetEWeights_;
93  const ViewType1 basisAtTargetEPoints_;
94  const ViewType1 wBasisDofAtTargetEPoints_;
95  const ViewType3 tagToOrdinal_;
96  const ViewType4 targetAtEPoints_;
97  const ViewType1 targetAtTargetEPoints_;
98  const ViewType1 refSideNormal_;
99  ordinal_type sideCardinality_;
100  ordinal_type offsetTarget_;
101  ordinal_type sideDim_;
102  ordinal_type dim_;
103  ordinal_type iside_;
104 
105  ComputeBasisCoeffsOnSides_HDiv(const ViewType2 targetEWeights,
106  const ViewType1 basisAtTargetEPoints, const ViewType1 wBasisDofAtTargetEvalPoint, const ViewType3 tagToOrdinal,
107  const ViewType4 targetAtEPoints, const ViewType1 targetAtTargetEPoints,
108  const ViewType1 refSideNormal, ordinal_type sideCardinality,
109  ordinal_type offsetTarget, ordinal_type sideDim,
110  ordinal_type dim, ordinal_type iside) :
111  targetEWeights_(targetEWeights),
112  basisAtTargetEPoints_(basisAtTargetEPoints), wBasisDofAtTargetEPoints_(wBasisDofAtTargetEvalPoint),
113  tagToOrdinal_(tagToOrdinal), targetAtEPoints_(targetAtEPoints),
114  targetAtTargetEPoints_(targetAtTargetEPoints),
115  refSideNormal_(refSideNormal), sideCardinality_(sideCardinality),
116  offsetTarget_(offsetTarget), sideDim_(sideDim), dim_(dim), iside_(iside)
117  {}
118 
119  void
120  KOKKOS_INLINE_FUNCTION
121  operator()(const ordinal_type ic) const {
122 
123  typename ViewType1::value_type tmp =0;
124  for(ordinal_type j=0; j <sideCardinality_; ++j) {
125  ordinal_type jdof = tagToOrdinal_(sideDim_, iside_, j);
126  for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
127  tmp=0;
128  for(ordinal_type d=0; d <dim_; ++d)
129  tmp += refSideNormal_(d)*basisAtTargetEPoints_(jdof,offsetTarget_+iq,d);
130  wBasisDofAtTargetEPoints_(ic,j,iq) = tmp * targetEWeights_(iq);
131  }
132  }
133 
134  for(ordinal_type d=0; d <dim_; ++d)
135  for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq)
136  targetAtTargetEPoints_(ic,iq) += refSideNormal_(d)*targetAtEPoints_(ic,offsetTarget_+iq,d);
137  }
138 };
139 
140 
141 template<typename ViewType1, typename ViewType2, typename ViewType3,
142 typename ViewType4>
144  const ViewType1 basisCoeffs_;
145  const ViewType1 negPartialProjAtBasisEPoints_;
146  const ViewType1 nonWeightedBasisAtBasisEPoints_;
147  const ViewType1 basisAtBasisEPoints_;
148  const ViewType2 basisEWeights_;
149  const ViewType1 wBasisAtBasisEPoints_;
150  const ViewType2 targetEWeights_;
151  const ViewType1 basisAtTargetEPoints_;
152  const ViewType1 wBasisAtTargetEPoints_;
153  const ViewType3 computedDofs_;
154  const ViewType4 cellDof_;
155  ordinal_type numCellDofs_;
156  ordinal_type offsetBasis_;
157  ordinal_type offsetTarget_;
158  ordinal_type numSideDofs_;
159 
160  ComputeBasisCoeffsOnCells_HDiv(const ViewType1 basisCoeffs, ViewType1 negPartialProjAtBasisEPoints, const ViewType1 nonWeightedBasisAtBasisEPoints,
161  const ViewType1 basisAtBasisEPoints, const ViewType2 basisEWeights, const ViewType1 wBasisAtBasisEPoints, const ViewType2 targetEWeights,
162  const ViewType1 basisAtTargetEPoints, const ViewType1 wBasisAtTargetEPoints, const ViewType3 computedDofs, const ViewType4 cellDof,
163  ordinal_type numCellDofs, ordinal_type offsetBasis, ordinal_type offsetTarget, ordinal_type numSideDofs) :
164  basisCoeffs_(basisCoeffs), negPartialProjAtBasisEPoints_(negPartialProjAtBasisEPoints), nonWeightedBasisAtBasisEPoints_(nonWeightedBasisAtBasisEPoints),
165  basisAtBasisEPoints_(basisAtBasisEPoints), basisEWeights_(basisEWeights), wBasisAtBasisEPoints_(wBasisAtBasisEPoints), targetEWeights_(targetEWeights),
166  basisAtTargetEPoints_(basisAtTargetEPoints), wBasisAtTargetEPoints_(wBasisAtTargetEPoints),
167  computedDofs_(computedDofs), cellDof_(cellDof),numCellDofs_(numCellDofs), offsetBasis_(offsetBasis),
168  offsetTarget_(offsetTarget), numSideDofs_(numSideDofs) {}
169 
170  void
171  KOKKOS_INLINE_FUNCTION
172  operator()(const ordinal_type ic) const {
173 
174  for(ordinal_type j=0; j <numCellDofs_; ++j) {
175  ordinal_type idof = cellDof_(j);
176  for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq) {
177  nonWeightedBasisAtBasisEPoints_(0,j,iq) = basisAtBasisEPoints_(idof,offsetBasis_+iq);
178  wBasisAtBasisEPoints_(ic,j,iq) = nonWeightedBasisAtBasisEPoints_(0,j,iq) * basisEWeights_(iq);
179  }
180  for(ordinal_type iq=0; iq <ordinal_type(targetEWeights_.extent(0)); ++iq) {
181  wBasisAtTargetEPoints_(ic,j,iq) = basisAtTargetEPoints_(idof,offsetTarget_+iq)* targetEWeights_(iq);
182  }
183  }
184  for(ordinal_type j=0; j < numSideDofs_; ++j) {
185  ordinal_type jdof = computedDofs_(j);
186  for(ordinal_type iq=0; iq <ordinal_type(basisEWeights_.extent(0)); ++iq)
187  negPartialProjAtBasisEPoints_(ic,iq) -= basisCoeffs_(ic,jdof)*basisAtBasisEPoints_(jdof,offsetBasis_+iq);
188  }
189  }
190 };
191 
192 
193 template<typename ViewType1, typename ViewType2, typename ViewType3,
194 typename ViewType4, typename ViewType5>
196  const ViewType1 basisCoeffs_;
197  const ViewType1 negPartialProjAtBasisEPoints_;
198  const ViewType1 nonWeightedBasisAtBasisEPoints_;
199  const ViewType1 basisAtBasisEPoints_;
200  const ViewType1 hcurlBasisCurlAtBasisEPoints_;
201  const ViewType2 basisEWeights_;
202  const ViewType1 wHCurlBasisAtBasisEPoints_;
203  const ViewType2 targetEWeights_;
204  const ViewType1 hcurlBasisCurlAtTargetEPoints_;
205  const ViewType1 wHCurlBasisAtTargetEPoints_;
206  const ViewType3 tagToOrdinal_;
207  const ViewType4 computedDofs_;
208  const ViewType5 hCurlDof_;
209  ordinal_type numCellDofs_;
210  ordinal_type offsetBasis_;
211  ordinal_type numSideDofs_;
212  ordinal_type dim_;
213 
214  ComputeHCurlBasisCoeffsOnCells_HDiv(const ViewType1 basisCoeffs, ViewType1 negPartialProjAtBasisEPoints, const ViewType1 nonWeightedBasisAtBasisEPoints,
215  const ViewType1 basisAtBasisEPoints, const ViewType1 hcurlBasisCurlAtBasisEPoints, const ViewType2 basisEWeights, const ViewType1 wHCurlBasisAtBasisEPoints, const ViewType2 targetEWeights,
216  const ViewType1 hcurlBasisCurlAtTargetEPoints, const ViewType1 wHCurlBasisAtTargetEPoints, const ViewType3 tagToOrdinal, const ViewType4 computedDofs, const ViewType5 hCurlDof,
217  ordinal_type numCellDofs, ordinal_type offsetBasis, ordinal_type numSideDofs, ordinal_type dim) :
218  basisCoeffs_(basisCoeffs), negPartialProjAtBasisEPoints_(negPartialProjAtBasisEPoints), nonWeightedBasisAtBasisEPoints_(nonWeightedBasisAtBasisEPoints),
219  basisAtBasisEPoints_(basisAtBasisEPoints), hcurlBasisCurlAtBasisEPoints_(hcurlBasisCurlAtBasisEPoints), basisEWeights_(basisEWeights), wHCurlBasisAtBasisEPoints_(wHCurlBasisAtBasisEPoints), targetEWeights_(targetEWeights),
220  hcurlBasisCurlAtTargetEPoints_(hcurlBasisCurlAtTargetEPoints), wHCurlBasisAtTargetEPoints_(wHCurlBasisAtTargetEPoints),
221  tagToOrdinal_(tagToOrdinal), computedDofs_(computedDofs), hCurlDof_(hCurlDof),numCellDofs_(numCellDofs), offsetBasis_(offsetBasis),
222  numSideDofs_(numSideDofs), dim_(dim) {}
223 
224  void
225  KOKKOS_INLINE_FUNCTION
226  operator()(const ordinal_type ic) const {
227 
228  ordinal_type numBasisEPoints = basisEWeights_.extent(0);
229 
230  for(ordinal_type i=0; i<numSideDofs_; ++i) {
231  ordinal_type idof = computedDofs_(i);
232  for(ordinal_type iq=0; iq<numBasisEPoints; ++iq){
233  for(ordinal_type d=0; d <dim_; ++d)
234  negPartialProjAtBasisEPoints_(ic,iq,d) -= basisCoeffs_(ic,idof)*basisAtBasisEPoints_(idof,offsetBasis_+iq,d);
235  }
236  }
237 
238  for(ordinal_type i=0; i<numCellDofs_; ++i) {
239  ordinal_type idof = tagToOrdinal_(dim_, 0, i);
240  for(ordinal_type iq=0; iq<numBasisEPoints; ++iq) {
241  for(ordinal_type d=0; d<dim_; ++d)
242  nonWeightedBasisAtBasisEPoints_(0,i,iq,d) = basisAtBasisEPoints_(idof,offsetBasis_+iq,d);
243  }
244  }
245 
246  for(ordinal_type i=0; i<static_cast<ordinal_type>(hCurlDof_.extent(0)); ++i) {
247  ordinal_type idof = hCurlDof_(i);
248  for(ordinal_type d=0; d<dim_; ++d) {
249  for(ordinal_type iq=0; iq<numBasisEPoints; ++iq) {
250  wHCurlBasisAtBasisEPoints_(ic,i,iq,d) = hcurlBasisCurlAtBasisEPoints_(idof,iq,d)*basisEWeights_(iq);
251  }
252  for(ordinal_type iq=0; iq<static_cast<ordinal_type>(targetEWeights_.extent(0)); ++iq) {
253  wHCurlBasisAtTargetEPoints_(ic,i,iq,d) = hcurlBasisCurlAtTargetEPoints_(idof,iq,d)*targetEWeights_(iq);
254  }
255  }
256  }
257  }
258 };
259 } // FunctorsProjectionTools namespace
260 
261 
262 template<typename DeviceType>
263 template<typename basisCoeffsValueType, class ...basisCoeffsProperties,
264 typename funValsValueType, class ...funValsProperties,
265 typename BasisType,
266 typename ortValueType,class ...ortProperties>
267 void
268 ProjectionTools<DeviceType>::getHDivBasisCoeffs(Kokkos::DynRankView<basisCoeffsValueType,basisCoeffsProperties...> basisCoeffs,
269  const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtEPoints,
270  const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetDivAtDivEPoints,
271  const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
272  const BasisType* cellBasis,
274  typedef typename BasisType::scalarType scalarType;
275  typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
276  typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
277  const auto cellTopo = cellBasis->getBaseCellTopology();
278  ordinal_type dim = cellTopo.getDimension();
279  ordinal_type basisCardinality = cellBasis->getCardinality();
280  ordinal_type numCells = targetAtEPoints.extent(0);
281  const ordinal_type sideDim = dim-1;
282 
283  const std::string& name = cellBasis->getName();
284 
285  ordinal_type numSides = cellBasis->getBaseCellTopology().getSideCount();
286 
287  ordinal_type numSideDofs(0);
288  for(ordinal_type is=0; is<numSides; ++is)
289  numSideDofs += cellBasis->getDofCount(sideDim,is);
290 
291  Kokkos::View<ordinal_type*, DeviceType> computedDofs("computedDofs",numSideDofs);
292 
293  const Kokkos::RangePolicy<ExecSpaceType> policy(0, numCells);
294 
295  auto targetEPointsRange = projStruct->getTargetPointsRange();
296  auto basisEPointsRange = projStruct->getBasisPointsRange();
297 
298  auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), cellBasis->getAllDofOrdinal());
299 
300  ordinal_type numTotalBasisEPoints = projStruct->getNumBasisEvalPoints(), numTotalBasisDivEPoints = projStruct->getNumBasisDerivEvalPoints();
301  auto basisEPoints = projStruct->getAllEvalPoints(EvalPointsType::BASIS);
302  auto basisDivEPoints = projStruct->getAllDerivEvalPoints(EvalPointsType::BASIS);
303 
304  ordinal_type numTotalTargetEPoints = projStruct->getNumTargetEvalPoints(), numTotalTargetDivEPoints = projStruct->getNumTargetDerivEvalPoints();
305  auto targetEPoints = projStruct->getAllEvalPoints(EvalPointsType::TARGET);
306  auto targetDivEPoints = projStruct->getAllDerivEvalPoints(EvalPointsType::TARGET);
307 
308  ScalarViewType basisAtBasisEPoints("basisAtBasisEPoints",basisCardinality, numTotalBasisEPoints, dim);
309  ScalarViewType basisAtTargetEPoints("basisAtTargetEPoints",basisCardinality, numTotalTargetEPoints, dim);
310  cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
311  cellBasis->getValues(basisAtBasisEPoints, basisEPoints);
312 
313  ScalarViewType basisDivAtBasisDivEPoints;
314  ScalarViewType basisDivAtTargetDivEPoints;
315  if(numTotalTargetDivEPoints>0) {
316  basisDivAtBasisDivEPoints = ScalarViewType ("basisDivAtBasisDivEPoints",basisCardinality, numTotalBasisDivEPoints);
317  basisDivAtTargetDivEPoints = ScalarViewType("basisDivAtTargetDivEPoints",basisCardinality, numTotalTargetDivEPoints);
318  cellBasis->getValues(basisDivAtBasisDivEPoints, basisDivEPoints, OPERATOR_DIV);
319  cellBasis->getValues(basisDivAtTargetDivEPoints, targetDivEPoints, OPERATOR_DIV);
320  }
321 
322  ScalarViewType refBasisCoeffs("refBasisCoeffs", basisCoeffs.extent(0), basisCoeffs.extent(1));
323 
324  ordinal_type computedDofsCount = 0;
325  for(ordinal_type is=0; is<numSides; ++is) {
326 
327  ordinal_type sideCardinality = cellBasis->getDofCount(sideDim,is);
328 
329  ordinal_type numTargetEPoints = range_size(targetEPointsRange(sideDim,is));
330  ordinal_type numBasisEPoints = range_size(basisEPointsRange(sideDim,is));
331 
332  auto sideDofs = Kokkos::subview(tagToOrdinal, sideDim, is, range_type(0,sideCardinality));
333  auto computedSideDofs = Kokkos::subview(computedDofs, range_type(computedDofsCount,computedDofsCount+sideCardinality));
334  deep_copy(computedSideDofs, sideDofs);
335  computedDofsCount += sideCardinality;
336 
337  ScalarViewType refSideNormal("refSideNormal", dim);
338  CellTools<DeviceType>::getReferenceSideNormal(refSideNormal, is, cellTopo);
339 
340  ScalarViewType basisNormalAtBasisEPoints("normalBasisAtBasisEPoints",1,sideCardinality, numBasisEPoints);
341  ScalarViewType wBasisNormalAtBasisEPoints("wBasisNormalAtBasisEPoints",1,sideCardinality, numBasisEPoints);
342  ScalarViewType wBasisNormalAtTargetEPoints("wBasisNormalAtTargetEPoints",numCells,sideCardinality, numTargetEPoints);
343  ScalarViewType targetNormalAtTargetEPoints("targetNormalAtTargetEPoints",numCells, numTargetEPoints);
344 
345  ordinal_type offsetBasis = basisEPointsRange(sideDim,is).first;
346  ordinal_type offsetTarget = targetEPointsRange(sideDim,is).first;
347  auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetEvalWeights(sideDim,is));
348  auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisEvalWeights(sideDim,is));
349 
351  Kokkos::parallel_for(Kokkos::MDRangePolicy<ExecSpaceType, Kokkos::Rank<2> >({0,0}, {sideCardinality,numBasisEPoints}),
352  functorTypeWBasisEdge(basisNormalAtBasisEPoints,wBasisNormalAtBasisEPoints,basisAtBasisEPoints,basisEWeights,refSideNormal,tagToOrdinal,sideDim,is,offsetBasis));
353 
355  Kokkos::parallel_for(policy, functorTypeSide(targetEWeights,
356  basisAtTargetEPoints, wBasisNormalAtTargetEPoints, tagToOrdinal,
357  targetAtEPoints, targetNormalAtTargetEPoints,
358  refSideNormal, sideCardinality,
359  offsetTarget, sideDim,
360  dim, is));
361 
362  ScalarViewType sideMassMat_("sideMassMat_", 1, sideCardinality+1, sideCardinality+1),
363  sideRhsMat_("rhsMat_", numCells, sideCardinality+1);
364 
365  ScalarViewType targetEWeights_("targetEWeights", numCells, 1, targetEWeights.extent(0));
366  RealSpaceTools<DeviceType>::clone(targetEWeights_, targetEWeights);
367 
368  range_type range_H(0, sideCardinality);
369  range_type range_B(sideCardinality, sideCardinality+1);
370  ScalarViewType ones("ones",1,1,numBasisEPoints);
371  Kokkos::deep_copy(ones,1);
372 
373  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(sideMassMat_, Kokkos::ALL(), range_H, range_H), basisNormalAtBasisEPoints, wBasisNormalAtBasisEPoints);
374  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(sideMassMat_, Kokkos::ALL(), range_H, range_B), wBasisNormalAtBasisEPoints, ones);
375 
376  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(sideRhsMat_, Kokkos::ALL(), range_H), targetNormalAtTargetEPoints, wBasisNormalAtTargetEPoints);
377  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(sideRhsMat_, Kokkos::ALL(), range_B), targetNormalAtTargetEPoints, targetEWeights_);
378 
379  typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
380  ScalarViewType t_("t",numCells, sideCardinality+1);
381  WorkArrayViewType w_("w",numCells, sideCardinality+1);
382 
383  auto sideDof = Kokkos::subview(tagToOrdinal, sideDim, is, Kokkos::ALL());
384 
385  ElemSystem sideSystem("sideSystem", true);
386  sideSystem.solve(refBasisCoeffs, sideMassMat_, sideRhsMat_, t_, w_, sideDof, sideCardinality, 1);
387  }
388 
389 
390  //Cell
391  ordinal_type numCellDofs = cellBasis->getDofCount(dim,0);
392  if(numCellDofs!=0) {
393  Basis<DeviceType,scalarType,scalarType> *hcurlBasis = NULL;
394  if(cellTopo.getKey() == shards::getCellTopologyData<shards::Hexahedron<8> >()->key)
395  hcurlBasis = new Basis_HCURL_HEX_In_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree());
396  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Tetrahedron<4> >()->key)
397  hcurlBasis = new Basis_HCURL_TET_In_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree());
398  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Wedge<6> >()->key)
399  hcurlBasis = new typename DerivedNodalBasisFamily<DeviceType,scalarType,scalarType>::HCURL_WEDGE(cellBasis->getDegree());
400  // TODO: uncomment the next two lines once H(curl) pyramid implemented
401  // else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Pyramid<5> >()->key)
402  // hcurlBasis = new typename DerivedNodalBasisFamily<DeviceType,scalarType,scalarType>::HCURL_PYR(cellBasis->getDegree());
403  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Quadrilateral<4> >()->key)
404  hcurlBasis = new Basis_HGRAD_QUAD_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree());
405  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Triangle<3> >()->key)
406  hcurlBasis = new Basis_HGRAD_TRI_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree());
407  else {
408  std::stringstream ss;
409  ss << ">>> ERROR (Intrepid2::ProjectionTools::getHDivBasisCoeffs): "
410  << "Method not implemented for basis " << name;
411  INTREPID2_TEST_FOR_EXCEPTION( true, std::runtime_error, ss.str().c_str() );
412  }
413  if(hcurlBasis == NULL) return;
414 
415 
416  auto targetDivEPointsRange = projStruct->getTargetDerivPointsRange();
417  auto basisDivEPointsRange = projStruct->getBasisDerivPointsRange();
418 
419  ordinal_type numTargetDivEPoints = range_size(targetDivEPointsRange(dim,0));
420  ordinal_type numBasisDivEPoints = range_size(basisDivEPointsRange(dim,0));
421 
422  auto targetDivEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetDerivEvalWeights(dim,0));
423  auto divEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisDerivEvalWeights(dim,0));
424 
425  ordinal_type offsetBasisDiv = basisDivEPointsRange(dim,0).first;
426  ordinal_type offsetTargetDiv = targetDivEPointsRange(dim,0).first;
427 
428  ScalarViewType weightedBasisDivAtBasisEPoints("weightedBasisDivAtBasisEPoints",numCells,numCellDofs, numBasisDivEPoints);
429  ScalarViewType weightedBasisDivAtTargetEPoints("weightedBasisDivAtTargetEPoints",numCells, numCellDofs, numTargetDivEPoints);
430  ScalarViewType basisDivAtBasisEPoints("basisDivAtBasisEPoints",1,numCellDofs, numBasisDivEPoints);
431  ScalarViewType targetSideDivAtBasisEPoints("targetSideDivAtBasisEPoints",numCells, numBasisDivEPoints);
432 
433  auto cellDofs = Kokkos::subview(tagToOrdinal, dim, 0, Kokkos::ALL());
435  Kokkos::parallel_for(policy, functorType( refBasisCoeffs, targetSideDivAtBasisEPoints, basisDivAtBasisEPoints,
436  basisDivAtBasisDivEPoints, divEWeights, weightedBasisDivAtBasisEPoints, targetDivEWeights, basisDivAtTargetDivEPoints, weightedBasisDivAtTargetEPoints,
437  computedDofs, cellDofs, numCellDofs, offsetBasisDiv, offsetTargetDiv, numSideDofs));
438 
439 
440  ordinal_type hcurlBasisCardinality = hcurlBasis->getCardinality();
441  ordinal_type numCurlInteriorDOFs = hcurlBasis->getDofCount(dim,0);
442 
443  range_type range_H(0, numCellDofs);
444  range_type range_B(numCellDofs, numCellDofs+numCurlInteriorDOFs);
445 
446 
447  ScalarViewType massMat_("massMat_",1,numCellDofs+numCurlInteriorDOFs,numCellDofs+numCurlInteriorDOFs),
448  rhsMatTrans("rhsMatTrans",numCells,numCellDofs+numCurlInteriorDOFs);
449 
450  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(massMat_, Kokkos::ALL(), range_H,range_H), basisDivAtBasisEPoints, Kokkos::subview(weightedBasisDivAtBasisEPoints, std::make_pair(0,1), Kokkos::ALL(), Kokkos::ALL()) );
451  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(rhsMatTrans, Kokkos::ALL(), range_H), targetDivAtDivEPoints, weightedBasisDivAtTargetEPoints);
452  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(rhsMatTrans, Kokkos::ALL(), range_H), targetSideDivAtBasisEPoints, weightedBasisDivAtBasisEPoints,true);
453 
454  if(numCurlInteriorDOFs>0){
455  ordinal_type numTargetEPoints = range_size(targetEPointsRange(dim,0));
456  ordinal_type numBasisEPoints = range_size(basisEPointsRange(dim,0));
457 
458  auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetEvalWeights(dim,0));
459  auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisEvalWeights(dim,0));
460 
461  ordinal_type offsetBasis = basisEPointsRange(dim,0).first;
462 
463  ScalarViewType negPartialProjAtBasisEPoints("targetSideAtBasisEPoints",numCells, numBasisEPoints, dim);
464  ScalarViewType nonWeightedBasisAtBasisEPoints("basisAtBasisEPoints",1,numCellDofs, numBasisEPoints, dim);
465  ScalarViewType hcurlBasisCurlAtBasisEPoints("hcurlBasisCurlAtBasisEPoints",hcurlBasisCardinality, numBasisEPoints,dim);
466  ScalarViewType hcurlBasisCurlAtTargetEPoints("hcurlBasisCurlAtTargetEPoints", hcurlBasisCardinality,numTargetEPoints, dim);
467  ScalarViewType wHcurlBasisCurlAtBasisEPoints("wHcurlBasisHcurlAtBasisEPoints", numCells, numCurlInteriorDOFs, numBasisEPoints,dim);
468  ScalarViewType wHcurlBasisCurlAtTargetEPoints("wHcurlBasisHcurlAtTargetEPoints",numCells, numCurlInteriorDOFs, numTargetEPoints,dim);
469 
470  hcurlBasis->getValues(hcurlBasisCurlAtBasisEPoints, Kokkos::subview(basisEPoints, basisEPointsRange(dim,0), Kokkos::ALL()), OPERATOR_CURL);
471  hcurlBasis->getValues(hcurlBasisCurlAtTargetEPoints, Kokkos::subview(targetEPoints,targetEPointsRange(dim,0),Kokkos::ALL()), OPERATOR_CURL);
472 
473  auto hCurlTagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), hcurlBasis->getAllDofOrdinal());
474  auto cellHCurlDof = Kokkos::subview(hCurlTagToOrdinal, dim, 0, range_type(0, numCurlInteriorDOFs));
475 
476  using functorTypeHCurlCells = FunctorsProjectionTools::ComputeHCurlBasisCoeffsOnCells_HDiv<ScalarViewType, decltype(divEWeights),
477  decltype(tagToOrdinal), decltype(computedDofs), decltype(cellDofs)>;
478  Kokkos::parallel_for(policy, functorTypeHCurlCells(refBasisCoeffs, negPartialProjAtBasisEPoints, nonWeightedBasisAtBasisEPoints,
479  basisAtBasisEPoints, hcurlBasisCurlAtBasisEPoints, basisEWeights, wHcurlBasisCurlAtBasisEPoints, targetEWeights,
480  hcurlBasisCurlAtTargetEPoints, wHcurlBasisCurlAtTargetEPoints, tagToOrdinal, computedDofs, cellHCurlDof,
481  numCellDofs, offsetBasis, numSideDofs, dim));
482 
483  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(massMat_, Kokkos::ALL(), range_H,range_B), nonWeightedBasisAtBasisEPoints, Kokkos::subview(wHcurlBasisCurlAtBasisEPoints, std::make_pair(0,1), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()) );
484  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(rhsMatTrans, Kokkos::ALL(), range_B), Kokkos::subview(targetAtEPoints, Kokkos::ALL(), targetEPointsRange(dim,0), Kokkos::ALL()), wHcurlBasisCurlAtTargetEPoints);
485  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(rhsMatTrans, Kokkos::ALL(), range_B), negPartialProjAtBasisEPoints, wHcurlBasisCurlAtBasisEPoints,true);
486  }
487  delete hcurlBasis;
488 
489  typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
490  ScalarViewType t_("t",numCells, numCellDofs+numCurlInteriorDOFs);
491  WorkArrayViewType w_("w",numCells, numCellDofs+numCurlInteriorDOFs);
492 
493  ElemSystem cellSystem("cellSystem", true);
494  cellSystem.solve(refBasisCoeffs, massMat_, rhsMatTrans, t_, w_, cellDofs, numCellDofs, numCurlInteriorDOFs);
495  }
496 
497  OrientationTools<DeviceType>::modifyBasisByOrientationInverse(basisCoeffs, refBasisCoeffs, orts, cellBasis, true);
498 
499 }
500 
501 } // Intrepid2 namespace
502 
503 #endif
504 
Header file for the abstract base class Intrepid2::DefaultCubatureFactory.
ordinal_type getCardinality() const
Returns cardinality of the basis.
virtual void getValues(const ExecutionSpace &, OutputViewType, const PointViewType, const EOperator=OPERATOR_VALUE) const
Evaluation of a FEM basis on a reference cell.
ordinal_type getNumBasisDerivEvalPoints()
Returns number of evaluation points for basis derivatives.
const range_tag getBasisPointsRange() const
Returns the range tag of the basis evaluation points subcells.
Implementation of the default H(curl)-compatible Nedelec (first kind) basis of arbitrary degree on Te...
const range_tag getTargetDerivPointsRange() const
Returns the range tag of the target function derivative evaluation points on subcells.
host_view_type getTargetDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function derivatives evaluation weights on a subcell.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
ordinal_type getNumBasisEvalPoints()
Returns number of basis evaluation points.
Implementation of the default H(curl)-compatible FEM basis on Hexahedron cell.
void solve(ViewType1 basisCoeffs, ViewType2 elemMat, ViewType2 elemRhs, ViewType2 tau, ViewType3 w, const ViewType4 elemDof, ordinal_type n, ordinal_type m=0)
Solve the system and returns the basis coefficients solve the system either using Kokkos Kernel QR or...
static void getHDivBasisCoeffs(Kokkos::DynRankView< basisCoeffsValueType, basisCoeffsProperties...> basisCoeffs, const Kokkos::DynRankView< funValsValueType, funValsProperties...> targetAtEvalPoints, const Kokkos::DynRankView< funValsValueType, funValsProperties...> targetDivAtDivEvalPoints, const Kokkos::DynRankView< ortValueType, ortProperties...> cellOrientations, const BasisType *cellBasis, ProjectionStruct< DeviceType, typename BasisType::scalarType > *projStruct)
Computes the basis coefficients of the HDiv projection of the target function.
static void clone(Kokkos::DynRankView< outputValueType, outputProperties...> output, const Kokkos::DynRankView< inputValueType, inputProperties...> input)
Clone input array.
const OrdinalTypeArray3DHost getAllDofOrdinal() const
DoF tag to ordinal data structure.
Header file for the Intrepid2::FunctionSpaceTools class.
static void getReferenceSideNormal(RefSideNormalViewType refSideNormal, const ordinal_type sideOrd, const shards::CellTopology parentCell)
Computes constant normal vectors to sides of 2D or 3D reference cells.
view_type getAllDerivEvalPoints(EvalPointsType type=TARGET) const
Returns all the evaluation points for basis/target derivatives in the cell.
view_type getAllEvalPoints(EvalPointsType type=TARGET) const
Returns the basis/target evaluation points in the cell.
host_view_type getBasisEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis evaluation weights on a subcell.
ordinal_type getNumTargetEvalPoints()
Returns number of points where to evaluate the target function.
const range_tag getBasisDerivPointsRange() const
Returns the range tag of the derivative evaluation points on subcell.
Header file for Intrepid2::ArrayTools class providing utilities for array operations.
static void integrate(Kokkos::DynRankView< outputValueValueType, outputValueProperties...> outputValues, const Kokkos::DynRankView< leftValueValueType, leftValueProperties...> leftValues, const Kokkos::DynRankView< rightValueValueType, rightValueProperties...> rightValues, const bool sumInto=false)
Contracts leftValues and rightValues arrays on the point and possibly space dimensions and stores the...
const range_tag getTargetPointsRange() const
Returns the range of the target function evaluation points on subcells.
host_view_type getBasisDerivEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the basis derivatives evaluation weights on a subcell.
Implementation of the default H(grad)-compatible Lagrange basis of arbitrary degree on Triangle cell...
ordinal_type getNumTargetDerivEvalPoints()
Returns number of points where to evaluate the derivatives of the target function.
host_view_type getTargetEvalWeights(const ordinal_type subCellDim, const ordinal_type subCellId)
Returns the function evaluation weights on a subcell.
ordinal_type getDofCount(const ordinal_type subcDim, const ordinal_type subcOrd) const
DoF count for specified subcell.
Implementation of the default H(grad)-compatible FEM basis of degree n on Quadrilateral cell Implemen...
Class to solve a square system A x = b on each cell A is expected to be saddle a point (KKT) matrix o...
An helper class to compute the evaluation points and weights needed for performing projections...
static void modifyBasisByOrientationInverse(Kokkos::DynRankView< outputValueType, outputProperties...> output, const Kokkos::DynRankView< inputValueType, inputProperties...> input, const OrientationViewType orts, const BasisType *basis, const bool transpose=false)
Modify basis due to orientation, applying the inverse of the operator applied in modifyBasisByOrienta...