Panzer Version of the Day
Loading...
Searching...
No Matches
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
47
52
53
54
55namespace panzer_stk {
56
59void WorksetFactory::setMesh(const Teuchos::RCP<const panzer_stk::STK_Interface> & mesh)
60{
61 mesh_ = mesh;
62}
63
64Teuchos::RCP<std::map<unsigned,panzer::Workset> > WorksetFactory::
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
73Teuchos::RCP<std::map<unsigned,panzer::Workset> > WorksetFactory::
75 const panzer::WorksetNeeds & needs_a,
76 const panzer::WorksetNeeds & needs_b) const
77{
78 // ensure that this is a interface descriptor
79 TEUCHOS_ASSERT(desc.connectsElementBlocks());
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
86Teuchos::RCP<std::vector<panzer::Workset> > WorksetFactory::
87getWorksets(const panzer::WorksetDescriptor & worksetDesc,
88 const panzer::WorksetNeeds & needs) const
89{
90
91 if(worksetDesc.requiresPartitioning()){
92
93 // Generate the local mesh info if it doesn't already exist
94 if(mesh_info_ == Teuchos::null){
95 TEUCHOS_ASSERT(mesh_ != Teuchos::null);
97 }
98
99 auto worksets = panzer::buildPartitionedWorksets(*mesh_info_, worksetDesc, this->getOrientationsInterface());
100
101 // Fill in whatever is in the needs object
102 // FIXME: This will just get optimized out... Adding volatile to the calls makes the worksets pretty ugly
103 for(auto & workset : *worksets){
104
105 // Initialize IntegrationValues from integration descriptors
106 for(const auto & id : needs.getIntegrators())
107 workset.getIntegrationValues(id);
108
109 // Initialize PointValues from point descriptors
110 for(const auto & pd : needs.getPoints())
111 workset.getPointValues(pd);
112
113 // Initialize BasisValues
114 for(const auto & bd : needs.getBases()){
115
116 // Initialize BasisValues from integrators
117 for(const auto & id : needs.getIntegrators())
118 workset.getBasisValues(bd,id);
119
120 // Initialize BasisValues from points
121 for(const auto & pd : needs.getPoints())
122 workset.getBasisValues(bd,pd);
123 }
124 }
125
126 return worksets;
127
128 } else if(!worksetDesc.useSideset()) {
129 // The non-partitioned case always creates worksets with just the
130 // owned elements. CLASSIC_MODE gets the workset size directly
131 // from needs that is populated externally. As we transition away
132 // from classic mode, we need to create a copy of needs and
133 // override the workset size with values from WorksetDescription.
135 return panzer_stk::buildWorksets(*mesh_,worksetDesc.getElementBlock(), needs);
136 else {
137 int worksetSize = worksetDesc.getWorksetSize();
138 if (worksetSize == panzer::WorksetSizeType::ALL_ELEMENTS) {
139 std::vector<stk::mesh::Entity> elements;
140 mesh_->getMyElements(worksetDesc.getElementBlock(),elements);
141 worksetSize = elements.size();
142 }
143 panzer::WorksetNeeds tmpNeeds(needs);
144 tmpNeeds.cellData = panzer::CellData(worksetSize,needs.cellData.getCellTopology());
145 return panzer_stk::buildWorksets(*mesh_,worksetDesc.getElementBlock(), needs);
146 }
147 }
148 else if(worksetDesc.useSideset() && worksetDesc.sideAssembly()) {
149 // uses cascade by default, each subcell has its own workset
150 return panzer_stk::buildWorksets(*mesh_,needs,worksetDesc.getSideset(),worksetDesc.getElementBlock(),true);
151 }
152 else {
153 TEUCHOS_ASSERT(false);
154 }
155}
156
157}
Data for determining cell topology and dimensionality.
Teuchos::RCP< const shards::CellTopology > getCellTopology() const
Get CellTopology for the base cell.
const std::string & getElementBlock(const int block=0) const
Get element block name.
bool sideAssembly() const
Expects side set assembly on volume.
const std::string & getSideset(const int block=0) const
Get sideset name.
int getWorksetSize() const
Get the requested workset size (default -2 (workset size is set elsewhere), -1 (largest possible work...
bool connectsElementBlocks() const
Identifies this workset as an interface between two element blocks.
bool useSideset() const
This descriptor is for a side set.
bool requiresPartitioning() const
Do we need to partition the local mesh prior to generating worksets.
Teuchos::RCP< const OrientationsInterface > getOrientationsInterface() const
Get the orientations associated with the worksets.
virtual void setMesh(const Teuchos::RCP< const panzer_stk::STK_Interface > &mesh)
virtual Teuchos::RCP< std::map< unsigned, panzer::Workset > > getSideWorksets(const panzer::WorksetDescriptor &desc, const panzer::WorksetNeeds &needs) const
virtual Teuchos::RCP< std::vector< panzer::Workset > > getWorksets(const panzer::WorksetDescriptor &worksetDesc, const panzer::WorksetNeeds &needs) const
Teuchos::RCP< const STK_Interface > mesh_
Mesh.
Teuchos::RCP< const panzer::LocalMeshInfo > mesh_info_
Alternative form of mesh.
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::RCP< std::vector< panzer::Workset > > buildWorksets(const panzer_stk::STK_Interface &mesh, const std::string &eBlock, const panzer::WorksetNeeds &needs)
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.
@ ALL_ELEMENTS
Workset size is set to the total number of local elements in the MPI process.
@ CLASSIC_MODE
Backwards compatibility mode that ignores the worksetSize in the WorksetDescriptor.
Teuchos::RCP< std::vector< panzer::Workset > > buildPartitionedWorksets(const panzer::LocalMeshInfo &mesh_info, const panzer::WorksetDescriptor &description, const Teuchos::RCP< const OrientationsInterface > &orientations)
const std::vector< panzer::IntegrationDescriptor > & getIntegrators() const
Get a list of integrators being requested.
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.