Panzer  Version of the Day
Panzer_FieldAggPattern.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_FieldAggPattern_hpp__
44 #define __Panzer_FieldAggPattern_hpp__
45 
46 #include "Panzer_FieldPattern.hpp"
47 
48 #include <map>
49 #include <vector>
50 
51 #include "Teuchos_RCP.hpp"
52 #include "Teuchos_Tuple.hpp"
53 
54 namespace panzer {
55 
63 class FieldAggPattern : public FieldPattern {
64 public:
65  // The FEI format for prescribing fields seems quite general,
66  // so it is my belief that an abstract can be written to it.
67 
69 
72  FieldAggPattern(std::vector<std::pair<int,Teuchos::RCP<const FieldPattern> > > & patterns,
73  const Teuchos::RCP<const FieldPattern> & geomAggPattern=Teuchos::null);
74 
75  virtual ~FieldAggPattern() {}
76 
79  virtual Teuchos::RCP<const FieldPattern> getGeometricAggFieldPattern() const;
80 
85  virtual void buildPattern(const std::vector<std::pair<int,Teuchos::RCP<const FieldPattern> > > & patterns,
86  const Teuchos::RCP<const FieldPattern> & geomAggPattern=Teuchos::null);
87 
88  // functions from the abstract FieldPattern
89  virtual int getDimension() const;
90  virtual int getSubcellCount(int dimension) const;
91  virtual const std::vector<int> & getSubcellIndices(int dimension, int subcell) const;
92  virtual void getSubcellClosureIndices(int, int, std::vector<int> &) const;
93  virtual shards::CellTopology getCellTopology() const;
94 
96  virtual void print(std::ostream & os) const;
97 
104  virtual Teuchos::RCP<const FieldPattern> getFieldPattern(int fieldId) const;
105 
107 
108 
110  const std::vector<int> & numFieldsPerId() const { return numFields_; }
111 
115  const std::vector<int> & fieldIds() const { return fieldIds_; }
116 
118 
120 
121 
139  const std::vector<int> & localOffsets(int fieldId) const;
140 
153  const std::pair<std::vector<int>,std::vector<int> > &
154  localOffsets_closure(int fieldId,int subcellDim,int subcellId) const;
155 
157 
158 protected:
159  typedef Teuchos::RCP<const FieldPattern> FPPtr; // for convenience
160 
165 
171  void buildFieldIdsVector();
172 
177  void mergeFieldPatterns(int dim,int subcell);
178 
182  void addAllPatternSubcellIndices(int dim,int sc,std::vector<int> & indices);
183 
186  void buildFieldPatternData();
187 
190  void localOffsets_build(int fieldId,std::vector<int> & offsets) const;
191 
192  std::size_t dimension_;
193  Teuchos::RCP<const FieldPattern> geomAggPattern_;
194 
195  // field pattern data
196  std::vector<std::vector<std::vector<int> > > patternData_;
197 
198  // FEI patterns
199  std::vector<int> numFields_; // number of fields at each geometric ID
200  std::vector<int> fieldIds_; // field IDs at each geometric ID
201 
202  // storage for patterns
203  std::vector<std::pair<int,Teuchos::RCP<const FieldPattern> > > patterns_;
204  std::map<int,int> fieldIdToPatternIdx_;
205 
206  mutable std::map<int, std::vector<int> > fieldOffsets_;
207 
208  struct LessThan
209  { bool operator()(const Teuchos::Tuple<int,3> & a,const Teuchos::Tuple<int,3> & b) const; };
210  mutable std::map<Teuchos::Tuple<int,3>, std::pair<std::vector<int>,std::vector<int> >,LessThan>
212 };
213 
214 }
215 
216 #endif
void mergeFieldPatterns(int dim, int subcell)
std::map< int, std::vector< int > > fieldOffsets_
std::map< Teuchos::Tuple< int, 3 >, std::pair< std::vector< int >, std::vector< int > >, LessThan > fieldSubcellOffsets_closure_
std::map< int, int > fieldIdToPatternIdx_
std::vector< std::pair< int, Teuchos::RCP< const FieldPattern > > > patterns_
virtual const std::vector< int > & getSubcellIndices(int dimension, int subcell) const
std::vector< std::vector< std::vector< int > > > patternData_
virtual Teuchos::RCP< const FieldPattern > getFieldPattern(int fieldId) const
bool operator()(const Teuchos::Tuple< int, 3 > &a, const Teuchos::Tuple< int, 3 > &b) const
Teuchos::RCP< const FieldPattern > geomAggPattern_
PHX::MDField< ScalarT > vector
virtual void buildPattern(const std::vector< std::pair< int, Teuchos::RCP< const FieldPattern > > > &patterns, const Teuchos::RCP< const FieldPattern > &geomAggPattern=Teuchos::null)
void localOffsets_build(int fieldId, std::vector< int > &offsets) const
virtual int getDimension() const
const std::vector< int > & numFieldsPerId() const
Lenght of vector is number of Ids, value is how many ids per field.
virtual Teuchos::RCP< const FieldPattern > getGeometricAggFieldPattern() const
void addAllPatternSubcellIndices(int dim, int sc, std::vector< int > &indices)
virtual void print(std::ostream &os) const
Print this pattern.
const std::vector< int > & localOffsets(int fieldId) const
virtual void getSubcellClosureIndices(int, int, std::vector< int > &) const
virtual shards::CellTopology getCellTopology() const
virtual int getSubcellCount(int dimension) const
Teuchos::RCP< const FieldPattern > FPPtr
const std::vector< int > & fieldIds() const
Kokkos::View< const int *, PHX::Device > offsets
const std::pair< std::vector< int >, std::vector< int > > & localOffsets_closure(int fieldId, int subcellDim, int subcellId) const