Panzer  Version of the Day
Panzer_WorksetContainer.hpp
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 
43 #ifndef __Panzer_WorksetContainer_hpp__
44 #define __Panzer_WorksetContainer_hpp__
45 
46 #include "Teuchos_RCP.hpp"
47 
48 #include "Panzer_PhysicsBlock.hpp"
50 #include "Panzer_WorksetDescriptor.hpp" // what the workset is defined over
51 #include "Panzer_WorksetNeeds.hpp" // whats in a workset basis/integration rules
52 
53 namespace panzer {
54 
55 // forward declaration
56 class UniqueGlobalIndexerBase;
57 
58 struct SideId {
59  SideId(const BC & bc)
60  : ss_id(bc.sidesetID()), eblk_id(bc.elementBlockID()),
61  is_interface(static_cast<int>(bc.bcType() == BCT_Interface)) {}
62 
63  std::string ss_id;
64  std::string eblk_id;
66 };
67 
71 struct LessSide {
72  bool operator()(const SideId & left,
73  const SideId right) const
74  {
75  return ((left.is_interface < right.is_interface) ||
76  (left.is_interface == right.is_interface &&
77  (left.ss_id + "_" + left.eblk_id < right.ss_id + "_" + right.eblk_id)));
78 
79  }
80 };
81 
95 public:
98 
106  WorksetContainer(const Teuchos::RCP<const WorksetFactoryBase> & factory,
107  const std::vector<Teuchos::RCP<PhysicsBlock> > & physicsBlocks,
108  std::size_t wkstSz);
109 
117  WorksetContainer(const Teuchos::RCP<const WorksetFactoryBase> & factory,
118  const std::map<std::string,WorksetNeeds> & needs);
119 
124 
128  void setFactory(const Teuchos::RCP<const WorksetFactoryBase> & factory)
129  { clear(); wkstFactory_ = factory; }
130 
132  Teuchos::RCP<const WorksetFactoryBase> getFactory() const
133  { return wkstFactory_; }
134 
136  void setPhysicsBlockVector(const std::vector<Teuchos::RCP<PhysicsBlock> > & physicsBlocks);
137 
139  void setWorksetSize(std::size_t worksetSize)
140  { worksetSize_ = worksetSize; }
141 
143  std::size_t getWorksetSize() const
144  { return worksetSize_; }
145 
149  void clear();
150 
152  const PhysicsBlock & lookupPhysicsBlock(const std::string & eBlock) const;
153 
155  const WorksetNeeds & lookupNeeds(const std::string & eBlock) const;
156 
158  Teuchos::RCP<std::vector<Workset> > getVolumeWorksets(const std::string & eBlock);
159 
161  Teuchos::RCP<std::vector<Workset> > getWorksets(const WorksetDescriptor & wd);
162 
164  Teuchos::RCP<std::map<unsigned,Workset> > getSideWorksets(const BC & bc);
165 
167  inline std::vector<Workset>::iterator begin(const std::string & eBlock)
168  { return getVolumeWorksets(eBlock)->begin(); }
169 
171  inline std::vector<Workset>::iterator end(const std::string & eBlock)
172  { return getVolumeWorksets(eBlock)->end(); }
173 
175  inline std::map<unsigned,Workset>::iterator begin(const BC & bc)
176  { return getSideWorksets(bc)->begin(); }
177 
179  inline std::map<unsigned,Workset>::iterator end(const BC & bc)
180  { return getSideWorksets(bc)->end(); }
181 
185  void allocateVolumeWorksets(const std::vector<std::string> & eBlocks);
186 
190  void allocateSideWorksets(const std::vector<BC> & bcs);
191 
195  void setGlobalIndexer(const Teuchos::RCP<const panzer::UniqueGlobalIndexerBase> & ugi);
196 
200  void addBasis(const std::string & type,int order,const std::string & rep_field);
201 
202 private:
207  void applyOrientations(const Teuchos::RCP<const panzer::UniqueGlobalIndexerBase> & ugi);
208 
212  void applyOrientations(const std::string & eBlock,std::vector<Workset> & worksets) const;
213 
216  void applyOrientations(const SideId & sideId,std::map<unsigned,Workset> & worksets) const;
217 
218  // typedef std::map<std::string,Teuchos::RCP<std::vector<Workset> > > VolumeMap;
219  typedef std::unordered_map<WorksetDescriptor,Teuchos::RCP<std::vector<Workset> > > VolumeMap;
220  typedef std::map<SideId,Teuchos::RCP<std::map<unsigned,Workset> >,LessSide> SideMap;
221 
222  Teuchos::RCP<const WorksetFactoryBase> wkstFactory_;
223  std::map<std::string,Teuchos::RCP<PhysicsBlock> > ebToPb_;
224  std::map<std::string,WorksetNeeds> ebToNeeds_;
225 
228 
229  std::size_t worksetSize_;
230 
231  Teuchos::RCP<const panzer::UniqueGlobalIndexerBase> globalIndexer_;
232 };
233 
244  const std::vector<std::string> & elementBlockNames,
245  std::map<std::string,Teuchos::RCP<std::vector<Workset> > > & volumeWksts);
246 
257  const std::vector<BC> & bcs,
258  std::map<BC,Teuchos::RCP<std::map<unsigned,Workset> >,LessBC> & sideWksts);
259 
260 }
261 
262 #endif
Teuchos::RCP< std::map< unsigned, Workset > > getSideWorksets(const BC &bc)
Access, and construction of side worksets.
const PhysicsBlock & lookupPhysicsBlock(const std::string &eBlock) const
Look up an input physics block, throws an exception if it can not be found.
Object that contains information on the physics and discretization of a block of elements with the SA...
void setGlobalIndexer(const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &ugi)
WorksetContainer()
Default contructor, starts with no workset factory objects.
std::map< unsigned, Workset >::iterator end(const BC &bc)
Iterator access to side worksets.
std::map< unsigned, Workset >::iterator begin(const BC &bc)
Iterator access to side worksets.
Teuchos::RCP< const WorksetFactoryBase > wkstFactory_
void setWorksetSize(std::size_t worksetSize)
set the workset size
Class that provides access to worksets on each element block and side set.
std::unordered_map< WorksetDescriptor, Teuchos::RCP< std::vector< Workset > > > VolumeMap
PHX::MDField< ScalarT > vector
void allocateVolumeWorksets(const std::vector< std::string > &eBlocks)
void applyOrientations(const Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > &ugi)
Teuchos::RCP< std::vector< Workset > > getWorksets(const WorksetDescriptor &wd)
Access to volume worksets.
bool operator()(const SideId &left, const SideId right) const
const WorksetNeeds & lookupNeeds(const std::string &eBlock) const
Look up an input physics block, throws an exception if it can not be found.
Teuchos::RCP< const panzer::UniqueGlobalIndexerBase > globalIndexer_
std::size_t getWorksetSize() const
get the workset size
std::map< std::string, Teuchos::RCP< PhysicsBlock > > ebToPb_
How to construct worksets.
std::vector< Workset >::iterator end(const std::string &eBlock)
Iterator access to volume worksets.
void setFactory(const Teuchos::RCP< const WorksetFactoryBase > &factory)
VolumeMap volWorksets_
Maps element blocks to input physics block objects.
Teuchos::RCP< const WorksetFactoryBase > getFactory() const
Access the workset factory pointer.
void setPhysicsBlockVector(const std::vector< Teuchos::RCP< PhysicsBlock > > &physicsBlocks)
The physics block vector.
void addBasis(const std::string &type, int order, const std::string &rep_field)
void allocateSideWorksets(const std::vector< BC > &bcs)
std::map< SideId, Teuchos::RCP< std::map< unsigned, Workset > >, LessSide > SideMap
void getSideWorksetsFromContainer(WorksetContainer &wc, const std::vector< BC > &bcs, std::map< BC, Teuchos::RCP< std::map< unsigned, Workset > >, LessBC > &sideWksts)
Stores input information for a boundary condition.
Definition: Panzer_BC.hpp:80
std::vector< Workset >::iterator begin(const std::string &eBlock)
Iterator access to volume worksets.
Teuchos::RCP< std::vector< Workset > > getVolumeWorksets(const std::string &eBlock)
Access to volume worksets.
std::map< std::string, WorksetNeeds > ebToNeeds_
Maps element blocks to input physics block objects.
void getVolumeWorksetsFromContainer(WorksetContainer &wc, const std::vector< std::string > &elementBlockNames, std::map< std::string, Teuchos::RCP< std::vector< Workset > > > &volumeWksts)