Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_BlockedDOFManager.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef __Panzer_BlockedDOFManager_hpp__
12#define __Panzer_BlockedDOFManager_hpp__
13
14#include <map>
15#include <set>
16
17#ifdef HAVE_MPI
18 #include <mpi.h>
19#endif
20
21#include "PanzerDofMgr_config.hpp"
26#include "Panzer_DOFManager.hpp"
27#include "Panzer_NodeType.hpp"
28#include "Panzer_HashUtils.hpp"
29
30#include "Teuchos_RCP.hpp"
31#include "Teuchos_DefaultMpiComm.hpp"
32
33#include <unordered_set>
34
35namespace panzer {
36
38public:
39 // typedef std::pair<int,GlobalOrdinalT> GlobalOrdinal;
40 using GlobalOrdinal = panzer::GlobalOrdinal;
41 using LocalOrdinal = panzer::LocalOrdinal;
42 using const_field_iterator = std::map<int,std::string>::const_iterator;
43
44 virtual ~BlockedDOFManager() {}
45
47
52 BlockedDOFManager(const Teuchos::RCP<ConnManager> & connMngr,MPI_Comm mpiComm);
53
57
58
61 virtual Teuchos::RCP<Teuchos::Comm<int> > getComm() const
62 { return communicator_; }
63
78 int getFieldNum(const std::string & str) const; // ?
79
93 const std::string & getFieldString(int num) const;
94
97 virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
98 { getConnManager()->getElementBlockIds(elementBlockIds); }
99
102 virtual bool fieldInBlock(const std::string & field, const std::string & block) const; // ?
103
111 virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const // ?
112 { return getConnManager()->getElementBlock(blockId); }
113
116 virtual const std::vector<int> & getBlockFieldNumbers(const std::string & block) const; // ?
117
121 void getElementGIDs(panzer::LocalOrdinal localElmtId,std::vector<GlobalOrdinal> & gids,const std::string & blockIdHint="") const; // ?
122
136 void getElementGIDsPair(panzer::LocalOrdinal localElmtId,std::vector<std::pair<int,GlobalOrdinal>> & gids,const std::string & blockIdHint="") const;
137
140 virtual void getElementOrientation(panzer::LocalOrdinal localElmtId,std::vector<double> & gidsOrientation) const; // ?
141
145 virtual const std::vector<int> & getGIDFieldOffsets(const std::string & blockId,int fieldNum) const; // ?
146
161 virtual const std::pair<std::vector<int>,std::vector<int> > &
162 getGIDFieldOffsets_closure(const std::string & blockId,int fieldNum,int subcellDim,int subcellId) const; // ?
163
170 virtual void getOwnedIndices(std::vector<GlobalOrdinal>& indices) const;
171
178 virtual void
179 getGhostedIndices(std::vector<GlobalOrdinal>& indices) const;
180
187 virtual void
188 getOwnedAndGhostedIndices(std::vector<GlobalOrdinal>& indices) const;
189
190 // For backwards compatibility with Epetra. Will be deprecated.
191 void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId,std::vector<int> & gids,const std::string & blockIdHint="") const;
192 virtual void getOwnedIndicesAsInt(std::vector<int>& indices) const;
193 virtual void getGhostedIndicesAsInt(std::vector<int>& indices) const;
194 virtual void getOwnedAndGhostedIndicesAsInt(std::vector<int>& indices) const;
195
201 virtual int
202 getNumOwned() const;
203
209 virtual int
210 getNumGhosted() const;
211
217 virtual int
218 getNumOwnedAndGhosted() const;
219
222 virtual void ownedIndices(const std::vector<GlobalOrdinal> & indices,std::vector<bool> & isOwned) const; // ?
223
225
227
230 void setUseDOFManagerFEI(bool useFEI)
231 { useDOFManagerFEI_ = useFEI; }
232
236 {
237 return false;
238 }
239
251 void setConnManager(const Teuchos::RCP<ConnManager> & connMngr,MPI_Comm mpiComm);
252
253
257 Teuchos::RCP<const FieldPattern> getGeometricFieldPattern() const // ?
258 { return geomPattern_; }
259
268 Teuchos::RCP<ConnManager> resetIndices(); // ?
269
282 void addField(const std::string & str,const Teuchos::RCP<const FieldPattern> & pattern);
283
284 void addField(const std::string & blockId,const std::string & str,const Teuchos::RCP<const FieldPattern> & pattern);
285
294 void setFieldOrder(const std::vector<std::vector<std::string> > & fieldOrder);
295
299 int getNumFieldBlocks() const;
300
303 void getFieldOrder(std::vector<std::vector<std::string> > & fieldOrder) const;
304
305 void getFieldOrder(std::vector<std::string>& /* fieldOrder */) const { TEUCHOS_ASSERT(false); } // what???
306
320 Teuchos::RCP<const FieldPattern> getFieldPattern(const std::string & blockId, const std::string & fieldName) const; // ?
321
329 int getNumFields() const; // ?
330
333 Teuchos::RCP<const ConnManager> getConnManager() const
334 { return connMngr_; }
335
338 Teuchos::RCP<ConnManager> getConnManager()
339 { return connMngr_; }
340
347 virtual void buildGlobalUnknowns();
348
365 virtual void buildGlobalUnknowns(const Teuchos::RCP<const FieldPattern> & geomPattern);
366
374 virtual void buildGlobalUnknowns(const std::vector<Teuchos::RCP<GlobalIndexer>> & fieldBlockManagers);
375
379 void printFieldInformation(std::ostream & os) const; // ?
380
389 bool validFieldOrder(const std::vector<std::vector<std::string> > & fieldOrder_ut,const std::set<std::string> & fields) const;
390
394 void registerFields(bool buildSubUGIs);
395
398 bool fieldsRegistered() const
399 { return fieldsRegistered_; }
400
404 const std::vector<Teuchos::RCP<GlobalIndexer>> &
407
411 inline int getMaxSubFieldNumber() const
412 { return maxSubFieldNum_; }
413
418 int getFieldBlock(int fieldNum) const
419 { return fieldNumToFieldBlk_.find(fieldNum)->second; }
420
425 int getBlockGIDOffset(const std::string & elementBlock,int fieldBlock) const
426 {
427 std::map<std::pair<std::string,int>,int>::const_iterator itr =
428 blockGIDOffset_.find(std::make_pair(elementBlock,fieldBlock));
429
430 if(itr==blockGIDOffset_.end())
431 return -1;
432 else
433 return itr->second;
434 }
435
439 { return requireOrientations_; }
440
445
448 void enableTieBreak(bool useTieBreak)
449 { useTieBreak_ = useTieBreak; }
450
456 virtual int getElementBlockGIDCount(const std::string & blockId) const;
457
463 virtual int getElementBlockGIDCount(const std::size_t & blockIndex) const;
464
465protected:
466
469 Teuchos::RCP<GlobalIndexer> buildNewIndexer(const Teuchos::RCP<ConnManager> & connManager,
470 MPI_Comm mpiComm) const;
471
474 void setOrientationsRequired(const Teuchos::RCP<GlobalIndexer> & indexer,bool required) const;
475
478 void buildGlobalUnknowns(const Teuchos::RCP<GlobalIndexer> & indexer,const Teuchos::RCP<const FieldPattern> & geomPattern) const;
479
482 int getElementBlockGIDCount(const Teuchos::RCP<GlobalIndexer> & indexer,const std::string & elementBlock) const;
483
486 int getElementBlockGIDCount(const Teuchos::RCP<GlobalIndexer> & indexer,const std::size_t & blockIndex) const;
487
490 void printFieldInformation(const Teuchos::RCP<GlobalIndexer> & indexer,std::ostream & os) const;
491
497 void addFieldsToFieldBlockManager(const std::vector<std::string> & activeFields,
498 GlobalIndexer & fieldBlockManager) const;
499
505 void addFieldsToFieldBlockManager(const std::vector<std::string> & activeFields,
506 DOFManager & fieldBlockManager) const;
507
508 // computes connectivity
509 Teuchos::RCP<ConnManager> connMngr_;
510
512
513
514 std::map<std::string,int> fieldStrToNum_;
515
517 std::map<int,std::string> fieldNumToStr_;
518
520 std::map<int,int> fieldNumToFieldBlk_;
521
523 std::map<std::pair<std::string,std::string>,Teuchos::RCP<const FieldPattern> > fieldStringToPattern_;
524
526 std::map<std::string,std::set<std::string> > blockIdToFieldStrings_;
527
529 std::map<std::string,std::vector<int> > blockIdToFieldNumbers_;
530
532 std::map<std::pair<std::string,int>,int> blockGIDOffset_;
533
535
536 // storage for fast lookups of GID ownership
537 //std::unordered_set<GlobalOrdinal,panzer::pair_hash> ownedGIDHashTable_;
538
539 std::vector<std::vector<std::string> > fieldOrder_;
540
542
543 Teuchos::RCP<const FieldPattern> geomPattern_;
544 Teuchos::RCP<Teuchos::MpiComm<int> > communicator_;
545
546 std::vector<Teuchos::RCP<GlobalIndexer>> fieldBlockManagers_;
547
548 MPI_Comm mpiComm_;
550
554 mutable std::map<std::string,std::map<int,std::vector<int> > > gidFieldOffsets_;
555
556 struct LessThan
557 { bool operator()(const Teuchos::Tuple<int,3> & a,const Teuchos::Tuple<int,3> & b) const; };
558 typedef std::map<Teuchos::Tuple<int,3>, std::pair<std::vector<int>,std::vector<int> >,LessThan> TupleToVectorPairMap;
559
563 mutable std::map<std::string,TupleToVectorPairMap> gidFieldOffsets_closure_;
564
566
569};
570
571}
572
573#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.
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