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 //
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 
45 
46 #include "Panzer_LocalMeshInfo.hpp"
47 
50 #include "Panzer_STK_Interface.hpp"
52 
53 
54 
55 namespace panzer_stk {
56 
60 {
61  mesh_ = mesh;
62 }
63 
66  const panzer::WorksetNeeds & needs) const
67 {
68  TEUCHOS_ASSERT(desc.useSideset());
69 
70  return panzer_stk::buildBCWorksets(*mesh_,needs,desc.getElementBlock(0),desc.getSideset());
71 }
72 
75  const panzer::WorksetNeeds & needs_a,
76  const panzer::WorksetNeeds & needs_b) const
77 {
78  // ensure that this is a interface descriptor
80  TEUCHOS_ASSERT(desc.getSideset(0)==desc.getSideset(1));
81  return panzer_stk::buildBCWorksets(*mesh_, needs_a, desc.getElementBlock(0),
82  needs_b, desc.getElementBlock(1),
83  desc.getSideset(0));
84 }
85 
88  const panzer::WorksetNeeds & needs) const
89 {
90 
91  if(worksetDesc.requiresPartitioning()){
92  if(mesh_info_ == Teuchos::null){
93  auto mesh_info = Teuchos::rcp(new panzer::LocalMeshInfo);
95  mesh_info_ = mesh_info;
96  }
97  return panzer::buildPartitionedWorksets(*mesh_info_,worksetDesc,needs);
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(), needs);
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  }
125 }
126 
127 }
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.
void generateLocalMeshInfo(const panzer_stk::STK_Interface &mesh, panzer::LocalMeshInfo &mesh_info)
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)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Data for determining cell topology and dimensionality.
Teuchos::RCP< const panzer::LocalMeshInfo > mesh_info_
Alternative form of mesh.
virtual Teuchos::RCP< std::map< unsigned, panzer::Workset > > getSideWorksets(const panzer::WorksetDescriptor &desc, const panzer::WorksetNeeds &needs) const
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...
Teuchos::RCP< std::vector< panzer::Workset > > buildPartitionedWorksets(const panzer::LocalMeshInfo &mesh_info, const panzer::WorksetDescriptor &description, const panzer::WorksetNeeds &needs)
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.