Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_BlockedDOFManager.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_BlockedDOFManager_hpp__
44#define __Panzer_BlockedDOFManager_hpp__
45
46#include <map>
47#include <set>
48
49#ifdef HAVE_MPI
50 #include <mpi.h>
51#endif
52
53#include "PanzerDofMgr_config.hpp"
58#include "Panzer_DOFManager.hpp"
59#include "Panzer_NodeType.hpp"
60#include "Panzer_HashUtils.hpp"
61
62#include "Teuchos_RCP.hpp"
63#include "Teuchos_DefaultMpiComm.hpp"
64
65#include <unordered_set>
66
67namespace panzer {
68
70public:
71 // typedef std::pair<int,GlobalOrdinalT> GlobalOrdinal;
72 using GlobalOrdinal = panzer::GlobalOrdinal;
73 using LocalOrdinal = panzer::LocalOrdinal;
74 using const_field_iterator = std::map<int,std::string>::const_iterator;
75
76 virtual ~BlockedDOFManager() {}
77
79
84 BlockedDOFManager(const Teuchos::RCP<ConnManager> & connMngr,MPI_Comm mpiComm);
85
89
90
93 virtual Teuchos::RCP<Teuchos::Comm<int> > getComm() const
94 { return communicator_; }
95
110 int getFieldNum(const std::string & str) const; // ?
111
125 const std::string & getFieldString(int num) const;
126
129 virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
130 { getConnManager()->getElementBlockIds(elementBlockIds); }
131
134 virtual bool fieldInBlock(const std::string & field, const std::string & block) const; // ?
135
143 virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const // ?
144 { return getConnManager()->getElementBlock(blockId); }
145
148 virtual const std::vector<int> & getBlockFieldNumbers(const std::string & block) const; // ?
149
153 void getElementGIDs(panzer::LocalOrdinal localElmtId,std::vector<GlobalOrdinal> & gids,const std::string & blockIdHint="") const; // ?
154
168 void getElementGIDsPair(panzer::LocalOrdinal localElmtId,std::vector<std::pair<int,GlobalOrdinal>> & gids,const std::string & blockIdHint="") const;
169
172 virtual void getElementOrientation(panzer::LocalOrdinal localElmtId,std::vector<double> & gidsOrientation) const; // ?
173
177 virtual const std::vector<int> & getGIDFieldOffsets(const std::string & blockId,int fieldNum) const; // ?
178
193 virtual const std::pair<std::vector<int>,std::vector<int> > &
194 getGIDFieldOffsets_closure(const std::string & blockId,int fieldNum,int subcellDim,int subcellId) const; // ?
195
202 virtual void getOwnedIndices(std::vector<GlobalOrdinal>& indices) const;
203
210 virtual void
211 getGhostedIndices(std::vector<GlobalOrdinal>& indices) const;
212
219 virtual void
220 getOwnedAndGhostedIndices(std::vector<GlobalOrdinal>& indices) const;
221
222 // For backwards compatibility with Epetra. Will be deprecated.
223 void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId,std::vector<int> & gids,const std::string & blockIdHint="") const;
224 virtual void getOwnedIndicesAsInt(std::vector<int>& indices) const;
225 virtual void getGhostedIndicesAsInt(std::vector<int>& indices) const;
226 virtual void getOwnedAndGhostedIndicesAsInt(std::vector<int>& indices) const;
227
233 virtual int
234 getNumOwned() const;
235
241 virtual int
242 getNumGhosted() const;
243
249 virtual int
250 getNumOwnedAndGhosted() const;
251
254 virtual void ownedIndices(const std::vector<GlobalOrdinal> & indices,std::vector<bool> & isOwned) const; // ?
255
257
259
262 void setUseDOFManagerFEI(bool useFEI)
263 { useDOFManagerFEI_ = useFEI; }
264
268 {
269 return false;
270 }
271
283 void setConnManager(const Teuchos::RCP<ConnManager> & connMngr,MPI_Comm mpiComm);
284
285
289 Teuchos::RCP<const FieldPattern> getGeometricFieldPattern() const // ?
290 { return geomPattern_; }
291
300 Teuchos::RCP<ConnManager> resetIndices(); // ?
301
314 void addField(const std::string & str,const Teuchos::RCP<const FieldPattern> & pattern);
315
316 void addField(const std::string & blockId,const std::string & str,const Teuchos::RCP<const FieldPattern> & pattern);
317
326 void setFieldOrder(const std::vector<std::vector<std::string> > & fieldOrder);
327
331 int getNumFieldBlocks() const;
332
335 void getFieldOrder(std::vector<std::vector<std::string> > & fieldOrder) const;
336
337 void getFieldOrder(std::vector<std::string>& /* fieldOrder */) const { TEUCHOS_ASSERT(false); } // what???
338
352 Teuchos::RCP<const FieldPattern> getFieldPattern(const std::string & blockId, const std::string & fieldName) const; // ?
353
361 int getNumFields() const; // ?
362
365 Teuchos::RCP<const ConnManager> getConnManager() const
366 { return connMngr_; }
367
370 Teuchos::RCP<ConnManager> getConnManager()
371 { return connMngr_; }
372
379 virtual void buildGlobalUnknowns();
380
397 virtual void buildGlobalUnknowns(const Teuchos::RCP<const FieldPattern> & geomPattern);
398
406 virtual void buildGlobalUnknowns(const std::vector<Teuchos::RCP<GlobalIndexer>> & fieldBlockManagers);
407
411 void printFieldInformation(std::ostream & os) const; // ?
412
421 bool validFieldOrder(const std::vector<std::vector<std::string> > & fieldOrder_ut,const std::set<std::string> & fields) const;
422
426 void registerFields(bool buildSubUGIs);
427
430 bool fieldsRegistered() const
431 { return fieldsRegistered_; }
432
436 const std::vector<Teuchos::RCP<GlobalIndexer>> &
438 { return fieldBlockManagers_; }
439
443 inline int getMaxSubFieldNumber() const
444 { return maxSubFieldNum_; }
445
450 int getFieldBlock(int fieldNum) const
451 { return fieldNumToFieldBlk_.find(fieldNum)->second; }
452
457 int getBlockGIDOffset(const std::string & elementBlock,int fieldBlock) const
458 {
459 std::map<std::pair<std::string,int>,int>::const_iterator itr =
460 blockGIDOffset_.find(std::make_pair(elementBlock,fieldBlock));
461
462 if(itr==blockGIDOffset_.end())
463 return -1;
464 else
465 return itr->second;
466 }
467
471 { return requireOrientations_; }
472
476 { requireOrientations_ = ro; }
477
480 void enableTieBreak(bool useTieBreak)
481 { useTieBreak_ = useTieBreak; }
482
488 virtual int getElementBlockGIDCount(const std::string & blockId) const;
489
495 virtual int getElementBlockGIDCount(const std::size_t & blockIndex) const;
496
497protected:
498
501 Teuchos::RCP<GlobalIndexer> buildNewIndexer(const Teuchos::RCP<ConnManager> & connManager,
502 MPI_Comm mpiComm) const;
503
506 void setOrientationsRequired(const Teuchos::RCP<GlobalIndexer> & indexer,bool required) const;
507
510 void buildGlobalUnknowns(const Teuchos::RCP<GlobalIndexer> & indexer,const Teuchos::RCP<const FieldPattern> & geomPattern) const;
511
514 int getElementBlockGIDCount(const Teuchos::RCP<GlobalIndexer> & indexer,const std::string & elementBlock) const;
515
518 int getElementBlockGIDCount(const Teuchos::RCP<GlobalIndexer> & indexer,const std::size_t & blockIndex) const;
519
522 void printFieldInformation(const Teuchos::RCP<GlobalIndexer> & indexer,std::ostream & os) const;
523
529 void addFieldsToFieldBlockManager(const std::vector<std::string> & activeFields,
530 GlobalIndexer & fieldBlockManager) const;
531
537 void addFieldsToFieldBlockManager(const std::vector<std::string> & activeFields,
538 DOFManager & fieldBlockManager) const;
539
540 // computes connectivity
541 Teuchos::RCP<ConnManager> connMngr_;
542
544
545
546 std::map<std::string,int> fieldStrToNum_;
547
549 std::map<int,std::string> fieldNumToStr_;
550
552 std::map<int,int> fieldNumToFieldBlk_;
553
555 std::map<std::pair<std::string,std::string>,Teuchos::RCP<const FieldPattern> > fieldStringToPattern_;
556
558 std::map<std::string,std::set<std::string> > blockIdToFieldStrings_;
559
561 std::map<std::string,std::vector<int> > blockIdToFieldNumbers_;
562
564 std::map<std::pair<std::string,int>,int> blockGIDOffset_;
565
567
568 // storage for fast lookups of GID ownership
569 //std::unordered_set<GlobalOrdinal,panzer::pair_hash> ownedGIDHashTable_;
570
571 std::vector<std::vector<std::string> > fieldOrder_;
572
574
575 Teuchos::RCP<const FieldPattern> geomPattern_;
576 Teuchos::RCP<Teuchos::MpiComm<int> > communicator_;
577
578 std::vector<Teuchos::RCP<GlobalIndexer>> fieldBlockManagers_;
579
580 MPI_Comm mpiComm_;
582
586 mutable std::map<std::string,std::map<int,std::vector<int> > > gidFieldOffsets_;
587
588 struct LessThan
589 { bool operator()(const Teuchos::Tuple<int,3> & a,const Teuchos::Tuple<int,3> & b) const; };
590 typedef std::map<Teuchos::Tuple<int,3>, std::pair<std::vector<int>,std::vector<int> >,LessThan> TupleToVectorPairMap;
591
595 mutable std::map<std::string,TupleToVectorPairMap> gidFieldOffsets_closure_;
596
598
601};
602
603}
604
605#endif
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral.
void setFieldOrder(const std::vector< std::vector< std::string > > &fieldOrder)
virtual void getGhostedIndicesAsInt(std::vector< int > &indices) const
Get the set of indices ghosted for this processor.
void enableTieBreak(bool useTieBreak)
Teuchos::RCP< ConnManager > connMngr_
int getFieldBlock(int fieldNum) const
void addFieldsToFieldBlockManager(const std::vector< std::string > &activeFields, GlobalIndexer &fieldBlockManager) const
virtual int getNumGhosted() const
Get the number of indices ghosted for this processor.
std::map< int, std::string >::const_iterator const_field_iterator
bool validFieldOrder(const std::vector< std::vector< std::string > > &fieldOrder_ut, const std::set< std::string > &fields) const
virtual void getOwnedIndicesAsInt(std::vector< int > &indices) const
Get the set of indices owned by this processor.
virtual void getGhostedIndices(std::vector< GlobalOrdinal > &indices) const
Get the set of indices ghosted for this processor.
void registerFields(bool buildSubUGIs)
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &block) const
Teuchos::RCP< Teuchos::MpiComm< int > > communicator_
std::map< std::string, TupleToVectorPairMap > gidFieldOffsets_closure_
std::map< int, std::string > fieldNumToStr_
field number ==> field string
void getFieldOrder(std::vector< std::string > &) const
void setUseDOFManagerFEI(bool useFEI)
Use the FEI DOF manager internally, or the standard version.
void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId, std::vector< int > &gids, const std::string &blockIdHint="") const
Get the global IDs for a particular element. This function overwrites the gids variable.
std::map< std::pair< std::string, int >, int > blockGIDOffset_
(element block,field block) ==> gid offset
void getElementGIDsPair(panzer::LocalOrdinal localElmtId, std::vector< std::pair< int, GlobalOrdinal > > &gids, const std::string &blockIdHint="") const
Get the global IDs for a particular element. This function overwrites the gids variable.
virtual int getNumOwnedAndGhosted() const
Get the number of owned and ghosted indices for this processor.
int getBlockGIDOffset(const std::string &elementBlock, int fieldBlock) const
void getElementGIDs(panzer::LocalOrdinal localElmtId, std::vector< GlobalOrdinal > &gids, const std::string &blockIdHint="") const
Get the global IDs for a particular element. This function overwrites the gids variable.
virtual void getElementOrientation(panzer::LocalOrdinal localElmtId, std::vector< double > &gidsOrientation) const
Get a vector containg the orientation of the GIDs relative to the neighbors.
virtual bool fieldInBlock(const std::string &field, const std::string &block) const
void addField(const std::string &str, const Teuchos::RCP< const FieldPattern > &pattern)
Add a field to the DOF manager.
void setConnManager(const Teuchos::RCP< ConnManager > &connMngr, MPI_Comm mpiComm)
Set the connection manager and MPI_Comm objects.
int getNumFields() const
How many fields are handled by this manager.
virtual const std::vector< int > & getGIDFieldOffsets(const std::string &blockId, int fieldNum) const
Use the field pattern so that you can find a particular field in the GIDs array.
bool getUseDOFManagerFEI() const
which DOF Manager is used internally?
std::vector< std::vector< std::string > > fieldOrder_
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const
Teuchos::RCP< ConnManager > getConnManager()
const std::vector< Teuchos::RCP< GlobalIndexer > > & getFieldDOFManagers() const
virtual void getOwnedAndGhostedIndicesAsInt(std::vector< int > &indices) const
Get the set of owned and ghosted indices for this processor.
std::map< std::pair< std::string, std::string >, Teuchos::RCP< const FieldPattern > > fieldStringToPattern_
(block ID x field string) ==> pattern
const std::string & getFieldString(int num) const
Get the string name associated with a field number.
Teuchos::RCP< const FieldPattern > geomPattern_
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const
virtual void getOwnedAndGhostedIndices(std::vector< GlobalOrdinal > &indices) const
Get the set of owned and ghosted indices for this processor.
virtual void getOwnedIndices(std::vector< GlobalOrdinal > &indices) const
Get the set of indices owned by this processor.
std::map< Teuchos::Tuple< int, 3 >, std::pair< std::vector< int >, std::vector< int > >, LessThan > TupleToVectorPairMap
virtual const std::pair< std::vector< int >, std::vector< int > > & getGIDFieldOffsets_closure(const std::string &blockId, int fieldNum, int subcellDim, int subcellId) const
Use the field pattern so that you can find a particular field in the GIDs array. This version lets yo...
int getFieldNum(const std::string &str) const
Get the number used for access to this field.
Teuchos::RCP< ConnManager > resetIndices()
Reset the indicies for this DOF manager.
Teuchos::RCP< const FieldPattern > getFieldPattern(const std::string &blockId, const std::string &fieldName) const
Find a field pattern stored for a particular block and field number. This will retrive the pattern ad...
virtual int getNumOwned() const
Get the number of indices owned by this processor.
std::vector< Teuchos::RCP< GlobalIndexer > > fieldBlockManagers_
Teuchos::RCP< GlobalIndexer > buildNewIndexer(const Teuchos::RCP< ConnManager > &connManager, MPI_Comm mpiComm) const
void getFieldOrder(std::vector< std::vector< std::string > > &fieldOrder) const
virtual void ownedIndices(const std::vector< GlobalOrdinal > &indices, std::vector< bool > &isOwned) const
std::map< int, int > fieldNumToFieldBlk_
field number ==> field block
std::map< std::string, int > fieldStrToNum_
field string ==> field number
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockId) const
Teuchos::RCP< const ConnManager > getConnManager() const
Teuchos::RCP< const FieldPattern > getGeometricFieldPattern() const
std::map< std::string, std::map< int, std::vector< int > > > gidFieldOffsets_
std::map< std::string, std::set< std::string > > blockIdToFieldStrings_
block ID ==> field strings
std::map< std::string, std::vector< int > > blockIdToFieldNumbers_
block ID ==> field numbers
virtual int getElementBlockGIDCount(const std::string &blockId) const
How any GIDs are associate with a particular element block.
void printFieldInformation(std::ostream &os) const
bool operator()(const Teuchos::Tuple< int, 3 > &a, const Teuchos::Tuple< int, 3 > &b) const