49 #ifndef __INTREPID2_PROJECTIONTOOLSDEFHCURL_HPP__
50 #define __INTREPID2_PROJECTIONTOOLSDEFHCURL_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 numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
80 ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
82 Kokkos::View<ordinal_type*> eOrt(
"eOrt", numEdges), fOrt(
"fOrt", numFaces);
84 for(ordinal_type ie=0; ie<numEdges; ++ie) {
85 range_type edgePointsRange;
86 scalarViewType cubPoints;
87 if(evalPointType == TARGET) {
88 edgePointsRange = projStruct->getTargetPointsRange(edgeDim, ie);
89 cubPoints = projStruct->getTargetEvalPoints(edgeDim, ie);
92 edgePointsRange = projStruct->getBasisPointsRange(edgeDim, ie);
93 cubPoints = projStruct->getBasisEvalPoints(edgeDim, ie);
96 scalarViewType orientedTargetCubPoints(
"orientedTargetCubPoints", cubPoints.extent(0),edgeDim);
98 const auto topoKey = projStruct->getTopologyKey(edgeDim,ie);
100 for(ordinal_type ic=0; ic<numCells; ++ic) {
101 orts(ic).getEdgeOrientation(eOrt.data(), numEdges);
102 ordinal_type ort = eOrt(ie);
109 for(ordinal_type iface=0; iface<numFaces; ++iface) {
111 scalarViewType cubPoints;
112 range_type facePointsRange;
113 if(evalPointType == TARGET) {
114 cubPoints = projStruct->getTargetEvalPoints(faceDim, iface);
115 facePointsRange = projStruct->getTargetPointsRange(faceDim, iface);
117 cubPoints = projStruct->getBasisEvalPoints(faceDim, iface);
118 facePointsRange = projStruct->getBasisPointsRange(faceDim, iface);
121 scalarViewType curlCubPoints;
122 range_type faceCurlPointsRange;
123 if(evalPointType == TARGET) {
124 curlCubPoints = projStruct->getTargetDerivEvalPoints(faceDim, iface);
125 faceCurlPointsRange = projStruct->getTargetDerivPointsRange(faceDim, iface);
127 curlCubPoints = projStruct->getBasisDerivEvalPoints(faceDim, iface);
128 faceCurlPointsRange = projStruct->getBasisDerivPointsRange(faceDim, iface);
131 scalarViewType faceCubPoints(
"faceCubPoints", cubPoints.extent(0), faceDim);
132 scalarViewType faceCurlCubPoints(
"faceCurlCubPoints", curlCubPoints.extent(0), faceDim);
134 const auto topoKey = projStruct->getTopologyKey(faceDim,iface);
135 for(ordinal_type ic=0; ic<numCells; ++ic) {
137 orts(ic).getFaceOrientation(fOrt.data(), numFaces);
139 ordinal_type ort = fOrt(iface);
144 CellTools<SpT>::mapToReferenceSubcell(Kokkos::subview(extDerivEvaluationPoints, ic, faceCurlPointsRange, Kokkos::ALL()), faceCurlCubPoints, faceDim, iface, cellBasis->getBaseCellTopology());
149 if(cellBasis->getDofCount(dim,0)>0) {
150 range_type cellPointsRange;
151 scalarViewType cubPoints;
152 if(evalPointType == TARGET) {
153 cubPoints = projStruct->getTargetEvalPoints(dim, 0);
154 cellPointsRange = projStruct->getTargetPointsRange(dim, 0);
156 cubPoints = projStruct->getBasisEvalPoints(dim, 0);
157 cellPointsRange = projStruct->getBasisPointsRange(dim, 0);
161 range_type cellCurlPointsRange;
162 scalarViewType curlCubPoints;
163 if(evalPointType == TARGET) {
164 curlCubPoints = projStruct->getTargetDerivEvalPoints(dim, 0);
165 cellCurlPointsRange = projStruct->getTargetDerivPointsRange(dim, 0);
167 curlCubPoints = projStruct->getBasisDerivEvalPoints(dim, 0);
168 cellCurlPointsRange = projStruct->getBasisDerivPointsRange(dim, 0);
170 RealSpaceTools<SpT>::clone(Kokkos::subview(extDerivEvaluationPoints, Kokkos::ALL(), cellCurlPointsRange, Kokkos::ALL()), curlCubPoints);
175 template<
typename SpT>
176 template<
typename basisCoeffsValueType,
class ...basisCoeffsProperties,
177 typename funValsValueType,
class ...funValsProperties,
179 typename ortValueType,
class ...ortProperties>
182 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtEvalPoints,
183 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetCurlAtCurlEvalPoints,
184 const typename BasisType::scalarViewType evaluationPoints,
185 const typename BasisType::scalarViewType extDerivEvaluationPoints,
186 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
187 const BasisType* cellBasis,
188 ProjectionStruct<SpT, typename BasisType::scalarType> * projStruct){
190 typedef typename Kokkos::Impl::is_space<SpT>::host_mirror_space::execution_space host_space_type;
191 typedef typename BasisType::scalarType scalarType;
192 typedef Kokkos::DynRankView<scalarType,SpT> scalarViewType;
193 typedef Kokkos::pair<ordinal_type,ordinal_type> range_type;
194 const auto cellTopo = cellBasis->getBaseCellTopology();
195 ordinal_type dim = cellTopo.getDimension();
196 ordinal_type numTotalEvaluationPoints(targetAtEvalPoints.extent(1)),
197 numTotalCurlEvaluationPoints(targetCurlAtCurlEvalPoints.extent(1));
198 ordinal_type basisCardinality = cellBasis->getCardinality();
199 ordinal_type numCells = targetAtEvalPoints.extent(0);
200 const ordinal_type edgeDim = 1;
201 const ordinal_type faceDim = 2;
202 const ordinal_type derDim = dim == 3 ? dim : 1;
204 const std::string& name = cellBasis->getName();
206 ordinal_type numEdges = (cellBasis->getDofCount(1, 0) > 0) ? cellTopo.getEdgeCount() : 0;
207 ordinal_type numFaces = (cellBasis->getDofCount(2, 0) > 0) ? cellTopo.getFaceCount() : 0;
209 Kokkos::View<ordinal_type*> eOrt(
"eOrt", numEdges);
210 Kokkos::View<ordinal_type*> fOrt(
"fOrt", numFaces);
211 scalarViewType refEdgeTan(
"refEdgeTan", dim);
212 scalarViewType refFaceTangents(
"refFaceTangents", dim, 2);
213 scalarViewType refFaceNormal(
"refFaceNormal", dim);
214 auto refFaceTanU = Kokkos::subview(refFaceTangents, Kokkos::ALL, 0);
215 auto refFaceTanV = Kokkos::subview(refFaceTangents, Kokkos::ALL, 1);
217 ordinal_type numEdgeDofs(0);
218 for(ordinal_type ie=0; ie<numEdges; ++ie)
219 numEdgeDofs += cellBasis->getDofCount(edgeDim,ie);
221 ordinal_type numFaceDofs(0);
222 for(ordinal_type iface=0; iface<numFaces; ++iface)
223 numFaceDofs += cellBasis->getDofCount(faceDim,iface);
225 Kokkos::View<ordinal_type*> computedDofs(
"computedDofs",numEdgeDofs+numFaceDofs);
227 ordinal_type computedDofsCount = 0;
229 ordinal_type numTotalCubPoints = projStruct->getNumBasisEvalPoints(), numTotalCurlCubPoints = projStruct->getNumBasisDerivEvalPoints();
230 scalarViewType cubPoints(
"cubPoints",numCells,numTotalCubPoints, dim);
231 scalarViewType curlCubPoints(
"curlCubPoints",numCells,numTotalCurlCubPoints, dim);
232 getHCurlEvaluationPoints(cubPoints, curlCubPoints, orts, cellBasis, projStruct, BASIS);
234 scalarViewType basisAtCubPoints(
"basisAtCubPoints",numCells,basisCardinality, numTotalCubPoints, dim);
235 scalarViewType basisAtTargetCubPoints(
"basisAtTargetCubPoints",numCells,basisCardinality, numTotalEvaluationPoints, dim);
237 scalarViewType nonOrientedBasisAtCubPoints(
"nonOrientedBasisAtCubPoints",numCells,basisCardinality, numTotalCubPoints, dim);
238 scalarViewType nonOrientedBasisAtTargetCubPoints(
"nonOrientedBasisAtTargetCubPoints",numCells,basisCardinality, numTotalEvaluationPoints, dim);
239 for(ordinal_type ic=0; ic<numCells; ++ic) {
240 cellBasis->getValues(Kokkos::subview(nonOrientedBasisAtTargetCubPoints,ic,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(evaluationPoints, ic, Kokkos::ALL(), Kokkos::ALL()));
241 cellBasis->getValues(Kokkos::subview(nonOrientedBasisAtCubPoints,ic,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(cubPoints, ic, Kokkos::ALL(), Kokkos::ALL()));
248 scalarViewType basisCurlAtCurlCubPoints;
249 scalarViewType basisCurlAtTargetCurlCubPoints;
250 if(numTotalCurlEvaluationPoints>0) {
251 scalarViewType nonOrientedBasisCurlAtTargetCurlCubPoints, nonOrientedBasisCurlAtCurlCubPoints;
253 basisCurlAtCurlCubPoints = scalarViewType (
"basisCurlAtCurlCubPoints",numCells,basisCardinality, numTotalCurlCubPoints, dim);
254 nonOrientedBasisCurlAtCurlCubPoints = scalarViewType (
"nonOrientedBasisCurlAtCurlCubPoints",numCells,basisCardinality, numTotalCurlCubPoints, dim);
255 basisCurlAtTargetCurlCubPoints = scalarViewType(
"basisCurlAtTargetCurlCubPoints",numCells,basisCardinality, numTotalCurlEvaluationPoints, dim);
256 nonOrientedBasisCurlAtTargetCurlCubPoints = scalarViewType(
"nonOrientedBasisCurlAtTargetCurlCubPoints",numCells,basisCardinality, numTotalCurlEvaluationPoints, dim);
258 basisCurlAtCurlCubPoints = scalarViewType (
"basisCurlAtCurlCubPoints",numCells,basisCardinality, numTotalCurlCubPoints);
259 nonOrientedBasisCurlAtCurlCubPoints = scalarViewType (
"nonOrientedBasisCurlAtCurlCubPoints",numCells,basisCardinality, numTotalCurlCubPoints);
260 basisCurlAtTargetCurlCubPoints = scalarViewType(
"basisCurlAtTargetCurlCubPoints",numCells,basisCardinality, numTotalCurlEvaluationPoints);
261 nonOrientedBasisCurlAtTargetCurlCubPoints = scalarViewType(
"nonOrientedBasisCurlAtTargetCurlCubPoints",numCells,basisCardinality, numTotalCurlEvaluationPoints);
263 for(ordinal_type ic=0; ic<numCells; ++ic) {
264 cellBasis->getValues(Kokkos::subview(nonOrientedBasisCurlAtCurlCubPoints,ic,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(curlCubPoints, ic, Kokkos::ALL(), Kokkos::ALL()),OPERATOR_CURL);
265 cellBasis->getValues(Kokkos::subview(nonOrientedBasisCurlAtTargetCurlCubPoints,ic,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()), Kokkos::subview(extDerivEvaluationPoints, ic, Kokkos::ALL(), Kokkos::ALL()),OPERATOR_CURL);
271 for(ordinal_type ie=0; ie<numEdges; ++ie) {
273 ordinal_type edgeCardinality = cellBasis->getDofCount(edgeDim,ie);
274 ordinal_type numCubPoints = projStruct->getNumBasisEvalPoints(edgeDim, ie);
275 ordinal_type numTargetCubPoints = projStruct->getNumTargetEvalPoints(edgeDim, ie);
279 scalarViewType tanBasisAtElemCubPoints(
"tanBasisAtElemCubPoints",numCells,edgeCardinality, numCubPoints);
280 scalarViewType tanBasisAtTargetCubPoints(
"tanBasisAtTargetCubPoints",numCells,edgeCardinality, numTargetCubPoints);
281 scalarViewType weightedTanBasisAtElemCubPoints(
"weightedTanBasisAtElemCubPoints",numCells,edgeCardinality, numCubPoints);
282 scalarViewType weightedTanBasisAtTargetCubPoints(
"weightedTanBasisAtTargetCubPoints",numCells,edgeCardinality, numTargetCubPoints);
283 scalarViewType tanTargetAtTargetCubPoints(
"normalTargetAtTargetCubPoints",numCells, numTargetCubPoints);
285 scalarViewType targetEvalWeights = projStruct->getTargetEvalWeights(edgeDim, ie);
286 scalarViewType basisEvalWeights = projStruct->getBasisEvalWeights(edgeDim, ie);
289 ordinal_type offsetBasis = projStruct->getBasisPointsRange(edgeDim, ie).first;
290 ordinal_type offsetTarget = projStruct->getTargetPointsRange(edgeDim, ie).first;
291 for(ordinal_type ic=0; ic<numCells; ++ic) {
292 for(ordinal_type j=0; j <edgeCardinality; ++j) {
293 ordinal_type jdof = cellBasis->getDofOrdinal(edgeDim, ie, j);
294 for(ordinal_type iq=0; iq <numCubPoints; ++iq) {
295 for(ordinal_type d=0; d <dim; ++d)
296 tanBasisAtElemCubPoints(ic,j,iq) += refEdgeTan(d)*basisAtCubPoints(ic,jdof,offsetBasis+iq,d);
297 weightedTanBasisAtElemCubPoints(ic,j,iq) = tanBasisAtElemCubPoints(ic,j,iq)*basisEvalWeights(iq);
299 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq) {
300 for(ordinal_type d=0; d <dim; ++d)
301 tanBasisAtTargetCubPoints(ic,j,iq) += refEdgeTan(d)*basisAtTargetCubPoints(ic,jdof,offsetTarget+iq,d);
302 weightedTanBasisAtTargetCubPoints(ic,j,iq) = tanBasisAtTargetCubPoints(ic,j,iq)*targetEvalWeights(iq);
305 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq)
306 for(ordinal_type d=0; d <dim; ++d)
307 tanTargetAtTargetCubPoints(ic,iq) += refEdgeTan(d)*targetAtEvalPoints(ic,offsetTarget+iq,d);
309 scalarViewType edgeMassMat_(
"edgeMassMat_", numCells, edgeCardinality+1, edgeCardinality+1),
310 edgeRhsMat_(
"rhsMat_", numCells, edgeCardinality+1);
312 scalarViewType cubWeights_(
"cubWeights_", numCells, 1, basisEvalWeights.extent(0)), targetEvalWeights_(
"targetEvalWeights", numCells, 1, targetEvalWeights.extent(0));
316 range_type range_H(0, edgeCardinality);
317 range_type range_B(edgeCardinality, edgeCardinality+1);
322 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> edgeMassMat(
"edgeMassMat", edgeCardinality+1,edgeCardinality+1);
323 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> edgeRhsMat(
"edgeRhsMat",edgeCardinality+1, 1);
325 Teuchos::LAPACK<ordinal_type,funValsValueType> lapack;
326 ordinal_type info = 0;
327 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> pivVec(
"pivVec", edgeCardinality+1, 1);
328 for(ordinal_type ic=0; ic<numCells; ++ic) {
329 Kokkos::deep_copy(edgeMassMat,funValsValueType(0));
331 for(ordinal_type i=0; i<edgeCardinality; ++i) {
332 edgeRhsMat(i,0) = edgeRhsMat_(ic,i);
333 for(ordinal_type j=0; j<edgeCardinality+1; ++j)
334 edgeMassMat(i,j) = edgeMassMat_(ic,i,j);
335 edgeMassMat(edgeCardinality,i) = edgeMassMat_(ic,i,edgeCardinality);
337 edgeRhsMat(edgeCardinality,0) = edgeRhsMat_(ic,edgeCardinality);
339 lapack.GESV(edgeCardinality+1, 1,
341 edgeMassMat.stride_1(),
342 (ordinal_type*)pivVec.data(),
344 edgeRhsMat.stride_1(),
348 std::stringstream ss;
349 ss <<
">>> ERROR (Intrepid::ProjectionTools::getBasisCoeffs): "
350 <<
"LAPACK return with error code: "
352 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
355 for(ordinal_type i=0; i<edgeCardinality; ++i){
356 ordinal_type edge_dof = cellBasis->getDofOrdinal(edgeDim, ie, i);
357 basisCoeffs(ic,edge_dof) = edgeRhsMat(i,0);
360 for(ordinal_type i=0; i<edgeCardinality; ++i)
361 computedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(edgeDim, ie, i);
365 scalarViewType ortJacobian(
"ortJacobian", faceDim, faceDim);
367 Basis<host_space_type,scalarType,scalarType> *hgradBasis = NULL;
368 for(ordinal_type iface=0; iface<numFaces; ++iface) {
370 if(name.find(
"HEX")!=std::string::npos)
371 hgradBasis =
new Basis_HGRAD_QUAD_Cn_FEM<host_space_type,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
372 else if(name.find(
"TET")!=std::string::npos)
373 hgradBasis =
new Basis_HGRAD_TRI_Cn_FEM<host_space_type,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
375 std::stringstream ss;
376 ss <<
">>> ERROR (Intrepid2::ProjectionTools::getHCurlBasisCoeffs): "
377 <<
"Method not implemented for basis " << name;
378 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
383 ordinal_type numFaceDofs = cellBasis->getDofCount(faceDim,iface);
384 ordinal_type numTargetCubPoints = projStruct->getNumTargetEvalPoints(faceDim, iface);
386 ordinal_type numTargetCurlCubPoints = projStruct->getNumTargetDerivEvalPoints(faceDim, iface);
387 ordinal_type numCubPoints = projStruct->getNumBasisEvalPoints(faceDim, iface);
389 scalarViewType hgradBasisGradAtCubPoints(
"hgradBasisGradAtCubPoints",hgradBasis->getCardinality(), numCubPoints, faceDim);
390 scalarViewType hgradBasisGradAtTargetCubPoints(
"hgradBasisGradAtTargetCubPoints",hgradBasis->getCardinality(), numTargetCubPoints, faceDim);
392 ordinal_type internalHgradCardinality = hgradBasis->getDofCount(faceDim,0);
393 scalarViewType internalHgradBasisGradAtCubPoints(
"internalHgradBasisGradAtCubPoints",1, internalHgradCardinality, numCubPoints, faceDim);
394 scalarViewType internalHgradBasisGradAtTargetCubPoints(
"internalHgradBasisGradAtTargetCubPoints",1, internalHgradCardinality, numTargetCubPoints, faceDim);
400 hgradBasis->getValues(hgradBasisGradAtCubPoints,projStruct->getBasisEvalPoints(faceDim, iface), OPERATOR_GRAD);
401 hgradBasis->getValues(hgradBasisGradAtTargetCubPoints,projStruct->getTargetEvalPoints(faceDim, iface),OPERATOR_GRAD);
403 for(ordinal_type j=0; j <internalHgradCardinality; ++j) {
404 ordinal_type face_dof = hgradBasis->getDofOrdinal(faceDim, 0, j);
405 for(ordinal_type d=0; d <faceDim; ++d) {
406 for(ordinal_type iq=0; iq <numCubPoints; ++iq)
407 internalHgradBasisGradAtCubPoints(0,j,iq,d)= hgradBasisGradAtCubPoints(face_dof,iq,d);
408 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq)
409 internalHgradBasisGradAtTargetCubPoints(0,j,iq,d)= hgradBasisGradAtTargetCubPoints(face_dof,iq,d);
413 scalarViewType tanBasisAtElemCubPoints(
"tanBasisAtElemCubPoints",numCells,numFaceDofs, numCubPoints,dim-1);
414 scalarViewType tanBasisAtTargetCubPoints(
"tanBasisAtTargetCubPoints",numCells,numFaceDofs, numTargetCubPoints,dim-1);
415 scalarViewType normalBasisCurlAtElemCubPoints(
"normaBasisCurlAtElemCubPoints",numCells,numFaceDofs, numCubPoints);
416 scalarViewType wNormalBasisCurlAtElemCubPoints(
"weightedNormalBasisCurlAtElemCubPoints",numCells,numFaceDofs, numCubPoints);
418 scalarViewType tanTargetAtTargetCubPoints(
"tanTargetAtTargetCubPoints",numCells, numTargetCubPoints, dim-1);
419 scalarViewType normalTargetCurlAtTargetCubPoints(
"normalTargetCurlAtTargetCubPoints",numCells, numTargetCurlCubPoints);
420 scalarViewType normalBasisCurlAtTargetCurlCubPoints(
"normalBasisCurlAtTargetCurlCubPoints",numCells,numFaceDofs, numTargetCurlCubPoints);
421 scalarViewType wNormalBasisCurlBasisAtTargetCurlCubPoints(
"weightedNormalBasisCurlAtTargetCurlCubPoints",numCells,numFaceDofs, numTargetCurlCubPoints);
423 scalarViewType wHgradBasisGradAtCubPoints(
"wHgradBasisGradAtCubPoints",1, internalHgradCardinality, numCubPoints, faceDim);
424 scalarViewType wHgradBasisGradAtCubPoints_(
"wHgradBasisGradAtCubPoints_",numCells, internalHgradCardinality, numCubPoints, faceDim);
425 scalarViewType wHgradBasisGradAtTargetCubPoints(
"wHgradBasisGradAtTargetCubPoints",1, internalHgradCardinality, numTargetCubPoints, faceDim);
426 scalarViewType wHgradBasisGradAtTargetCubPoints_(
"wHgradBasisGradAtTargetCubPoints_",numCells, internalHgradCardinality, numTargetCubPoints, faceDim);
428 scalarViewType mNormalComputedProjectionCurl(
"mNormalComputedProjection", numCells,numCubPoints);
429 scalarViewType mTanComputedProjection(
"mTanComputedProjection", numCells,numCubPoints,dim-1);
431 scalarViewType targetDerivEvalWeights = projStruct->getTargetDerivEvalWeights(faceDim, iface);
432 ordinal_type offsetBasis = projStruct->getBasisPointsRange(faceDim, iface).first;
433 ordinal_type offsetBasisCurl = projStruct->getBasisDerivPointsRange(faceDim, iface).first;
434 ordinal_type offsetTarget = projStruct->getTargetPointsRange(faceDim, iface).first;
435 ordinal_type offsetTargetCurl = projStruct->getTargetDerivPointsRange(faceDim, iface).first;
439 const auto topoKey = projStruct->getTopologyKey(faceDim,iface);
440 for(ordinal_type ic=0; ic<numCells; ++ic) {
441 orts(ic).getFaceOrientation(fOrt.data(), numFaces);
443 ordinal_type ort = fOrt(iface);
447 for(ordinal_type j=0; j <numFaceDofs; ++j) {
448 ordinal_type jdof = cellBasis->getDofOrdinal(faceDim, iface, j);
449 for(ordinal_type iq=0; iq <numCubPoints; ++iq)
450 for(ordinal_type d=0; d <dim; ++d) {
451 normalBasisCurlAtElemCubPoints(ic,j,iq) += refFaceNormal(d)*basisCurlAtCurlCubPoints(ic,jdof,offsetBasisCurl+iq,d);
452 for(ordinal_type itan=0; itan <dim-1; ++itan)
453 for(ordinal_type jtan=0; jtan <dim-1; ++jtan)
454 tanBasisAtElemCubPoints(ic,j,iq,itan) += refFaceTangents(d,jtan)*ortJacobian(jtan,itan)*basisAtCubPoints(ic,jdof,offsetBasis+iq,d);
456 for(ordinal_type iq=0; iq <numTargetCurlCubPoints; ++iq) {
457 for(ordinal_type d=0; d <dim; ++d)
458 normalBasisCurlAtTargetCurlCubPoints(ic,j,iq) += refFaceNormal(d)*basisCurlAtTargetCurlCubPoints(ic,jdof,offsetTargetCurl+iq,d);
459 wNormalBasisCurlBasisAtTargetCurlCubPoints(ic,j,iq) = normalBasisCurlAtTargetCurlCubPoints(ic,j,iq)*targetDerivEvalWeights[iq];
462 for(ordinal_type j=0; j <numEdgeDofs; ++j) {
463 ordinal_type jdof = computedDofs(j);
464 for(ordinal_type iq=0; iq <numCubPoints; ++iq)
465 for(ordinal_type d=0; d <dim; ++d) {
466 mNormalComputedProjectionCurl(ic,iq) -= refFaceNormal(d)*basisCoeffs(ic,jdof)*basisCurlAtCurlCubPoints(ic,jdof,offsetBasisCurl+iq,d);
467 for(ordinal_type itan=0; itan <dim-1; ++itan)
468 for(ordinal_type jtan=0; jtan <dim-1; ++jtan)
469 mTanComputedProjection(ic,iq,itan) -= refFaceTangents(d,jtan)*ortJacobian(jtan,itan)*basisCoeffs(ic,jdof)*basisAtCubPoints(ic,jdof,offsetBasis+iq,d);
472 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq)
473 for(ordinal_type d=0; d <dim; ++d)
474 for(ordinal_type itan=0; itan <dim-1; ++itan)
475 for(ordinal_type jtan=0; jtan <dim-1; ++jtan)
476 tanTargetAtTargetCubPoints(ic,iq,itan) += refFaceTangents(d,jtan)*ortJacobian(jtan,itan)*targetAtEvalPoints(ic,offsetTarget+iq,d);
477 for(ordinal_type iq=0; iq <numTargetCurlCubPoints; ++iq)
478 for(ordinal_type d=0; d <dim; ++d)
479 normalTargetCurlAtTargetCubPoints(ic,iq) += refFaceNormal(d)*targetCurlAtCurlEvalPoints(ic,offsetTargetCurl+iq,d);
482 scalarViewType faceMassMat_(
"faceMassMat_", numCells, numFaceDofs+internalHgradCardinality, numFaceDofs+internalHgradCardinality),
483 faceRhsMat_(
"rhsMat_", numCells, numFaceDofs+internalHgradCardinality);
485 scalarViewType targetCubWeights_(
"targetCubWeights_", 1, projStruct->getNumTargetEvalPoints(faceDim, iface));
487 scalarViewType cubWeights_(
"cubWeights_", numCells, 1, numCubPoints);
493 RealSpaceTools<SpT>::clone(wHgradBasisGradAtCubPoints_,Kokkos::subview(wHgradBasisGradAtCubPoints,0,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()));
494 RealSpaceTools<SpT>::clone(wHgradBasisGradAtTargetCubPoints_,Kokkos::subview(wHgradBasisGradAtTargetCubPoints,0,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL()));
496 range_type range_H(0, numFaceDofs);
497 range_type range_B(numFaceDofs, numFaceDofs+internalHgradCardinality);
507 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> faceMassMat(
"faceMassMat", numFaceDofs+internalHgradCardinality,numFaceDofs+internalHgradCardinality);
508 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> faceRhsMat(
"faceRhsMat",numFaceDofs+internalHgradCardinality, 1);
510 Teuchos::LAPACK<ordinal_type,funValsValueType> lapack;
511 ordinal_type info = 0;
512 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> pivVec(
"pivVec", numFaceDofs+internalHgradCardinality, 1);
513 for(ordinal_type ic=0; ic<numCells; ++ic) {
514 Kokkos::deep_copy(faceMassMat,funValsValueType(0));
516 for(ordinal_type i=0; i<numFaceDofs; ++i) {
517 for(ordinal_type j=0; j<numFaceDofs+internalHgradCardinality; ++j)
518 faceMassMat(i,j) = faceMassMat_(ic,i,j);
519 for(ordinal_type j=0; j<internalHgradCardinality; ++j)
520 faceMassMat(numFaceDofs+j,i) = faceMassMat_(ic,i,numFaceDofs+j);
523 for(ordinal_type i=0; i<numFaceDofs+internalHgradCardinality; ++i)
524 faceRhsMat(i,0) = faceRhsMat_(ic,i);
526 lapack.GESV(numFaceDofs+internalHgradCardinality, 1,
528 faceMassMat.stride_1(),
529 (ordinal_type*)pivVec.data(),
531 faceRhsMat.stride_1(),
535 std::stringstream ss;
536 ss <<
">>> ERROR (Intrepid::ProjectionTools::getBasisCoeffs): "
537 <<
"LAPACK return with error code: "
539 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
542 for(ordinal_type i=0; i<numFaceDofs; ++i){
543 ordinal_type face_dof = cellBasis->getDofOrdinal(faceDim, iface, i);
544 basisCoeffs(ic,face_dof) = faceRhsMat(i,0);
548 for(ordinal_type i=0; i<numFaceDofs; ++i)
549 computedDofs(computedDofsCount++) = cellBasis->getDofOrdinal(faceDim, iface, i);
554 ordinal_type numElemDofs = cellBasis->getDofCount(dim,0);
556 if(name.find(
"HEX")!=std::string::npos)
557 hgradBasis =
new Basis_HGRAD_HEX_Cn_FEM<host_space_type,scalarType,scalarType>(cellBasis->getDegree());
558 else if(name.find(
"TET")!=std::string::npos)
559 hgradBasis =
new Basis_HGRAD_TET_Cn_FEM<host_space_type,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
560 else if(name.find(
"TRI")!=std::string::npos)
561 hgradBasis =
new Basis_HGRAD_TRI_Cn_FEM<host_space_type,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
562 else if(name.find(
"QUAD")!=std::string::npos)
563 hgradBasis =
new Basis_HGRAD_QUAD_Cn_FEM<host_space_type,scalarType,scalarType>(cellBasis->getDegree(),POINTTYPE_WARPBLEND);
565 std::stringstream ss;
566 ss <<
">>> ERROR (Intrepid2::ProjectionTools::getHCurlBasisCoeffs): "
567 <<
"Method not implemented for basis " << name;
568 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
572 range_type cellPointsRange = projStruct->getTargetPointsRange(dim, 0);
573 range_type cellCurlPointsRange = projStruct->getTargetDerivPointsRange(dim, 0);
575 ordinal_type numTargetCurlCubPoints = projStruct->getNumTargetDerivEvalPoints(dim,0);
576 ordinal_type numCubPoints = projStruct->getNumBasisEvalPoints(dim,0);
577 ordinal_type numTargetCubPoints = projStruct->getNumTargetEvalPoints(dim,0);
579 scalarViewType hgradBasisGradAtCubPoints(
"hgradBasisGradAtCubPoints",hgradBasis->getCardinality(), numCubPoints, dim);
580 scalarViewType hgradBasisGradAtTargetCubPoints(
"hgradBasisGradAtTargetCubPoints",hgradBasis->getCardinality(), numTargetCubPoints, dim);
582 ordinal_type internalHgradCardinality = hgradBasis->getDofCount(dim,0);
583 scalarViewType internalHgradBasisGradAtCubPoints(
"internalHgradBasisGradAtCubPoints",1, internalHgradCardinality, numCubPoints, dim);
584 scalarViewType internalHgradBasisGradAtTargetCubPoints(
"internalHgradBasisGradAtTargetCubPoints",numCells, internalHgradCardinality, numTargetCubPoints, dim);
585 scalarViewType wHgradBasisGradAtTargetCubPoints(
"wHgradBasisGradAtTargetCubPoints",numCells, internalHgradCardinality, numTargetCubPoints, dim);
586 scalarViewType wHgradBasisGradAtCubPoints(
"wHgradBasisGradAtCubPoints",numCells, internalHgradCardinality, numCubPoints, dim);
588 scalarViewType targetEvalWeights = projStruct->getTargetEvalWeights(dim, 0);
589 scalarViewType basisEvalWeights = projStruct->getBasisEvalWeights(dim, 0);
591 hgradBasis->getValues(hgradBasisGradAtCubPoints,projStruct->getBasisEvalPoints(dim, 0), OPERATOR_GRAD);
592 hgradBasis->getValues(hgradBasisGradAtTargetCubPoints,projStruct->getTargetEvalPoints(dim, 0),OPERATOR_GRAD);
594 for(ordinal_type j=0; j <internalHgradCardinality; ++j) {
595 ordinal_type idof = hgradBasis->getDofOrdinal(dim, 0, j);
596 for(ordinal_type d=0; d <dim; ++d) {
597 for(ordinal_type iq=0; iq <numCubPoints; ++iq) {
598 internalHgradBasisGradAtCubPoints(0,j,iq,d)= hgradBasisGradAtCubPoints(idof,iq,d);
599 for(ordinal_type ic=0; ic<numCells; ++ic)
600 wHgradBasisGradAtCubPoints(ic,j,iq,d) = internalHgradBasisGradAtCubPoints(0,j,iq,d)*basisEvalWeights[iq];
602 for(ordinal_type iq=0; iq <numTargetCubPoints; ++iq)
603 for(ordinal_type ic=0; ic<numCells; ++ic) {
604 internalHgradBasisGradAtTargetCubPoints(ic,j,iq,d)= hgradBasisGradAtTargetCubPoints(idof,iq,d);
605 wHgradBasisGradAtTargetCubPoints(ic,j,iq,d) = internalHgradBasisGradAtTargetCubPoints(ic,j,iq,d)*targetEvalWeights[iq];
610 scalarViewType internalBasisAtElemcubPoints(
"basisElemAtcubPoints",numCells,numElemDofs, numCubPoints, dim);
611 scalarViewType internalBasisCurlAtElemcubPoints(
"internalBasisCurlAtElemcubPoints",numCells,numElemDofs, numCubPoints, derDim);
612 scalarViewType internalBasisCurlAtTargetCurlCubPoints(
"weightedBasisCurlAtElemCubPoints",numCells,numElemDofs, numTargetCurlCubPoints,derDim);
613 scalarViewType mComputedProjectionCurl(
"mComputedProjectionCurl", numCells, numCubPoints, derDim);
614 scalarViewType mComputedProjection(
"mComputedProjection", numCells, numCubPoints, dim);
615 scalarViewType wBasisCurlAtElemCubPoints(
"weightedBasisCurlAtElemCubPoints",numCells,numElemDofs, numCubPoints,derDim);
616 scalarViewType wBasisCurlBasisAtTargetCurlCubPoints(
"weightedBasisCurlAtTargetCurlCubPoints",numCells,numElemDofs, numTargetCurlCubPoints,derDim);
617 scalarViewType targetDerivEvalWeights = projStruct->getTargetDerivEvalWeights(dim, 0);
618 ordinal_type offsetBasis = projStruct->getBasisPointsRange(dim, 0).first;
619 ordinal_type offsetBasisCurl = projStruct->getBasisDerivPointsRange(dim, 0).first;
620 ordinal_type offsetTargetCurl = projStruct->getTargetDerivPointsRange(dim, 0).first;
622 for(ordinal_type j=0; j <numElemDofs; ++j) {
623 ordinal_type idof = cellBasis->getDofOrdinal(dim, 0, j);
624 for(ordinal_type ic=0; ic<numCells; ++ic) {
625 for(ordinal_type d=0; d <dim; ++d)
626 for(ordinal_type iq=0; iq <numCubPoints; ++iq)
627 internalBasisAtElemcubPoints(ic,j,iq,d)=basisAtCubPoints(ic,idof,offsetBasis+iq,d);
629 for(ordinal_type d=0; d <derDim; ++d) {
630 for(ordinal_type iq=0; iq <numCubPoints; ++iq) {
631 internalBasisCurlAtElemcubPoints(ic,j,iq,d)=basisCurlAtCurlCubPoints(ic,idof,offsetBasisCurl+iq,d);
632 wBasisCurlAtElemCubPoints(ic,j,iq,d)=internalBasisCurlAtElemcubPoints(ic,j,iq,d)*basisEvalWeights[iq];
634 for(ordinal_type iq=0; iq <numTargetCurlCubPoints; ++iq) {
635 internalBasisCurlAtTargetCurlCubPoints(ic,j,iq,d)= basisCurlAtTargetCurlCubPoints(ic,idof,offsetTargetCurl+iq,d);
636 wBasisCurlBasisAtTargetCurlCubPoints(ic,j,iq,d) = internalBasisCurlAtTargetCurlCubPoints(ic,j,iq,d)*targetDerivEvalWeights[iq];
642 for(ordinal_type j=0; j <numEdgeDofs+numFaceDofs; ++j) {
643 ordinal_type jdof = computedDofs(j);
644 for(ordinal_type iq=0; iq <numCubPoints; ++iq)
645 for(ordinal_type ic=0; ic<numCells; ++ic) {
646 for(ordinal_type d=0; d <derDim; ++d)
647 mComputedProjectionCurl(ic,iq,d) -= basisCoeffs(ic,jdof)*basisCurlAtCurlCubPoints(ic,jdof,offsetBasisCurl+iq,d);
648 for(ordinal_type d=0; d <dim; ++d)
649 mComputedProjection(ic,iq,d) -= basisCoeffs(ic,jdof)*basisAtCubPoints(ic,jdof,offsetBasis+iq,d);
653 scalarViewType cellMassMat_(
"cellMassMat_", numCells, numElemDofs+internalHgradCardinality, numElemDofs+internalHgradCardinality),
654 cellRhsMat_(
"rhsMat_", numCells, numElemDofs+internalHgradCardinality);
656 range_type range_H(0, numElemDofs);
657 range_type range_B(numElemDofs, numElemDofs+internalHgradCardinality);
661 FunctionSpaceTools<SpT >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_H), Kokkos::subview(targetCurlAtCurlEvalPoints,Kokkos::ALL(),cellCurlPointsRange,Kokkos::ALL()), wBasisCurlBasisAtTargetCurlCubPoints);
663 FunctionSpaceTools<SpT >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_H), Kokkos::subview(targetCurlAtCurlEvalPoints,Kokkos::ALL(),cellCurlPointsRange), Kokkos::subview(wBasisCurlBasisAtTargetCurlCubPoints,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL(),0));
666 FunctionSpaceTools<SpT >::integrate(Kokkos::subview(cellRhsMat_,Kokkos::ALL(),range_B), Kokkos::subview(targetAtEvalPoints,Kokkos::ALL(),cellPointsRange,Kokkos::ALL()), wHgradBasisGradAtTargetCubPoints);
669 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> cellMassMat(
"cellMassMat", numElemDofs+internalHgradCardinality,numElemDofs+internalHgradCardinality);
670 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> cellRhsMat(
"cellRhsMat",numElemDofs+internalHgradCardinality, 1);
672 Teuchos::LAPACK<ordinal_type,funValsValueType> lapack;
673 ordinal_type info = 0;
674 Kokkos::View<funValsValueType**,Kokkos::LayoutLeft,host_space_type> pivVec(
"pivVec", numElemDofs+internalHgradCardinality, 1);
676 for(ordinal_type ic=0; ic<numCells; ++ic) {
677 Kokkos::deep_copy(cellMassMat,funValsValueType(0));
679 for(ordinal_type i=0; i<numElemDofs; ++i) {
680 for(ordinal_type j=0; j<numElemDofs+internalHgradCardinality; ++j)
681 cellMassMat(i,j) = cellMassMat_(ic,i,j);
682 for(ordinal_type j=0; j<internalHgradCardinality; ++j)
683 cellMassMat(numElemDofs+j,i) = cellMassMat_(0,i,numElemDofs+j);
686 for(ordinal_type i=0; i<numElemDofs+internalHgradCardinality; ++i)
687 cellRhsMat(i,0) = cellRhsMat_(ic,i);
690 lapack.GESV(numElemDofs+internalHgradCardinality, 1,
692 cellMassMat.stride_1(),
693 (ordinal_type*)pivVec.data(),
695 cellRhsMat.stride_1(),
698 for(ordinal_type i=0; i<numElemDofs; ++i){
699 ordinal_type idof = cellBasis->getDofOrdinal(dim, 0, i);
700 basisCoeffs(ic,idof) = cellRhsMat(i,0);
704 std::stringstream ss;
705 ss <<
">>> ERROR (Intrepid::ProjectionTools::getBasisCoeffs): "
706 <<
"LAPACK return with error code: "
708 INTREPID2_TEST_FOR_EXCEPTION(
true, std::runtime_error, ss.str().c_str() );
Header file for the abstract base class Intrepid2::DefaultCubatureFactory.