Intrepid2
Intrepid2_ProjectionToolsDefHCURL.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_PROJECTIONTOOLSDEFHCURL_HPP__
50 #define __INTREPID2_PROJECTIONTOOLSDEFHCURL_HPP__
51 
53 #include "Intrepid2_ArrayTools.hpp"
56 
57 
58 namespace Intrepid2 {
59 
60 namespace FunctorsProjectionTools {
61 
62 
63 template<typename ViewType1, typename ViewType2, typename ViewType3>
65  ViewType1 basisTanAtBasisEPoints_;
66  ViewType1 weightedTanBasisAtBasisEPoints_;
67  const ViewType1 basisAtBasisEPoints_;
68  const ViewType2 basisEWeights_;
69  const ViewType1 refEdgeTangent_;
70  const ViewType3 tagToOrdinal_;
71  ordinal_type edgeDim_;
72  ordinal_type iedge_;
73  ordinal_type offsetBasis_;
74 
75  ComputeWBasisEdge_HCurl(ViewType1 basisTanAtBasisEPoints, ViewType1 weightedTanBasisAtBasisEPoints,
76  ViewType1 basisAtBasisEPoints, ViewType2 basisEWeights, ViewType1 refEdgeTangent, ViewType3 tagToOrdinal,
77  ordinal_type edgeDim, ordinal_type iedge, ordinal_type offsetBasis) :
78  basisTanAtBasisEPoints_(basisTanAtBasisEPoints), weightedTanBasisAtBasisEPoints_(weightedTanBasisAtBasisEPoints), basisAtBasisEPoints_(basisAtBasisEPoints),
79  basisEWeights_(basisEWeights), refEdgeTangent_(refEdgeTangent), tagToOrdinal_(tagToOrdinal),
80  edgeDim_(edgeDim), iedge_(iedge), offsetBasis_(offsetBasis) {}
81 
82  void
83  KOKKOS_INLINE_FUNCTION
84  operator()(const ordinal_type j, const ordinal_type iq) const {
85  ordinal_type jdof = tagToOrdinal_(edgeDim_, iedge_, j);
86  for(ordinal_type d=0; d <ordinal_type(refEdgeTangent_.extent(0)); ++d)
87  basisTanAtBasisEPoints_(0,j,iq) += refEdgeTangent_(d)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
88  weightedTanBasisAtBasisEPoints_(0,j,iq) = basisTanAtBasisEPoints_(0,j,iq)*basisEWeights_(iq);
89  }
90 };
91 
92 template<typename ViewType1, typename ViewType2, typename ViewType3, typename ViewType4>
94  const ViewType2 targetEWeights_;
95  const ViewType1 basisAtTargetEPoints_;
96  const ViewType1 wTanBasisAtTargetEPoints_;
97  const ViewType3 tagToOrdinal_;
98  const ViewType4 targetAtTargetEPoints_;
99  const ViewType1 targetTanAtTargetEPoints_;
100  const ViewType1 refEdgeTangent_;
101  ordinal_type edgeCardinality_;
102  ordinal_type offsetTarget_;
103  ordinal_type edgeDim_;
104  ordinal_type dim_;
105  ordinal_type iedge_;
106 
108  const ViewType2 targetEWeights,
109  const ViewType1 basisAtTargetEPoints, const ViewType1 wTanBasisAtTargetEPoints, const ViewType3 tagToOrdinal,
110  const ViewType4 targetAtTargetEPoints, const ViewType1 targetTanAtTargetEPoints,
111  const ViewType1 refEdgeTangent, ordinal_type edgeCardinality,
112  ordinal_type offsetTarget, ordinal_type edgeDim,
113  ordinal_type dim, ordinal_type iedge) :
114  targetEWeights_(targetEWeights),
115  basisAtTargetEPoints_(basisAtTargetEPoints), wTanBasisAtTargetEPoints_(wTanBasisAtTargetEPoints),
116  tagToOrdinal_(tagToOrdinal), targetAtTargetEPoints_(targetAtTargetEPoints),
117  targetTanAtTargetEPoints_(targetTanAtTargetEPoints),
118  refEdgeTangent_(refEdgeTangent), edgeCardinality_(edgeCardinality),
119  offsetTarget_(offsetTarget), edgeDim_(edgeDim), dim_(dim), iedge_(iedge)
120  {}
121 
122  void
123  KOKKOS_INLINE_FUNCTION
124  operator()(const ordinal_type ic) const {
125 
126  ordinal_type numTargetEPoints = targetEWeights_.extent(0);
127  typename ViewType1::value_type tmp = 0;
128  for(ordinal_type j=0; j <edgeCardinality_; ++j) {
129  ordinal_type jdof = tagToOrdinal_(edgeDim_, iedge_, j);
130  for(ordinal_type iq=0; iq <numTargetEPoints; ++iq) {
131  tmp = 0;
132  for(ordinal_type d=0; d <dim_; ++d)
133  tmp += refEdgeTangent_(d)*basisAtTargetEPoints_(jdof,offsetTarget_+iq,d);
134  wTanBasisAtTargetEPoints_(ic,j,iq) = tmp*targetEWeights_(iq);
135  }
136  }
137  for(ordinal_type iq=0; iq <numTargetEPoints; ++iq)
138  for(ordinal_type d=0; d <dim_; ++d)
139  targetTanAtTargetEPoints_(ic,iq) += refEdgeTangent_(d)*targetAtTargetEPoints_(ic,offsetTarget_+iq,d);
140  }
141 };
142 
143 
144 template<typename ViewType1, typename ViewType2, typename ViewType3, typename ViewType4,
145 typename ViewType5>
147  const ViewType1 basisCoeffs_;
148  const ViewType1 negPartialProjTan_;
149  const ViewType1 negPartialProjCurlNormal_;
150  const ViewType1 hgradBasisGradAtBasisEPoints_;
151  const ViewType1 wHgradBasisGradAtBasisEPoints_;
152  const ViewType1 basisCurlAtBasisCurlEPoints_;
153  const ViewType1 basisCurlNormalAtBasisCurlEPoints_;
154  const ViewType1 basisAtBasisEPoints_;
155  const ViewType1 normalTargetCurlAtTargetEPoints_;
156  const ViewType1 basisTanAtBasisEPoints_;
157  const ViewType1 hgradBasisGradAtTargetEPoints_;
158  const ViewType1 wHgradBasisGradAtTargetEPoints_;
159  const ViewType1 wNormalBasisCurlAtBasisCurlEPoints_;
160  const ViewType1 basisCurlAtTargetCurlEPoints_;
161  const ViewType1 wNormalBasisCurlBasisAtTargetCurlEPoints_;
162  const ViewType2 targetAtTargetEPoints_;
163  const ViewType1 targetTanAtTargetEPoints_;
164  const ViewType2 targetCurlAtTargetCurlEPoints_;
165  const ViewType3 basisEWeights_;
166  const ViewType3 targetEWeights_;
167  const ViewType3 basisCurlEWeights_;
168  const ViewType3 targetCurlEWeights_;
169  const ViewType4 tagToOrdinal_;
170  const ViewType4 hGradTagToOrdinal_;
171  const ViewType5 computedDofs_;
172  const ViewType1 refFaceNormal_;
173  ordinal_type offsetBasis_;
174  ordinal_type offsetBasisCurl_;
175  ordinal_type offsetTarget_;
176  ordinal_type offsetTargetCurl_;
177  ordinal_type iface_;
178  ordinal_type hgradCardinality_;
179  ordinal_type numFaces_;
180  ordinal_type numFaceDofs_;
181  ordinal_type numEdgeDofs_;
182  ordinal_type faceDim_;
183  ordinal_type dim_;
184 
185 
186 
187 
188  ComputeBasisCoeffsOnFaces_HCurl(const ViewType1 basisCoeffs,
189  const ViewType1 negPartialProjTan, const ViewType1 negPartialProjCurlNormal,
190  const ViewType1 hgradBasisGradAtBasisEPoints, const ViewType1 wHgradBasisGradAtBasisEPoints,
191  const ViewType1 basisCurlAtBasisCurlEPoints, const ViewType1 basisCurlNormalAtBasisCurlEPoints,
192  const ViewType1 basisAtBasisEPoints,
193  const ViewType1 normalTargetCurlAtTargetEPoints,
194  const ViewType1 basisTanAtBasisEPoints,
195  const ViewType1 hgradBasisGradAtTargetEPoints, const ViewType1 wHgradBasisGradAtTargetEPoints,
196  const ViewType1 wNormalBasisCurlAtBasisCurlEPoints, const ViewType1 basisCurlAtTargetCurlEPoints,
197  const ViewType1 wNormalBasisCurlBasisAtTargetCurlEPoints, const ViewType2 targetAtTargetEPoints,
198  const ViewType1 targetTanAtTargetEPoints, const ViewType2 targetCurlAtTargetCurlEPoints,
199  const ViewType3 basisEWeights, const ViewType3 targetEWeights,
200  const ViewType3 basisCurlEWeights, const ViewType3 targetCurlEWeights, const ViewType4 tagToOrdinal,
201  const ViewType4 hGradTagToOrdinal, const ViewType5 computedDofs,
202  const ViewType1 refFaceNormal , ordinal_type offsetBasis,
203  ordinal_type offsetBasisCurl, ordinal_type offsetTarget,
204  ordinal_type offsetTargetCurl, ordinal_type iface,
205  ordinal_type hgradCardinality, ordinal_type numFaces,
206  ordinal_type numFaceDofs, ordinal_type numEdgeDofs,
207  ordinal_type faceDim, ordinal_type dim):
208  basisCoeffs_(basisCoeffs),
209  negPartialProjTan_(negPartialProjTan), negPartialProjCurlNormal_(negPartialProjCurlNormal),
210  hgradBasisGradAtBasisEPoints_(hgradBasisGradAtBasisEPoints), wHgradBasisGradAtBasisEPoints_(wHgradBasisGradAtBasisEPoints),
211  basisCurlAtBasisCurlEPoints_(basisCurlAtBasisCurlEPoints), basisCurlNormalAtBasisCurlEPoints_(basisCurlNormalAtBasisCurlEPoints),
212  basisAtBasisEPoints_(basisAtBasisEPoints),
213  normalTargetCurlAtTargetEPoints_(normalTargetCurlAtTargetEPoints), basisTanAtBasisEPoints_(basisTanAtBasisEPoints),
214  hgradBasisGradAtTargetEPoints_(hgradBasisGradAtTargetEPoints), wHgradBasisGradAtTargetEPoints_(wHgradBasisGradAtTargetEPoints),
215  wNormalBasisCurlAtBasisCurlEPoints_(wNormalBasisCurlAtBasisCurlEPoints), basisCurlAtTargetCurlEPoints_(basisCurlAtTargetCurlEPoints),
216  wNormalBasisCurlBasisAtTargetCurlEPoints_(wNormalBasisCurlBasisAtTargetCurlEPoints), targetAtTargetEPoints_(targetAtTargetEPoints),
217  targetTanAtTargetEPoints_(targetTanAtTargetEPoints), targetCurlAtTargetCurlEPoints_(targetCurlAtTargetCurlEPoints),
218  basisEWeights_(basisEWeights), targetEWeights_(targetEWeights),
219  basisCurlEWeights_(basisCurlEWeights), targetCurlEWeights_(targetCurlEWeights), tagToOrdinal_(tagToOrdinal),
220  hGradTagToOrdinal_(hGradTagToOrdinal), computedDofs_(computedDofs),
221  refFaceNormal_(refFaceNormal), offsetBasis_(offsetBasis),
222  offsetBasisCurl_(offsetBasisCurl), offsetTarget_(offsetTarget),
223  offsetTargetCurl_(offsetTargetCurl), iface_(iface),
224  hgradCardinality_(hgradCardinality), numFaces_(numFaces),
225  numFaceDofs_(numFaceDofs), numEdgeDofs_(numEdgeDofs),
226  faceDim_(faceDim), dim_(dim){}
227 
228  void
229  KOKKOS_INLINE_FUNCTION
230  operator()(const ordinal_type ic) const {
231 
232  typename ViewType1::value_type n[3] = {refFaceNormal_(0), refFaceNormal_(1), refFaceNormal_(2)};
233  typename ViewType1::value_type tmp=0;
234 
235  ordinal_type numBasisEPoints = basisEWeights_.extent(0);
236  ordinal_type numTargetEPoints = targetEWeights_.extent(0);
237  for(ordinal_type j=0; j <hgradCardinality_; ++j) {
238  ordinal_type face_dof = hGradTagToOrdinal_(faceDim_, iface_, j);
239  for(ordinal_type iq=0; iq <numBasisEPoints; ++iq) {
240  for(ordinal_type d=0; d <dim_; ++d) {
241  ordinal_type dp1 = (d+1) % dim_;
242  ordinal_type dp2 = (d+2) % dim_;
243  // basis \times n
244  wHgradBasisGradAtBasisEPoints_(ic,j,iq,d) = (hgradBasisGradAtBasisEPoints_(face_dof,iq,dp1)*n[dp2] - hgradBasisGradAtBasisEPoints_(face_dof,iq,dp2)*n[dp1]) * basisEWeights_(iq);
245  }
246  }
247 
248  for(ordinal_type iq=0; iq <numTargetEPoints; ++iq) {
249  for(ordinal_type d=0; d <dim_; ++d) {
250  ordinal_type dp1 = (d+1) % dim_;
251  ordinal_type dp2 = (d+2) % dim_;
252  wHgradBasisGradAtTargetEPoints_(ic,j,iq,d) = (hgradBasisGradAtTargetEPoints_(face_dof,iq,dp1)*n[dp2] - hgradBasisGradAtTargetEPoints_(face_dof,iq,dp2)*n[dp1]) * targetEWeights_(iq);
253  }
254  }
255  }
256 
257  ordinal_type numBasisCurlEPoints = basisCurlEWeights_.extent(0);
258  for(ordinal_type j=0; j <numFaceDofs_; ++j) {
259  ordinal_type jdof = tagToOrdinal_(faceDim_, iface_, j);
260  for(ordinal_type iq=0; iq <numBasisEPoints; ++iq) {
261  for(ordinal_type d=0; d <dim_; ++d) {
262  ordinal_type dp1 = (d+1) % dim_;
263  ordinal_type dp2 = (d+2) % dim_;
264  // basis \times n
265  basisTanAtBasisEPoints_(0,j,iq,d) = basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp1)*n[dp2] - basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp2)*n[dp1];
266  }
267  }
268  //Note: we are not considering the jacobian of the orientation map for normals since it is simply a scalar term for the integrals and it does not affect the projection
269  for(ordinal_type iq=0; iq <numBasisCurlEPoints; ++iq) {
270  tmp=0;
271  for(ordinal_type d=0; d <dim_; ++d)
272  tmp += n[d]*basisCurlAtBasisCurlEPoints_(jdof,offsetBasisCurl_+iq,d);
273  basisCurlNormalAtBasisCurlEPoints_(0,j,iq) = tmp;
274  wNormalBasisCurlAtBasisCurlEPoints_(ic,j,iq) = tmp * basisCurlEWeights_(iq);
275  }
276 
277  ordinal_type numTargetCurlEPoints = targetCurlEWeights_.extent(0);
278  for(ordinal_type iq=0; iq <numTargetCurlEPoints; ++iq) {
279  tmp=0;
280  // target \cdot n
281  for(ordinal_type d=0; d <dim_; ++d)
282  tmp += n[d]*basisCurlAtTargetCurlEPoints_(jdof,offsetTargetCurl_+iq,d);
283  wNormalBasisCurlBasisAtTargetCurlEPoints_(ic,j,iq) = tmp*targetCurlEWeights_(iq);
284  }
285  }
286 
287  for(ordinal_type j=0; j <numEdgeDofs_; ++j) {
288  ordinal_type jdof = computedDofs_(j);
289  for(ordinal_type iq=0; iq <numBasisEPoints; ++iq)
290  for(ordinal_type d=0; d <dim_; ++d) {
291  ordinal_type dp1 = (d+1) % dim_;
292  ordinal_type dp2 = (d+2) % dim_;
293  negPartialProjCurlNormal_(ic,iq) -= n[d]*basisCoeffs_(ic,jdof)*basisCurlAtBasisCurlEPoints_(jdof,offsetBasisCurl_+iq,d);
294  // basis \times n
295  negPartialProjTan_(ic,iq,d) -= (basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp1)*n[dp2] - basisAtBasisEPoints_(jdof,offsetBasis_+iq,dp2)*n[dp1])*basisCoeffs_(ic,jdof);
296  }
297  }
298 
299  ordinal_type numTargetCurlEPoints = targetCurlEWeights_.extent(0);
300  for(ordinal_type iq=0; iq <numTargetEPoints; ++iq)
301  for(ordinal_type d=0; d <dim_; ++d) {
302  ordinal_type dp1 = (d+1) % dim_;
303  ordinal_type dp2 = (d+2) % dim_;
304  // target \times n
305  targetTanAtTargetEPoints_(ic,iq,d) = (targetAtTargetEPoints_(ic,offsetTarget_+iq,dp1)*n[dp2] - targetAtTargetEPoints_(ic,offsetTarget_+iq,dp2)*n[dp1]);
306  }
307 
308  for(ordinal_type iq=0; iq <numTargetCurlEPoints; ++iq)
309  for(ordinal_type d=0; d <dim_; ++d) {
310  // target \cdot n
311  normalTargetCurlAtTargetEPoints_(ic,iq) += n[d]*targetCurlAtTargetCurlEPoints_(ic,offsetTargetCurl_+iq,d);
312  }
313  }
314 };
315 
316 
317 template<typename ViewType1, typename ViewType2, typename ViewType3,
318 typename ViewType4>
320  const ViewType1 basisCoeffs_;
321  const ViewType1 negPartialProj_;
322  const ViewType1 negPartialProjCurl_;
323  const ViewType1 cellBasisAtBasisEPoints_;
324  const ViewType1 cellBasisCurlAtBasisCurlEPoints_;
325  const ViewType1 basisAtBasisEPoints_;
326  const ViewType1 hgradBasisGradAtBasisEPoints_;
327  const ViewType1 basisCurlAtBasisCurlEPoints_;
328  const ViewType1 hgradBasisGradAtTargetEPoints_;
329  const ViewType1 basisCurlAtTargetCurlEPoints_;
330  const ViewType2 basisEWeights_;
331  const ViewType2 basisCurlEWeights_;
332  const ViewType1 wHgradBasisGradAtBasisEPoints_;
333  const ViewType1 wBasisCurlAtBasisCurlEPoints_;
334  const ViewType2 targetEWeights_;
335  const ViewType2 targetCurlEWeights_;
336  const ViewType1 wHgradBasisGradAtTargetEPoints_;
337  const ViewType1 wBasisCurlAtTargetCurlEPoints_;
338  const ViewType3 computedDofs_;
339  const ViewType4 tagToOrdinal_;
340  const ViewType4 hGradTagToOrdinal_;
341  ordinal_type numCellDofs_;
342  ordinal_type hgradCardinality_;
343  ordinal_type offsetBasis_;
344  ordinal_type offsetBasisCurl_;
345  ordinal_type offsetTargetCurl_;
346  ordinal_type numEdgeFaceDofs_;
347  ordinal_type dim_;
348  ordinal_type derDim_;
349 
350  ComputeBasisCoeffsOnCell_HCurl(const ViewType1 basisCoeffs, ViewType1 negPartialProj, ViewType1 negPartialProjCurl,
351  const ViewType1 cellBasisAtBasisEPoints, const ViewType1 cellBasisCurlAtBasisCurlEPoints,
352  const ViewType1 basisAtBasisEPoints, const ViewType1 hgradBasisGradAtBasisEPoints, const ViewType1 basisCurlAtBasisCurlEPoints,
353  const ViewType1 hgradBasisGradAtTargetEPoints, const ViewType1 basisCurlAtTargetCurlEPoints,
354  const ViewType2 basisEWeights, const ViewType2 basisCurlEWeights,
355  const ViewType1 wHgradBasisGradAtBasisEPoints, const ViewType1 wBasisCurlAtBasisCurlEPoints,
356  const ViewType2 targetEWeights, const ViewType2 targetCurlEWeights,
357  const ViewType1 wHgradBasisGradAtTargetEPoints,
358  const ViewType1 wBasisCurlAtTargetCurlEPoints, const ViewType3 computedDofs,
359  const ViewType4 tagToOrdinal, const ViewType4 hGradTagToOrdinal,
360  ordinal_type numCellDofs, ordinal_type hgradCardinality,
361  ordinal_type offsetBasis, ordinal_type offsetBasisCurl, ordinal_type offsetTargetCurl,
362  ordinal_type numEdgeFaceDofs, ordinal_type dim, ordinal_type derDim) :
363  basisCoeffs_(basisCoeffs), negPartialProj_(negPartialProj), negPartialProjCurl_(negPartialProjCurl),
364  cellBasisAtBasisEPoints_(cellBasisAtBasisEPoints), cellBasisCurlAtBasisCurlEPoints_(cellBasisCurlAtBasisCurlEPoints),
365  basisAtBasisEPoints_(basisAtBasisEPoints), hgradBasisGradAtBasisEPoints_(hgradBasisGradAtBasisEPoints),
366  basisCurlAtBasisCurlEPoints_(basisCurlAtBasisCurlEPoints),
367  hgradBasisGradAtTargetEPoints_(hgradBasisGradAtTargetEPoints),
368  basisCurlAtTargetCurlEPoints_(basisCurlAtTargetCurlEPoints),
369  basisEWeights_(basisEWeights), basisCurlEWeights_(basisCurlEWeights),
370  wHgradBasisGradAtBasisEPoints_(wHgradBasisGradAtBasisEPoints),
371  wBasisCurlAtBasisCurlEPoints_(wBasisCurlAtBasisCurlEPoints),
372  targetEWeights_(targetEWeights), targetCurlEWeights_(targetCurlEWeights),
373  wHgradBasisGradAtTargetEPoints_(wHgradBasisGradAtTargetEPoints),
374  wBasisCurlAtTargetCurlEPoints_(wBasisCurlAtTargetCurlEPoints),
375  computedDofs_(computedDofs), tagToOrdinal_(tagToOrdinal), hGradTagToOrdinal_(hGradTagToOrdinal),
376  numCellDofs_(numCellDofs), hgradCardinality_(hgradCardinality),
377  offsetBasis_(offsetBasis), offsetBasisCurl_(offsetBasisCurl), offsetTargetCurl_(offsetTargetCurl),
378  numEdgeFaceDofs_(numEdgeFaceDofs), dim_(dim), derDim_(derDim) {}
379 
380  void
381  KOKKOS_INLINE_FUNCTION
382  operator()(const ordinal_type ic) const {
383 
384  ordinal_type numBasisPoints = basisEWeights_.extent(0);
385  ordinal_type numBasisCurlPoints = basisCurlEWeights_.extent(0);
386  ordinal_type numTargetPoints = targetEWeights_.extent(0);
387  ordinal_type numTargetCurlPoints = targetCurlEWeights_.extent(0);
388  for(ordinal_type j=0; j <hgradCardinality_; ++j) {
389  ordinal_type idof = hGradTagToOrdinal_(dim_, 0, j);
390  for(ordinal_type d=0; d <dim_; ++d) {
391  for(ordinal_type iq=0; iq <numBasisPoints; ++iq)
392  wHgradBasisGradAtBasisEPoints_(ic,j,iq,d) = hgradBasisGradAtBasisEPoints_(idof,iq,d)*basisEWeights_(iq);
393  for(ordinal_type iq=0; iq <numTargetPoints; ++iq)
394  wHgradBasisGradAtTargetEPoints_(ic,j,iq,d) = hgradBasisGradAtTargetEPoints_(idof,iq,d)*targetEWeights_(iq);
395  }
396  }
397  for(ordinal_type j=0; j <numCellDofs_; ++j) {
398  ordinal_type idof = tagToOrdinal_(dim_, 0, j);
399  for(ordinal_type d=0; d <dim_; ++d)
400  for(ordinal_type iq=0; iq <numBasisPoints; ++iq)
401  cellBasisAtBasisEPoints_(0,j,iq,d)=basisAtBasisEPoints_(idof,offsetBasis_+iq,d);
402 
403  for(ordinal_type d=0; d <derDim_; ++d) {
404  for(ordinal_type iq=0; iq <numBasisCurlPoints; ++iq) {
405  cellBasisCurlAtBasisCurlEPoints_(0,j,iq,d)=basisCurlAtBasisCurlEPoints_(idof,offsetBasisCurl_+iq,d);
406  wBasisCurlAtBasisCurlEPoints_(ic,j,iq,d)=cellBasisCurlAtBasisCurlEPoints_(0,j,iq,d)*basisCurlEWeights_(iq);
407  }
408  for(ordinal_type iq=0; iq <numTargetCurlPoints; ++iq)
409  wBasisCurlAtTargetCurlEPoints_(ic,j,iq,d) = basisCurlAtTargetCurlEPoints_(idof,offsetTargetCurl_+iq,d)*targetCurlEWeights_(iq);
410  }
411  }
412  for(ordinal_type j=0; j < numEdgeFaceDofs_; ++j) {
413  ordinal_type jdof = computedDofs_(j);
414  for(ordinal_type d=0; d <derDim_; ++d)
415  for(ordinal_type iq=0; iq <numBasisCurlPoints; ++iq)
416  negPartialProjCurl_(ic,iq,d) -= basisCoeffs_(ic,jdof)*basisCurlAtBasisCurlEPoints_(jdof,offsetBasisCurl_+iq,d);
417  for(ordinal_type d=0; d <dim_; ++d)
418  for(ordinal_type iq=0; iq <numBasisPoints; ++iq)
419  negPartialProj_(ic,iq,d) -= basisCoeffs_(ic,jdof)*basisAtBasisEPoints_(jdof,offsetBasis_+iq,d);
420  }
421  }
422 };
423 
424 } // FunctorsProjectionTools namespace
425 
426 
427 template<typename DeviceType>
428 template<typename basisCoeffsValueType, class ...basisCoeffsProperties,
429 typename funValsValueType, class ...funValsProperties,
430 typename BasisType,
431 typename ortValueType,class ...ortProperties>
432 void
433 ProjectionTools<DeviceType>::getHCurlBasisCoeffs(Kokkos::DynRankView<basisCoeffsValueType,basisCoeffsProperties...> basisCoeffs,
434  const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
435  const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetCurlAtTargetCurlEPoints,
436  const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
437  const BasisType* cellBasis,
439 
440  typedef typename BasisType::scalarType scalarType;
441  typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
442  typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
443  const auto cellTopo = cellBasis->getBaseCellTopology();
444  ordinal_type dim = cellTopo.getDimension();
445  ordinal_type basisCardinality = cellBasis->getCardinality();
446  ordinal_type numCells = targetAtTargetEPoints.extent(0);
447  const ordinal_type edgeDim = 1;
448  const ordinal_type faceDim = 2;
449  const ordinal_type derDim = dim == 3 ? dim : 1;
450 
451  const Kokkos::RangePolicy<ExecSpaceType> policy(0, numCells);
452 
453  const std::string& name = cellBasis->getName();
454 
455  ordinal_type numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
456  ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
457 
458  ScalarViewType refEdgeTangent("refEdgeTangent", dim);
459  ScalarViewType refFaceNormal("refFaceNormal", dim);
460 
461  ordinal_type numEdgeDofs(0);
462  for(ordinal_type ie=0; ie<numEdges; ++ie)
463  numEdgeDofs += cellBasis->getDofCount(edgeDim,ie);
464 
465  ordinal_type numTotalFaceDofs(0);
466  for(ordinal_type iface=0; iface<numFaces; ++iface)
467  numTotalFaceDofs += cellBasis->getDofCount(faceDim,iface);
468 
469  auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), cellBasis->getAllDofOrdinal());
470 
471  Kokkos::View<ordinal_type*, DeviceType> computedDofs("computedDofs",numEdgeDofs+numTotalFaceDofs);
472 
473  auto targetEPointsRange = projStruct->getTargetPointsRange();
474  auto targetCurlEPointsRange = projStruct->getTargetDerivPointsRange();
475 
476  auto basisEPointsRange = projStruct->getBasisPointsRange();
477  auto basisCurlEPointsRange = projStruct->getBasisDerivPointsRange();
478 
479  ordinal_type numTotalBasisEPoints = projStruct->getNumBasisEvalPoints(), numTotalBasisCurlEPoints = projStruct->getNumBasisDerivEvalPoints();
480  auto basisEPoints = projStruct->getAllEvalPoints(EvalPointsType::BASIS);
481  auto basisCurlEPoints = projStruct->getAllDerivEvalPoints(EvalPointsType::BASIS);
482 
483  ordinal_type numTotalTargetEPoints = projStruct->getNumTargetEvalPoints(), numTotalTargetCurlEPoints = projStruct->getNumTargetDerivEvalPoints();
484  auto targetEPoints = projStruct->getAllEvalPoints(EvalPointsType::TARGET);
485  auto targetCurlEPoints = projStruct->getAllDerivEvalPoints(EvalPointsType::TARGET);
486 
487  ScalarViewType basisAtBasisEPoints("basisAtBasisEPoints",basisCardinality, numTotalBasisEPoints, dim);
488  ScalarViewType basisAtTargetEPoints("basisAtTargetEPoints",basisCardinality, numTotalTargetEPoints, dim);
489  cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
490  cellBasis->getValues(basisAtBasisEPoints, basisEPoints);
491 
492  ScalarViewType basisCurlAtBasisCurlEPoints;
493  ScalarViewType basisCurlAtTargetCurlEPoints;
494  if(numTotalBasisCurlEPoints>0) {
495  ScalarViewType nonOrientedBasisCurlAtTargetCurlEPoints, nonOrientedBasisCurlAtBasisCurlEPoints;
496  if (dim == 3) {
497  basisCurlAtBasisCurlEPoints = ScalarViewType ("basisCurlAtBasisCurlEPoints",basisCardinality, numTotalBasisCurlEPoints, dim);
498  basisCurlAtTargetCurlEPoints = ScalarViewType("basisCurlAtTargetCurlEPoints",basisCardinality, numTotalTargetCurlEPoints, dim);
499  } else {
500  basisCurlAtBasisCurlEPoints = ScalarViewType ("basisCurlAtBasisCurlEPoints",basisCardinality, numTotalBasisCurlEPoints);
501  basisCurlAtTargetCurlEPoints = ScalarViewType("basisCurlAtTargetCurlEPoints",basisCardinality, numTotalTargetCurlEPoints);
502  }
503 
504  cellBasis->getValues(basisCurlAtBasisCurlEPoints, basisCurlEPoints,OPERATOR_CURL);
505  cellBasis->getValues(basisCurlAtTargetCurlEPoints, targetCurlEPoints,OPERATOR_CURL);
506  }
507 
508  ScalarViewType refBasisCoeffs("refBasisCoeffs", basisCoeffs.extent(0), basisCoeffs.extent(1));
509 
510  ordinal_type computedDofsCount = 0;
511  for(ordinal_type ie=0; ie<numEdges; ++ie) {
512 
513  ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
514  ordinal_type numBasisEPoints = range_size(basisEPointsRange(edgeDim, ie));
515  ordinal_type numTargetEPoints = range_size(targetEPointsRange(edgeDim, ie));
516 
517  CellTools<DeviceType>::getReferenceEdgeTangent(refEdgeTangent, ie, cellTopo);
518 
519  ScalarViewType basisTanAtBasisEPoints("basisTanAtBasisEPoints",1,edgeCardinality, numBasisEPoints);
520  ScalarViewType weightedTanBasisAtBasisEPoints("weightedTanBasisAtBasisEPoints",1,edgeCardinality, numBasisEPoints);
521  ScalarViewType weightedTanBasisAtTargetEPoints("weightedTanBasisAtTargetEPoints",numCells,edgeCardinality, numTargetEPoints);
522  ScalarViewType targetTanAtTargetEPoints("normalTargetAtTargetEPoints",numCells, numTargetEPoints);
523 
524  auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetEvalWeights(edgeDim,ie));
525  auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisEvalWeights(edgeDim,ie));
526 
527  ordinal_type offsetBasis = basisEPointsRange(edgeDim, ie).first;
528  ordinal_type offsetTarget = targetEPointsRange(edgeDim, ie).first;
529 
531  Kokkos::parallel_for(Kokkos::MDRangePolicy<ExecSpaceType, Kokkos::Rank<2> >({0,0}, {edgeCardinality,numBasisEPoints}),
532  functorTypeWBasisEdge(basisTanAtBasisEPoints,weightedTanBasisAtBasisEPoints,basisAtBasisEPoints,basisEWeights,refEdgeTangent,tagToOrdinal,edgeDim,ie,offsetBasis));
533 
535  Kokkos::parallel_for(policy, functorTypeEdge(targetEWeights,
536  basisAtTargetEPoints, weightedTanBasisAtTargetEPoints, tagToOrdinal,
537  targetAtTargetEPoints, targetTanAtTargetEPoints,
538  refEdgeTangent, edgeCardinality,
539  offsetTarget, edgeDim,
540  dim, ie));
541 
542  ScalarViewType edgeMassMat_("edgeMassMat_", 1, edgeCardinality+1, edgeCardinality+1),
543  edgeRhsMat_("rhsMat_", numCells, edgeCardinality+1);
544 
545  ScalarViewType eWeights_("eWeights_", 1, 1, basisEWeights.extent(0)), targetEWeights_("targetEWeights", numCells, 1, targetEWeights.extent(0));
546  RealSpaceTools<DeviceType>::clone(eWeights_, basisEWeights);
547  RealSpaceTools<DeviceType>::clone(targetEWeights_, targetEWeights);
548 
549  range_type range_H(0, edgeCardinality);
550  range_type range_B(edgeCardinality, edgeCardinality+1);
551  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(edgeMassMat_,Kokkos::ALL(),range_H,range_H), basisTanAtBasisEPoints, weightedTanBasisAtBasisEPoints);
552  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(edgeMassMat_,Kokkos::ALL(),range_H,range_B), basisTanAtBasisEPoints, eWeights_);
553  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(edgeRhsMat_,Kokkos::ALL(),range_H), targetTanAtTargetEPoints, weightedTanBasisAtTargetEPoints);
554  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(edgeRhsMat_,Kokkos::ALL(),range_B), targetTanAtTargetEPoints, targetEWeights_);
555 
556  typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
557  ScalarViewType t_("t",numCells, edgeCardinality+1);
558  WorkArrayViewType w_("w",numCells, edgeCardinality+1);
559 
560  auto edgeDofs = Kokkos::subview(tagToOrdinal, edgeDim, ie, range_type(0,edgeCardinality));
561  ElemSystem edgeSystem("edgeSystem", true);
562  edgeSystem.solve(refBasisCoeffs, edgeMassMat_, edgeRhsMat_, t_, w_, edgeDofs, edgeCardinality, 1);
563 
564  auto computedEdgeDofs = Kokkos::subview(computedDofs, range_type(computedDofsCount,computedDofsCount+edgeCardinality));
565  deep_copy(computedEdgeDofs, edgeDofs);
566  computedDofsCount += edgeCardinality;
567 
568  }
569 
570  typename RefSubcellParametrization<DeviceType>::ConstViewType subcellParamFace;
571  Basis<DeviceType,scalarType,scalarType> *hgradBasis = NULL;
572  if(numFaces>0) {
573  subcellParamFace = RefSubcellParametrization<DeviceType>::get(faceDim, cellBasis->getBaseCellTopology().getKey());
574  if(cellTopo.getKey() == shards::getCellTopologyData<shards::Hexahedron<8> >()->key)
575  hgradBasis = new Basis_HGRAD_HEX_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
576  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Tetrahedron<4> >()->key)
577  hgradBasis = new Basis_HGRAD_TET_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
578  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Wedge<6> >()->key) {
579  hgradBasis = new typename DerivedNodalBasisFamily<DeviceType,scalarType,scalarType>::HGRAD_WEDGE(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
580  }
581  else {
582  std::stringstream ss;
583  ss << ">>> ERROR (Intrepid2::ProjectionTools::getHCurlBasisCoeffs): "
584  << "Method not implemented for basis " << name;
585  INTREPID2_TEST_FOR_EXCEPTION( true, std::runtime_error, ss.str().c_str() );
586  }
587  }
588  for(ordinal_type iface=0; iface<numFaces; ++iface) {
589 
590  ordinal_type numTargetEPoints = range_size(targetEPointsRange(faceDim, iface));
591  ordinal_type numTargetCurlEPoints = range_size(targetCurlEPointsRange(faceDim, iface));
592  ordinal_type numBasisEPoints = range_size(basisEPointsRange(faceDim, iface));
593  ordinal_type numBasisCurlEPoints = range_size(basisCurlEPointsRange(faceDim, iface));
594 
595  ordinal_type numFaceDofs = cellBasis->getDofCount(faceDim,iface);
596 
597  ScalarViewType hgradBasisGradAtBasisEPoints("hgradBasisGradAtBasisEPoints", hgradBasis->getCardinality(), numBasisEPoints, dim);
598  ScalarViewType hgradBasisGradAtTargetEPoints("hgradBasisGradAtTargetEPoints", hgradBasis->getCardinality(), numTargetEPoints, dim);
599 
600  ordinal_type hgradCardinality = hgradBasis->getDofCount(faceDim,iface);
601 
602  hgradBasis->getValues(hgradBasisGradAtBasisEPoints, Kokkos::subview(basisEPoints, basisEPointsRange(faceDim, iface), Kokkos::ALL()), OPERATOR_GRAD);
603  hgradBasis->getValues(hgradBasisGradAtTargetEPoints, Kokkos::subview(targetEPoints, targetEPointsRange(faceDim, iface), Kokkos::ALL()), OPERATOR_GRAD);
604 
605  //no need to orient these basis as they act locally as test functions.
606 
607  auto hGradTagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), hgradBasis->getAllDofOrdinal());
608 
609  ScalarViewType basisTanAtBasisEPoints("basisTanAtBasisEPoints",1,numFaceDofs, numBasisEPoints,dim);
610  ScalarViewType basisCurlNormalAtBasisCurlEPoints("normaBasisCurlAtBasisEPoints",1,numFaceDofs, numBasisCurlEPoints);
611  ScalarViewType wNormalBasisCurlAtBasisCurlEPoints("weightedNormalBasisCurlAtBasisEPoints",numCells,numFaceDofs, numBasisCurlEPoints);
612 
613  ScalarViewType targetTanAtTargetEPoints("targetTanAtTargetEPoints",numCells, numTargetEPoints, dim);
614  ScalarViewType normalTargetCurlAtTargetEPoints("normalTargetCurlAtTargetEPoints",numCells, numTargetCurlEPoints);
615  ScalarViewType wNormalBasisCurlBasisAtTargetCurlEPoints("weightedNormalBasisCurlAtTargetCurlEPoints",numCells,numFaceDofs, numTargetCurlEPoints);
616 
617  ScalarViewType wHgradBasisGradAtBasisEPoints("wHgradBasisGradAtBasisEPoints",numCells, hgradCardinality, numBasisEPoints, dim);
618  ScalarViewType wHgradBasisGradAtTargetEPoints("wHgradBasisGradAtTargetEPoints",numCells, hgradCardinality, numTargetEPoints, dim);
619 
620  ScalarViewType negPartialProjCurlNormal("mNormalComputedProjection", numCells,numBasisEPoints);
621  ScalarViewType negPartialProjTan("negPartialProjTan", numCells,numBasisEPoints,dim);
622 
623  ordinal_type offsetBasis = basisEPointsRange(faceDim, iface).first;
624  ordinal_type offsetBasisCurl = basisCurlEPointsRange(faceDim, iface).first;
625  ordinal_type offsetTarget = targetEPointsRange(faceDim, iface).first;
626  ordinal_type offsetTargetCurl = targetCurlEPointsRange(faceDim, iface).first;
627 
628  auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisEvalWeights(faceDim,iface));
629  auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetEvalWeights(faceDim,iface));
630  auto targetCurlEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetDerivEvalWeights(faceDim,iface));
631  auto basisCurlEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisDerivEvalWeights(faceDim,iface));
632 
633  CellTools<DeviceType>::getReferenceFaceNormal(refFaceNormal, iface, cellTopo);
634 
635  using functorTypeFaces = FunctorsProjectionTools::ComputeBasisCoeffsOnFaces_HCurl<ScalarViewType, decltype(targetAtTargetEPoints), decltype(basisEWeights),
636  decltype(tagToOrdinal), decltype(computedDofs)>;
637  Kokkos::parallel_for(policy, functorTypeFaces(refBasisCoeffs,
638  negPartialProjTan, negPartialProjCurlNormal,
639  hgradBasisGradAtBasisEPoints, wHgradBasisGradAtBasisEPoints,
640  basisCurlAtBasisCurlEPoints, basisCurlNormalAtBasisCurlEPoints,
641  basisAtBasisEPoints,
642  normalTargetCurlAtTargetEPoints, basisTanAtBasisEPoints,
643  hgradBasisGradAtTargetEPoints, wHgradBasisGradAtTargetEPoints,
644  wNormalBasisCurlAtBasisCurlEPoints, basisCurlAtTargetCurlEPoints,
645  wNormalBasisCurlBasisAtTargetCurlEPoints, targetAtTargetEPoints,
646  targetTanAtTargetEPoints, targetCurlAtTargetCurlEPoints,
647  basisEWeights, targetEWeights,
648  basisCurlEWeights, targetCurlEWeights, tagToOrdinal,
649  hGradTagToOrdinal,
650  computedDofs, refFaceNormal, offsetBasis,
651  offsetBasisCurl, offsetTarget,
652  offsetTargetCurl, iface,
653  hgradCardinality, numFaces,
654  numFaceDofs, numEdgeDofs,
655  faceDim, dim));
656 
657 
658  ScalarViewType faceMassMat_("faceMassMat_", 1, numFaceDofs+hgradCardinality, numFaceDofs+hgradCardinality),
659  faceRhsMat_("rhsMat_", numCells, numFaceDofs+hgradCardinality);
660  range_type range_H(0, numFaceDofs);
661  range_type range_B(numFaceDofs, numFaceDofs+hgradCardinality);
662  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(faceMassMat_,Kokkos::ALL(),range_H,range_H), basisCurlNormalAtBasisCurlEPoints, Kokkos::subview(wNormalBasisCurlAtBasisCurlEPoints, std::make_pair(0,1), Kokkos::ALL(), Kokkos::ALL()) );
663  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(faceMassMat_,Kokkos::ALL(),range_H,range_B), basisTanAtBasisEPoints, Kokkos::subview(wHgradBasisGradAtBasisEPoints, std::make_pair(0,1), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()) );
664 
665  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(faceRhsMat_,Kokkos::ALL(),range_H), normalTargetCurlAtTargetEPoints, wNormalBasisCurlBasisAtTargetCurlEPoints);
666  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(faceRhsMat_,Kokkos::ALL(),range_H), negPartialProjCurlNormal, wNormalBasisCurlAtBasisCurlEPoints,true);
667 
668  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(faceRhsMat_,Kokkos::ALL(),range_B), targetTanAtTargetEPoints, wHgradBasisGradAtTargetEPoints);
669  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(faceRhsMat_,Kokkos::ALL(),range_B), negPartialProjTan, wHgradBasisGradAtBasisEPoints,true);
670 
671 
672  typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
673  ScalarViewType t_("t",numCells, numFaceDofs+hgradCardinality);
674  WorkArrayViewType w_("w",numCells, numFaceDofs+hgradCardinality);
675 
676  auto faceDofs = Kokkos::subview(tagToOrdinal, faceDim, iface, range_type(0,numFaceDofs));
677  ElemSystem faceSystem( "faceSystem", true);
678  faceSystem.solve(refBasisCoeffs, faceMassMat_, faceRhsMat_, t_, w_, faceDofs, numFaceDofs, hgradCardinality);
679 
680  auto computedFaceDofs = Kokkos::subview(computedDofs, range_type(computedDofsCount,computedDofsCount+numFaceDofs));
681  deep_copy(computedFaceDofs, faceDofs);
682  computedDofsCount += numFaceDofs;
683 
684  }
685  delete hgradBasis;
686 
687  ordinal_type numCellDofs = cellBasis->getDofCount(dim,0);
688  if(numCellDofs>0) {
689  if(cellTopo.getKey() == shards::getCellTopologyData<shards::Hexahedron<8> >()->key)
690  hgradBasis = new Basis_HGRAD_HEX_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree());
691  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Tetrahedron<4> >()->key)
692  hgradBasis = new Basis_HGRAD_TET_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
693  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Wedge<6> >()->key)
694  hgradBasis = new typename DerivedNodalBasisFamily<DeviceType,scalarType,scalarType>::HGRAD_WEDGE(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
695  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Triangle<3> >()->key)
696  hgradBasis = new Basis_HGRAD_TRI_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
697  else if(cellTopo.getKey() == shards::getCellTopologyData<shards::Quadrilateral<4> >()->key)
698  hgradBasis = new Basis_HGRAD_QUAD_Cn_FEM<DeviceType,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
699  else {
700  std::stringstream ss;
701  ss << ">>> ERROR (Intrepid2::ProjectionTools::getHCurlBasisCoeffs): "
702  << "Method not implemented for basis " << name;
703  INTREPID2_TEST_FOR_EXCEPTION( true, std::runtime_error, ss.str().c_str() );
704  }
705 
706  range_type cellPointsRange = targetEPointsRange(dim, 0);
707  range_type cellCurlPointsRange = targetCurlEPointsRange(dim, 0);
708 
709  ordinal_type numTargetCurlEPoints = range_size(targetCurlEPointsRange(dim,0));
710  ordinal_type numBasisCurlEPoints = range_size(basisCurlEPointsRange(dim,0));
711  ordinal_type numBasisEPoints = range_size(basisEPointsRange(dim,0));
712  ordinal_type numTargetEPoints = range_size(targetEPointsRange(dim,0));
713 
714  ScalarViewType hgradBasisGradAtBasisEPoints("hgradBasisGradAtBasisEPoints",hgradBasis->getCardinality(), numBasisEPoints, dim);
715  ScalarViewType hgradBasisGradAtTargetEPoints("hgradBasisGradAtTargetEPoints",hgradBasis->getCardinality(), numTargetEPoints, dim);
716 
717  ordinal_type hgradCardinality = hgradBasis->getDofCount(dim,0);
718  ScalarViewType wHgradBasisGradAtTargetEPoints("wHgradBasisGradAtTargetEPoints",numCells, hgradCardinality, numTargetEPoints, dim);
719  ScalarViewType wHgradBasisGradAtBasisEPoints("wHgradBasisGradAtBasisEPoints",numCells, hgradCardinality, numBasisEPoints, dim);
720 
721  hgradBasis->getValues(hgradBasisGradAtBasisEPoints,Kokkos::subview(basisEPoints, basisEPointsRange(dim, 0), Kokkos::ALL()), OPERATOR_GRAD);
722  hgradBasis->getValues(hgradBasisGradAtTargetEPoints,Kokkos::subview(targetEPoints, targetEPointsRange(dim, 0), Kokkos::ALL()),OPERATOR_GRAD);
723 
724  ScalarViewType cellBasisAtBasisEPoints("basisCellAtEPoints",1,numCellDofs, numBasisEPoints, dim);
725  ScalarViewType cellBasisCurlAtCurlEPoints("cellBasisCurlAtCurlEPoints",1,numCellDofs, numBasisCurlEPoints, derDim);
726  ScalarViewType negPartialProjCurl("negPartialProjCurl", numCells, numBasisEPoints, derDim);
727  ScalarViewType negPartialProj("negPartialProj", numCells, numBasisEPoints, dim);
728  ScalarViewType wBasisCurlAtCurlEPoints("weightedBasisCurlAtBasisEPoints",numCells,numCellDofs, numBasisCurlEPoints,derDim);
729  ScalarViewType wBasisCurlBasisAtTargetCurlEPoints("weightedBasisCurlAtTargetCurlEPoints",numCells,numCellDofs, numTargetCurlEPoints,derDim);
730 
731  auto targetEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetEvalWeights(dim,0));
732  auto basisEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisEvalWeights(dim,0));
733  auto targetCurlEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getTargetDerivEvalWeights(dim,0));
734  auto basisCurlEWeights = Kokkos::create_mirror_view_and_copy(MemSpaceType(),projStruct->getBasisDerivEvalWeights(dim,0));
735  ordinal_type offsetBasis = basisEPointsRange(dim, 0).first;
736  ordinal_type offsetBasisCurl = basisCurlEPointsRange(dim, 0).first;
737  ordinal_type offsetTargetCurl = targetCurlEPointsRange(dim, 0).first;
738 
739 
740  auto hGradTagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), hgradBasis->getAllDofOrdinal());
741 
742  using functorTypeCell = FunctorsProjectionTools::ComputeBasisCoeffsOnCell_HCurl<ScalarViewType, decltype(basisEWeights),
743  decltype(computedDofs), decltype(tagToOrdinal)>;
744  Kokkos::parallel_for(policy, functorTypeCell(refBasisCoeffs, negPartialProj, negPartialProjCurl,
745  cellBasisAtBasisEPoints, cellBasisCurlAtCurlEPoints,
746  basisAtBasisEPoints, hgradBasisGradAtBasisEPoints, basisCurlAtBasisCurlEPoints,
747  hgradBasisGradAtTargetEPoints, basisCurlAtTargetCurlEPoints,
748  basisEWeights, basisCurlEWeights, wHgradBasisGradAtBasisEPoints,
749  wBasisCurlAtCurlEPoints, targetEWeights, targetCurlEWeights,
750  wHgradBasisGradAtTargetEPoints,
751  wBasisCurlBasisAtTargetCurlEPoints, computedDofs,
752  tagToOrdinal, hGradTagToOrdinal,
753  numCellDofs, hgradCardinality,
754  offsetBasis, offsetBasisCurl, offsetTargetCurl,
755  numEdgeDofs+numTotalFaceDofs, dim, derDim));
756 
757  ScalarViewType cellMassMat_("cellMassMat_", 1, numCellDofs+hgradCardinality, numCellDofs+hgradCardinality),
758  cellRhsMat_("rhsMat_", numCells, numCellDofs+hgradCardinality);
759 
760  range_type range_H(0, numCellDofs);
761  range_type range_B(numCellDofs, numCellDofs+hgradCardinality);
762  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellMassMat_,Kokkos::ALL(),range_H,range_H), cellBasisCurlAtCurlEPoints, Kokkos::subview(wBasisCurlAtCurlEPoints, std::make_pair(0,1), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()) );
763  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellMassMat_,Kokkos::ALL(),range_H,range_B), cellBasisAtBasisEPoints, Kokkos::subview(wHgradBasisGradAtBasisEPoints, std::make_pair(0,1), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL()) );
764  if(dim==3)
765  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_H), Kokkos::subview(targetCurlAtTargetCurlEPoints,Kokkos::ALL(),cellCurlPointsRange,Kokkos::ALL()), wBasisCurlBasisAtTargetCurlEPoints);
766  else
767  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_H), Kokkos::subview(targetCurlAtTargetCurlEPoints,Kokkos::ALL(),cellCurlPointsRange), Kokkos::subview(wBasisCurlBasisAtTargetCurlEPoints,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL(),0));
768  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_H), negPartialProjCurl, wBasisCurlAtCurlEPoints, true);
769 
770  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_B), Kokkos::subview(targetAtTargetEPoints,Kokkos::ALL(),cellPointsRange,Kokkos::ALL()), wHgradBasisGradAtTargetEPoints);
771  FunctionSpaceTools<DeviceType >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_B), negPartialProj, wHgradBasisGradAtBasisEPoints, true);
772 
773  typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
774  ScalarViewType t_("t",numCells, numCellDofs+hgradCardinality);
775  WorkArrayViewType w_("w",numCells, numCellDofs+hgradCardinality);
776 
777  auto cellDofs = Kokkos::subview(tagToOrdinal, dim, 0, Kokkos::ALL());
778  ElemSystem cellSystem( "cellSystem", true);
779  cellSystem.solve(refBasisCoeffs, cellMassMat_, cellRhsMat_, t_, w_, cellDofs, numCellDofs, hgradCardinality);
780 
781  delete hgradBasis;
782  }
783 
784  OrientationTools<DeviceType>::modifyBasisByOrientationInverse(basisCoeffs, refBasisCoeffs, orts, cellBasis, true);
785 }
786 
787 } // Intrepid2 namespace
788 
789 #endif
790 
static void getHCurlBasisCoeffs(Kokkos::DynRankView< basisCoeffsValueType, basisCoeffsProperties...> basisCoeffs, const Kokkos::DynRankView< funValsValueType, funValsProperties...> targetAtEvalPoints, const Kokkos::DynRankView< funValsValueType, funValsProperties...> targetCurlAtCurlEvalPoints, const Kokkos::DynRankView< ortValueType, ortProperties...> cellOrientations, const BasisType *cellBasis, ProjectionStruct< DeviceType, typename BasisType::scalarType > *projStruct)
Computes the basis coefficients of the HCurl projection of the target function.
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.
const range_tag getTargetDerivPointsRange() const
Returns the range tag of the target function derivative evaluation points on subcells.
static ConstViewType get(const ordinal_type subcellDim, const unsigned parentCellKey)
Returns a Kokkos view with the coefficients of the parametrization maps for the edges or faces of a r...
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.
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...
Implementation of the default H(grad)-compatible FEM basis of degree 2 on Hexahedron cell...
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.
static void getReferenceEdgeTangent(RefEdgeTangentViewType refEdgeTangent, const ordinal_type edgeOrd, const shards::CellTopology parentCell)
Computes constant tangent vectors to edges of 2D or 3D reference cells.
Header file for the Intrepid2::FunctionSpaceTools class.
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.
Implementation of the default H(grad)-compatible Lagrange basis of arbitrary degree on Tetrahedron ce...
static void getReferenceFaceNormal(RefFaceNormalViewType refFaceNormal, const ordinal_type faceOrd, const shards::CellTopology parentCell)
Computes constant normal vectors to faces of 3D reference 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...
Stateless class that acts as a factory for a family of nodal bases (hypercube topologies only at this...