Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_Workset.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_WORKSET_HPP
12 #define PANZER_WORKSET_HPP
13 
14 #include <cstddef>
15 #include <vector>
16 #include <map>
17 #include <iostream>
18 
19 #include "Panzer_Dimension.hpp"
20 #include "Panzer_BasisValues2.hpp"
21 #include "Panzer_PointValues2.hpp"
23 #include "Panzer_Dimension.hpp"
24 
27 
28 #include "Phalanx_KokkosDeviceTypes.hpp"
29 
30 namespace panzer {
31 
32  struct WorksetNeeds;
33 
34  struct LocalMeshPartition;
35 
36  class SubcellConnectivity;
37 
38  class OrientationsInterface;
39 
45  struct
47  {
50  side_assembly_(false),
51  align_side_points_(false)
52  {
53 
54  }
55 
58 
61 
64  };
65 
71  public:
73 
76 
78  void
79  setup(const LocalMeshPartition & partition,
80  const WorksetOptions & options);
81 
83  int num_cells;
84 
87 
88  // DEPRECATED - use: getLocalCellIDs()
89  PHX::View<const int*> cell_local_ids_k;
90 
91  // DEPRECATED - use: getLocalCellIDs()
92  std::vector<size_t> cell_local_ids;
93 
96 
98  std::string block_id;
99 
102 
104  //TEUCHOS_DEPRECATED
106 
107  //TEUCHOS_DEPRECATED
108  mutable std::vector<Teuchos::RCP<panzer::IntegrationValues2<double> > > int_rules;
109 
111  //TEUCHOS_DEPRECATED
113 
115  //TEUCHOS_DEPRECATED
116  mutable std::vector<Teuchos::RCP< panzer::BasisValues2<double> > > bases;
117 
122 
125 
127  const panzer::PureBasis & getBasis(const panzer::BasisDescriptor & description) const;
128 
130  const std::string &
132  {return block_id;}
133 
135  const std::string &
136  getSideset() const
137  {return sideset_;}
138 
140  unsigned int
142  {return num_dimensions_;}
143 
145  int
147  {return subcell_index;}
148 
150  int
152  {return subcell_dim;}
153 
156  getCellNodes() const
157  {return cell_node_coordinates;}
158 
162  {return cell_local_ids_k;}
163 
193  const SubcellConnectivity &
194  getSubcellConnectivity(const unsigned int subcell_dimension) const;
195 
197  bool
198  hasSubcellConnectivity(const unsigned int subcell_dimension) const;
199 
212  const bool lazy_version=false) const;
213 
214  /*
215  * \brief Grab the basis values for a given basis description
216  *
217  * \note An arbitrary integration order is used - only use for getting basis coordinates
218  *
219  * \throws If setup has not been called
220  *
221  * \param[in] basis_description Description of requested basis
222  * \param[in] lazy_version Get an empty BasisValues2 object that will construct/allocate itself on demand (less memory - EXPERIMENTAL)
223  *
224  * \return Object containing basis values
225  */
227  getBasisValues(const panzer::BasisDescriptor & basis_description,
228  const bool lazy_version=false) const;
229 
230  /*
231  * \brief Grab the basis values for a given basis description
232  *
233  * \throws If setup has not been called
234  *
235  * \todo This needs to be const, but one path for workset construction requires non-const
236  *
237  * \param[in] basis_description Description of requested basis
238  * \param[in] integration_description Descriptor for integration scheme
239  * \param[in] lazy_version Get an empty BasisValues2 object that will construct/allocate itself on demand (less memory - EXPERIMENTAL)
240  *
241  * \return Object containing basis values
242  */
244  getBasisValues(const panzer::BasisDescriptor & basis_description,
245  const panzer::IntegrationDescriptor & integration_description,
246  const bool lazy_version=false) const;
247 
248  /*
249  * \brief Grab the basis values for a given basis description
250  *
251  * \throws If setup has not been called
252  * \throws if point_descriptor has not been registered
253  *
254  * \param[in] basis_description Description of requested basis
255  * \param[in] point_description Descriptor for points
256  * \param[in] lazy_version Get an empty BasisValues2 object that will construct/allocate itself on demand (less memory - EXPERIMENTAL)
257  *
258  * \return Object containing basis values
259  */
261  getBasisValues(const panzer::BasisDescriptor & basis_description,
262  const panzer::PointDescriptor & point_description,
263  const bool lazy_version=false) const;
264 
271  getPointValues(const panzer::PointDescriptor & point_description) const;
272 
274  int numCells() const {return num_cells;}
275 
277  int numOwnedCells() const {return num_owned_cells_;}
278 
280  int numGhostCells() const {return num_ghost_cells_;}
281 
283  int numVirtualCells() const {return num_virtual_cells_;}
284 
286  void setNumberOfCells(const int owned_cells,
287  const int ghost_cells,
288  const int virtual_cells);
289 
290  protected:
291 
292  bool setup_;
293 
297 
299 
300  std::string sideset_;
301 
303 
305 
306  // TODO: Const vs non-const is complicated here due to how point values are generated and orientations are applied
307  // Unifying the construction method for worksets will help reduce the clutter here, but point values will almost always be non-const
308  mutable std::map<size_t,Teuchos::RCP<const panzer::PureBasis > > _pure_basis_map;
309  mutable std::map<size_t,Teuchos::RCP<const panzer::IntegrationRule > > _integration_rule_map;
310  mutable std::map<size_t,Teuchos::RCP<const panzer::PointRule > > _point_rule_map;
311 
312  mutable std::map<size_t,Teuchos::RCP<const panzer::IntegrationValues2<double> > > integration_values_map_;
313  mutable std::map<size_t,Teuchos::RCP<panzer::PointValues2<double> > > point_values_map_;
314  mutable std::map<size_t,std::map<size_t,Teuchos::RCP<panzer::BasisValues2<double> > > > basis_integration_values_map_;
315  mutable std::map<size_t,std::map<size_t,Teuchos::RCP<panzer::BasisValues2<double> > > > basis_point_values_map_;
316 
318 
319  };
320 
325  class Workset : public WorksetDetails {
326  public:
329 
331  Workset(std::size_t identifier) : identifier_(identifier) {}
332 
334  void setIdentifier(std::size_t identifier) { identifier_ = identifier; }
335 
337  std::size_t getIdentifier() const { return identifier_; }
338 
339  double alpha;
340  double beta;
341  double time;
342  double step_size;
343  double stage_number;
344  std::vector<double> gather_seeds; // generic gather seeds
346 
351 
353  WorksetDetails& operator()(const int i) {
354  TEUCHOS_ASSERT(i == 0 || (i == 1 && Teuchos::nonnull(other)));
355  return i == 0 ? static_cast<WorksetDetails&>(*this) : *other;
356  }
358  const WorksetDetails& operator()(const int i) const {
359  TEUCHOS_ASSERT(i == 0 || (i == 1 && Teuchos::nonnull(other)));
360  return i == 0 ? static_cast<const WorksetDetails&>(*this) : *other;
361  }
363  WorksetDetails& details(const int i) { return operator()(i); }
364  const WorksetDetails& details(const int i) const { return operator()(i); }
366  size_t numDetails() const { return Teuchos::nonnull(other) ? 2 : 1; }
367 
368  private:
369  std::size_t identifier_;
370  };
371 
372  std::ostream& operator<<(std::ostream& os, const panzer::Workset& w);
373 
381  public:
385  void setDetailsIndex(const int di) { details_index_ = di; }
388  int getDetailsIndex() const { return details_index_; }
390  WorksetDetails& operator()(Workset& workset) const {
391  return workset(details_index_);
392  }
394  const WorksetDetails& operator()(const Workset& workset) const {
395  return workset(details_index_);
396  }
397  private:
399  };
400 
401 } // namespace panzer
402 
403 #endif
int num_cells
DEPRECATED - use: numCells()
bool hasSubcellConnectivity(const unsigned int subcell_dimension) const
Check if subcell connectivity exists for a given dimension.
std::map< size_t, Teuchos::RCP< const panzer::IntegrationRule > > _integration_rule_map
PHX::View< const int * > cell_local_ids_k
std::size_t getIdentifier() const
Get the unique identifier for this workset, this is not an index!
Teuchos::RCP< panzer::SubcellConnectivity > face_connectivity_
unsigned int numDimensions() const
Get the cell dimension for the mesh.
std::map< size_t, std::map< size_t, Teuchos::RCP< panzer::BasisValues2< double > > > > basis_point_values_map_
const SubcellConnectivity & getSubcellConnectivity(const unsigned int subcell_dimension) const
Get the subcell connectivity for the workset topology.
void setDetailsIndex(const int di)
An evaluator builder sets the details index.
std::vector< size_t > cell_local_ids
bool nonnull(const std::shared_ptr< T > &p)
Used to define options for lazy evaluation of BasisValues and IntegrationValues objects.
WorksetOptions()
Default constructor.
void setIdentifier(std::size_t identifier)
Set the unique identifier for this workset, this is not an index!
Teuchos::RCP< std::vector< int > > ir_degrees
If workset corresponds to a sub cell, what is the index?
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::map< size_t, Teuchos::RCP< const panzer::IntegrationValues2< double > > > integration_values_map_
Teuchos::RCP< std::vector< std::string > > basis_names
Value corresponds to basis type. Use the offest for indexing.
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 subcell_dim
DEPRECATED - use: getSubcellDimension()
int numOwnedCells() const
Number of cells owned by this workset.
int getSubcellIndex() const
Get the subcell index (returns -1 if not a subcell)
std::map< size_t, Teuchos::RCP< const panzer::PureBasis > > _pure_basis_map
std::size_t identifier_
int numGhostCells() const
Number of cells owned by a different workset.
Workset(std::size_t identifier)
Constructor that that requires a unique identifier.
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)
Teuchos::RCP< const shards::CellTopology > cell_topology_
std::map< size_t, Teuchos::RCP< const panzer::PointRule > > _point_rule_map
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...
Teuchos::RCP< WorksetDetails > other
PHX::MDField< double, Cell, NODE, Dim > CellCoordArray
Teuchos::RCP< const OrientationsInterface > orientations_
Must be set to apply orientations - if it is set, then orientations will be applied to basis values...
WorksetDetailsAccessor()
Default value is 0, which is backwards compatible.
bool side_assembly_
Build integration values for sides.
std::vector< Teuchos::RCP< panzer::IntegrationValues2< double > > > int_rules
std::map< size_t, Teuchos::RCP< panzer::PointValues2< double > > > point_values_map_
std::vector< double > gather_seeds
size_t numDetails() const
Return the number of WorksetDetails this Workset holds.
const WorksetDetails & operator()(const Workset &workset) const
const accessor.
const std::string & getSideset() const
Get the sideset id (returns &quot;&quot; if not a sideset)
WorksetDetails & operator()(const int i)
op(0) return *this; op(1) returns *other.
std::map< size_t, std::map< size_t, Teuchos::RCP< panzer::BasisValues2< double > > > > basis_integration_values_map_
const panzer::IntegrationValues2< double > & getIntegrationValues(const panzer::IntegrationDescriptor &description, const bool lazy_version=false) const
Get the integration values for a given integration description.
Kokkos::View< const int *, PHX::Device > getLocalCellIDs() const
Get the local cell IDs for the workset.
std::string block_id
DEPRECATED - use: getElementBlock()
const WorksetDetails & details(const int i) const
WorksetDetails()
Default constructor.
const panzer::IntegrationRule & getIntegrationRule(const panzer::IntegrationDescriptor &description) const
Grab the integration rule for a given integration description (throws error if integration doesn&#39;t ex...
int subcell_index
DEPRECATED - use: getSubcellIndex()
int numCells() const
Number of total cells in workset (owned, ghost, and virtual)
int getSubcellDimension() const
Get the subcell dimension.
CellCoordArray getCellNodes() const
Get the node coordinates for the cells.
std::ostream & operator<<(std::ostream &os, const AssemblyEngineInArgs &in)
WorksetDetails & details(const int i)
Convenience wrapper to operator() for pointer access.
bool align_side_points_
If workset side integration values must align with another workset, there must be a unique order assi...
CellCoordArray cell_node_coordinates
DEPRECATED - use: getCellNodes()
const std::string & getElementBlock() const
Get the element block id.
int numVirtualCells() const
Number of cells not owned by any workset - these are used for boundary conditions.
Description and data layouts associated with a particular basis.
#define TEUCHOS_ASSERT(assertion_test)
WorksetDetails & operator()(Workset &workset) const
Workset wrapper to extract the correct details. Example: wda(workset).bases[i].
const panzer::SubcellConnectivity & getFaceConnectivity() const
void setup(const LocalMeshPartition &partition, const WorksetOptions &options)
Constructs the workset details from a given chunk of the mesh.
Workset()
Default constructor, identifier is a useless 0 by default.
const panzer::BasisValues2< double > & getBasisValues(const panzer::BasisDescriptor &basis_description, const bool lazy_version=false) const
const WorksetDetails & operator()(const int i) const
const accessor.