Panzer  Version of the Day
Panzer_Workset.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 
44 #ifndef PANZER_WORKSET_HPP
45 #define PANZER_WORKSET_HPP
46 
47 #include <cstddef>
48 #include <vector>
49 #include <map>
50 #include <iostream>
51 
52 #include "Panzer_Dimension.hpp"
53 #include "Panzer_BasisValues2.hpp"
54 #include "Panzer_PointValues2.hpp"
56 #include "Panzer_Dimension.hpp"
57 
60 
61 #include "Phalanx_KokkosDeviceTypes.hpp"
62 
63 namespace panzer {
64 
65  struct WorksetNeeds;
66 
67  struct LocalMeshPartition;
68 
69  class SubcellConnectivity;
70 
71  class OrientationsInterface;
72 
78  struct
80  {
83  side_assembly_(false),
84  align_side_points_(false)
85  {
86 
87  }
88 
91 
94 
96  Teuchos::RCP<const OrientationsInterface> orientations_;
97  };
98 
104  public:
105  typedef PHX::MDField<double,Cell,NODE,Dim> CellCoordArray;
106 
108  WorksetDetails();
109 
111  void
112  setup(const LocalMeshPartition & partition,
113  const WorksetOptions & options);
114 
117 
120 
121  // DEPRECATED - use: getLocalCellIDs()
122  PHX::View<const int*> cell_local_ids_k;
123 
124  // DEPRECATED - use: getLocalCellIDs()
125  std::vector<size_t> cell_local_ids;
126 
129 
131  std::string block_id;
132 
135 
137  //TEUCHOS_DEPRECATED
138  Teuchos::RCP< std::vector<int> > ir_degrees;
139 
140  //TEUCHOS_DEPRECATED
141  mutable std::vector<Teuchos::RCP<panzer::IntegrationValues2<double> > > int_rules;
142 
144  //TEUCHOS_DEPRECATED
145  Teuchos::RCP< std::vector<std::string> > basis_names;
146 
148  //TEUCHOS_DEPRECATED
149  mutable std::vector<Teuchos::RCP< panzer::BasisValues2<double> > > bases;
150 
155 
158 
160  const panzer::PureBasis & getBasis(const panzer::BasisDescriptor & description) const;
161 
163  const std::string &
165  {return block_id;}
166 
168  const std::string &
169  getSideset() const
170  {return sideset_;}
171 
173  unsigned int
175  {return num_dimensions_;}
176 
178  int
180  {return subcell_index;}
181 
183  int
185  {return subcell_dim;}
186 
190  {return cell_vertex_coordinates;}
191 
193  Kokkos::View<const int*,PHX::Device>
195  {return cell_local_ids_k;}
196 
226  const SubcellConnectivity &
227  getSubcellConnectivity(const unsigned int subcell_dimension) const;
228 
230  bool
231  hasSubcellConnectivity(const unsigned int subcell_dimension) const;
232 
243  getIntegrationValues(const panzer::IntegrationDescriptor & description) const;
244 
245  /*
246  * \brief Grab the basis values for a given basis description
247  *
248  * \note An arbitrary integration order is used - only use for getting basis coordinates
249  *
250  * \throws If setup has not been called
251  *
252  * \param[in] basis_description Description of requested basis
253  * \param[in] lazy_version Get an empty BasisValues2 object that will construct/allocate itself on demand (less memory - EXPERIMENTAL)
254  *
255  * \return Object containing basis values
256  */
258  getBasisValues(const panzer::BasisDescriptor & basis_description,
259  const bool lazy_version=false) const;
260 
261  /*
262  * \brief Grab the basis values for a given basis description
263  *
264  * \throws If setup has not been called
265  *
266  * \todo This needs to be const, but one path for workset construction requires non-const
267  *
268  * \param[in] basis_description Description of requested basis
269  * \param[in] integration_description Descriptor for integration scheme
270  * \param[in] lazy_version Get an empty BasisValues2 object that will construct/allocate itself on demand (less memory - EXPERIMENTAL)
271  *
272  * \return Object containing basis values
273  */
275  getBasisValues(const panzer::BasisDescriptor & basis_description,
276  const panzer::IntegrationDescriptor & integration_description,
277  const bool lazy_version=false) const;
278 
279  /*
280  * \brief Grab the basis values for a given basis description
281  *
282  * \throws If setup has not been called
283  * \throws if point_descriptor has not been registered
284  *
285  * \param[in] basis_description Description of requested basis
286  * \param[in] point_description Descriptor for points
287  * \param[in] lazy_version Get an empty BasisValues2 object that will construct/allocate itself on demand (less memory - EXPERIMENTAL)
288  *
289  * \return Object containing basis values
290  */
292  getBasisValues(const panzer::BasisDescriptor & basis_description,
293  const panzer::PointDescriptor & point_description,
294  const bool lazy_version=false) const;
295 
302  getPointValues(const panzer::PointDescriptor & point_description) const;
303 
305  int numCells() const {return num_cells;}
306 
308  int numOwnedCells() const {return num_owned_cells_;}
309 
311  int numGhostCells() const {return num_ghost_cells_;}
312 
314  int numVirtualCells() const {return num_virtual_cells_;}
315 
317  void setNumberOfCells(const int owned_cells,
318  const int ghost_cells,
319  const int virtual_cells);
320 
321  protected:
322 
323  bool setup_;
324 
328 
330 
331  std::string sideset_;
332 
334 
335  Teuchos::RCP<const shards::CellTopology> cell_topology_;
336 
337  // TODO: Const vs non-const is complicated here due to how point values are generated and orientations are applied
338  // Unifying the construction method for worksets will help reduce the clutter here, but point values will almost always be non-const
339  mutable std::map<size_t,Teuchos::RCP<const panzer::PureBasis > > _pure_basis_map;
340  mutable std::map<size_t,Teuchos::RCP<const panzer::IntegrationRule > > _integration_rule_map;
341  mutable std::map<size_t,Teuchos::RCP<const panzer::PointRule > > _point_rule_map;
342 
343  mutable std::map<size_t,Teuchos::RCP<const panzer::IntegrationValues2<double> > > integration_values_map_;
344  mutable std::map<size_t,Teuchos::RCP<panzer::PointValues2<double> > > point_values_map_;
345  mutable std::map<size_t,std::map<size_t,Teuchos::RCP<panzer::BasisValues2<double> > > > basis_integration_values_map_;
346  mutable std::map<size_t,std::map<size_t,Teuchos::RCP<panzer::BasisValues2<double> > > > basis_point_values_map_;
347 
348  Teuchos::RCP<panzer::SubcellConnectivity> face_connectivity_;
349 
350  };
351 
356  class Workset : public WorksetDetails {
357  public:
360 
362  Workset(std::size_t identifier) : identifier_(identifier) {}
363 
365  void setIdentifier(std::size_t identifier) { identifier_ = identifier; }
366 
368  std::size_t getIdentifier() const { return identifier_; }
369 
370  double alpha;
371  double beta;
372  double time;
373  double step_size;
374  double stage_number;
375  std::vector<double> gather_seeds; // generic gather seeds
377 
381  Teuchos::RCP<WorksetDetails> other;
382 
384  WorksetDetails& operator()(const int i) {
385  TEUCHOS_ASSERT(i == 0 || (i == 1 && Teuchos::nonnull(other)));
386  return i == 0 ? static_cast<WorksetDetails&>(*this) : *other;
387  }
389  const WorksetDetails& operator()(const int i) const {
390  TEUCHOS_ASSERT(i == 0 || (i == 1 && Teuchos::nonnull(other)));
391  return i == 0 ? static_cast<const WorksetDetails&>(*this) : *other;
392  }
394  WorksetDetails& details(const int i) { return operator()(i); }
395  const WorksetDetails& details(const int i) const { return operator()(i); }
397  size_t numDetails() const { return Teuchos::nonnull(other) ? 2 : 1; }
398 
399  private:
400  std::size_t identifier_;
401  };
402 
403  std::ostream& operator<<(std::ostream& os, const panzer::Workset& w);
404 
412  public:
416  void setDetailsIndex(const int di) { details_index_ = di; }
419  int getDetailsIndex() const { return details_index_; }
421  WorksetDetails& operator()(Workset& workset) const {
422  return workset(details_index_);
423  }
425  const WorksetDetails& operator()(const Workset& workset) const {
426  return workset(details_index_);
427  }
428  private:
430  };
431 
432 } // namespace panzer
433 
434 #endif
int num_cells
DEPRECATED - use: numCells()
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...
const SubcellConnectivity & getSubcellConnectivity(const unsigned int subcell_dimension) const
Get the subcell connectivity for the workset topology.
std::map< size_t, Teuchos::RCP< const panzer::IntegrationRule > > _integration_rule_map
PHX::View< const int * > cell_local_ids_k
Teuchos::RCP< panzer::SubcellConnectivity > face_connectivity_
std::size_t getIdentifier() const
Get the unique identifier for this workset, this is not an index!
int numVirtualCells() const
Number of cells not owned by any workset - these are used for boundary conditions.
std::map< size_t, std::map< size_t, Teuchos::RCP< panzer::BasisValues2< double > > > > basis_point_values_map_
void setDetailsIndex(const int di)
An evaluator builder sets the details index.
std::vector< size_t > cell_local_ids
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.
int subcell_dim
DEPRECATED - use: getSubcellDimension()
unsigned int numDimensions() const
Get the cell dimension for the mesh.
std::map< size_t, Teuchos::RCP< const panzer::PureBasis > > _pure_basis_map
const std::string & getElementBlock() const
Get the element block id.
int numCells() const
Number of total cells in workset (owned, ghost, and virtual)
std::size_t identifier_
size_t numDetails() const
Return the number of WorksetDetails this Workset holds.
CellCoordArray cell_vertex_coordinates
DEPRECATED - use: getCellVertices()
Workset(std::size_t identifier)
Constructor that that requires a unique identifier.
const WorksetDetails & operator()(const int i) const
const accessor.
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...
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_
const panzer::IntegrationValues2< double > & getIntegrationValues(const panzer::IntegrationDescriptor &description) const
Get the integration values for a given integration description.
std::map< size_t, Teuchos::RCP< const panzer::PointRule > > _point_rule_map
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.
int getSubcellIndex() const
Get the subcell index (returns -1 if not a subcell)
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
const panzer::BasisValues2< double > & getBasisValues(const panzer::BasisDescriptor &basis_description, const bool lazy_version=false) const
bool hasSubcellConnectivity(const unsigned int subcell_dimension) const
Check if subcell connectivity exists for a given dimension.
int getSubcellDimension() const
Get the subcell dimension.
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 WorksetDetails & operator()(const Workset &workset) const
const accessor.
Kokkos::View< const int *, PHX::Device > getLocalCellIDs() const
Get the local cell IDs for the workset.
std::string block_id
DEPRECATED - use: getElementBlock()
WorksetDetails()
Default constructor.
int subcell_index
DEPRECATED - use: getSubcellIndex()
int numOwnedCells() const
Number of cells owned by this workset.
const WorksetDetails & details(const int i) const
const std::string & getSideset() const
Get the sideset id (returns "" if not a sideset)
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...
WorksetDetails & operator()(Workset &workset) const
Workset wrapper to extract the correct details. Example: wda(workset).bases[i].
const panzer::SubcellConnectivity & getFaceConnectivity() const
int numGhostCells() const
Number of cells owned by a different workset.
Description and data layouts associated with a particular basis.
CellCoordArray getCellVertices() const
Get the vertices for the cells.
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::PureBasis & getBasis(const panzer::BasisDescriptor &description) const
Grab the pure basis (contains data layouts) for a given basis description (throws error if integratio...