Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_GlobalIndexer_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_GlobalIndexer_Utilities_decl_hpp__
44 #define __Panzer_GlobalIndexer_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 
55 #include "Panzer_GlobalIndexer.hpp"
56 #include "Panzer_FieldPattern.hpp"
57 
58 namespace panzer {
59 
63 std::vector<Teuchos::RCP<const GlobalIndexer>>
64 nc2c_vector(const std::vector<Teuchos::RCP<GlobalIndexer>> & ugis);
65 
75 int getFieldBlock(const std::string & fieldName,
76  const std::vector<Teuchos::RCP<GlobalIndexer>> & ugis);
77 
87 int getFieldBlock(const std::string & fieldName,
88  const std::vector<Teuchos::RCP<const GlobalIndexer>> & ugis);
89 
103 void computeBlockOffsets(const std::string & blockId,
104  const std::vector<Teuchos::RCP<GlobalIndexer>> & ugis,
105  std::vector<int> & blockOffsets);
106 
120 void computeBlockOffsets(const std::string & blockId,
121  const std::vector<Teuchos::RCP<const GlobalIndexer>> & ugis,
122  std::vector<int> & blockOffsets);
123 
128 std::string printUGILoadBalancingInformation(const GlobalIndexer & ugi);
129 
134 void printMeshTopology(std::ostream & os,const panzer::GlobalIndexer & ugi);
135 
149 buildGhostedFieldReducedVector(const GlobalIndexer & ugi);
150 
162 buildGhostedFieldVector(const GlobalIndexer & ugi,
163  const Teuchos::RCP<const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > & reducedVec=Teuchos::null);
164 
178 void buildGhostedFieldVector(const GlobalIndexer & ugi,
179  std::vector<int> & fieldNumbers,
180  const Teuchos::RCP<const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> > & reducedVec=Teuchos::null);
181 
194 template <typename ScalarT,typename ArrayT>
195 void updateGhostedDataReducedVector(const std::string & fieldName,const std::string blockId,
196  const GlobalIndexer & ugi,
197  const ArrayT & data,
198  Tpetra::MultiVector<ScalarT,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> & dataVector);
199 
210 getFieldMap(int fieldNum,const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> & fieldVector);
211 
212 
213 namespace orientation_helpers {
214 
224 void computePatternEdgeIndices(const FieldPattern & pattern,std::vector<std::pair<int,int> > & edgeIndices);
225 
242 void computeCellEdgeOrientations(const std::vector<std::pair<int,int> > & topEdgeIndices,
243  const std::vector<panzer::GlobalOrdinal> & topology,
244  const FieldPattern & fieldPattern,
245  std::vector<signed char> & orientation);
246 
260 void computePatternFaceIndices(const FieldPattern & pattern,std::vector<std::vector<int> > & faceIndices);
261 
278 void computeCellFaceOrientations(const std::vector<std::vector<int>> & topEdgeIndices,
279  const std::vector<panzer::GlobalOrdinal> & topology,
280  const FieldPattern & fieldPattern,
281  std::vector<signed char> & orientation);
282 
283 } // end orientations_helpers
284 
285 
289 public:
294 
304  template <typename ScalarT,typename ArrayT>
306  getGhostedDataVector(const std::string & fieldName,const std::map<std::string,ArrayT> & data) const;
307 
317  template <typename ScalarT,typename ArrayT>
319  getDataVector(const std::string & fieldName,const std::map<std::string,ArrayT> & data) const;
320 
326  getFieldMap(const std::string & fieldName) const;
327 
333  getFieldMap(int fieldNum) const;
334 
335 protected:
336  using IntVector = Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
337  using Map = Tpetra::Map<int,panzer::GlobalOrdinal,panzer::TpetraNodeType>;
338 
340  void buildFieldVector(const Tpetra::Vector<int,int,panzer::GlobalOrdinal,panzer::TpetraNodeType> & source) const;
341 
344 
347 
348  mutable std::map<int,Teuchos::RCP<const Map> > gh_reducedFieldMaps_;
349  mutable std::map<int,Teuchos::RCP<const Map> > gh_fieldMaps_;
350 
352  mutable std::map<int,Teuchos::RCP<const Map> > fieldMaps_;
353 
354 private:
355  // hide some constructors
358 };
359 
360 
361 } // end namspace panzer
362 
364 
365 #endif
std::map< int, Teuchos::RCP< const Map > > fieldMaps_
(unghosted) field vector (as needed)
std::map< int, Teuchos::RCP< const Map > > gh_fieldMaps_
Maps for each field (as needed)
Teuchos::RCP< const IntVector > gh_reducedFieldVector_
Teuchos::RCP< Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > buildGhostedFieldReducedVector(const GlobalIndexer &ugi)
std::map< int, Teuchos::RCP< const Map > > gh_reducedFieldMaps_
ghosted field vector
Teuchos::RCP< const IntVector > gh_fieldVector_
ghosted reduced field vector
Teuchos::RCP< const Tpetra::Map< int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > getFieldMap(int fieldNum, const Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > &fieldTVector)
void computeBlockOffsets(const std::string &blockId, const std::vector< Teuchos::RCP< GlobalIndexer >> &ugis, std::vector< int > &blockOffsets)
Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > IntVector
void updateGhostedDataReducedVector(const std::string &fieldName, const std::string blockId, const GlobalIndexer &ugi, const ArrayT &data, Tpetra::MultiVector< ScalarT, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > &dataVector)
Teuchos::RCP< const GlobalIndexer > ugi_
DOF mapping.
std::vector< Teuchos::RCP< const GlobalIndexer > > nc2c_vector(const std::vector< Teuchos::RCP< GlobalIndexer > > &ugis)
int getFieldBlock(const std::string &fieldName, const std::vector< Teuchos::RCP< const GlobalIndexer >> &ugis)
void computeCellEdgeOrientations(const std::vector< std::pair< int, int > > &topEdgeIndices, const std::vector< panzer::GlobalOrdinal > &topology, const FieldPattern &fieldPattern, std::vector< signed char > &orientation)
Teuchos::RCP< Tpetra::MultiVector< ScalarT, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > getGhostedDataVector(const std::string &fieldName, const std::map< std::string, ArrayT > &data) const
void computePatternFaceIndices(const FieldPattern &pattern, std::vector< std::vector< int > > &faceIndices)
void computeCellFaceOrientations(const std::vector< std::vector< int > > &topFaceIndices, const std::vector< panzer::GlobalOrdinal > &topology, const FieldPattern &fieldPattern, std::vector< signed char > &orientation)
Tpetra::Map< int, panzer::GlobalOrdinal, panzer::TpetraNodeType > Map
Teuchos::RCP< const Tpetra::Map< int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > getFieldMap(const std::string &fieldName) const
Teuchos::RCP< Tpetra::MultiVector< ScalarT, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > getDataVector(const std::string &fieldName, const std::map< std::string, ArrayT > &data) const
void buildFieldVector(const Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > &source) const
build unghosted field vector from ghosted field vector
Teuchos::RCP< const IntVector > fieldVector_
Maps for each field (as needed)
void printMeshTopology(std::ostream &os, const panzer::GlobalIndexer &ugi)
void computePatternEdgeIndices(const FieldPattern &pattern, std::vector< std::pair< int, int > > &edgeIndices)
void buildGhostedFieldVector(const GlobalIndexer &ugi, std::vector< int > &fieldNumbers, const Teuchos::RCP< const Tpetra::Vector< int, int, panzer::GlobalOrdinal, panzer::TpetraNodeType > > &reducedVec)
ArrayToFieldVector()
Maps for each field (as needed)
std::string printUGILoadBalancingInformation(const GlobalIndexer &ugi)