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_Print.hpp" 57 #include "Kokkos_ViewFactory.hpp" 62 template<
typename EvalT,
typename Traits>
65 const Teuchos::ParameterList& p)
67 std::string residual_name = p.get<std::string>(
"Residual Name");
69 basis = p.get<Teuchos::RCP<const panzer::PureBasis> >(
"Basis");
70 pointRule = p.get<Teuchos::RCP<const panzer::PointRule> >(
"Point Rule");
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");
76 Teuchos::RCP<PHX::DataLayout> basis_layout = basis->functional;
77 Teuchos::RCP<PHX::DataLayout> vector_layout_dof = pointRule->dl_vector;
78 Teuchos::RCP<PHX::DataLayout> vector_layout_vector = basis->functional_grad;
81 TEUCHOS_ASSERT(basis->isVectorBasis());
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 this->addDependentField(pointValues.jac);
102 this->addEvaluatedField(residual);
103 this->addDependentField(dof);
104 this->addDependentField(value);
106 std::string n =
"Dirichlet Residual Edge Basis Evaluator";
111 template<
typename EvalT,
typename Traits>
119 this->utils.setFieldData(pointValues.jac,fm);
121 const auto cellTopo = *basis->getCellTopology();
122 const int edgeDim = 1;
123 const int faceDim = 2;
124 if(cellTopo.getDimension() > edgeDim)
125 edgeParam = Intrepid2::RefSubcellParametrization<Kokkos::HostSpace>::get(edgeDim, cellTopo.getKey());
127 if(cellTopo.getDimension() > faceDim)
128 faceParam = Intrepid2::RefSubcellParametrization<Kokkos::HostSpace>::get(faceDim, cellTopo.getKey());
132 template<
typename EvalT,
typename Traits>
142 residual.deep_copy(
ScalarT(0.0));
147 const int subcellOrd = this->wda(workset).subcell_index;
149 const auto cellTopo = *basis->getCellTopology();
150 const auto worksetJacobians = pointValues.jac.get_view();
152 const int cellDim = cellTopo.getDimension();
153 const int edgeDim = 1;
154 const int faceDim = 2;
156 auto intrepid_basis = basis->getIntrepid2Basis();
163 auto residual_h = Kokkos::create_mirror_view(residual.get_static_view());
164 auto dof_h = Kokkos::create_mirror_view(dof.get_static_view());
165 auto value_h = Kokkos::create_mirror_view(value.get_static_view());
166 Kokkos::deep_copy(dof_h, dof.get_static_view());
167 Kokkos::deep_copy(value_h, value.get_static_view());
168 switch (subcellDim) {
170 if (intrepid_basis->getDofCount(1, subcellOrd)) {
171 auto ortEdgeTan = Kokkos::subview(work, 0, Kokkos::ALL());
172 auto phyEdgeTan = Kokkos::subview(work, 1, Kokkos::ALL());
174 const int ndofsEdge = intrepid_basis->getDofCount(1, subcellOrd);
175 const int numEdges = cellTopo.getEdgeCount();
176 int edgeOrts[4] = {};
178 for(index_t c=0;c<workset.
num_cells;c++) {
179 orientations->at(
details.cell_local_ids[c]).getEdgeOrientation(edgeOrts, numEdges);
181 Intrepid2::Impl::OrientationTools::getRefSubcellTangents(work,
183 cellTopo.getKey(edgeDim,subcellOrd),
185 edgeOrts[subcellOrd]);
187 for (
int i=0;i<ndofsEdge;++i) {
188 const int b = intrepid_basis->getDofOrdinal(1, subcellOrd, i);
189 auto J = Kokkos::create_mirror_view(Kokkos::subview(worksetJacobians, c, b, Kokkos::ALL(), Kokkos::ALL()));
190 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan, J, ortEdgeTan);
192 for(
int d=0;d<cellDim;d++) {
193 residual_h(c,b) += (dof_h(c,b,d)-value_h(c,b,d))*phyEdgeTan(d);
201 const int numEdges = cellTopo.getEdgeCount();
202 const int numFaces = cellTopo.getFaceCount();
206 auto ortEdgeTan = Kokkos::subview(work, 0, Kokkos::ALL());
207 auto phyEdgeTan = Kokkos::subview(work, 1, Kokkos::ALL());
209 const int numEdgesOfFace= cellTopo.getEdgeCount(2, subcellOrd);
211 int edgeOrts[12] = {};
212 for(index_t c=0;c<workset.
num_cells;c++) {
213 for (
int i=0;i<numEdgesOfFace;++i) {
215 const int edgeOrd = Intrepid2::Orientation::getEdgeOrdinalOfFace(i, subcellOrd, cellTopo);
216 const int b = edgeOrd;
217 orientations->at(
details.cell_local_ids[c]).getEdgeOrientation(edgeOrts, numEdges);
219 Intrepid2::Impl::OrientationTools::getRefSubcellTangents(work,
221 cellTopo.getKey(edgeDim,edgeOrd),
226 auto J = Kokkos::create_mirror_view(Kokkos::subview(worksetJacobians, c, b, Kokkos::ALL(), Kokkos::ALL()));
227 Intrepid2::Kernels::Serial::matvec_product(phyEdgeTan, J, ortEdgeTan);
229 for(
int d=0;d<dof.extent_int(2);d++) {
230 residual_h(c,b) += (dof_h(c,b,d)-value_h(c,b,d))*phyEdgeTan(d);
237 if (intrepid_basis->getDofCount(2, subcellOrd)) {
238 auto ortFaceTanU = Kokkos::subview(work, 0, Kokkos::ALL());
239 auto ortFaceTanV = Kokkos::subview(work, 1, Kokkos::ALL());
240 auto phyFaceTanU = Kokkos::subview(work, 2, Kokkos::ALL());
241 auto phyFaceTanV = Kokkos::subview(work, 3, Kokkos::ALL());
243 int faceOrts[6] = {};
244 for(index_t c=0;c<workset.
num_cells;c++) {
245 orientations->at(
details.cell_local_ids[c]).getFaceOrientation(faceOrts, numFaces);
247 Intrepid2::Impl::OrientationTools::getRefSubcellTangents(work,
249 cellTopo.getKey(faceDim,subcellOrd),
251 faceOrts[subcellOrd]);
253 for(
int b=0;b<dof.extent_int(1);b++) {
254 auto J = Kokkos::create_mirror_view(Kokkos::subview(worksetJacobians, c, b, Kokkos::ALL(), Kokkos::ALL()));
255 Intrepid2::Kernels::Serial::matvec_product(phyFaceTanU, J, ortFaceTanU);
256 Intrepid2::Kernels::Serial::matvec_product(phyFaceTanV, J, ortFaceTanV);
258 for(
int d=0;d<dof.extent_int(2);d++) {
259 residual_h(c,b) += (dof_h(c,b,d)-value_h(c,b,d))*phyFaceTanU(d);
260 residual_h(c,b) += (dof_h(c,b,d)-value_h(c,b,d))*phyFaceTanV(d);
269 Kokkos::deep_copy(residual.get_static_view(), residual_h);
Teuchos::RCP< const std::vector< Intrepid2::Orientation > > orientations_
int num_cells
DEPRECATED - use: numCells()
DirichletResidual_EdgeBasis(const Teuchos::ParameterList &p)
int subcell_dim
DEPRECATED - use: getSubcellDimension()
void setupArrays(const Teuchos::RCP< const panzer::PointRule > &pr)
Sizes/allocates memory for arrays.
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.
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
void evaluateFields(typename Traits::EvalData d)
typename EvalT::ScalarT ScalarT