Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_UniqueGlobalIndexer_Utilities.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_UniqueGlobalIndexer_Utilities_decl_hpp__
44 #define __Panzer_UniqueGlobalIndexer_Utilities_decl_hpp__
45 
46 #include <map>
47 #include <string>
48 
49 #include <unordered_map>
50 
51 #include <Panzer_NodeType.hpp>
52 #include <Tpetra_Vector.hpp>
53 #include <Tpetra_MultiVector.hpp>
54 
56 #include "Panzer_FieldPattern.hpp"
57 
58 namespace panzer {
59 
63 template <typename LocalOrdinalT,typename GlobalOrdinalT>
64 std::vector<Teuchos::RCP<const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> > >
65 nc2c_vector(const std::vector<Teuchos::RCP<UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> > > & ugis);
66 
76 template <typename LocalOrdinalT,typename GlobalOrdinalT>
77 int getFieldBlock(const std::string & fieldName,
78  const std::vector<Teuchos::RCP<UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> > > & ugis);
79 
89 template <typename LocalOrdinalT,typename GlobalOrdinalT>
90 int getFieldBlock(const std::string & fieldName,
91  const std::vector<Teuchos::RCP<const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> > > & ugis);
92 
106 template <typename LocalOrdinalT,typename GlobalOrdinalT>
107 void computeBlockOffsets(const std::string & blockId,
108  const std::vector<Teuchos::RCP<UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> > > & ugis,
109  std::vector<int> & blockOffsets);
110 
124 template <typename LocalOrdinalT,typename GlobalOrdinalT>
125 void computeBlockOffsets(const std::string & blockId,
126  const std::vector<Teuchos::RCP<const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> > > & ugis,
127  std::vector<int> & blockOffsets);
128 
133 template <typename LocalOrdinalT,typename GlobalOrdinalT>
134 std::string printUGILoadBalancingInformation(const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> & ugi);
135 
140 template <typename LocalOrdinalT,typename GlobalOrdinalT>
142 
155 template <typename LocalOrdinalT,typename GlobalOrdinalT,typename Node>
157 buildGhostedFieldReducedVector(const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> & ugi);
158 
169 template <typename LocalOrdinalT,typename GlobalOrdinalT,typename Node>
171 buildGhostedFieldVector(const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> & ugi,
172  const Teuchos::RCP<const Tpetra::Vector<int,int,GlobalOrdinalT,Node> > & reducedVec=Teuchos::null);
173 
176 template <typename LocalOrdinalT,typename GlobalOrdinalT>
179  const Teuchos::RCP<const Tpetra::Vector<int,int,GlobalOrdinalT,panzer::TpetraNodeType> > & reducedVec=Teuchos::null)
180 { return buildGhostedFieldVector<LocalOrdinalT,GlobalOrdinalT,panzer::TpetraNodeType>(ugi,reducedVec); }
181 
195 template <typename LocalOrdinalT,typename GlobalOrdinalT,typename Node>
196 void buildGhostedFieldVector(const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> & ugi,
197  std::vector<int> & fieldNumbers,
198  const Teuchos::RCP<const Tpetra::Vector<int,int,GlobalOrdinalT,Node> > & reducedVec=Teuchos::null);
199 
202 template <typename LocalOrdinalT,typename GlobalOrdinalT>
204  std::vector<int> & fieldNumbers,
205  const Teuchos::RCP<const Tpetra::Vector<int,int,GlobalOrdinalT,panzer::TpetraNodeType> > & reducedVec=Teuchos::null)
206 { buildGhostedFieldVector<LocalOrdinalT,GlobalOrdinalT,panzer::TpetraNodeType>(ugi,fieldNumbers,reducedVec); }
207 
220 template <typename ScalarT,typename ArrayT,typename LocalOrdinalT,typename GlobalOrdinalT,typename Node>
221 void updateGhostedDataReducedVector(const std::string & fieldName,const std::string blockId,
222  const UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT> & ugi,
223  const ArrayT & data,
224  Tpetra::MultiVector<ScalarT,int,GlobalOrdinalT,Node> & dataVector);
225 
235 template <typename GlobalOrdinalT,typename Node>
237 getFieldMap(int fieldNum,const Tpetra::Vector<int,int,GlobalOrdinalT,Node> & fieldVector);
238 
239 
240 namespace orientation_helpers {
241 
251 void computePatternEdgeIndices(const FieldPattern & pattern,std::vector<std::pair<int,int> > & edgeIndices);
252 
269 template <typename GlobalOrdinalT>
270 void computeCellEdgeOrientations(const std::vector<std::pair<int,int> > & topEdgeIndices,
271  const std::vector<GlobalOrdinalT> & topology,
272  const FieldPattern & fieldPattern,
273  std::vector<signed char> & orientation);
274 
288 void computePatternFaceIndices(const FieldPattern & pattern,std::vector<std::vector<int> > & faceIndices);
289 
306 template <typename GlobalOrdinalT>
307 void computeCellFaceOrientations(const std::vector<std::pair<int,int> > & topEdgeIndices,
308  const std::vector<GlobalOrdinalT> & topology,
309  const FieldPattern & fieldPattern,
310  std::vector<signed char> & orientation);
311 
312 } // end orientations_helpers
313 
314 
317 template <typename LocalOrdinalT,typename GlobalOrdinalT,typename Node>
319 public:
324 
334  template <typename ScalarT,typename ArrayT>
336  getGhostedDataVector(const std::string & fieldName,const std::map<std::string,ArrayT> & data) const;
337 
347  template <typename ScalarT,typename ArrayT>
349  getDataVector(const std::string & fieldName,const std::map<std::string,ArrayT> & data) const;
350 
356  getFieldMap(const std::string & fieldName) const;
357 
363  getFieldMap(int fieldNum) const;
364 
365 protected:
366  typedef Tpetra::Vector<int,int,GlobalOrdinalT,Node> IntVector;
367  typedef Tpetra::Map<int,GlobalOrdinalT,Node> Map;
368 
370  void buildFieldVector(const Tpetra::Vector<int,int,GlobalOrdinalT,Node> & source) const;
371 
374 
377 
378  mutable std::map<int,Teuchos::RCP<const Map> > gh_reducedFieldMaps_;
379  mutable std::map<int,Teuchos::RCP<const Map> > gh_fieldMaps_;
380 
382  mutable std::map<int,Teuchos::RCP<const Map> > fieldMaps_;
383 
384 private:
385  // hide some constructors
388 };
389 
390 
391 } // end namspace panzer
392 
394 
395 #endif
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > > &ugis)
std::map< int, Teuchos::RCP< const Map > > fieldMaps_
(unghosted) field vector (as needed)
void computeCellEdgeOrientations(const std::vector< std::pair< int, int > > &topEdgeIndices, const std::vector< GlobalOrdinalT > &topology, const FieldPattern &fieldPattern, std::vector< signed char > &orientation)
Teuchos::RCP< const IntVector > fieldVector_
Maps for each field (as needed)
void computeBlockOffsets(const std::string &blockId, const std::vector< Teuchos::RCP< UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > > &ugis, std::vector< int > &blockOffsets)
Teuchos::RCP< Tpetra::MultiVector< ScalarT, int, GlobalOrdinalT, Node > > getGhostedDataVector(const std::string &fieldName, const std::map< std::string, ArrayT > &data) const
void buildFieldVector(const Tpetra::Vector< int, int, GlobalOrdinalT, Node > &source) const
build unghosted field vector from ghosted field vector
Teuchos::RCP< const Tpetra::Map< int, GlobalOrdinalT, Node > > getFieldMap(const std::string &fieldName) const
std::map< int, Teuchos::RCP< const Map > > gh_fieldMaps_
Maps for each field (as needed)
std::map< int, Teuchos::RCP< const Map > > gh_reducedFieldMaps_
ghosted field vector
Teuchos::RCP< const Tpetra::Map< int, GlobalOrdinalT, Node > > getFieldMap(int fieldNum, const Tpetra::Vector< int, int, GlobalOrdinalT, Node > &fieldVector)
std::vector< Teuchos::RCP< const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > > nc2c_vector(const std::vector< Teuchos::RCP< UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > > &ugis)
void updateGhostedDataReducedVector(const std::string &fieldName, const std::string blockId, const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi, const ArrayT &data, Tpetra::MultiVector< ScalarT, int, GlobalOrdinalT, Node > &dataVector)
Teuchos::RCP< const Tpetra::Vector< int, int, GlobalOrdinalT, Node > > buildGhostedFieldVector(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi, const Teuchos::RCP< const Tpetra::Vector< int, int, GlobalOrdinalT, Node > > &reducedVec=Teuchos::null)
std::string printUGILoadBalancingInformation(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi)
Teuchos::RCP< const IntVector > gh_fieldVector_
ghosted reduced field vector
void printMeshTopology(std::ostream &os, const panzer::UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi)
void computePatternFaceIndices(const FieldPattern &pattern, std::vector< std::vector< int > > &faceIndices)
Teuchos::RCP< Tpetra::Vector< int, int, GlobalOrdinalT, Node > > buildGhostedFieldReducedVector(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &ugi)
void computeCellFaceOrientations(const std::vector< std::pair< int, int > > &topEdgeIndices, const std::vector< GlobalOrdinalT > &topology, const FieldPattern &fieldPattern, std::vector< signed char > &orientation)
Teuchos::RCP< const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > ugi_
DOF mapping.
Tpetra::Map< int, GlobalOrdinalT, Node > Map
Teuchos::RCP< const IntVector > gh_reducedFieldVector_
Teuchos::RCP< Tpetra::MultiVector< ScalarT, int, GlobalOrdinalT, Node > > getDataVector(const std::string &fieldName, const std::map< std::string, ArrayT > &data) const
void computePatternEdgeIndices(const FieldPattern &pattern, std::vector< std::pair< int, int > > &edgeIndices)
Tpetra::Vector< int, int, GlobalOrdinalT, Node > IntVector
ArrayToFieldVector()
Maps for each field (as needed)