Intrepid2
Intrepid2_ProjectionToolsDefHVOL.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_PROJECTIONTOOLSDEFHVOL_HPP__
17#define __INTREPID2_PROJECTIONTOOLSDEFHVOL_HPP__
18
22
23
24namespace Intrepid2 {
25
26template<typename DeviceType>
27template<typename basisCoeffsValueType, class ...basisCoeffsProperties,
28typename funValsValueType, class ...funValsProperties,
29typename BasisType,
30typename ortValueType,class ...ortProperties>
31void
32ProjectionTools<DeviceType>::getHVolBasisCoeffs(Kokkos::DynRankView<basisCoeffsValueType,basisCoeffsProperties...> basisCoeffs,
33 const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
34 const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
35 const BasisType* cellBasis,
37
38 typedef typename BasisType::scalarType scalarType;
39 typedef Kokkos::DynRankView<scalarType,DeviceType> ScalarViewType;
40 ordinal_type dim = cellBasis->getBaseCellTopology().getDimension();
41
42 ordinal_type basisCardinality = cellBasis->getCardinality();
43
44 ordinal_type numCells = targetAtTargetEPoints.extent(0);
45
46 auto refTargetEWeights = projStruct->getTargetEvalWeights(dim,0);
47 auto targetEPointsRange = projStruct->getTargetPointsRange();
48
49 auto refBasisEWeights = projStruct->getBasisEvalWeights(dim,0);
50 auto basisEPointsRange = projStruct->getBasisPointsRange();
51
52 ordinal_type numTargetEPoints = range_size(targetEPointsRange(dim,0));
53 ordinal_type numBasisEPoints = range_size(basisEPointsRange(dim,0));
54
55 ScalarViewType basisAtBasisEPoints("basisAtBasisEPoints", 1, basisCardinality, numBasisEPoints);
56 ScalarViewType basisAtTargetEPoints("basisAtTargetEPoints", basisCardinality, numTargetEPoints);
57
58 auto basisEPoints = projStruct->getAllEvalPoints(EvalPointsType::BASIS);
59 auto targetEPoints = projStruct->getAllEvalPoints(EvalPointsType::TARGET);
60
61 cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints, 0, Kokkos::ALL(), Kokkos::ALL()), basisEPoints);
62 cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
63
64 ScalarViewType weightedBasisAtTargetEPoints("weightedBasisAtTargetEPoints_",numCells, basisCardinality, numTargetEPoints);
65 ScalarViewType weightedBasisAtBasisEPoints("weightedBasisAtBasisEPoints", 1, basisCardinality, numBasisEPoints);
66
67 auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(MemSpaceType(), cellBasis->getAllDofOrdinal());
68 auto cellDofs = Kokkos::subview(tagToOrdinal, dim, 0, Kokkos::ALL());
69
70 ScalarViewType
71 massMat0("massMat0", 1, basisCardinality, basisCardinality),
72 massMat("massMat", numCells, basisCardinality, basisCardinality),
73 rhsMat("rhsMat", numCells, basisCardinality );
74
75 ordinal_type offsetBasis = basisEPointsRange(dim,0).first;
76 ordinal_type offsetTarget = targetEPointsRange(dim,0).first;
77
78 using HostSpaceType = Kokkos::DefaultHostExecutionSpace;
79 auto hWeightedBasisAtBasisEPoints = Kokkos::create_mirror_view(weightedBasisAtBasisEPoints);
80 auto hWeightedBasisAtTargetEPoints = Kokkos::create_mirror_view(weightedBasisAtTargetEPoints);
81 auto hBasisAtBasisEPoints = Kokkos::create_mirror_view_and_copy(HostSpaceType(), basisAtBasisEPoints);
82 auto hBasisAtTargetEPoints = Kokkos::create_mirror_view_and_copy(HostSpaceType(), basisAtTargetEPoints);
83
84 for(ordinal_type j=0; j <basisCardinality; ++j) {
85 ordinal_type idof = cellBasis->getDofOrdinal(dim, 0, j);
86 for(ordinal_type iq=0; iq <ordinal_type(refBasisEWeights.extent(0)); ++iq)
87 hWeightedBasisAtBasisEPoints(0,j,iq) = hBasisAtBasisEPoints(0,idof,offsetBasis+iq) * refBasisEWeights(iq);
88 for(ordinal_type iq=0; iq <ordinal_type(refTargetEWeights.extent(0)); ++iq)
89 hWeightedBasisAtTargetEPoints(0,j,iq) = hBasisAtTargetEPoints(idof,offsetTarget+iq)* refTargetEWeights(iq);
90 }
91 Kokkos::deep_copy(weightedBasisAtBasisEPoints,hWeightedBasisAtBasisEPoints);
92 Kokkos::deep_copy(weightedBasisAtTargetEPoints,hWeightedBasisAtTargetEPoints);
93 FunctionSpaceTools<DeviceType >::integrate(massMat0, basisAtBasisEPoints, weightedBasisAtBasisEPoints);
94 RealSpaceTools<DeviceType>::clone(massMat, Kokkos::subview(massMat0,0,Kokkos::ALL(), Kokkos::ALL()));
95 RealSpaceTools<DeviceType>::clone(weightedBasisAtTargetEPoints, Kokkos::subview(weightedBasisAtTargetEPoints,0,Kokkos::ALL(), Kokkos::ALL()));
96 FunctionSpaceTools<DeviceType >::integrate(rhsMat, targetAtTargetEPoints, weightedBasisAtTargetEPoints);
97
98 typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, DeviceType> WorkArrayViewType;
99 ScalarViewType t_("t",numCells, basisCardinality);
100 WorkArrayViewType w_("w",numCells,basisCardinality);
101
102 ElemSystem cellSystem("cellSystem", true);
103 cellSystem.solve(basisCoeffs, massMat, rhsMat, t_, w_, cellDofs, basisCardinality);
104}
105
106} // Intrepid2 namespace
107
108#endif
109
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.
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...
An helper class to compute the evaluation points and weights needed for performing projections.
const range_tag getBasisPointsRange() const
Returns the range tag of the basis evaluation points subcells.
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 getTargetPointsRange() const
Returns the range of the target function evaluation points on subcells.
view_type getAllEvalPoints(EvalPointsType type=TARGET) const
Returns the basis/target evaluation points in the cell.
static void getHVolBasisCoeffs(Kokkos::DynRankView< basisCoeffsValueType, basisCoeffsProperties... > basisCoeffs, const Kokkos::DynRankView< funValsValueType, funValsProperties... > targetAtEvalPoints, const Kokkos::DynRankView< ortValueType, ortProperties... > cellOrientations, const BasisType *cellBasis, ProjectionStruct< DeviceType, typename BasisType::scalarType > *projStruct)
Computes the basis coefficients of the HVol 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...