Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_WorksetFactory.cpp
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 
13 
14 #include "Panzer_LocalMeshInfo.hpp"
15 
18 #include "Panzer_STK_Interface.hpp"
20 
21 
22 
23 namespace panzer_stk {
24 
28 {
29  mesh_ = mesh;
30 }
31 
34  const panzer::WorksetNeeds & needs) const
35 {
36  TEUCHOS_ASSERT(desc.useSideset());
37 
38  return panzer_stk::buildBCWorksets(*mesh_,needs,desc.getElementBlock(0),desc.getSideset());
39 }
40 
43  const panzer::WorksetNeeds & needs_a,
44  const panzer::WorksetNeeds & needs_b) const
45 {
46  // ensure that this is a interface descriptor
48  TEUCHOS_ASSERT(desc.getSideset(0)==desc.getSideset(1));
49  return panzer_stk::buildBCWorksets(*mesh_, needs_a, desc.getElementBlock(0),
50  needs_b, desc.getElementBlock(1),
51  desc.getSideset(0));
52 }
53 
56  const panzer::WorksetNeeds & needs) const
57 {
58  PANZER_FUNC_TIME_MONITOR("panzer_stk::WorksetFactory::getWorksets");
59  if(worksetDesc.requiresPartitioning()){
60 
61  // Generate the local mesh info if it doesn't already exist
62  if(mesh_info_ == Teuchos::null){
63  TEUCHOS_ASSERT(mesh_ != Teuchos::null);
65  }
66 
67  auto worksets = panzer::buildPartitionedWorksets(*mesh_info_, worksetDesc, this->getOrientationsInterface());
68 
69  // Fill in whatever is in the needs object
70  // FIXME: This will just get optimized out... Adding volatile to the calls makes the worksets pretty ugly
71  for(auto & workset : *worksets){
72 
73  // Initialize IntegrationValues from integration descriptors
74  for(const auto & id : needs.getIntegrators())
75  workset.getIntegrationValues(id);
76 
77  // Initialize PointValues from point descriptors
78  for(const auto & pd : needs.getPoints())
79  workset.getPointValues(pd);
80 
81  // Initialize BasisValues
82  for(const auto & bd : needs.getBases()){
83 
84  // Initialize BasisValues from integrators
85  for(const auto & id : needs.getIntegrators())
86  workset.getBasisValues(bd,id);
87 
88  // Initialize BasisValues from points
89  for(const auto & pd : needs.getPoints())
90  workset.getBasisValues(bd,pd);
91  }
92  }
93 
94  return worksets;
95 
96  } else if(!worksetDesc.useSideset()) {
97  // The non-partitioned case always creates worksets with just the
98  // owned elements. CLASSIC_MODE gets the workset size directly
99  // from needs that is populated externally. As we transition away
100  // from classic mode, we need to create a copy of needs and
101  // override the workset size with values from WorksetDescription.
103  return panzer_stk::buildWorksets(*mesh_,worksetDesc.getElementBlock(), needs);
104  else {
105  int worksetSize = worksetDesc.getWorksetSize();
106  if (worksetSize == panzer::WorksetSizeType::ALL_ELEMENTS) {
107  std::vector<stk::mesh::Entity> elements;
108  mesh_->getMyElements(worksetDesc.getElementBlock(),elements);
109  worksetSize = elements.size();
110  }
111  panzer::WorksetNeeds tmpNeeds(needs);
112  tmpNeeds.cellData = panzer::CellData(worksetSize,needs.cellData.getCellTopology());
113  return panzer_stk::buildWorksets(*mesh_,worksetDesc.getElementBlock(), tmpNeeds);
114  }
115  }
116  else if(worksetDesc.useSideset() && worksetDesc.sideAssembly()) {
117  // uses cascade by default, each subcell has its own workset
118  return panzer_stk::buildWorksets(*mesh_,needs,worksetDesc.getSideset(),worksetDesc.getElementBlock(),true);
119  }
120  else {
121  TEUCHOS_ASSERT(false);
122  }
123 }
124 
125 }
Backwards compatibility mode that ignores the worksetSize in the WorksetDescriptor.
const std::string & getSideset(const int block=0) const
Get sideset name.
bool connectsElementBlocks() const
Identifies this workset as an interface between two element blocks.
Teuchos::RCP< panzer::LocalMeshInfo > generateLocalMeshInfo(const panzer_stk::STK_Interface &mesh)
Create a structure containing information about the local portion of a given element block...
const std::string & getElementBlock(const int block=0) const
Get element block name.
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
bool useSideset() const
This descriptor is for a side set.
Teuchos::RCP< std::vector< panzer::Workset > > buildWorksets(const panzer_stk::STK_Interface &mesh, const std::string &eBlock, const panzer::WorksetNeeds &needs)
virtual Teuchos::RCP< std::vector< panzer::Workset > > getWorksets(const panzer::WorksetDescriptor &worksetDesc, const panzer::WorksetNeeds &needs) const
Teuchos::RCP< std::map< unsigned, panzer::Workset > > buildBCWorksets(const panzer_stk::STK_Interface &mesh, const panzer::WorksetNeeds &needs_a, const std::string &blockid_a, const panzer::WorksetNeeds &needs_b, const std::string &blockid_b, const std::string &sideset)
const std::vector< panzer::PointDescriptor > & getPoints() const
Get a list of points being requested.
const std::vector< panzer::BasisDescriptor > & getBases() const
Get a list of bases being requested.
Data for determining cell topology and dimensionality.
Teuchos::RCP< const panzer::LocalMeshInfo > mesh_info_
Alternative form of mesh.
Teuchos::RCP< std::vector< panzer::Workset > > buildPartitionedWorksets(const panzer::LocalMeshInfo &mesh_info, const panzer::WorksetDescriptor &description, const Teuchos::RCP< const OrientationsInterface > &orientations)
virtual Teuchos::RCP< std::map< unsigned, panzer::Workset > > getSideWorksets(const panzer::WorksetDescriptor &desc, const panzer::WorksetNeeds &needs) const
const std::vector< panzer::IntegrationDescriptor > & getIntegrators() const
Get a list of integrators being requested.
bool sideAssembly() const
Expects side set assembly on volume.
virtual void setMesh(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh)
Teuchos::RCP< const STK_Interface > mesh_
Mesh.
#define TEUCHOS_ASSERT(assertion_test)
int getWorksetSize() const
Get the requested workset size (default -2 (workset size is set elsewhere), -1 (largest possible work...
bool requiresPartitioning() const
Do we need to partition the local mesh prior to generating worksets.
Workset size is set to the total number of local elements in the MPI process.
Teuchos::RCP< const OrientationsInterface > getOrientationsInterface() const
Get the orientations associated with the worksets.