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