Intrepid2
Intrepid2_ProjectionToolsDefHVOL.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kyungjoo Kim (kyukim@sandia.gov), or
38 // Mauro Perego (mperego@sandia.gov)
39 //
40 // ************************************************************************
41 // @HEADER
42 
49 #ifndef __INTREPID2_PROJECTIONTOOLSDEFHVOL_HPP__
50 #define __INTREPID2_PROJECTIONTOOLSDEFHVOL_HPP__
51 
53 #include "Intrepid2_ArrayTools.hpp"
55 
56 
57 namespace Intrepid2 {
58 namespace Experimental {
59 
60 template<typename SpT>
61 template<typename BasisType,
62 typename ortValueType, class ...ortProperties>
63 void
64 ProjectionTools<SpT>::getHVolEvaluationPoints(typename BasisType::ScalarViewType ePoints,
65  const Kokkos::DynRankView<ortValueType, ortProperties...> /*orts*/,
66  const BasisType* cellBasis,
67  ProjectionStruct<SpT, typename BasisType::scalarType> * projStruct,
68  const EvalPointsType ePointType) {
69  ordinal_type dim = cellBasis->getBaseCellTopology().getDimension();
70  auto refEPoints = Kokkos::create_mirror_view_and_copy(typename SpT::memory_space(),projStruct->getEvalPoints(dim,0,ePointType));
71  auto ePointsRange = projStruct->getPointsRange(ePointType);
72  RealSpaceTools<SpT>::clone(Kokkos::subview(ePoints, Kokkos::ALL(), ePointsRange(dim, 0), Kokkos::ALL()), refEPoints);
73 }
74 
75 
76 template<typename SpT>
77 template<typename basisCoeffsValueType, class ...basisCoeffsProperties,
78 typename funValsValueType, class ...funValsProperties,
79 typename BasisType,
80 typename ortValueType,class ...ortProperties>
81 void
82 ProjectionTools<SpT>::getHVolBasisCoeffs(Kokkos::DynRankView<basisCoeffsValueType,basisCoeffsProperties...> basisCoeffs,
83  const Kokkos::DynRankView<funValsValueType,funValsProperties...> targetAtTargetEPoints,
84  const typename BasisType::ScalarViewType targetEPoints,
85  const Kokkos::DynRankView<ortValueType, ortProperties...> orts,
86  const BasisType* cellBasis,
87  ProjectionStruct<SpT, typename BasisType::scalarType> * projStruct){
88 
89  typedef typename BasisType::scalarType scalarType;
90  typedef Kokkos::DynRankView<scalarType,SpT> ScalarViewType;
91  ordinal_type dim = cellBasis->getBaseCellTopology().getDimension();
92 
93  ordinal_type basisCardinality = cellBasis->getCardinality();
94 
95  ordinal_type numCells = targetAtTargetEPoints.extent(0);
96 
97  auto refTargetEWeights = Kokkos::create_mirror_view_and_copy(typename SpT::memory_space(),projStruct->getTargetEvalWeights(dim,0));
98  auto targetEPointsRange = Kokkos::create_mirror_view_and_copy(typename SpT::memory_space(),projStruct->getTargetPointsRange());
99 
100  auto refBasisEWeights = Kokkos::create_mirror_view_and_copy(typename SpT::memory_space(),projStruct->getBasisEvalWeights(dim,0));
101  auto basisEPointsRange = Kokkos::create_mirror_view_and_copy(typename SpT::memory_space(),projStruct->getBasisPointsRange());
102 
103  ordinal_type numTargetEPoints = range_size(targetEPointsRange(dim,0));
104  ordinal_type numBasisEPoints = range_size(basisEPointsRange(dim,0));
105 
106  ScalarViewType basisAtBasisEPoints("basisAtBasisEPoints", 1, basisCardinality, numBasisEPoints);
107  ScalarViewType basisAtTargetEPoints("basisAtTargetEPoints", basisCardinality, numTargetEPoints);
108 
109  ScalarViewType basisEPoints("basisEPoints",numCells,projStruct->getNumBasisEvalPoints(), dim);
110  getHVolEvaluationPoints(basisEPoints, orts, cellBasis, projStruct, EvalPointsType::BASIS);
111 
112  cellBasis->getValues(Kokkos::subview(basisAtBasisEPoints, 0, Kokkos::ALL(), Kokkos::ALL()), Kokkos::subview(basisEPoints,0, Kokkos::ALL(), Kokkos::ALL()));
113  if(targetEPoints.rank()==3)
114  cellBasis->getValues(basisAtTargetEPoints, Kokkos::subview(targetEPoints, 0, Kokkos::ALL(), Kokkos::ALL()));
115  else
116  cellBasis->getValues(basisAtTargetEPoints, targetEPoints);
117 
118  ScalarViewType weightedBasisAtTargetEPoints("weightedBasisAtTargetEPoints_",numCells, basisCardinality, numTargetEPoints);
119  ScalarViewType weightedBasisAtBasisEPoints("weightedBasisAtBasisEPoints", 1, basisCardinality, numBasisEPoints);
120 
121  auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(typename SpT::memory_space(), cellBasis->getAllDofOrdinal());
122  auto cellDofs = Kokkos::subview(tagToOrdinal, dim, 0, Kokkos::ALL());
123 
124  ScalarViewType
125  massMat0("massMat0", 1, basisCardinality, basisCardinality),
126  massMat("massMat", numCells, basisCardinality, basisCardinality),
127  rhsMat("rhsMat", numCells, basisCardinality );
128 
129  ordinal_type offsetBasis = basisEPointsRange(dim,0).first;
130  ordinal_type offsetTarget = targetEPointsRange(dim,0).first;
131  for(ordinal_type j=0; j <basisCardinality; ++j) {
132  ordinal_type idof = cellDofs(j);
133  for(ordinal_type iq=0; iq <ordinal_type(refBasisEWeights.extent(0)); ++iq)
134  weightedBasisAtBasisEPoints(0,j,iq) = basisAtBasisEPoints(0,idof,offsetBasis+iq) * refBasisEWeights(iq);
135  for(ordinal_type iq=0; iq <ordinal_type(refTargetEWeights.extent(0)); ++iq)
136  weightedBasisAtTargetEPoints(0,j,iq) = basisAtTargetEPoints(idof,offsetTarget+iq)* refTargetEWeights(iq);
137  }
138 
139  FunctionSpaceTools<SpT >::integrate(massMat0, basisAtBasisEPoints, weightedBasisAtBasisEPoints);
140  RealSpaceTools<SpT>::clone(massMat, Kokkos::subview(massMat0,0,Kokkos::ALL(), Kokkos::ALL()));
141  RealSpaceTools<SpT>::clone(weightedBasisAtTargetEPoints, Kokkos::subview(weightedBasisAtTargetEPoints,0,Kokkos::ALL(), Kokkos::ALL()));
142  FunctionSpaceTools<SpT >::integrate(rhsMat, targetAtTargetEPoints, weightedBasisAtTargetEPoints);
143 
144  typedef Kokkos::DynRankView<scalarType, Kokkos::LayoutRight, SpT> WorkArrayViewType;
145  ScalarViewType t_("t",numCells, basisCardinality);
146  WorkArrayViewType w_("w",numCells,basisCardinality);
147 
148  ElemSystem cellSystem("cellSystem", true);
149  cellSystem.solve(basisCoeffs, massMat, rhsMat, t_, w_, cellDofs, basisCardinality);
150 }
151 
152 }
153 }
154 
155 #endif
156 
Header file for the abstract base class Intrepid2::DefaultCubatureFactory.
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...
Header file for the Intrepid2::FunctionSpaceTools class.
static void clone(Kokkos::DynRankView< outputValueType, outputProperties...> output, const Kokkos::DynRankView< inputValueType, inputProperties...> input)
Clone input array.
Header file for Intrepid2::ArrayTools class providing utilities for array operations.
static void getHVolEvaluationPoints(typename BasisType::ScalarViewType evaluationPoints, const Kokkos::DynRankView< ortValueType, ortProperties...> cellOrientations, const BasisType *cellBasis, ProjectionStruct< ExecSpaceType, typename BasisType::scalarType > *projStruct, const EvalPointsType evalPointType=EvalPointsType::TARGET)
Computes evaluation points for HVol projection.
static void getHVolBasisCoeffs(Kokkos::DynRankView< basisCoeffsValueType, basisCoeffsProperties...> basisCoeffs, const Kokkos::DynRankView< funValsValueType, funValsProperties...> targetAtEvalPoints, const typename BasisType::ScalarViewType evaluationPoints, const Kokkos::DynRankView< ortValueType, ortProperties...> cellOrientations, const BasisType *cellBasis, ProjectionStruct< ExecSpaceType, typename BasisType::scalarType > *projStruct)
Computes the basis coefficients of the HVol projection of the target function.