43#ifndef PANZER_GATHER_TANGENTS_IMPL_HPP
44#define PANZER_GATHER_TANGENTS_IMPL_HPP
46#include "Teuchos_Assert.hpp"
47#include "Phalanx_DataLayout.hpp"
49#include "Intrepid2_Kernels.hpp"
50#include "Intrepid2_OrientationTools.hpp"
53#include "Kokkos_ViewFactory.hpp"
55#include "Teuchos_FancyOStream.hpp"
57template<
typename EvalT,
typename Traits>
60 const Teuchos::ParameterList& p)
62 dof_name_ = (p.get< std::string >(
"DOF Name"));
64 if(p.isType< Teuchos::RCP<PureBasis> >(
"Basis"))
65 basis_ = p.get< Teuchos::RCP<PureBasis> >(
"Basis");
67 basis_ = p.get< Teuchos::RCP<const PureBasis> >(
"Basis");
69 pointRule_ = p.get<Teuchos::RCP<const PointRule> >(
"Point Rule");
71 Teuchos::RCP<PHX::DataLayout> basis_layout = basis_->functional;
72 Teuchos::RCP<PHX::DataLayout> vector_layout_vector = basis_->functional_grad;
75 TEUCHOS_ASSERT(basis_->isVectorBasis());
78 std::string orientationFieldName = basis_->name() +
" Orientation";
81 pointValues_.setupArrays(pointRule_);
84 constJac_ = pointValues_.jac;
85 this->addDependentField(constJac_);
87 gatherFieldTangents_ = PHX::MDField<ScalarT,Cell,NODE,Dim>(dof_name_+
"_Tangents",vector_layout_vector);
88 this->addEvaluatedField(gatherFieldTangents_);
90 this->setName(
"Gather Tangents");
94template<
typename EvalT,
typename Traits>
100 orientations_ = Kokkos::View<Intrepid2::Orientation*>(
"orientations_",orientations->size());
101 auto orientations_host = Kokkos::create_mirror_view(orientations_);
102 for (
size_t i=0; i < orientations->size(); ++i)
103 orientations_host(i) = (*orientations)[i];
104 Kokkos::deep_copy(orientations_,orientations_host);
106 this->utils.setFieldData(pointValues_.jac,fm);
107 const shards::CellTopology & parentCell = *basis_->getCellTopology();
108 const int edgeDim = 1;
109 edgeParam_ = Intrepid2::RefSubcellParametrization<PHX::Device>::get(edgeDim, parentCell.getKey());
111 const int numEdges = gatherFieldTangents_.extent(1);
112 keys_ = Kokkos::View<unsigned int*>(
"parentCell.keys",numEdges);
113 auto keys_host = Kokkos::create_mirror_view(keys_);
114 for (
int i=0; i < numEdges; ++i)
115 keys_host(i) = parentCell.getKey(edgeDim,i);
116 Kokkos::deep_copy(keys_,keys_host);
120template<
typename EvalT,
typename Traits>
128 const shards::CellTopology & parentCell = *basis_->getCellTopology();
129 const int cellDim = parentCell.getDimension();
130 const int numEdges = gatherFieldTangents_.extent(1);
132 auto workspace_tmp = Kokkos::createDynRankView(gatherFieldTangents_.get_static_view(),
"workspace", workset.
num_cells,4, cellDim);
133 const auto worksetJacobians = pointValues_.jac.get_view();
135 auto gatherFieldTangents = gatherFieldTangents_.get_static_view();
137 auto orientations = orientations_;
138 auto edgeParam = edgeParam_;
141 Kokkos::parallel_for(
"panzer::GatherTangets",workset.
num_cells,KOKKOS_LAMBDA(
const int c){
142 int edgeOrts[12] = {};
143 orientations(cell_local_ids(c)).getEdgeOrientation(edgeOrts, numEdges);
145 auto workspace = Kokkos::subview(workspace_tmp,c,Kokkos::ALL(),Kokkos::ALL());
146 for(
int pt = 0; pt < numEdges; pt++) {
147 auto phyEdgeTan = Kokkos::subview(gatherFieldTangents, c, pt, Kokkos::ALL());
148 auto ortEdgeTan = Kokkos::subview(workspace_tmp,c,0,Kokkos::ALL());
150 Intrepid2::Impl::OrientationTools::getRefSubcellTangents(
157 auto J = Kokkos::subview(worksetJacobians, c, pt, Kokkos::ALL(), Kokkos::ALL());
158 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan, J, ortEdgeTan);
void evaluateFields(typename Traits::EvalData d)
GatherTangents(const Teuchos::ParameterList &p)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
Kokkos::View< const int *, PHX::Device > getLocalCellIDs() const
Get the local cell IDs for the workset.
int num_cells
DEPRECATED - use: numCells()
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_