11 #ifndef PANZER_DIRICHLET_RESIDUAL_FACEBASIS_IMPL_HPP
12 #define PANZER_DIRICHLET_RESIDUAL_FACEBASIS_IMPL_HPP
18 #include "Intrepid2_CellTools.hpp"
20 #include "Kokkos_ViewFactory.hpp"
25 template<
typename EvalT,
typename Traits>
30 std::string residual_name = p.
get<std::string>(
"Residual Name");
35 std::string field_name = p.
get<std::string>(
"DOF Name");
36 std::string dof_name = field_name+
"_"+pointRule->getName();
37 std::string value_name = p.
get<std::string>(
"Value Name");
45 TEUCHOS_ASSERT(basis_layout->extent(0)==vector_layout_dof->extent(0));
46 TEUCHOS_ASSERT(basis_layout->extent(1)==vector_layout_dof->extent(1));
47 TEUCHOS_ASSERT(basis->dimension()==vector_layout_dof->extent_int(2));
48 TEUCHOS_ASSERT(vector_layout_vector->extent(0)==vector_layout_dof->extent(0));
49 TEUCHOS_ASSERT(vector_layout_vector->extent(1)==vector_layout_dof->extent(1));
50 TEUCHOS_ASSERT(vector_layout_vector->extent(2)==vector_layout_dof->extent(2));
58 pointValues.setupArrays(pointRule);
61 constJac_ = pointValues.jac;
62 this->addDependentField(constJac_);
65 this->addEvaluatedField(residual);
66 this->addDependentField(dof);
67 this->addDependentField(value);
69 std::string n =
"Dirichlet Residual Face Basis Evaluator";
74 template<
typename EvalT,
typename Traits>
82 this->utils.setFieldData(pointValues.jac,fm);
83 faceNormal =
Kokkos::createDynRankView(residual.get_static_view(),
"faceNormal",dof.extent(0),dof.extent(1),dof.extent(2));
87 template<
typename EvalT,
typename Traits>
94 const shards::CellTopology & parentCell = *basis->getCellTopology();
95 const int cellDim = parentCell.getDimension();
98 const int subcellDim = 2;
99 const int subcellOrd = this->wda(workset).subcell_index;
101 const int numFaces = parentCell.getSubcellCount(subcellDim);
102 const int numFaceDofs = dof.extent_int(1);
109 Intrepid2::CellTools<PHX::exec_space>::getPhysicalFaceNormals(faceNormal,
110 pointValues.jac.get_view(),
113 PHX::Device().fence();
115 const auto subcellBaseTopo = shards::CellTopology(parentCell.getBaseCellTopologyData(subcellDim, subcellOrd));
116 TEUCHOS_ASSERT(subcellBaseTopo.getBaseKey() == shards::Triangle<>::key ||
117 subcellBaseTopo.getBaseKey() == shards::Quadrilateral<>::key);
120 const auto subcellVertexCount =
static_cast<Intrepid2::ordinal_type
>(subcellBaseTopo.getVertexCount());
124 auto orientations_host = Kokkos::create_mirror_view(Kokkos::WithoutInitializing,orientations_device);
125 for (
size_t i=0; i < orientations_host.extent(0); ++i)
126 orientations_host(i) = orientations->at(i);
127 Kokkos::deep_copy(orientations_device,orientations_host);
130 const auto cell_local_ids_k = details.cell_local_ids_k;
131 auto residual_local = residual;
132 auto dof_local = dof;
133 auto value_local = value;
134 auto faceNormal_local = faceNormal;
136 Kokkos::parallel_for(
"panzer::DirichletRsidual_FaceBasis::evalauteFields",
138 KOKKOS_LAMBDA(
const index_t c) {
139 const auto ort = orientations_device(cell_local_ids_k[c]);
140 Intrepid2::ordinal_type faceOrts[6] = {};
141 ort.getFaceOrientation(faceOrts, numFaces);
144 const double ortVal = faceOrts[subcellOrd] < subcellVertexCount ? 1.0 : -1.0;
145 for(
int b=0;b<numFaceDofs;b++) {
146 residual_local(c,b) = 0.0;
147 for(
int d=0;d<cellDim;d++)
148 residual_local(c,b) += (dof_local(c,b,d)-value_local(c,b,d))*faceNormal_local(c,b,d);
149 residual_local(c,b) *= ortVal;
Kokkos::DynRankView< typename InputArray::value_type, PHX::Device > createDynRankView(const InputArray &a, const std::string &name, const DimensionPack...dims)
Wrapper to simplify Panzer use of Sacado ViewFactory.
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_
int num_cells
DEPRECATED - use: numCells()
T & get(const std::string &name, T def_value)
DirichletResidual_FaceBasis(const Teuchos::ParameterList &p)
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void evaluateFields(typename Traits::EvalData d)
#define TEUCHOS_ASSERT(assertion_test)