49 #ifndef __INTREPID2_PROJECTIONTOOLSDEFHGRAD_HPP__
50 #define __INTREPID2_PROJECTIONTOOLSDEFHGRAD_HPP__
58 namespace Experimental {
60 template<
typename SpT>
61 template<
typename BasisType,
62 typename ortValueType,
class ...ortProperties>
65 typename BasisType::scalarViewType extDerivEvaluationPoints,
66 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
67 const BasisType* cellBasis,
68 ProjectionStruct<SpT, typename BasisType::scalarType> * projStruct,
69 const EvalPointsType evalPointType) {
70 typedef typename BasisType::scalarType scalarType;
71 typedef Kokkos::DynRankView<scalarType,SpT> scalarViewType;
72 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
73 const auto cellTopo = cellBasis->getBaseCellTopology();
74 ordinal_type dim = cellTopo.getDimension();
75 ordinal_type numCells = evaluationPoints.extent(0);
76 const ordinal_type edgeDim = 1;
77 const ordinal_type faceDim = 2;
79 ordinal_type numVertices = (cellBasis->getDofCount(0, 0) > 0) ? cellTopo.getVertexCount() : 0;
80 ordinal_type numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
81 ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
83 Kokkos::View<ordinal_type*> eOrt(
"eOrt", numEdges), fOrt(
"fOrt", numFaces);
87 scalarViewType dofCoords(
"dofCoords", cellBasis->getCardinality(), dim);
88 cellBasis->getDofCoords(dofCoords);
89 for(ordinal_type iv=0; iv<numVertices; ++iv) {
90 ordinal_type idof = cellBasis->getDofOrdinal(0, iv, 0);
91 for(ordinal_type d=0; d<dim; d++)
92 for(ordinal_type ic=0; ic<numCells; ++ic)
93 evaluationPoints(ic,iv,d) = dofCoords(idof,d);
97 for(ordinal_type ie=0; ie<numEdges; ++ie) {
98 range_type edgeGradPointsRange;
99 scalarViewType cubPoints;
100 if(evalPointType == TARGET) {
101 edgeGradPointsRange = projStruct->getTargetDerivPointsRange(edgeDim, ie);
102 cubPoints = projStruct->getTargetDerivEvalPoints(edgeDim, ie);
105 edgeGradPointsRange = projStruct->getBasisDerivPointsRange(edgeDim, ie);
106 cubPoints = projStruct->getBasisDerivEvalPoints(edgeDim, ie);
109 scalarViewType orientedTargetCubPoints(
"orientedTargetCubPoints", cubPoints.extent(0),edgeDim);
111 const auto topoKey = projStruct->getTopologyKey(edgeDim,ie);
113 for(ordinal_type ic=0; ic<numCells; ++ic) {
114 orts(ic).getEdgeOrientation(eOrt.data(), numEdges);
115 ordinal_type ort = eOrt(ie);
117 CellTools<SpT>::mapToReferenceSubcell(Kokkos::subview(extDerivEvaluationPoints,ic,edgeGradPointsRange,Kokkos::ALL()), orientedTargetCubPoints, edgeDim, ie, cellBasis->getBaseCellTopology());
122 for(ordinal_type iface=0; iface<numFaces; ++iface) {
124 scalarViewType gradCubPoints;
125 range_type faceGradPointsRange;
126 if(evalPointType == TARGET) {
127 gradCubPoints = projStruct->getTargetDerivEvalPoints(faceDim, iface);
128 faceGradPointsRange = projStruct->getTargetDerivPointsRange(faceDim, iface);
130 gradCubPoints = projStruct->getBasisDerivEvalPoints(faceDim, iface);
131 faceGradPointsRange = projStruct->getBasisDerivPointsRange(faceDim, iface);
134 scalarViewType faceGradCubPoints(
"faceGradCubPoints", gradCubPoints.extent(0), faceDim);
136 const auto topoKey = projStruct->getTopologyKey(faceDim,iface);
137 for(ordinal_type ic=0; ic<numCells; ++ic) {
139 orts(ic).getFaceOrientation(fOrt.data(), numFaces);
141 ordinal_type ort = fOrt(iface);
143 CellTools<SpT>::mapToReferenceSubcell(Kokkos::subview(extDerivEvaluationPoints, ic, faceGradPointsRange, Kokkos::ALL()), faceGradCubPoints, faceDim, iface, cellBasis->getBaseCellTopology());
147 if(cellBasis->getDofCount(dim,0)>0) {
148 range_type cellGradPointsRange;
149 scalarViewType gradCubPoints;
150 if(evalPointType == TARGET) {
151 gradCubPoints = projStruct->getTargetDerivEvalPoints(dim, 0);
152 cellGradPointsRange = projStruct->getTargetDerivPointsRange(dim, 0);
154 gradCubPoints = projStruct->getBasisDerivEvalPoints(dim, 0);
155 cellGradPointsRange = projStruct->getBasisDerivPointsRange(dim, 0);
157 RealSpaceTools<SpT>::clone(Kokkos::subview(extDerivEvaluationPoints, Kokkos::ALL(), cellGradPointsRange, Kokkos::ALL()), gradCubPoints);
162 template<
typename SpT>
163 template<
typename basisCoeffsValueType,
class ...basisCoeffsProperties,
164 typename funValsValueType,
class ...funValsProperties,
166 typename ortValueType,
class ...ortProperties>
169 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtEvalPoints,
170 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetGradAtGradEvalPoints,
171 const typename BasisType::scalarViewType evaluationPoints,
172 const typename BasisType::scalarViewType extDerivEvaluationPoints,
173 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
174 const BasisType* cellBasis,
175 ProjectionStruct<SpT, typename BasisType::scalarType> * projStruct){
177 typedef typename Kokkos::Impl::is_space<SpT>::host_mirror_space::execution_space host_space_type;
178 typedef typename BasisType::scalarType scalarType;
179 typedef Kokkos::DynRankView<scalarType,SpT> scalarViewType;
180 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
181 const auto cellTopo = cellBasis->getBaseCellTopology();
182 ordinal_type dim = cellTopo.getDimension();
183 ordinal_type numTotalEvaluationPoints(targetAtEvalPoints.extent(1)),
184 numTotalGradEvaluationPoints(targetGradAtGradEvalPoints.extent(1));
185 ordinal_type basisCardinality = cellBasis->getCardinality();
186 ordinal_type numCells = targetAtEvalPoints.extent(0);
187 const ordinal_type edgeDim = 1;
188 const ordinal_type faceDim = 2;
190 ordinal_type numVertices = (cellBasis->getDofCount(0, 0) > 0) ? cellTopo.getVertexCount() : 0;
191 ordinal_type numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
192 ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
194 Kokkos::View<ordinal_type*> eOrt(
"eOrt", numEdges);
195 Kokkos::View<ordinal_type*> fOrt(
"fOrt", numFaces);
196 scalarViewType refEdgeTan(
"refEdgeTan", dim);
197 scalarViewType refFaceTangents(
"refFaceTangents", dim, 2);
198 auto refFaceTanU = Kokkos::subview(refFaceTangents, Kokkos::ALL, 0);
199 auto refFaceTanV = Kokkos::subview(refFaceTangents, Kokkos::ALL, 1);
201 ordinal_type numVertexDofs = numVertices;
203 ordinal_type numEdgeDofs(0);
204 for(ordinal_type ie=0; ie<numEdges; ++ie)
205 numEdgeDofs += cellBasis->getDofCount(edgeDim,ie);
207 ordinal_type numFaceDofs(0);
208 for(ordinal_type iface=0; iface<numFaces; ++iface)
209 numFaceDofs += cellBasis->getDofCount(faceDim,iface);
211 Kokkos::View<ordinal_type*> computedDofs(
"computedDofs",numVertexDofs+numEdgeDofs+numFaceDofs);
213 ordinal_type computedDofsCount = 0;
215 ordinal_type numTotalCubPoints = projStruct->getNumBasisEvalPoints(),
216 numTotalGradCubPoints = projStruct->getNumBasisDerivEvalPoints();
217 scalarViewType cubPoints(
"cubPoints",numCells,numTotalCubPoints, dim);
218 scalarViewType gradCubPoints(
"gradCubPoints",numCells,numTotalGradCubPoints, dim);
219 getHGradEvaluationPoints(cubPoints, gradCubPoints, orts, cellBasis, projStruct, BASIS);
221 scalarViewType basisAtCubPoints(
"basisAtCubPoints",numCells,basisCardinality, numTotalCubPoints);
222 scalarViewType basisAtTargetCubPoints(
"basisAtTargetCubPoints",numCells,basisCardinality, numTotalEvaluationPoints);
224 scalarViewType nonOrientedBasisAtCubPoints(
"nonOrientedBasisAtCubPoints",numCells,basisCardinality, numTotalCubPoints);
225 scalarViewType nonOrientedBasisAtTargetCubPoints(
"nonOrientedBasisAtTargetCubPoints",numCells,basisCardinality, numTotalEvaluationPoints);
227 for(ordinal_type ic=0; ic<numCells; ++ic) {
228 cellBasis->getValues(Kokkos::subview(nonOrientedBasisAtTargetCubPoints,ic,Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(evaluationPoints, ic, Kokkos::ALL(), Kokkos::ALL()));
229 cellBasis->getValues(Kokkos::subview(nonOrientedBasisAtCubPoints,ic,Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(cubPoints, ic, Kokkos::ALL(), Kokkos::ALL()));
236 scalarViewType basisGradAtGradCubPoints;
237 scalarViewType basisGradAtTargetGradCubPoints;
238 if(numTotalGradEvaluationPoints>0) {
239 scalarViewType nonOrientedBasisGradAtTargetGradCubPoints, nonOrientedBasisGradAtGradCubPoints;
241 basisGradAtGradCubPoints = scalarViewType (
"basisGradAtGradCubPoints",numCells,basisCardinality, numTotalGradCubPoints, dim);
242 nonOrientedBasisGradAtGradCubPoints = scalarViewType (
"nonOrientedBasisGradAtGradCubPoints",numCells,basisCardinality, numTotalGradCubPoints, dim);
243 basisGradAtTargetGradCubPoints = scalarViewType(
"basisGradAtTargetGradCubPoints",numCells,basisCardinality, numTotalGradEvaluationPoints, dim);
244 nonOrientedBasisGradAtTargetGradCubPoints = scalarViewType(
"nonOrientedBasisGradAtTargetGradCubPoints",numCells,basisCardinality, numTotalGradEvaluationPoints, dim);
246 for(ordinal_type ic=0; ic<numCells; ++ic) {
247 cellBasis->getValues(Kokkos::subview(nonOrientedBasisGradAtGradCubPoints,ic,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(gradCubPoints, ic, Kokkos::ALL(), Kokkos::ALL()),OPERATOR_GRAD);
248 cellBasis->getValues(Kokkos::subview(nonOrientedBasisGradAtTargetGradCubPoints,ic,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(extDerivEvaluationPoints, ic, Kokkos::ALL(), Kokkos::ALL()),OPERATOR_GRAD);
255 for(ordinal_type iv=0; iv<numVertices; ++iv) {
256 ordinal_type idof = cellBasis->getDofOrdinal(0, iv, 0);
257 computedDofs(computedDofsCount++) = idof;
258 for(ordinal_type ic=0; ic<numCells; ++ic)
259 basisCoeffs(ic,idof) = targetAtEvalPoints(ic,iv);
262 for(ordinal_type ie=0; ie<numEdges; ++ie) {
264 ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
265 ordinal_type numCubPoints = projStruct->getNumBasisDerivEvalPoints(edgeDim, ie);
266 ordinal_type numTargetCubPoints = projStruct->getNumTargetDerivEvalPoints(edgeDim, ie);
270 scalarViewType edgeBasisAtCubPoints(
"tanBasisAtElemCubPoints",numCells,edgeCardinality, numCubPoints);
271 scalarViewType edgeTargetAtTargetCubPoints(
"tanBasisAtTargetCubPoints",numCells, numTargetCubPoints);
272 scalarViewType weightedBasisAtElemCubPoints(
"weightedTanBasisAtElemCubPoints",numCells,edgeCardinality, numCubPoints);
273 scalarViewType weightedBasisAtTargetCubPoints(
"weightedTanBasisAtTargetCubPoints",numCells,edgeCardinality, numTargetCubPoints);
274 scalarViewType mComputedProjection(
"mComputedProjection", numCells, numCubPoints);
276 scalarViewType targetEvalWeights = projStruct->getTargetDerivEvalWeights(edgeDim, ie);
277 scalarViewType basisEvalWeights = projStruct->getBasisDerivEvalWeights(edgeDim, ie);
280 ordinal_type offsetBasis = projStruct->getBasisDerivPointsRange(edgeDim, ie).first;
281 ordinal_type offsetTarget = projStruct->getTargetDerivPointsRange(edgeDim, ie).first;
282 for(ordinal_type j=0; j <edgeCardinality; ++j) {
283 ordinal_type jdof = cellBasis->getDofOrdinal(edgeDim, ie, j);
284 for(ordinal_type ic=0; ic<numCells; ++ic) {
285 for(ordinal_type iq=0; iq <numCubPoints; ++iq) {
286 for(ordinal_type d=0; d <dim; ++d)
287 edgeBasisAtCubPoints(ic,j,iq) += basisGradAtGradCubPoints(ic,jdof,offsetBasis+iq,d)*refEdgeTan(d);
288 weightedBasisAtElemCubPoints(ic,j,iq) = edgeBasisAtCubPoints(ic,j,iq)*basisEvalWeights(iq);
290 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq) {
291 for(ordinal_type d=0; d <dim; ++d)
292 weightedBasisAtTargetCubPoints(ic,j,iq) += basisGradAtTargetGradCubPoints(ic,jdof,offsetTarget+iq,d)*refEdgeTan(d)*targetEvalWeights(iq);
297 for(ordinal_type ic=0; ic<numCells; ++ic)
298 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq)
299 for(ordinal_type d=0; d <dim; ++d)
300 edgeTargetAtTargetCubPoints(ic,iq) += targetGradAtGradEvalPoints(ic,offsetTarget+iq,d)*refEdgeTan(d);
302 for(ordinal_type j=0; j <numVertexDofs; ++j) {
303 ordinal_type jdof = computedDofs(j);
304 for(ordinal_type ic=0; ic<numCells; ++ic)
305 for(ordinal_type iq=0; iq <numCubPoints; ++iq)
306 for(ordinal_type d=0; d <dim; ++d)
307 mComputedProjection(ic,iq) -= basisCoeffs(ic,jdof)*basisGradAtGradCubPoints(ic,jdof,offsetBasis+iq,d)*refEdgeTan(d);
311 scalarViewType edgeMassMat_(
"edgeMassMat_", numCells, edgeCardinality, edgeCardinality),
312 edgeRhsMat_(
"rhsMat_", numCells, edgeCardinality);
314 scalarViewType cubWeights_(
"cubWeights_", numCells, 1, basisEvalWeights.extent(0)), targetEvalWeights_(
"targetEvalWeights", numCells, 1, targetEvalWeights.extent(0));
323 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> edgeMassMat(
"edgeMassMat", edgeCardinality,edgeCardinality);
324 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> edgeRhsMat(
"edgeRhsMat",edgeCardinality, 1);
326 Teuchos::LAPACK<ordinal_type,funValsValueType> lapack;
327 ordinal_type info = 0;
328 for(ordinal_type ic=0; ic<numCells; ++ic) {
329 for(ordinal_type i=0; i<edgeCardinality; ++i) {
330 edgeRhsMat(i,0) = edgeRhsMat_(ic,i);
331 for(ordinal_type j=0; j<edgeCardinality; ++j)
332 edgeMassMat(i,j) = edgeMassMat_(ic,i,j);
335 lapack.POSV(
'U', edgeCardinality, 1,
337 edgeMassMat.stride_1(),
339 edgeRhsMat.stride_1(),
343 std::stringstream ss;
344 ss <<
">>> ERROR (Intrepid::ProjectionTools::getBasisCoeffs): "
345 <<
"LAPACK return with error code: "
347 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
350 for(ordinal_type i=0; i<edgeCardinality; ++i){
351 ordinal_type edge_dof = cellBasis->getDofOrdinal(edgeDim, ie, i);
352 basisCoeffs(ic,edge_dof) = edgeRhsMat(i,0);
355 for(ordinal_type i=0; i<edgeCardinality; ++i)
356 computedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(edgeDim, ie, i);
359 scalarViewType ortJacobian(
"ortJacobian", faceDim, faceDim);
361 for(ordinal_type iface=0; iface<numFaces; ++iface) {
364 const auto topoKey = projStruct->getTopologyKey(faceDim,iface);
367 ordinal_type faceCardinality = cellBasis->getDofCount(faceDim,iface);
369 ordinal_type numTargetGradCubPoints = projStruct->getNumTargetDerivEvalPoints(faceDim, iface);
370 ordinal_type numGradCubPoints = projStruct->getNumBasisDerivEvalPoints(faceDim, iface);
374 scalarViewType faceBasisGradAtGradCubPoints(
"normaBasisGradAtGradCubPoints",numCells,faceCardinality, numGradCubPoints,faceDim);
375 scalarViewType wBasisGradAtGradCubPoints(
"weightedNormalBasisGradAtGradCubPoints",numCells,faceCardinality, numGradCubPoints,faceDim);
377 scalarViewType faceBasisGradAtTargetGradCubPoints(
"normalBasisGradAtTargetGradCubPoints",numCells,faceCardinality, numTargetGradCubPoints,faceDim);
378 scalarViewType wBasisGradBasisAtTargetGradCubPoints(
"weightedNormalBasisGradAtTargetGradCubPoints",numCells,faceCardinality, numTargetGradCubPoints,faceDim);
380 scalarViewType targetGradAtTargetGradCubPoints(
"targetGradAtTargetGradCubPoints",numCells, numTargetGradCubPoints,faceDim);
381 scalarViewType mComputedProjectionGrad(
"mNormalComputedProjection", numCells,numGradCubPoints,faceDim);
383 ordinal_type offsetBasisGrad = projStruct->getBasisDerivPointsRange(faceDim, iface).first;
384 ordinal_type offsetTargetGrad = projStruct->getTargetDerivPointsRange(faceDim, iface).first;
385 scalarViewType targetGradCubWeights = projStruct->getTargetDerivEvalWeights(faceDim, iface);
386 scalarViewType gradCubWeights = projStruct->getBasisDerivEvalWeights(faceDim, iface);
389 for(ordinal_type ic=0; ic<numCells; ++ic) {
391 orts(ic).getFaceOrientation(fOrt.data(), numFaces);
393 ordinal_type ort = fOrt(iface);
395 for(ordinal_type j=0; j <faceCardinality; ++j) {
396 ordinal_type jdof = cellBasis->getDofOrdinal(faceDim, iface, j);
397 for(ordinal_type itan=0; itan <faceDim; ++itan) {
398 for(ordinal_type iq=0; iq <numGradCubPoints; ++iq) {
399 for(ordinal_type d=0; d <dim; ++d)
400 for(ordinal_type jtan=0; jtan <faceDim; ++jtan)
401 faceBasisGradAtGradCubPoints(ic,j,iq,itan) += refFaceTangents(d, jtan)*ortJacobian(jtan,itan)*basisGradAtGradCubPoints(ic,jdof,offsetBasisGrad+iq,d);
402 wBasisGradAtGradCubPoints(ic,j,iq,itan) = faceBasisGradAtGradCubPoints(ic,j,iq,itan) * gradCubWeights(iq);
404 for(ordinal_type iq=0; iq <numTargetGradCubPoints; ++iq) {
405 for(ordinal_type d=0; d <dim; ++d)
406 for(ordinal_type jtan=0; jtan <faceDim; ++jtan)
407 faceBasisGradAtTargetGradCubPoints(ic,j,iq,itan) += refFaceTangents(d, jtan)*ortJacobian(jtan,itan)*basisGradAtTargetGradCubPoints(ic,jdof,offsetTargetGrad+iq,d);
408 wBasisGradBasisAtTargetGradCubPoints(ic,j,iq,itan) = faceBasisGradAtTargetGradCubPoints(ic,j,iq,itan) * targetGradCubWeights(iq);
413 for(ordinal_type d=0; d <dim; ++d)
414 for(ordinal_type itan=0; itan <faceDim; ++itan)
415 for(ordinal_type iq=0; iq <numTargetGradCubPoints; ++iq)
416 for(ordinal_type jtan=0; jtan <faceDim; ++jtan)
417 targetGradAtTargetGradCubPoints(ic,iq,itan) += refFaceTangents(d, jtan)*ortJacobian(jtan,itan)*targetGradAtGradEvalPoints(ic,offsetTargetGrad+iq,d);
419 for(ordinal_type j=0; j <numVertexDofs+numEdgeDofs; ++j) {
420 ordinal_type jdof = computedDofs(j);
421 for(ordinal_type iq=0; iq <numGradCubPoints; ++iq)
422 for(ordinal_type d=0; d <dim; ++d)
423 for(ordinal_type itan=0; itan <faceDim; ++itan)
424 for(ordinal_type jtan=0; jtan <faceDim; ++jtan)
425 mComputedProjectionGrad(ic,iq,itan) -= basisCoeffs(ic,jdof)*refFaceTangents(d, jtan)*ortJacobian(jtan,itan)*basisGradAtGradCubPoints(ic,jdof,offsetBasisGrad+iq,d);
429 scalarViewType faceMassMat_(
"faceMassMat_", numCells, faceCardinality, faceCardinality),
430 faceRhsMat_(
"rhsMat_", numCells, faceCardinality);
437 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> faceMassMat(
"faceMassMat", faceCardinality,faceCardinality);
438 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> faceRhsMat(
"faceRhsMat",faceCardinality, 1);
440 Teuchos::LAPACK<ordinal_type,funValsValueType> lapack;
441 ordinal_type info = 0;
442 for(ordinal_type ic=0; ic<numCells; ++ic) {
444 for(ordinal_type i=0; i<faceCardinality; ++i) {
445 faceRhsMat(i,0) = faceRhsMat_(ic,i);
446 for(ordinal_type j=0; j<faceCardinality; ++j)
447 faceMassMat(i,j) = faceMassMat_(ic,i,j);
450 lapack.POSV(
'U', faceCardinality, 1,
452 faceMassMat.stride_1(),
454 faceRhsMat.stride_1(),
458 std::stringstream ss;
459 ss <<
">>> ERROR (Intrepid::ProjectionTools::getBasisCoeffs): "
460 <<
"LAPACK return with error code: "
462 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
465 for(ordinal_type i=0; i<faceCardinality; ++i){
466 ordinal_type face_dof = cellBasis->getDofOrdinal(faceDim, iface, i);
467 basisCoeffs(ic,face_dof) = faceRhsMat(i,0);
471 for(ordinal_type i=0; i<faceCardinality; ++i)
472 computedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(faceDim, iface, i);
475 ordinal_type numElemDofs = cellBasis->getDofCount(dim,0);
478 range_type cellGradPointsRange = projStruct->getTargetDerivPointsRange(dim, 0);
480 ordinal_type numTargetGradCubPoints = projStruct->getNumTargetDerivEvalPoints(dim,0);
481 ordinal_type numGradCubPoints = projStruct->getNumBasisDerivEvalPoints(dim,0);
483 scalarViewType internalBasisGradAtGradCubPoints(
"internalBasisGradAtCubPoints",numCells,numElemDofs, numGradCubPoints, dim);
484 scalarViewType internalBasisGradAtTargetGradCubPoints(
"weightedBasisGradAtGradCubPoints",numCells,numElemDofs, numTargetGradCubPoints,dim);
485 scalarViewType mComputedProjectionGrad(
"mComputedProjectionGrad", numCells, numGradCubPoints, dim);
487 scalarViewType targetGradCubWeights = projStruct->getTargetDerivEvalWeights(dim, 0);
488 scalarViewType cubGradWeights = projStruct->getBasisDerivEvalWeights(dim, 0);
489 ordinal_type offsetBasisGrad = projStruct->getBasisDerivPointsRange(dim, 0).first;
490 ordinal_type offsetTargetGrad = projStruct->getTargetDerivPointsRange(dim, 0).first;
493 scalarViewType wBasisGradAtGradCubPoints(
"weightedBasisGradAtGradCubPoints",numCells,numElemDofs, numGradCubPoints,dim);
494 scalarViewType wBasisGradBasisAtTargetGradCubPoints(
"weightedBasisGradAtTargetGradCubPoints",numCells,numElemDofs, numTargetGradCubPoints,dim);
495 for(ordinal_type j=0; j <numElemDofs; ++j) {
496 ordinal_type idof = cellBasis->getDofOrdinal(dim, 0, j);
497 for(ordinal_type ic=0; ic<numCells; ++ic) {
498 for(ordinal_type d=0; d <dim; ++d) {
499 for(ordinal_type iq=0; iq <numGradCubPoints; ++iq) {
500 internalBasisGradAtGradCubPoints(ic,j,iq,d) = basisGradAtGradCubPoints(ic,idof,offsetBasisGrad+iq,d);
501 wBasisGradAtGradCubPoints(ic,j,iq,d) = internalBasisGradAtGradCubPoints(ic,j,iq,d) * cubGradWeights(iq);
503 for(ordinal_type iq=0; iq <numTargetGradCubPoints; ++iq) {
504 internalBasisGradAtTargetGradCubPoints(ic,j,iq,d) = basisGradAtTargetGradCubPoints(ic,idof,offsetTargetGrad+iq,d);
505 wBasisGradBasisAtTargetGradCubPoints(ic,j,iq,d )= internalBasisGradAtTargetGradCubPoints(ic,j,iq,d) * targetGradCubWeights(iq);
511 for(ordinal_type j=0; j <numVertexDofs+numEdgeDofs+numFaceDofs; ++j) {
512 ordinal_type jdof = computedDofs(j);
513 for(ordinal_type iq=0; iq <numGradCubPoints; ++iq)
514 for(ordinal_type ic=0; ic<numCells; ++ic) {
515 for(ordinal_type d=0; d <dim; ++d) {
516 mComputedProjectionGrad(ic,iq,d) -= basisCoeffs(ic,jdof)*basisGradAtGradCubPoints(ic,jdof,offsetBasisGrad+iq,d);
522 scalarViewType cellMassMat_(
"cellMassMat_", numCells, numElemDofs, numElemDofs),
523 cellRhsMat_(
"rhsMat_", numCells, numElemDofs);
526 FunctionSpaceTools<SpT >::integrate(cellRhsMat_, Kokkos::subview(targetGradAtGradEvalPoints,Kokkos::ALL(),cellGradPointsRange,Kokkos::ALL()), wBasisGradBasisAtTargetGradCubPoints);
529 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> cellMassMat(
"cellMassMat", numElemDofs,numElemDofs);
530 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> cellRhsMat(
"cellRhsMat",numElemDofs, 1);
532 Teuchos::LAPACK<ordinal_type,funValsValueType> lapack;
533 ordinal_type info = 0;
534 for(ordinal_type ic=0; ic<numCells; ++ic) {
535 for(ordinal_type i=0; i<numElemDofs; ++i) {
536 cellRhsMat(i,0) = cellRhsMat_(ic,i);
537 for(ordinal_type j=0; j<numElemDofs; ++j)
538 cellMassMat(i,j) = cellMassMat_(ic,i,j);
541 lapack.POSV(
'U', numElemDofs, 1,
543 cellMassMat.stride_1(),
545 cellRhsMat.stride_1(),
548 for(ordinal_type i=0; i<numElemDofs; ++i){
549 ordinal_type idof = cellBasis->getDofOrdinal(dim, 0, i);
550 basisCoeffs(ic,idof) = cellRhsMat(i,0);
554 std::stringstream ss;
555 ss <<
">>> ERROR (Intrepid::ProjectionTools::getBasisCoeffs): "
556 <<
"LAPACK return with error code: "
558 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
Header file for the abstract base class Intrepid2::DefaultCubatureFactory.