13#include "Phalanx_DataLayout.hpp"
14#include "Phalanx_DataLayout_MDALayout.hpp"
17#include "Panzer_Workset_Builder.hpp"
29#include "Shards_CellTopology.hpp"
35void buildLocalOrientations(
const int num_cells,
36 const Kokkos::View<const panzer::LocalOrdinal*,PHX::Device> & local_cell_ids,
37 const Teuchos::RCP<const OrientationsInterface> & orientations_interface,
38 std::vector<Intrepid2::Orientation> & workset_orientations)
42 const auto & local_orientations = *orientations_interface->getOrientations();
43 workset_orientations.resize(num_cells);
46 auto local_cell_ids_host = Kokkos::create_mirror_view(local_cell_ids);
47 Kokkos::deep_copy(local_cell_ids_host, local_cell_ids);
48 for(
int i=0; i<num_cells; ++i)
49 workset_orientations[i] = local_orientations[local_cell_ids_host[i]];
53applyBV2Orientations(
const int num_cells,
54 BasisValues2<double> & basis_values,
55 const Kokkos::View<const panzer::LocalOrdinal*,PHX::Device> & local_cell_ids,
56 const Teuchos::RCP<const OrientationsInterface> & orientations_interface)
62 if(orientations_interface.is_null())
66 if(basis_values.orientationsApplied())
70 std::vector<Intrepid2::Orientation> workset_orientations(num_cells);
71 buildLocalOrientations(num_cells,local_cell_ids,orientations_interface, workset_orientations);
73 basis_values.applyOrientations(workset_orientations,num_cells);
83 , ir_degrees(new
std::vector<int>())
84 , basis_names(new
std::vector<
std::string>())
88 , num_virtual_cells_(0)
118 Kokkos::View<LocalOrdinal*, PHX::Device> cell_ids = Kokkos::View<LocalOrdinal*, PHX::Device>(
"cell_ids",
num_cells);
119 Kokkos::deep_copy(cell_ids, partition.
local_cells);
123 auto local_cells_h = Kokkos::create_mirror_view(partition.
local_cells);
124 Kokkos::deep_copy(local_cells_h, partition.
local_cells);
127 const int local_cell = local_cells_h(cell);
135 TEUCHOS_ASSERT(partition.
cell_nodes.rank == 3);
138 const int num_partition_cells = partition.
cell_nodes.extent(0);
139 const int num_nodes_per_cell = partition.
cell_nodes.extent(1);
140 const int num_dims_per_node = partition.
cell_nodes.extent(2);
143 TEUCHOS_ASSERT(num_partition_cells ==
num_cells);
144 TEUCHOS_ASSERT(num_nodes_per_cell > 0);
145 TEUCHOS_ASSERT(num_dims_per_node > 0);
152 const auto partition_nodes = partition.
cell_nodes;
154 Kokkos::parallel_for(
num_cells, KOKKOS_LAMBDA (
int i) {
155 for(
int j=0;j<num_nodes_per_cell;++j)
156 for(
int k=0;k<num_dims_per_node;++k)
157 cnc(i,j,k) = partition_nodes(i,j,k);
165 face_connectivity->setup(partition);
188 "Workset::getSubcellConnectivity : Requested subcell dimension "<<subcell_dimension<<
" for a "<<
num_dimensions_<<
"D workset. This is not supported.");
203 const bool lazy_version)
const
208 size_t key = description.
getKey();
210 panzer::hash_combine<int>(key, 123);
215 return *(itr->second);
226 "Workset::getIntegrationValues : Attempted to build integration values for side '"<<description.
getSide()<<
"', but workset is constructed for side '"<<
getSubcellIndex()<<
"'");
231 Teuchos::RCP<IntegrationValues2<double>> iv;
255 ir_degrees->push_back(iv->int_rule->cubature_degree);
265 const bool lazy_version)
const
272 for(
const auto & pr : itr->second)
297 const bool lazy_version)
const
302 size_t basis_key = basis_description.
getKey();
304 panzer::hash_combine<int>(basis_key, 123);
307 size_t integration_key = integration_description.
getKey();
309 panzer::hash_combine<int>(integration_key, 123);
314 const auto & submap = itr->second;
315 const auto itr2 = submap.find(integration_key);
316 if(itr2 != submap.end())
317 return *(itr2->second);
325 Teuchos::RCP<BasisValues2<double>> biv;
334 biv->setupUniform(bir, iv.getUniformCubaturePointsRef(
false), iv.getJacobian(
false), iv.getJacobianDeterminant(
false), iv.getJacobianInverse(
false));
336 biv->setup(bir, iv.getCubaturePointsRef(
false), iv.getJacobian(
false), iv.getJacobianDeterminant(
false), iv.getJacobianInverse(
false));
339 std::vector<Intrepid2::Orientation> workset_orientations;
343 biv->setWeightedMeasure(iv.getWeightedMeasure(
false));
351 biv->setupArrays(bir);
356 biv->evaluateValuesCV(iv.ref_ip_coordinates,
369 biv->evaluateValues(iv.cub_points,
380 biv->evaluateValues(iv.ref_ip_coordinates,
396 bases.push_back(biv);
414 return *(itr->second);
416 TEUCHOS_TEST_FOR_EXCEPT_MSG(not description.
hasGenerator(),
417 "Point Descriptor of type '"<<description.
getType()<<
"' does not have associated generator.");
440 const bool lazy_version)
const
445 size_t basis_key = basis_description.
getKey();
447 panzer::hash_combine<int>(basis_key, 123);
452 const auto & submap = itr->second;
453 const auto itr2 = submap.find(point_description.
getKey());
454 if(itr2 != submap.end())
455 return *(itr2->second);
464 Teuchos::RCP<BasisValues2<double>> bpv;
472 bpv->setupUniform(bir, pv.coords_ref, pv.jac, pv.jac_det, pv.jac_inv);
475 std::vector<Intrepid2::Orientation> workset_orientations;
486 bpv->setupArrays(bir);
487 bpv->evaluateValues(pv.coords_ref,
525 "Workset::getIntegrationValues : Attempted to build integration values for side '"<<description.
getSide()<<
"', but workset is constructed for side '"<<
getSubcellIndex()<<
"'");
534 return *(itr->second);
552 return *(itr->second);
574 os <<
"Workset" << endl;
576 os <<
" num_cells:" << w.
num_cells << endl;
580 os <<
" cell_local_ids (size=" << w.
getLocalCellIDs().size() <<
")" << endl;
584 os <<
" ir_degrees: " << endl;
585 for (std::vector<int>::const_iterator ir = w.
ir_degrees->begin();
587 os <<
" " << *ir << std::endl;
589 std::vector<int>::const_iterator ir = w.
ir_degrees->begin();
593 os <<
" IR Values (Degree=" << *ir <<
"):" << endl;
595 os <<
" cub_points:" << endl;
596 os << (*irv)->cub_points << endl;
598 os <<
" side_cub_points:" << endl;
599 os << (*irv)->side_cub_points << endl;
601 os <<
" cub_weights:" << endl;
602 os << (*irv)->cub_weights << endl;
604 os <<
" node_coordinates:" << endl;
605 os << (*irv)->node_coordinates << endl;
607 os <<
" jac:" << endl;
608 os << (*irv)->jac << endl;
610 os <<
" jac_inv:" << endl;
611 os << (*irv)->jac_inv << endl;
613 os <<
" jac_det:" << endl;
614 os << (*irv)->jac_det << endl;
616 os <<
" weighted_measure:" << endl;
617 os << (*irv)->weighted_measure << endl;
619 os <<
" covarient:" << endl;
620 os << (*irv)->covarient << endl;
622 os <<
" contravarient:" << endl;
623 os << (*irv)->contravarient << endl;
625 os <<
" norm_contravarient:" << endl;
626 os << (*irv)->norm_contravarient << endl;
628 os <<
" ip_coordinates:" << endl;
629 os << (*irv)->ip_coordinates << endl;
631 os <<
" int_rule->getName():" << (*irv)->int_rule->getName() << endl;
635 os <<
" basis_names: " << endl;
636 for (std::vector<std::string>::const_iterator b = w.
basis_names->begin();
638 os <<
" " << *b << std::endl;
640 std::vector<std::string>::const_iterator b = w.
basis_names->begin();
644 os <<
" Basis Values (basis_name=" << *b <<
"):" << endl;
672 os <<
" basis_layout->name():" << (*bv)->basis_layout->name() << endl;
int getOrder() const
Get order of basis.
const std::string & getType() const
Get type of basis.
std::size_t getKey() const
Get unique key associated with basis of this order and type The key is used to sort through a map of ...
Generates a SubcellConnectivity associated with faces and cells given a partition of the local mesh.
@ VOLUME
No integral specified - default state.
@ CV_VOLUME
Integral over a specific side of cells (side must be set)
@ CV_SIDE
Control volume integral.
@ CV_BOUNDARY
Control volume side integral.
@ SIDE
Integral over all sides of cells (closed surface integral)
@ SURFACE
Integral over volume.
const int & getSide() const
Get side associated with integration - this is for backward compatibility.
std::size_t getKey() const
Get unique key associated with integrator of this order and type The key is used to sort through a ma...
const int & getType() const
Get type of integrator.
PHX::MDField< Scalar, T0 > buildStaticArray(const std::string &str, int d0) const
const PointGenerator & getGenerator() const
bool hasGenerator() const
Check if the point descriptor has a generator for generating point values.
const std::string & getType() const
Get unique string associated with the type of point descriptor. This will be used generate a hash to ...
std::size_t getKey() const
Get unique key associated with integrator of this order and type The key is used to sort through a ma...
virtual Kokkos::DynRankView< double > getPoints(const shards::CellTopology &topo) const =0
Get the points for a particular topology.
virtual bool hasPoints(const shards::CellTopology &topo) const =0
Check if the generator can generate points for the given topology.
Description and data layouts associated with a particular basis.
KOKKOS_INLINE_FUNCTION int numSubcells() const
Gives number of subcells (e.g. faces) in connectivity.
int numOwnedCells() const
Number of cells owned by this workset.
CellCoordArray cell_node_coordinates
DEPRECATED - use: getCellNodes()
const panzer::IntegrationRule & getIntegrationRule(const panzer::IntegrationDescriptor &description) const
Grab the integration rule for a given integration description (throws error if integration doesn't ex...
std::string block_id
DEPRECATED - use: getElementBlock()
Teuchos::RCP< panzer::SubcellConnectivity > face_connectivity_
std::map< size_t, Teuchos::RCP< const panzer::IntegrationValues2< double > > > integration_values_map_
std::map< size_t, std::map< size_t, Teuchos::RCP< panzer::BasisValues2< double > > > > basis_integration_values_map_
CellCoordArray getCellNodes() const
Get the node coordinates for the cells.
const panzer::SubcellConnectivity & getFaceConnectivity() const
int subcell_dim
DEPRECATED - use: getSubcellDimension()
std::vector< Teuchos::RCP< panzer::BasisValues2< double > > > bases
Static basis function data, key is basis name, value is index in the static_bases vector.
std::vector< Teuchos::RCP< panzer::IntegrationValues2< double > > > int_rules
Teuchos::RCP< const shards::CellTopology > cell_topology_
const std::string & getElementBlock() const
Get the element block id.
PHX::View< const int * > cell_local_ids_k
std::map< size_t, Teuchos::RCP< const panzer::IntegrationRule > > _integration_rule_map
unsigned int numDimensions() const
Get the cell dimension for the mesh.
Kokkos::View< const int *, PHX::Device > getLocalCellIDs() const
Get the local cell IDs for the workset.
int num_cells
DEPRECATED - use: numCells()
bool hasSubcellConnectivity(const unsigned int subcell_dimension) const
Check if subcell connectivity exists for a given dimension.
panzer::PointValues2< double > & getPointValues(const panzer::PointDescriptor &point_description) const
Grab the basis values for a given basis description and integration description (throws error if it d...
int numCells() const
Number of total cells in workset (owned, ghost, and virtual)
Teuchos::RCP< std::vector< std::string > > basis_names
Value corresponds to basis type. Use the offest for indexing.
const panzer::IntegrationValues2< double > & getIntegrationValues(const panzer::IntegrationDescriptor &description, const bool lazy_version=false) const
Get the integration values for a given integration description.
std::map< size_t, Teuchos::RCP< const panzer::PureBasis > > _pure_basis_map
std::map< size_t, std::map< size_t, Teuchos::RCP< panzer::BasisValues2< double > > > > basis_point_values_map_
int numGhostCells() const
Number of cells owned by a different workset.
Teuchos::RCP< std::vector< int > > ir_degrees
If workset corresponds to a sub cell, what is the index?
const panzer::PureBasis & getBasis(const panzer::BasisDescriptor &description) const
Grab the pure basis (contains data layouts) for a given basis description (throws error if integratio...
const SubcellConnectivity & getSubcellConnectivity(const unsigned int subcell_dimension) const
Get the subcell connectivity for the workset topology.
int getSubcellDimension() const
Get the subcell dimension.
int subcell_index
DEPRECATED - use: getSubcellIndex()
void setNumberOfCells(const int owned_cells, const int ghost_cells, const int virtual_cells)
Provides access to set numbers of cells (required for backwards compatibility)
const panzer::BasisValues2< double > & getBasisValues(const panzer::BasisDescriptor &basis_description, const bool lazy_version=false) const
std::map< size_t, Teuchos::RCP< panzer::PointValues2< double > > > point_values_map_
WorksetDetails()
Default constructor.
int getSubcellIndex() const
Get the subcell index (returns -1 if not a subcell)
int numVirtualCells() const
Number of cells not owned by any workset - these are used for boundary conditions.
std::vector< size_t > cell_local_ids
void setup(const LocalMeshPartition &partition, const WorksetOptions &options)
Constructs the workset details from a given chunk of the mesh.
std::ostream & operator<<(std::ostream &os, const AssemblyEngineInArgs &in)
panzer::LocalOrdinal num_owned_cells
panzer::LocalOrdinal num_ghstd_cells
panzer::LocalOrdinal num_virtual_cells
PHX::View< panzer::LocalOrdinal * > local_cells
PHX::View< double *** > cell_nodes
Teuchos::RCP< const shards::CellTopology > cell_topology
std::string element_block_name
Used to define options for lazy evaluation of BasisValues and IntegrationValues objects.
bool align_side_points_
If workset side integration values must align with another workset, there must be a unique order assi...
Teuchos::RCP< const OrientationsInterface > orientations_
Must be set to apply orientations - if it is set, then orientations will be applied to basis values.
bool side_assembly_
Build integration values for sides.