43 #ifndef PANZER_DIRICHLET_RESIDUAL_EDGEBASIS_IMPL_HPP
44 #define PANZER_DIRICHLET_RESIDUAL_EDGEBASIS_IMPL_HPP
50 #include "Intrepid2_Kernels.hpp"
51 #include "Intrepid2_CellTools.hpp"
52 #include "Intrepid2_OrientationTools.hpp"
54 #include "Phalanx_TypeStrings.hpp"
57 #include "Kokkos_ViewFactory.hpp"
62 template<
typename EvalT,
typename Traits>
67 std::string residual_name = p.
get<std::string>(
"Residual Name");
72 std::string field_name = p.
get<std::string>(
"DOF Name");
73 std::string dof_name = field_name+
"_"+pointRule->getName();
74 std::string value_name = p.
get<std::string>(
"Value Name");
82 TEUCHOS_ASSERT(basis_layout->extent(0)==vector_layout_dof->extent(0));
83 TEUCHOS_ASSERT(basis_layout->extent(1)==vector_layout_dof->extent(1));
84 TEUCHOS_ASSERT(Teuchos::as<unsigned>(basis->dimension())==vector_layout_dof->extent(2));
85 TEUCHOS_ASSERT(vector_layout_vector->extent(0)==vector_layout_dof->extent(0));
86 TEUCHOS_ASSERT(vector_layout_vector->extent(1)==vector_layout_dof->extent(1));
87 TEUCHOS_ASSERT(vector_layout_vector->extent(2)==vector_layout_dof->extent(2));
89 residual = PHX::MDField<ScalarT,Cell,BASIS>(residual_name, basis_layout);
90 dof = PHX::MDField<const ScalarT,Cell,Point,Dim>(dof_name, vector_layout_dof);
91 value = PHX::MDField<const ScalarT,Cell,Point,Dim>(value_name, vector_layout_vector);
100 constJac_ = pointValues.jac;
101 this->addDependentField(constJac_);
103 this->addEvaluatedField(residual);
104 this->addDependentField(dof);
105 this->addDependentField(value);
107 std::string n =
"Dirichlet Residual Edge Basis Evaluator";
112 template<
typename EvalT,
typename Traits>
120 this->utils.setFieldData(pointValues.jac,fm);
124 template<
typename EvalT,
typename Traits>
134 residual.deep_copy(
ScalarT(0.0));
139 const int subcellOrd = this->wda(workset).subcell_index;
141 const auto cellTopo = *basis->getCellTopology();
142 const auto worksetJacobians = pointValues.jac.get_view();
144 const int cellDim = cellTopo.getDimension();
146 auto intrepid_basis = basis->getIntrepid2Basis();
149 const bool is_normalize =
true;
153 switch (subcellDim) {
155 if (intrepid_basis->getDofCount(1, subcellOrd)) {
156 auto phyEdgeTan = Kokkos::subview(work, 0, Kokkos::ALL());
157 auto ortEdgeTan = Kokkos::subview(work, 1, Kokkos::ALL());
159 const int ndofsEdge = intrepid_basis->getDofCount(1, subcellOrd);
160 const int numEdges = cellTopo.getEdgeCount();
161 int edgeOrts[4] = {};
162 for(index_t c=0;c<workset.
num_cells;c++) {
163 orientations->at(details.
cell_local_ids[c]).getEdgeOrientation(edgeOrts, numEdges);
165 Intrepid2::Orientation::getReferenceEdgeTangent(ortEdgeTan,
168 edgeOrts[subcellOrd],
171 for (
int i=0;i<ndofsEdge;++i) {
172 const int b = intrepid_basis->getDofOrdinal(1, subcellOrd, i);
173 auto J = Kokkos::subview(worksetJacobians, c, b, Kokkos::ALL(), Kokkos::ALL());
174 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan, J, ortEdgeTan);
176 for(
int d=0;d<cellDim;d++) {
177 residual(c,b) += (dof(c,b,d)-value(c,b,d))*phyEdgeTan(d);
185 const int numEdges = cellTopo.getEdgeCount();
186 const int numFaces = cellTopo.getFaceCount();
189 auto phyEdgeTan = Kokkos::subview(work, 0, Kokkos::ALL());
190 auto ortEdgeTan = Kokkos::subview(work, 1, Kokkos::ALL());
192 const int numEdgesOfFace= cellTopo.getEdgeCount(2, subcellOrd);
194 int edgeOrts[12] = {};
195 for(index_t c=0;c<workset.
num_cells;c++) {
196 for (
int i=0;i<numEdgesOfFace;++i) {
198 const int edgeOrd = Intrepid2::Orientation::getEdgeOrdinalOfFace(i, subcellOrd, cellTopo);
199 const int b = edgeOrd;
200 orientations->at(details.
cell_local_ids[c]).getEdgeOrientation(edgeOrts, numEdges);
202 Intrepid2::Orientation::getReferenceEdgeTangent(ortEdgeTan,
210 auto J = Kokkos::subview(worksetJacobians, c, b, Kokkos::ALL(), Kokkos::ALL());
211 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan, J, ortEdgeTan);
213 for(
int d=0;d<dof.extent_int(2);d++) {
214 residual(c,b) += (dof(c,b,d)-value(c,b,d))*phyEdgeTan(d);
221 if (intrepid_basis->getDofCount(2, subcellOrd)) {
222 auto phyFaceTanU = Kokkos::subview(work, 0, Kokkos::ALL());
223 auto ortFaceTanU = Kokkos::subview(work, 1, Kokkos::ALL());
224 auto phyFaceTanV = Kokkos::subview(work, 2, Kokkos::ALL());
225 auto ortFaceTanV = Kokkos::subview(work, 3, Kokkos::ALL());
227 int faceOrts[6] = {};
228 for(index_t c=0;c<workset.
num_cells;c++) {
229 orientations->at(details.
cell_local_ids[c]).getFaceOrientation(faceOrts, numFaces);
230 Intrepid2::Orientation::getReferenceFaceTangents(ortFaceTanU,
234 faceOrts[subcellOrd],
237 for(
int b=0;b<dof.extent_int(1);b++) {
238 auto J = Kokkos::subview(worksetJacobians, c, b, Kokkos::ALL(), Kokkos::ALL());
239 Intrepid2::Kernels::Serial::matvec_product(phyFaceTanU, J, ortFaceTanU);
240 Intrepid2::Kernels::Serial::matvec_product(phyFaceTanV, J, ortFaceTanV);
242 for(
int d=0;d<dof.extent_int(2);d++) {
243 residual(c,b) += (dof(c,b,d)-value(c,b,d))*phyFaceTanU(d);
244 residual(c,b) += (dof(c,b,d)-value(c,b,d))*phyFaceTanV(d);
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_
T & get(const std::string &name, T def_value)
DirichletResidual_EdgeBasis(const Teuchos::ParameterList &p)
void setupArrays(const Teuchos::RCP< const panzer::PointRule > &pr)
Sizes/allocates memory for arrays.
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void evaluateFields(typename Traits::EvalData d)
typename EvalT::ScalarT ScalarT
#define TEUCHOS_ASSERT(assertion_test)
std::vector< GO > cell_local_ids