Panzer  Version of the Day
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){
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 }
panzer_stk::buildWorksets
Teuchos::RCP< std::vector< panzer::Workset > > buildWorksets(const panzer_stk::STK_Interface &mesh, const std::string &eBlock, const panzer::WorksetNeeds &needs)
Definition: Panzer_STK_SetupUtilities.cpp:53
panzer_stk
Definition: Panzer_STK_GatherFields_decl.hpp:58
panzer::CellData
Data for determining cell topology and dimensionality.
Definition: Panzer_CellData.hpp:65
Panzer_STK_Interface.hpp
panzer::WorksetNeeds::cellData
CellData cellData
Definition: Panzer_WorksetNeeds.hpp:142
panzer::WorksetDescriptor::getWorksetSize
int getWorksetSize() const
Get the requested workset size (default -2 (workset size is set elsewhere), -1 (largest possible work...
Definition: Panzer_WorksetDescriptor.hpp:263
Panzer_STK_WorksetFactory.hpp
Panzer_LocalMeshInfo.hpp
Panzer_WorksetFactoryBase.hpp
panzer::WorksetDescriptor::getElementBlock
const std::string & getElementBlock(const int block=0) const
Get element block name.
Definition: Panzer_WorksetDescriptor.hpp:218
panzer::CLASSIC_MODE
Backwards compatibility mode that ignores the worksetSize in the WorksetDescriptor.
Definition: Panzer_WorksetDescriptor.hpp:56
Panzer_STK_SetupUtilities.hpp
TEUCHOS_ASSERT
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
panzer::buildPartitionedWorksets
Teuchos::RCP< std::vector< panzer::Workset > > buildPartitionedWorksets(const panzer::LocalMeshInfo< int, panzer::Ordinal64 > &mesh_info, const panzer::WorksetDescriptor &description, const panzer::WorksetNeeds &needs)
Definition: Panzer_SetupPartitionedWorksetUtilities.cpp:72
panzer_stk::buildBCWorksets
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)
Definition: Panzer_STK_SetupUtilities.cpp:193
Teuchos::RCP< const panzer_stk::STK_Interface >
panzer::CellData::getCellTopology
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
Definition: Panzer_CellData.hpp:113
panzer::WorksetDescriptor::connectsElementBlocks
bool connectsElementBlocks() const
Identifies this workset as an interface between two element blocks.
Definition: Panzer_WorksetDescriptor.hpp:241
panzer::LocalMeshInfo
Definition: Panzer_LocalMeshInfo.hpp:143
panzer_stk::generateLocalMeshInfo
void generateLocalMeshInfo(const panzer_stk::STK_Interface &mesh, panzer::LocalMeshInfo< LO, GO > &mesh_info)
Definition: Panzer_STK_LocalMeshUtilities.cpp:743
panzer::ALL_ELEMENTS
Workset size is set to the total number of local elements in the MPI process.
Definition: Panzer_WorksetDescriptor.hpp:58
panzer::WorksetDescriptor::requiresPartitioning
bool requiresPartitioning() const
Do we need to partition the local mesh prior to generating worksets.
Definition: Panzer_WorksetDescriptor.hpp:252
panzer::WorksetDescriptor
Definition: Panzer_WorksetDescriptor.hpp:82
panzer::WorksetNeeds
Definition: Panzer_WorksetNeeds.hpp:72
panzer_stk::WorksetFactory::mesh_info_
Teuchos::RCP< const panzer::LocalMeshInfo< int, panzer::Ordinal64 > > mesh_info_
Alternative form of mesh.
Definition: Panzer_STK_WorksetFactory.hpp:106
panzer_stk::WorksetFactory::getWorksets
virtual Teuchos::RCP< std::vector< panzer::Workset > > getWorksets(const panzer::WorksetDescriptor &worksetDesc, const panzer::WorksetNeeds &needs) const
Definition: Panzer_STK_WorksetFactory.cpp:87
panzer_stk::WorksetFactory::setMesh
virtual void setMesh(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh)
Definition: Panzer_STK_WorksetFactory.cpp:59
panzer::WorksetDescriptor::useSideset
bool useSideset() const
This descriptor is for a side set.
Definition: Panzer_WorksetDescriptor.hpp:258
Panzer_STK_LocalMeshUtilities.hpp
panzer_stk::WorksetFactory::getSideWorksets
virtual Teuchos::RCP< std::map< unsigned, panzer::Workset > > getSideWorksets(const panzer::WorksetDescriptor &desc, const panzer::WorksetNeeds &needs) const
Definition: Panzer_STK_WorksetFactory.cpp:65
Panzer_SetupPartitionedWorksetUtilities.hpp
panzer_stk::WorksetFactory::mesh_
Teuchos::RCP< const STK_Interface > mesh_
Mesh.
Definition: Panzer_STK_WorksetFactory.hpp:101
panzer::WorksetDescriptor::sideAssembly
bool sideAssembly() const
Expects side set assembly on volume.
Definition: Panzer_WorksetDescriptor.hpp:233
panzer::WorksetDescriptor::getSideset
const std::string & getSideset(const int block=0) const
Get sideset name.
Definition: Panzer_WorksetDescriptor.hpp:228