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 
11 #include "Teuchos_CompilerCodeTweakMacros.hpp"
12 
15 
16 #include "Panzer_LocalMeshInfo.hpp"
17 
20 #include "Panzer_STK_Interface.hpp"
22 
23 
24 
25 namespace panzer_stk {
26 
30 {
31  mesh_ = mesh;
32 }
33 
36  const panzer::WorksetNeeds & needs) const
37 {
38  TEUCHOS_ASSERT(desc.useSideset());
39 
40  return panzer_stk::buildBCWorksets(*mesh_,needs,desc.getElementBlock(0),desc.getSideset());
41 }
42 
45  const panzer::WorksetNeeds & needs_a,
46  const panzer::WorksetNeeds & needs_b) const
47 {
48  // ensure that this is a interface descriptor
50  TEUCHOS_ASSERT(desc.getSideset(0)==desc.getSideset(1));
51  return panzer_stk::buildBCWorksets(*mesh_, needs_a, desc.getElementBlock(0),
52  needs_b, desc.getElementBlock(1),
53  desc.getSideset(0));
54 }
55 
58  const panzer::WorksetNeeds & needs) const
59 {
60  PANZER_FUNC_TIME_MONITOR("panzer_stk::WorksetFactory::getWorksets");
61  if(worksetDesc.requiresPartitioning()){
62 
63  // Generate the local mesh info if it doesn't already exist
64  if(mesh_info_ == Teuchos::null){
65  TEUCHOS_ASSERT(mesh_ != Teuchos::null);
67  }
68 
69  auto worksets = panzer::buildPartitionedWorksets(*mesh_info_, worksetDesc, this->getOrientationsInterface());
70 
71  // Fill in whatever is in the needs object
72  // FIXME: This will just get optimized out... Adding volatile to the calls makes the worksets pretty ugly
73  for(auto & workset : *worksets){
74 
75  // Initialize IntegrationValues from integration descriptors
76  for(const auto & id : needs.getIntegrators())
77  workset.getIntegrationValues(id);
78 
79  // Initialize PointValues from point descriptors
80  for(const auto & pd : needs.getPoints())
81  workset.getPointValues(pd);
82 
83  // Initialize BasisValues
84  for(const auto & bd : needs.getBases()){
85 
86  // Initialize BasisValues from integrators
87  for(const auto & id : needs.getIntegrators())
88  workset.getBasisValues(bd,id);
89 
90  // Initialize BasisValues from points
91  for(const auto & pd : needs.getPoints())
92  workset.getBasisValues(bd,pd);
93  }
94  }
95 
96  return worksets;
97 
98  } else if(!worksetDesc.useSideset()) {
99  // The non-partitioned case always creates worksets with just the
100  // owned elements. CLASSIC_MODE gets the workset size directly
101  // from needs that is populated externally. As we transition away
102  // from classic mode, we need to create a copy of needs and
103  // override the workset size with values from WorksetDescription.
105  return panzer_stk::buildWorksets(*mesh_,worksetDesc.getElementBlock(), needs);
106  else {
107  int worksetSize = worksetDesc.getWorksetSize();
108  if (worksetSize == panzer::WorksetSizeType::ALL_ELEMENTS) {
109  std::vector<stk::mesh::Entity> elements;
110  mesh_->getMyElements(worksetDesc.getElementBlock(),elements);
111  worksetSize = elements.size();
112  }
113  panzer::WorksetNeeds tmpNeeds(needs);
114  tmpNeeds.cellData = panzer::CellData(worksetSize,needs.cellData.getCellTopology());
115  return panzer_stk::buildWorksets(*mesh_,worksetDesc.getElementBlock(), tmpNeeds);
116  }
117  }
118  else if(worksetDesc.useSideset() && worksetDesc.sideAssembly()) {
119  // uses cascade by default, each subcell has its own workset
120  return panzer_stk::buildWorksets(*mesh_,needs,worksetDesc.getSideset(),worksetDesc.getElementBlock(),true);
121  }
122  else {
123  TEUCHOS_ASSERT(false);
124  TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
125  }
126 }
127 
128 }
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.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
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.