11 #ifndef PANZER_GATHER_NORMALS_IMPL_HPP
12 #define PANZER_GATHER_NORMALS_IMPL_HPP
14 #include "Teuchos_Assert.hpp"
15 #include "Phalanx_DataLayout.hpp"
18 #include "Kokkos_ViewFactory.hpp"
20 #include "Intrepid2_Kernels.hpp"
21 #include "Intrepid2_OrientationTools.hpp"
23 #include "Teuchos_FancyOStream.hpp"
25 template<
typename EvalT,
typename Traits>
30 dof_name_ = (p.
get< std::string >(
"DOF Name"));
46 std::string orientationFieldName = basis_->name() +
" Orientation";
52 constJac_ = pointValues_.jac;
53 this->addDependentField(constJac_);
56 this->addEvaluatedField(gatherFieldNormals_);
58 this->setName(
"Gather Normals");
62 template<
typename EvalT,
typename Traits>
69 auto orientations_host = Kokkos::create_mirror_view(orientations_);
70 for (
size_t i=0; i < orientations->size(); ++i)
71 orientations_host(i) = (*orientations)[i];
72 Kokkos::deep_copy(orientations_,orientations_host);
74 this->utils.setFieldData(pointValues_.jac,fm);
76 const shards::CellTopology & parentCell = *basis_->getCellTopology();
77 int sideDim = parentCell.getDimension()-1;
78 sideParam_ = Intrepid2::RefSubcellParametrization<PHX::Device>::get(sideDim, parentCell.getKey());
80 int numFaces = gatherFieldNormals_.extent(1);
82 auto keys_host = Kokkos::create_mirror_view(keys_);
83 for (
int i=0; i < numFaces; ++i)
84 keys_host(i) = parentCell.getKey(sideDim,i);
85 Kokkos::deep_copy(keys_,keys_host);
88 int cellDim = parentCell.getDimension();
89 refEdges_ = Kokkos::createDynRankViewWithType<Kokkos::DynRankView<ScalarT,PHX::Device>>(gatherFieldNormals_.get_static_view(),
"ref_edges", (*d.
worksets_)[0].num_cells, sideDim, cellDim);
90 phyEdges_ = Kokkos::createDynRankViewWithType<Kokkos::DynRankView<ScalarT,PHX::Device>>(gatherFieldNormals_.get_static_view(),
"phy_edges", (*d.
worksets_)[0].num_cells, sideDim, cellDim);
94 template<
typename EvalT,
typename Traits>
102 int numFaces = gatherFieldNormals_.extent(1);
103 const auto worksetJacobians = pointValues_.jac.get_view();
105 auto gatherFieldNormals = gatherFieldNormals_;
106 auto sideParam = sideParam_;
108 auto orientations = orientations_;
109 auto refEdges = refEdges_;
110 auto phyEdges = phyEdges_;
113 Kokkos::parallel_for(
"panzer::GatherNormals",workset.
num_cells,KOKKOS_LAMBDA(
const int c){
114 int faceOrts[6] = {};
115 orientations(cell_local_ids(c)).getFaceOrientation(faceOrts, numFaces);
117 for(
int pt = 0; pt < numFaces; pt++) {
118 auto ortEdgeTan_U = Kokkos::subview(refEdges, c, 0, Kokkos::ALL());
119 auto ortEdgeTan_V = Kokkos::subview(refEdges, c, 1, Kokkos::ALL());
121 auto tmpRefEdges = Kokkos::subview(refEdges, c, Kokkos::ALL(), Kokkos::ALL());
122 Intrepid2::Impl::OrientationTools::getRefSubcellTangents(tmpRefEdges,
128 auto phyEdgeTan_U = Kokkos::subview(phyEdges, c, 0, Kokkos::ALL());
129 auto phyEdgeTan_V = Kokkos::subview(phyEdges, c, 1, Kokkos::ALL());
130 auto J = Kokkos::subview(worksetJacobians, c, pt, Kokkos::ALL(), Kokkos::ALL());
132 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan_U, J, ortEdgeTan_U);
133 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan_V, J, ortEdgeTan_V);
136 gatherFieldNormals(c,pt,0) = (phyEdgeTan_U(1)*phyEdgeTan_V(2) - phyEdgeTan_U(2)*phyEdgeTan_V(1));
137 gatherFieldNormals(c,pt,1) = (phyEdgeTan_U(2)*phyEdgeTan_V(0) - phyEdgeTan_U(0)*phyEdgeTan_V(2));
138 gatherFieldNormals(c,pt,2) = (phyEdgeTan_U(0)*phyEdgeTan_V(1) - phyEdgeTan_U(1)*phyEdgeTan_V(0));
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_
int num_cells
DEPRECATED - use: numCells()
T & get(const std::string &name, T def_value)
void setupArrays(const Teuchos::RCP< const panzer::PointRule > &pr)
Sizes/allocates memory for arrays.
void evaluateFields(typename Traits::EvalData d)
Kokkos::View< const int *, PHX::Device > getLocalCellIDs() const
Get the local cell IDs for the workset.
bool isType(const std::string &name) const
#define TEUCHOS_ASSERT(assertion_test)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)
Teuchos::RCP< const std::vector< panzer::Workset > > worksets_