43#include "PanzerDiscFE_config.hpp"
47#include "Kokkos_ViewFactory.hpp"
50#include "Intrepid2_Utils.hpp"
51#include "Intrepid2_FunctionSpaceTools.hpp"
52#include "Intrepid2_Orientation.hpp"
53#include "Intrepid2_OrientationTools.hpp"
56#include "Phalanx_GetNonConstDynRankViewFromConstMDField.hpp"
61template<
typename Scalar>
63applyOrientationsImpl(
const int num_cells,
64 Kokkos::DynRankView<Scalar, PHX::Device> view,
65 Kokkos::DynRankView<Intrepid2::Orientation, PHX::Device> orientations,
68 using ots=Intrepid2::OrientationTools<PHX::Device>;
70 auto sub_orientations = Kokkos::subview(orientations, std::make_pair(0,num_cells));
75 auto sub_view = Kokkos::subview(view, std::make_pair(0,num_cells), Kokkos::ALL(), Kokkos::ALL());
76 auto sub_view_clone = Kokkos::createDynRankView(view,
"sub_view_clone", sub_view.extent(0), sub_view.extent(1), sub_view.extent(2));
77 Kokkos::deep_copy(sub_view_clone, sub_view);
80 ots::modifyBasisByOrientation(sub_view, sub_view_clone, sub_orientations, &basis);
81 }
else if (view.rank() == 4){
83 auto sub_view = Kokkos::subview(view, std::make_pair(0,num_cells), Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
84 auto sub_view_clone = Kokkos::createDynRankView(view,
"sub_view_clone", sub_view.extent(0), sub_view.extent(1), sub_view.extent(2), sub_view.extent(3));
85 Kokkos::deep_copy(sub_view_clone, sub_view);
88 ots::modifyBasisByOrientation(sub_view, sub_view_clone, sub_orientations, &basis);
90 throw std::logic_error(
"applyOrientationsImpl : Unknown view of rank " + std::to_string(view.rank()));
93template<
typename Scalar>
95applyOrientationsImpl(
const int num_cells,
96 Kokkos::DynRankView<Scalar, PHX::Device> view,
97 const std::vector<Intrepid2::Orientation> & orientations,
102 Kokkos::DynRankView<Intrepid2::Orientation,PHX::Device> device_orientations(
"drv_orts", num_cells);
103 auto host_orientations = Kokkos::create_mirror_view(device_orientations);
104 for(
int i=0; i < num_cells; ++i)
105 host_orientations(i) = orientations[i];
106 Kokkos::deep_copy(device_orientations,host_orientations);
109 applyOrientationsImpl(num_cells, view, device_orientations, basis);
115template <
typename Scalar>
118 const bool allocArrays,
119 const bool buildWeighted)
155template <
typename Scalar>
158 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac,
159 const PHX::MDField<Scalar,Cell,IP> & jac_det,
160 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac_inv,
161 const int in_num_cells)
169 const int num_dims = jac.extent(2);
184 else if(num_dims == 3)
206 else if(num_dims == 3)
217template <
typename Scalar>
220 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac,
221 const PHX::MDField<Scalar,Cell,IP> & jac_det,
222 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac_inv,
223 const PHX::MDField<Scalar,Cell,IP> & weighted_measure,
224 const PHX::MDField<Scalar,Cell,NODE,Dim> & vertex_coordinates,
225 bool use_vertex_coordinates,
226 const int in_num_cells)
231 if(weighted_measure.size() > 0)
239 const int num_dims = jac.extent(2);
253 else if(num_dims == 3)
261 if(use_vertex_coordinates){
270template <
typename Scalar>
272evaluateValues(
const PHX::MDField<Scalar,Cell,IP,Dim> & cub_points,
273 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac,
274 const PHX::MDField<Scalar,Cell,IP> & jac_det,
275 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac_inv,
276 const PHX::MDField<Scalar,Cell,IP> & weighted_measure,
277 const PHX::MDField<Scalar,Cell,NODE,Dim> & vertex_coordinates,
278 bool use_vertex_coordinates,
279 const int in_num_cells)
285 if(weighted_measure.size() > 0)
289 const int num_dims = jac.extent(2);
310 }
else if(num_dims == 3) {
322 if(use_vertex_coordinates){
331template <
typename Scalar>
334 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac,
335 const PHX::MDField<Scalar,Cell,IP> & jac_det,
336 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac_inv)
339 PHX::MDField<Scalar,Cell,IP> weighted_measure;
340 PHX::MDField<Scalar,Cell,NODE,Dim> vertex_coordinates;
341 evaluateValues(cub_points,jac,jac_det,jac_inv,weighted_measure,vertex_coordinates,
false,jac.extent(0));
345template <
typename Scalar>
348 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac,
349 const PHX::MDField<Scalar,Cell,IP> & jac_det,
350 const PHX::MDField<Scalar,Cell,IP,Dim,Dim> & jac_inv,
351 const PHX::MDField<Scalar,Cell,NODE,Dim> & vertex_coordinates,
352 bool use_vertex_coordinates,
353 const int in_num_cells)
355 PHX::MDField<Scalar,Cell,IP> weighted_measure;
356 evaluateValues(cell_cub_points,jac,jac_det,jac_inv,weighted_measure,vertex_coordinates,use_vertex_coordinates,in_num_cells);
359template <
typename Scalar>
362 const int in_num_cells)
371template <
typename Scalar>
374 const int in_num_cells)
384 const int num_cell_basis_layout = in_num_cells < 0 ?
basis_layout->numCells() : in_num_cells;
385 const int num_cell_orientation = orientations.size();
386 const int num_cells = num_cell_basis_layout < num_cell_orientation ? num_cell_basis_layout : num_cell_orientation;
390 Kokkos::DynRankView<Intrepid2::Orientation,PHX::Device> device_orientations(
"device_orientations", num_cells);
391 auto host_orientations = Kokkos::create_mirror_view(device_orientations);
392 for(
int i=0; i < num_cells; ++i)
393 host_orientations(i) = orientations[i];
394 Kokkos::deep_copy(device_orientations,host_orientations);
427template <
typename Scalar>
431 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"panzer::BasisValues2::applyOrientations : this should not be called.");
434template <
typename Scalar>
438template <
typename Scalar>
440setupArrays(
const Teuchos::RCP<const panzer::BasisIRLayout>& layout,
441 bool computeDerivatives)
448 Teuchos::RCP<const panzer::PureBasis> basisDesc = layout->getBasis();
451 int num_quad = layout->numPoints();
452 int dim = basisDesc->dimension();
453 int card = basisDesc->cardinality();
454 int numcells = basisDesc->numCells();
456 Teuchos::RCP<const shards::CellTopology> cellTopo = basisDesc->getCellTopology();
458 intrepid_basis = basisDesc->getIntrepid2Basis<PHX::Device::execution_space,Scalar,Scalar>();
527 else { TEUCHOS_ASSERT(
false); }
589 else { TEUCHOS_ASSERT(
false); }
600template <
typename Scalar>
603setup(
const Teuchos::RCP<const panzer::BasisIRLayout> & basis,
604 PHX::MDField<const Scalar, Cell, IP, Dim> reference_points,
605 PHX::MDField<const Scalar, Cell, IP, Dim, Dim> point_jacobian,
606 PHX::MDField<const Scalar, Cell, IP> point_jacobian_determinant,
607 PHX::MDField<const Scalar, Cell, IP, Dim, Dim> point_jacobian_inverse,
608 const int num_evaluated_cells)
611 intrepid_basis = basis->getBasis()->getIntrepid2Basis<PHX::Device::execution_space,Scalar,Scalar>();
627template <
typename Scalar>
630setupUniform(
const Teuchos::RCP<const panzer::BasisIRLayout> & basis,
631 PHX::MDField<const Scalar, IP, Dim> reference_points,
632 PHX::MDField<const Scalar, Cell, IP, Dim, Dim> point_jacobian,
633 PHX::MDField<const Scalar, Cell, IP> point_jacobian_determinant,
634 PHX::MDField<const Scalar, Cell, IP, Dim, Dim> point_jacobian_inverse,
635 const int num_evaluated_cells)
638 intrepid_basis = basis->getBasis()->getIntrepid2Basis<PHX::Device::execution_space,Scalar,Scalar>();
654template <
typename Scalar>
657setOrientations(
const std::vector<Intrepid2::Orientation> & orientations,
658 const int num_orientations_cells)
660 if(num_orientations_cells < 0)
664 if(orientations.size() == 0){
675template <
typename Scalar>
683template <
typename Scalar>
736template <
typename Scalar>
742 "BasisValues2::setWeightedMeasure : Weighted measure already set. Can only set weighted measure once after setup or setupUniform have beens called.");
752#define PANZER_CACHE_DATA(name) \
754 if(name.size()==tmp_##name.size()){ \
755 Kokkos::deep_copy(name.get_view(), tmp_##name.get_view()); \
759 name##_evaluated_ = true; \
762template <
typename Scalar>
766 const bool force)
const
777 using coordsScalarType =
typename Intrepid2::Basis<PHX::Device::execution_space,Scalar,Scalar>::scalarType;
778 auto tmp_basis_coordinates_ref = af.
buildStaticArray<coordsScalarType,
BASIS,
Dim>(
"basis_coordinates_ref", num_card, num_dim);
779 intrepid_basis->getDofCoords(tmp_basis_coordinates_ref.get_view());
780 PHX::Device().fence();
785 return tmp_basis_coordinates_ref;
788template <
typename Scalar>
792 const bool force)
const
813 intrepid_basis->getValues(tmp_basis_ref_scalar.get_view(), cubature_points_uniform_ref, Intrepid2::OPERATOR_VALUE);
814 PHX::Device().fence();
819 return tmp_basis_ref_scalar;
822template <
typename Scalar>
826 const bool force)
const
848 intrepid_basis->getValues(tmp_basis_ref_vector.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_VALUE);
849 PHX::Device().fence();
854 return tmp_basis_ref_vector;
857template <
typename Scalar>
861 const bool force)
const
883 intrepid_basis->getValues(tmp_grad_basis_ref.get_view(), cubature_points_uniform_ref, Intrepid2::OPERATOR_GRAD);
884 PHX::Device().fence();
889 return tmp_grad_basis_ref;
892template <
typename Scalar>
896 const bool force)
const
915 auto tmp_curl_basis_ref_scalar = af.
buildStaticArray<Scalar,
BASIS,
IP>(
"dyn_curl_basis_ref_scalar",num_card,num_quad);
918 intrepid_basis->getValues(tmp_curl_basis_ref_scalar.get_view(), cubature_points_uniform_ref, Intrepid2::OPERATOR_CURL);
919 PHX::Device().fence();
924 return tmp_curl_basis_ref_scalar;
927template <
typename Scalar>
931 const bool force)
const
951 auto tmp_curl_basis_ref_vector = af.
buildStaticArray<Scalar,
BASIS,
IP,
Dim>(
"dyn_curl_basis_ref_vector",num_card,num_quad,num_dim);
954 intrepid_basis->getValues(tmp_curl_basis_ref_vector.get_view(), cubature_points_uniform_ref, Intrepid2::OPERATOR_CURL);
955 PHX::Device().fence();
960 return tmp_curl_basis_ref_vector;
963template <
typename Scalar>
967 const bool force)
const
988 intrepid_basis->getValues(tmp_div_basis_ref.get_view(), cubature_points_uniform_ref, Intrepid2::OPERATOR_DIV);
989 PHX::Device().fence();
994 return tmp_div_basis_ref;
997template <
typename Scalar>
1001 const bool force)
const
1010 const auto s_vertex_coordinates = Kokkos::subview(
cell_vertex_coordinates_.get_view(),cell_range,Kokkos::ALL(),Kokkos::ALL());
1018 auto s_aux = Kokkos::subview(tmp_basis_coordinates.get_view(),cell_range,Kokkos::ALL(),Kokkos::ALL());
1022 auto bcr = PHX::getNonConstDynRankViewFromConstMDField(const_bcr);
1024 Intrepid2::CellTools<PHX::Device::execution_space> cell_tools;
1025 cell_tools.mapToPhysicalFrame(s_aux, bcr, s_vertex_coordinates,
intrepid_basis->getBaseCellTopology());
1026 PHX::Device().fence();
1031 return tmp_basis_coordinates;
1034template <
typename Scalar>
1039 const bool force)
const
1062 auto tmp_weighted_basis_scalar = af.
buildStaticArray<Scalar,
Cell,
BASIS,
IP>(
"weighted_basis_scalar", num_cells, num_card, num_points);
1065 auto s_aux = Kokkos::subview(tmp_weighted_basis_scalar.get_view(),cell_range,Kokkos::ALL(),Kokkos::ALL());
1066 auto s_cw = Kokkos::subview(
cubature_weights_.get_view(),cell_range,Kokkos::ALL());
1067 auto s_bv = Kokkos::subview(bv.get_view(),cell_range,Kokkos::ALL(),Kokkos::ALL());
1069 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1070 fst::multiplyMeasure(s_aux,s_cw,s_bv);
1078 return tmp_weighted_basis_scalar;
1090 auto cell_basis_ref_scalar = af.
buildStaticArray<Scalar,
BASIS,
IP>(
"cell_basis_ref_scalar",num_card,num_points);
1098 intrepid_basis->getValues(cell_basis_ref_scalar.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_VALUE);
1101 auto s_aux = Kokkos::subview(tmp_basis_scalar.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1104 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1107 fst::HVOLtransformVALUE(s_aux,s_cjd,cell_basis_ref_scalar.get_view());
1109 fst::HGRADtransformVALUE(s_aux,cell_basis_ref_scalar.get_view());
1111 PHX::Device().fence();
1130 auto cell_basis_scalar_host = Kokkos::create_mirror_view(cell_basis_scalar.get_view());
1131 auto cell_cub_points_host = Kokkos::create_mirror_view(cell_cub_points.get_view());
1132 auto cell_jac_det_host = Kokkos::create_mirror_view(cell_jac_det.get_view());
1133 auto cell_basis_ref_scalar_host = Kokkos::create_mirror_view(cell_basis_ref_scalar.get_view());
1138 auto tmp_basis_scalar_host = Kokkos::create_mirror_view(tmp_basis_scalar.get_view());
1144 for(
int p=0;p<num_points;++p)
1145 for(
int d=0;d<num_dim;++d)
1146 cell_cub_points_host(p,d)=cubature_points_ref_host(cell,p,d);
1147 Kokkos::deep_copy(cell_cub_points.get_view(),cell_cub_points_host);
1153 intrepid_basis->getValues(cell_basis_ref_scalar.get_view(),cell_cub_points.get_view(),Intrepid2::OPERATOR_VALUE);
1154 Kokkos::deep_copy(cell_basis_ref_scalar_host,cell_basis_ref_scalar.get_view());
1156 using fst=Intrepid2::FunctionSpaceTools<Kokkos::HostSpace>;
1160 for(
int p=0;p<num_points;++p)
1161 cell_jac_det_host(0,p)=cubature_jacobian_determinant_host(cell,p);
1163 fst::HVOLtransformVALUE(cell_basis_scalar_host,cell_jac_det_host,cell_basis_ref_scalar_host);
1165 fst::HGRADtransformVALUE(cell_basis_scalar_host,cell_basis_ref_scalar_host);
1168 for(
int b=0; b<num_card; ++b)
1169 for(
int p=0; p<num_points; ++p)
1170 tmp_basis_scalar_host(cell,b,p) = cell_basis_scalar_host(0,b,p);
1172 Kokkos::deep_copy(tmp_basis_scalar.get_view(),tmp_basis_scalar_host);
1187 return tmp_basis_scalar;
1193template <
typename Scalar>
1198 const bool force)
const
1222 auto tmp_weighted_basis_vector = af.
buildStaticArray<Scalar,
Cell,
BASIS,
IP,
Dim>(
"weighted_basis_vector", num_cells, num_card, num_points, num_dim);
1225 auto s_aux = Kokkos::subview(tmp_weighted_basis_vector.get_view(),cell_range,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL());
1226 auto s_cw = Kokkos::subview(
cubature_weights_.get_view(),cell_range,Kokkos::ALL());
1227 auto s_bv = Kokkos::subview(bv.get_view(),cell_range,Kokkos::ALL(),Kokkos::ALL(),Kokkos::ALL());
1229 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1230 fst::multiplyMeasure(s_aux, s_cw, s_bv);
1235 return tmp_weighted_basis_vector;
1241 TEUCHOS_ASSERT(num_dim != 1);
1258 intrepid_basis->getValues(cell_basis_ref_vector.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_VALUE);
1261 auto s_aux = Kokkos::subview(tmp_basis_vector.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1264 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1267 auto s_jac_inv = Kokkos::subview(
cubature_jacobian_inverse_.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1269 fst::HCURLtransformVALUE(s_aux,s_jac_inv,cell_basis_ref_vector.get_view());
1272 auto s_jac = Kokkos::subview(
cubature_jacobian_.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1275 fst::HDIVtransformVALUE(s_aux,s_jac, s_jac_det, cell_basis_ref_vector.get_view());
1278 PHX::Device().fence();
1299 auto cell_basis_vector_host = Kokkos::create_mirror_view(cell_basis_vector.get_view());
1300 auto cell_cub_points_host = Kokkos::create_mirror_view(cell_cub_points.get_view());
1301 auto cell_jac_det_host = Kokkos::create_mirror_view(cell_jac_det.get_view());
1302 auto cell_jac_host = Kokkos::create_mirror_view(cell_jac.get_view());
1303 auto cell_jac_inv_host = Kokkos::create_mirror_view(cell_jac_inv.get_view());
1304 auto cell_basis_ref_vector_host = Kokkos::create_mirror_view(cell_basis_ref_vector.get_view());
1307 auto cubature_jacobian_host = Kokkos::create_mirror_view(
cubature_jacobian_.get_view());
1313 auto tmp_basis_vector_host = Kokkos::create_mirror_view(tmp_basis_vector.get_view());
1319 for(
int p=0;p<num_points;++p)
1320 for(
int d=0;d<num_dim;++d)
1321 cell_cub_points_host(p,d)=cubature_points_ref_host(cell,p,d);
1322 Kokkos::deep_copy(cell_cub_points.get_view(),cell_cub_points_host);
1328 intrepid_basis->getValues(cell_basis_ref_vector.get_view(),cell_cub_points.get_view(),Intrepid2::OPERATOR_VALUE);
1329 Kokkos::deep_copy(cell_basis_ref_vector_host,cell_basis_ref_vector.get_view());
1331 using fst=Intrepid2::FunctionSpaceTools<Kokkos::HostSpace>;
1335 for(
int p=0;p<num_points;++p)
1336 for(
int i=0; i<num_dim; ++i)
1337 for(
int j=0; j<num_dim; ++j)
1338 cell_jac_inv_host(0,p,i,j)=cubature_jacobian_inverse_host(cell,p,i,j);
1340 fst::HCURLtransformVALUE(cell_basis_vector_host,cell_jac_inv_host,cell_basis_ref_vector_host);
1343 for(
int p=0;p<num_points;++p)
1344 for(
int i=0; i<num_dim; ++i)
1345 for(
int j=0; j<num_dim; ++j)
1346 cell_jac_host(0,p,i,j)=cubature_jacobian_host(cell,p,i,j);
1348 for(
int p=0;p<num_points;++p)
1349 cell_jac_det_host(0,p)=cubature_jacobian_determinant_host(cell,p);
1351 fst::HDIVtransformVALUE(cell_basis_vector_host,cell_jac_host,cell_jac_det_host,cell_basis_ref_vector_host);
1355 for(
int b=0; b<num_card; ++b)
1356 for(
int p=0; p<num_points; ++p)
1357 for(
int d=0; d<num_dim; ++d)
1358 tmp_basis_vector_host(cell,b,p,d) = cell_basis_vector_host(0,b,p,d);
1360 Kokkos::deep_copy(tmp_basis_vector.get_view(),tmp_basis_vector_host);
1370 return tmp_basis_vector;
1376template <
typename Scalar>
1381 const bool force)
const
1405 auto tmp_weighted_grad_basis = af.
buildStaticArray<Scalar,
Cell,
BASIS,
IP,
Dim>(
"weighted_grad_basis", num_cells, num_card, num_points, num_dim);
1408 auto s_aux = Kokkos::subview(tmp_weighted_grad_basis.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1409 auto s_cw = Kokkos::subview(
cubature_weights_.get_view(), cell_range, Kokkos::ALL());
1410 auto s_bv = Kokkos::subview(bv.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1412 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1413 fst::multiplyMeasure(s_aux,s_cw,s_bv);
1418 return tmp_weighted_grad_basis;
1435 intrepid_basis->getValues(cell_grad_basis_ref.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_GRAD);
1438 auto s_aux = Kokkos::subview(tmp_grad_basis.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1439 auto s_jac_inv = Kokkos::subview(
cubature_jacobian_inverse_.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1442 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1443 fst::HGRADtransformGRAD(s_aux, s_jac_inv,cell_grad_basis_ref.get_view());
1445 PHX::Device().fence();
1467 auto cell_cub_points_host = Kokkos::create_mirror_view(cell_cub_points.get_view());
1470 auto cell_jac_inv_host = Kokkos::create_mirror_view(cell_jac_inv.get_view());
1473 auto cell_grad_basis_ref_host = Kokkos::create_mirror_view(cell_grad_basis_ref.get_view());
1474 auto cell_grad_basis_host = Kokkos::create_mirror_view(cell_grad_basis.get_view());
1475 auto tmp_grad_basis_host = Kokkos::create_mirror_view(tmp_grad_basis.get_view());
1481 for(
int p=0;p<num_points;++p)
1482 for(
int d=0;d<num_dim;++d)
1483 cell_cub_points_host(p,d)=cubature_points_ref_host(cell,p,d);
1489 Kokkos::deep_copy(cell_cub_points.get_view(),cell_cub_points_host);
1490 intrepid_basis->getValues(cell_grad_basis_ref.get_view(),cell_cub_points.get_view(),Intrepid2::OPERATOR_GRAD);
1491 Kokkos::deep_copy(cell_grad_basis_ref_host,cell_grad_basis_ref.get_view());
1493 for(
int p=0;p<num_points;++p)
1494 for(
int d=0;d<num_dim;++d)
1495 for(
int d2=0;d2<num_dim;++d2)
1496 cell_jac_inv_host(0,p,d,d2)=cubature_jacobian_inverse_host(cell,p,d,d2);
1498 using fst=Intrepid2::FunctionSpaceTools<Kokkos::HostSpace>;
1499 fst::HGRADtransformGRAD(cell_grad_basis_host,cell_jac_inv_host,cell_grad_basis_ref_host);
1503 for(
int b=0; b<num_card; ++b)
1504 for(
int p=0; p<num_points; ++p)
1505 for(
int d=0; d<num_dim; ++d)
1506 tmp_grad_basis_host(cell,b,p,d) = cell_grad_basis_host(0,b,p,d);
1507 Kokkos::deep_copy(tmp_grad_basis.get_view(),tmp_grad_basis_host);
1517 return tmp_grad_basis;
1523template <
typename Scalar>
1528 const bool force)
const
1552 auto tmp_weighted_curl_basis_scalar = af.
buildStaticArray<Scalar,
Cell,
BASIS,
IP>(
"weighted_curl_basis_scalar", num_cells, num_card, num_points);
1555 auto s_aux = Kokkos::subview(tmp_weighted_curl_basis_scalar.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1556 auto s_cw = Kokkos::subview(
cubature_weights_.get_view(), cell_range, Kokkos::ALL());
1557 auto s_bv = Kokkos::subview(bv.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1559 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1560 fst::multiplyMeasure(s_aux,s_cw,s_bv);
1565 return tmp_weighted_curl_basis_scalar;
1570 TEUCHOS_ASSERT(num_dim == 2);
1575 auto cell_curl_basis_ref_scalar = af.
buildStaticArray<Scalar,
BASIS,
IP>(
"cell_curl_basis_ref_scalar",num_card,num_points);
1582 intrepid_basis->getValues(cell_curl_basis_ref_scalar.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_CURL);
1585 auto s_aux = Kokkos::subview(tmp_curl_basis_scalar.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1591 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1592 fst::HDIVtransformDIV(s_aux,s_jac_det,cell_curl_basis_ref_scalar.get_view());
1593 PHX::Device().fence();
1612 auto cell_cub_points_host = Kokkos::create_mirror_view(cell_cub_points.get_view());
1615 auto cell_jac_det_host = Kokkos::create_mirror_view(cell_jac_det.get_view());
1618 auto cell_curl_basis_ref_scalar_host = Kokkos::create_mirror_view(cell_curl_basis_ref_scalar.get_view());
1619 auto cell_curl_host = Kokkos::create_mirror_view(cell_curl.get_view());
1620 auto tmp_curl_basis_scalar_host = Kokkos::create_mirror_view(tmp_curl_basis_scalar.get_view());
1626 for(
int p=0;p<num_points;++p)
1627 for(
int d=0;d<num_dim;++d)
1628 cell_cub_points_host(p,d)=cubature_points_ref_host(cell,p,d);
1629 for(
int p=0;p<num_points;++p)
1630 cell_jac_det_host(0,p)=cubature_jacobian_determinant_host(cell,p);
1637 Kokkos::deep_copy(cell_cub_points.get_view(),cell_cub_points_host);
1638 intrepid_basis->getValues(cell_curl_basis_ref_scalar.get_view(),cell_cub_points.get_view(),Intrepid2::OPERATOR_CURL);
1639 Kokkos::deep_copy(cell_curl_basis_ref_scalar_host,cell_curl_basis_ref_scalar.get_view());
1644 using fst=Intrepid2::FunctionSpaceTools<Kokkos::HostSpace>;
1645 fst::HDIVtransformDIV(cell_curl_host,cell_jac_det_host,cell_curl_basis_ref_scalar_host);
1646 PHX::Device().fence();
1649 for(
int b=0; b<num_card; ++b)
1650 for(
int p=0; p<num_points; ++p)
1651 tmp_curl_basis_scalar_host(cell,b,p) = cell_curl_host(0,b,p);
1652 Kokkos::deep_copy(tmp_curl_basis_scalar.get_view(),tmp_curl_basis_scalar_host);
1662 return tmp_curl_basis_scalar;
1668template <
typename Scalar>
1673 const bool force)
const
1697 auto tmp_weighted_curl_basis_vector = af.
buildStaticArray<Scalar,
Cell,
BASIS,
IP,
Dim>(
"weighted_curl_basis_vector", num_cells, num_card, num_points, num_dim);
1700 auto s_aux = Kokkos::subview(tmp_weighted_curl_basis_vector.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1701 auto s_cw = Kokkos::subview(
cubature_weights_.get_view(), cell_range, Kokkos::ALL());
1702 auto s_bv = Kokkos::subview(bv.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1704 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1705 fst::multiplyMeasure(s_aux, s_cw, s_bv);
1710 return tmp_weighted_curl_basis_vector;
1715 TEUCHOS_ASSERT(num_dim == 3);
1720 auto cell_curl_basis_ref_vector = af.
buildStaticArray<Scalar,
BASIS,
IP,
Dim>(
"cell_curl_basis_ref_vector",num_card,num_points,num_dim);
1727 intrepid_basis->getValues(cell_curl_basis_ref_vector.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_CURL);
1730 auto s_aux = Kokkos::subview(tmp_curl_basis_vector.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1731 auto s_jac = Kokkos::subview(
cubature_jacobian_.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
1734 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1735 fst::HCURLtransformCURL(s_aux, s_jac, s_jac_det,cell_curl_basis_ref_vector.get_view());
1736 PHX::Device().fence();
1756 auto cell_cub_points_host = Kokkos::create_mirror_view(cell_cub_points.get_view());
1759 auto cell_jac_host = Kokkos::create_mirror_view(cell_jac.get_view());
1760 auto cubature_jacobian_host = Kokkos::create_mirror_view(
cubature_jacobian_.get_view());
1762 auto cell_jac_det_host = Kokkos::create_mirror_view(cell_jac_det.get_view());
1765 auto cell_curl_basis_ref_vector_host = Kokkos::create_mirror_view(cell_curl_basis_ref_vector.get_view());
1766 auto cell_curl_host = Kokkos::create_mirror_view(cell_curl.get_view());
1767 auto tmp_curl_basis_vector_host = Kokkos::create_mirror_view(tmp_curl_basis_vector.get_view());
1773 for(
int p=0;p<num_points;++p)
1774 for(
int d=0;d<num_dim;++d)
1775 cell_cub_points_host(p,d)=cubature_points_ref_host(cell,p,d);
1776 for(
int p=0;p<num_points;++p)
1777 for(
int d=0;d<num_dim;++d)
1778 for(
int d2=0;d2<num_dim;++d2)
1779 cell_jac_host(0,p,d,d2)=cubature_jacobian_host(cell,p,d,d2);
1780 for(
int p=0;p<num_points;++p)
1781 cell_jac_det_host(0,p)=cubature_jacobian_determinant_host(cell,p);
1787 Kokkos::deep_copy(cell_cub_points.get_view(),cell_cub_points_host);
1788 intrepid_basis->getValues(cell_curl_basis_ref_vector.get_view(),cell_cub_points.get_view(),Intrepid2::OPERATOR_CURL);
1789 Kokkos::deep_copy(cell_curl_basis_ref_vector_host,cell_curl_basis_ref_vector.get_view());
1791 using fst=Intrepid2::FunctionSpaceTools<Kokkos::HostSpace>;
1792 fst::HCURLtransformCURL(cell_curl_host,cell_jac_host,cell_jac_det_host,cell_curl_basis_ref_vector_host);
1796 for(
int b=0; b<num_card; ++b)
1797 for(
int p=0; p<num_points; ++p)
1798 for(
int d=0;d<num_dim;++d)
1799 tmp_curl_basis_vector_host(cell,b,p,d) = cell_curl_host(0,b,p,d);
1800 Kokkos::deep_copy(tmp_curl_basis_vector.get_view(),tmp_curl_basis_vector_host);
1810 return tmp_curl_basis_vector;
1816template <
typename Scalar>
1821 const bool force)
const
1845 auto tmp_weighted_div_basis = af.
buildStaticArray<Scalar,
Cell,
BASIS,
IP>(
"weighted_div_basis", num_cells, num_card, num_points);
1848 auto s_aux = Kokkos::subview(tmp_weighted_div_basis.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1849 auto s_cw = Kokkos::subview(
cubature_weights_.get_view(), cell_range, Kokkos::ALL());
1850 auto s_bv = Kokkos::subview(bv.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1852 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1853 fst::multiplyMeasure(s_aux, s_cw, s_bv);
1858 return tmp_weighted_div_basis;
1874 intrepid_basis->getValues(cell_div_basis_ref.get_view(),cubature_points_uniform_ref,Intrepid2::OPERATOR_DIV);
1877 auto s_aux = Kokkos::subview(tmp_div_basis.get_view(), cell_range, Kokkos::ALL(), Kokkos::ALL());
1880 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1881 fst::HDIVtransformDIV(s_aux,s_jac_det,cell_div_basis_ref.get_view());
1882 PHX::Device().fence();
1901 auto cell_cub_points_host = Kokkos::create_mirror_view(cell_cub_points.get_view());
1904 auto cell_jac_det_host = Kokkos::create_mirror_view(cell_jac_det.get_view());
1907 auto cell_div_basis_ref_host = Kokkos::create_mirror_view(cell_div_basis_ref.get_view());
1908 auto cell_div_basis_host = Kokkos::create_mirror_view(cell_div_basis.get_view());
1909 auto tmp_div_basis_host = Kokkos::create_mirror_view(tmp_div_basis.get_view());
1915 for(
int p=0;p<num_points;++p)
1916 for(
int d=0;d<num_dim;++d)
1917 cell_cub_points_host(p,d)=cubature_points_ref_host(cell,p,d);
1918 for(
int p=0;p<num_points;++p)
1919 cell_jac_det_host(0,p)=cubature_jacobian_determinant_host(cell,p);
1925 Kokkos::deep_copy(cell_cub_points.get_view(),cell_cub_points_host);
1926 intrepid_basis->getValues(cell_div_basis_ref.get_view(),cell_cub_points.get_view(),Intrepid2::OPERATOR_DIV);
1927 Kokkos::deep_copy(cell_div_basis_ref_host,cell_div_basis_ref.get_view());
1929 using fst=Intrepid2::FunctionSpaceTools<PHX::Device::execution_space>;
1930 fst::HDIVtransformDIV(cell_div_basis.get_view(),cell_jac_det.get_view(),cell_div_basis_ref.get_view());
1931 Kokkos::deep_copy(cell_div_basis_host, cell_div_basis.get_static_view());
1935 for(
int b=0; b<num_card; ++b)
1936 for(
int p=0; p<num_points; ++p)
1937 tmp_div_basis_host(cell,b,p) = cell_div_basis_host(0,b,p);
1938 Kokkos::deep_copy(tmp_div_basis.get_view(),tmp_div_basis_host);
1948 return tmp_div_basis;
#define PANZER_CACHE_DATA(name)
PHX::MDField< const Scalar, Cell, BASIS, IP > ConstArray_CellBasisIP
Array_CellBasisIP weighted_div_basis
Teuchos::RCP< const panzer::BasisIRLayout > basis_layout
ConstArray_BasisIP getCurl2DVectorBasisRef(const bool cache=true, const bool force=false) const
Get the curl of a vector basis evaluated at reference points.
Array_CellBasisIP basis_scalar
bool weighted_div_basis_evaluated_
Array_BasisIPDim grad_basis_ref
BasisValues2(const std::string &prefix="", const bool allocArrays=false, const bool buildWeighted=false)
Main constructor.
Intrepid2::Basis< PHX::Device::execution_space, Scalar, Scalar > IntrepidBasis
PHX::MDField< const Scalar, Cell, IP > cubature_jacobian_determinant_
Array_CellBasisIPDim weighted_curl_basis_vector
ConstArray_CellBasisIP getDivVectorBasis(const bool weighted, const bool cache=true, const bool force=false) const
Get the divergence of a vector basis evaluated at mesh points.
bool grad_basis_evaluated_
Array_BasisIP curl_basis_ref_scalar
Array_BasisDim basis_coordinates_ref
void evaluateValuesCV(const PHX::MDField< Scalar, Cell, IP, Dim > &cell_cub_points, const PHX::MDField< Scalar, Cell, IP, Dim, Dim > &jac, const PHX::MDField< Scalar, Cell, IP > &jac_det, const PHX::MDField< Scalar, Cell, IP, Dim, Dim > &jac_inv)
ConstArray_BasisIPDim getGradBasisValuesRef(const bool cache=true, const bool force=false) const
Get the gradient of the basis evaluated at reference points.
bool curl_basis_vector_evaluated_
Array_CellBasisIP weighted_curl_basis_scalar
bool basis_coordinates_evaluated_
ConstArray_BasisIPDim getVectorBasisValuesRef(const bool cache=true, const bool force=false) const
Get the vector basis values evaluated at reference points.
Array_CellBasisIPDim weighted_grad_basis
bool orientations_applied_
bool basis_vector_evaluated_
PureBasis::EElementSpace getElementSpace() const
bool weighted_curl_basis_scalar_evaluated_
bool curl_basis_ref_scalar_evaluated_
Array_CellBasisIPDim curl_basis_vector
bool div_basis_ref_evaluated_
ConstArray_CellBasisIPDim getCurlVectorBasis(const bool weighted, const bool cache=true, const bool force=false) const
Get the curl of a 3D vector basis evaluated at mesh points.
int num_orientations_cells_
Array_CellBasisIP curl_basis_scalar
bool weighted_basis_vector_evaluated_
bool weighted_grad_basis_evaluated_
void setup(const Teuchos::RCP< const panzer::BasisIRLayout > &basis, PHX::MDField< const Scalar, Cell, IP, Dim > reference_points, PHX::MDField< const Scalar, Cell, IP, Dim, Dim > point_jacobian, PHX::MDField< const Scalar, Cell, IP > point_jacobian_determinant, PHX::MDField< const Scalar, Cell, IP, Dim, Dim > point_jacobian_inverse, const int num_evaluated_cells=-1)
Setup for lazy evaluation for non-uniform point layout.
const std::vector< PHX::index_size_type > & getExtendedDimensions() const
Get the extended dimensions used by sacado AD allocations.
bool basis_ref_vector_evaluated_
ConstArray_CellBasisIP getBasisValues(const bool weighted, const bool cache=true, const bool force=false) const
Get the basis values evaluated at mesh points.
bool div_basis_evaluated_
ConstArray_BasisIP getBasisValuesRef(const bool cache=true, const bool force=false) const
Get the basis values evaluated at reference points.
PHX::MDField< const Scalar, BASIS, IP, Dim > ConstArray_BasisIPDim
bool grad_basis_ref_evaluated_
bool basis_coordinates_ref_evaluated_
void evaluateBasisCoordinates(const PHX::MDField< Scalar, Cell, NODE, Dim > &vertex_coordinates, const int in_num_cells=-1)
void setOrientations(const std::vector< Intrepid2::Orientation > &orientations, const int num_orientations_cells=-1)
Set the orientations object for applying orientations using the lazy evaluation path - required for c...
void evaluateValues(const PHX::MDField< Scalar, IP, Dim > &cub_points, const PHX::MDField< Scalar, Cell, IP, Dim, Dim > &jac, const PHX::MDField< Scalar, Cell, IP > &jac_det, const PHX::MDField< Scalar, Cell, IP, Dim, Dim > &jac_inv, const int in_num_cells=-1)
Array_BasisIPDim curl_basis_ref_vector
std::vector< PHX::index_size_type > ddims_
PHX::MDField< const Scalar, IP, Dim > cubature_points_uniform_ref_
Array_BasisIP div_basis_ref
ConstArray_CellBasisIPDim getGradBasisValues(const bool weighted, const bool cache=true, const bool force=false) const
Get the gradient of the basis evaluated at mesh points.
bool hasUniformReferenceSpace() const
Check if reference point space is uniform across all cells (faster evaluation).
PHX::MDField< const Scalar, Cell, IP, Dim > cubature_points_ref_
bool curl_basis_ref_vector_evaluated_
Array_CellBasisIP div_basis
PHX::MDField< const Scalar, Cell, BASIS, IP, Dim > ConstArray_CellBasisIPDim
bool weighted_basis_scalar_evaluated_
void setWeightedMeasure(PHX::MDField< const Scalar, Cell, IP > weighted_measure)
Set the cubature weights (weighted measure) for the basis values object - required to get weighted ba...
Array_CellBasisIPDim basis_vector
ConstArray_BasisDim getBasisCoordinatesRef(const bool cache=true, const bool force=false) const
Get the reference coordinates for basis.
Array_CellBasisDim basis_coordinates
bool weighted_curl_basis_vector_evaluated_
PHX::MDField< const Scalar, Cell, IP, Dim, Dim > cubature_jacobian_inverse_
PHX::MDField< const Scalar, Cell, NODE, Dim > cell_vertex_coordinates_
ConstArray_CellBasisIP getCurl2DVectorBasis(const bool weighted, const bool cache=true, const bool force=false) const
Get the curl of a 2D vector basis evaluated at mesh points.
PHX::MDField< const Scalar, BASIS, IP > ConstArray_BasisIP
bool references_evaluated
void setCellVertexCoordinates(PHX::MDField< Scalar, Cell, NODE, Dim > vertex_coordinates)
Set the cell vertex coordinates (required for getBasisCoordinates()).
Array_BasisIPDim basis_ref_vector
ConstArray_BasisIPDim getCurlVectorBasisRef(const bool cache=true, const bool force=false) const
Get the curl of a vector basis evaluated at reference points.
Array_BasisIP basis_ref_scalar
bool basis_ref_scalar_evaluated_
Used to check if arrays have been cached.
Teuchos::RCP< IntrepidBasis > intrepid_basis
ConstArray_CellBasisDim getBasisCoordinates(const bool cache=true, const bool force=false) const
Carterisan coordinates for basis coefficients in mesh space.
PHX::MDField< const Scalar, Cell, IP > cubature_weights_
bool curl_basis_scalar_evaluated_
Array_CellBasisIPDim grad_basis
void setupArrays(const Teuchos::RCP< const panzer::BasisIRLayout > &basis, bool computeDerivatives=true)
Sizes/allocates memory for arrays.
void setupUniform(const Teuchos::RCP< const panzer::BasisIRLayout > &basis, PHX::MDField< const Scalar, IP, Dim > reference_points, PHX::MDField< const Scalar, Cell, IP, Dim, Dim > point_jacobian, PHX::MDField< const Scalar, Cell, IP > point_jacobian_determinant, PHX::MDField< const Scalar, Cell, IP, Dim, Dim > point_jacobian_inverse, const int num_evaluated_cells=-1)
Setup for lazy evaluation for uniform point layout.
Array_CellBasisIP weighted_basis_scalar
PHX::MDField< const Scalar, Cell, BASIS, Dim > ConstArray_CellBasisDim
Array_CellBasisIPDim weighted_basis_vector
PHX::MDField< const Scalar, Cell, IP, Dim, Dim > cubature_jacobian_
ConstArray_CellBasisIPDim getVectorBasisValues(const bool weighted, const bool cache=true, const bool force=false) const
Get the vector basis values evaluated at mesh points.
std::vector< Intrepid2::Orientation > orientations_
ConstArray_BasisIP getDivVectorBasisRef(const bool cache=true, const bool force=false) const
Get the divergence of a vector basis evaluated at reference points.
void applyOrientations(const PHX::MDField< const Scalar, Cell, BASIS > &orientations)
Method to apply orientations to a basis values container.
bool basis_scalar_evaluated_
PHX::MDField< const Scalar, BASIS, Dim > ConstArray_BasisDim
PHX::MDField< Scalar, T0 > buildStaticArray(const std::string &str, int d0) const