Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_DOFManager.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_DOFManager_hpp__
12#define __Panzer_DOFManager_hpp__
13#include <map>
14
15#include <mpi.h>
16
17#include "PanzerDofMgr_config.hpp"
23#include "Panzer_NodeType.hpp"
24#include "Panzer_FieldType.hpp"
25#include "Phalanx_KokkosDeviceTypes.hpp"
26#include "Phalanx_KokkosViewOfViews.hpp"
27
28#include "Teuchos_RCP.hpp"
29
30#include "Tpetra_Map.hpp"
31#include "Tpetra_MultiVector.hpp"
32
33namespace panzer {
34
35class DOFManager : public GlobalIndexer {
36public:
37
38 virtual ~DOFManager() {}
39
40 DOFManager();
41
46 DOFManager(const Teuchos::RCP<ConnManager> & connMngr, MPI_Comm mpiComm);
47
49 void setConnManager(const Teuchos::RCP<ConnManager> & connMngr, MPI_Comm mpiComm);
50
51 Teuchos::RCP<const ConnManager> getConnManager() const
52 { return connMngr_; }
53
67 int addField(const std::string & str, const Teuchos::RCP<const FieldPattern> & pattern,
69
84 int addField(const std::string & blockID, const std::string & str,
85 const Teuchos::RCP<const FieldPattern> & pattern,
87
101 Teuchos::RCP<const FieldPattern> getFieldPattern(const std::string & name) const;
102
116 Teuchos::RCP<const FieldPattern> getFieldPattern(const std::string & blockId, const std::string & fieldName) const;
117
124 void getOwnedIndices(std::vector<panzer::GlobalOrdinal>& indices) const;
125
132 void getGhostedIndices(std::vector<panzer::GlobalOrdinal>& indices) const;
133
140 void getOwnedAndGhostedIndices(std::vector<panzer::GlobalOrdinal>& indices) const;
141
142 // Epetra specifiic interfaces. Will be deprecated.
143 void getElementGIDsAsInt(panzer::LocalOrdinal localElementID, std::vector<int> & gids, const std::string & blockIdHint="") const;
144 void getOwnedIndicesAsInt(std::vector<int>& indices) const;
145 void getGhostedIndicesAsInt(std::vector<int>& indices) const;
146 void getOwnedAndGhostedIndicesAsInt(std::vector<int>& indices) const;
147
153 int
154 getNumOwned() const;
155
161 int
162 getNumGhosted() const;
163
169 int
170 getNumOwnedAndGhosted() const;
171
173 int getNumFields() const;
174
179 const std::vector<int> & getGIDFieldOffsets(const std::string & blockID, int fieldNum) const;
180
185 const PHX::View<const int*> getGIDFieldOffsetsKokkos(const std::string & blockID, int fieldNum) const;
186
187
192 const PHX::ViewOfViews<1,PHX::View<const int*>> getGIDFieldOffsetsKokkos(const std::string & blockID, const std::vector<int> & fieldNum) const;
193
195 void getElementGIDs(panzer::LocalOrdinal localElementID, std::vector<panzer::GlobalOrdinal> & gids, const std::string & blockIdHint="") const;
196
198 virtual void buildGlobalUnknowns();
199
201 virtual void buildGlobalUnknowns(const Teuchos::RCP<const FieldPattern> & geomPattern);
202
203 int getFieldNum(const std::string & string) const;
204
205 Teuchos::RCP<Teuchos::Comm<int> > getComm() const
206 { return communicator_; }
207
208 Teuchos::RCP<const FieldPattern> getGeometricFieldPattern() const
209 { return ga_fp_; }
210
211 void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
212 { connMngr_->getElementBlockIds(elementBlockIds); }
213
214 bool fieldInBlock(const std::string & field, const std::string & block) const;
215
216 const std::vector<int> & getBlockFieldNumbers(const std::string & blockId) const;
217
218//************************************************************************
219
232 const std::pair<std::vector<int>,std::vector<int> > &
233 getGIDFieldOffsets_closure(const std::string & blockId, int fieldNum, int subcellDim,int subcellId) const;
234
236 const std::vector<panzer::LocalOrdinal> & getElementBlock(const std::string & blockId) const
237 { return connMngr_->getElementBlock(blockId); }
238
239 void ownedIndices(const std::vector<panzer::GlobalOrdinal> & indices,std::vector<bool> & isOwned) const;
240
241 void setFieldOrder(const std::vector<std::string> & fieldOrder );
242
243 void getFieldOrder(std::vector<std::string> & fieldOrder) const;
244
245 bool validFieldOrder(const std::vector<std::string> & proposed_fieldOrder);
246
247 //TODO:this
249
251 { return requireOrientations_; }
252
255
258 void getElementOrientation(panzer::LocalOrdinal localElmtId,std::vector<double> & gidsOrientation) const;
259
260 const std::string & getFieldString(int num) const;
261
270 Teuchos::RCP<ConnManager> resetIndices();
271
277 virtual int getElementBlockGIDCount(const std::string & blockId) const
278 { return getElementBlockGIDCount(blockIdToIndex(blockId)); }
279
285 virtual int getElementBlockGIDCount(const std::size_t & blockIndex) const
286 { return elementBlockGIDCount_[blockIndex]; }
287
291 void printFieldInformation(std::ostream & os) const;
292
297 void enableTieBreak(bool enable)
298 { useTieBreak_ = enable; }
299
305 void useNeighbors(bool flag)
306 { useNeighbors_ = flag; }
307
308 // These functions are primarily for testing purposes
309 // they are not intended to be useful otherwise (thus they are not
310 // documented in the Doxygen style
311
312 // Return the number of elemnts as measured by the count of GID arrays.
313 // note that this will include ghosted elements!
314 std::size_t getNumberElementGIDArrays() const
315 { return elementGIDs_.size(); }
316
317protected:
318
321 Teuchos::RCP<const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >
322 runLocalRCMReordering(const Teuchos::RCP<const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> > &);
323
327 std::size_t blockIdToIndex(const std::string & blockId) const;
328
335 public:
337 Teuchos::RCP<const ConnManager> connMngr_;
338 public:
339 ElementBlockAccess(bool owned,const Teuchos::RCP<const ConnManager> & connMngr)
340 : useOwned_(owned), connMngr_(connMngr) {}
341
342 const std::vector<panzer::LocalOrdinal> & getElementBlock(const std::string & eBlock) const
343 {
344 if(useOwned_==true)
345 return connMngr_->getElementBlock(eBlock);
346 else
347 return connMngr_->getNeighborElementBlock(eBlock);
348 }
349 };
350
355 virtual Teuchos::RCP<const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >
356 buildOverlapMapFromElements(const ElementBlockAccess & access) const;
357
361 virtual Teuchos::RCP<Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >
362 buildTaggedMultiVector(const ElementBlockAccess & access);
363
369 virtual std::pair<Teuchos::RCP<Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >,
370 Teuchos::RCP<Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> > >
371 buildGlobalUnknowns_GUN(const Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & tagged_overlap_mv,
372 Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & overlap_mv) const;
373
374 virtual void fillGIDsFromOverlappedMV(const ElementBlockAccess & access,
375 std::vector<std::vector< panzer::GlobalOrdinal > > & elementGIDs,
376 const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & overlapmap,
377 const Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & overlap_mv) const;
379
380 Teuchos::RCP<ConnManager> connMngr_;
381 Teuchos::RCP<Teuchos::Comm<int> > communicator_;
382
383 //Please note: AID=absolute ID. This is an attempt to remember that
384 // fieldPatterns_ is unchanging storage for FPs.
385 std::vector<Teuchos::RCP<const FieldPattern> > fieldPatterns_;
386 std::vector<FieldType> fieldTypes_; // FieldType for a Field Pattern. Use AID to access just like fieldPatterns_.
387 std::map<std::string,int> fieldNameToAID_;
388
389 std::vector<std::string> blockOrder_; // Get this from the ConnManager.
390 std::map<std::string,int> blockNameToID_; // I'm not sure the above vector is needed, this might suffice.
391 std::vector<std::vector<int> > blockToAssociatedFP_; // each sub-vector is associated by
392 // a block, with ordering given in blockOrder_. ints refer to the order in fieldPatterns_;
393 std::vector<std::string> fieldStringOrder_;
394 std::vector<int> fieldAIDOrder_; // Both of these must be updated and edited together.
395 // The AID offers a simpler way to manage FPs internally.
396
397 Teuchos::RCP<const panzer::FieldPattern> ga_fp_; // geometric aggregate field pattern
398 std::vector<Teuchos::RCP<panzer::FieldAggPattern> > fa_fps_; //Ordered by blockOrder_;
399
400 std::vector<panzer::GlobalOrdinal> owned_;
401 std::vector<panzer::GlobalOrdinal> ghosted_;
402
403 // Element GIDS ordered by LID.
404 std::vector<std::vector< panzer::GlobalOrdinal > > elementGIDs_;
405
406 // Mimics the functionality of the getElemenentBlockGIDCount in
407 // the original DOFManager. Indexed according to blockOrder_.
408 std::vector<int> elementBlockGIDCount_;
409
411
413
415 std::vector<std::vector<signed char> > orientation_;
416
419};
420
421}
422
423#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.
Teuchos::RCP< const ConnManager > connMngr_
const std::vector< panzer::LocalOrdinal > & getElementBlock(const std::string &eBlock) const
ElementBlockAccess(bool owned, const Teuchos::RCP< const ConnManager > &connMngr)
void ownedIndices(const std::vector< panzer::GlobalOrdinal > &indices, std::vector< bool > &isOwned) const
std::vector< int > elementBlockGIDCount_
bool validFieldOrder(const std::vector< std::string > &proposed_fieldOrder)
Teuchos::RCP< Teuchos::Comm< int > > getComm() const
const PHX::View< const int * > getGIDFieldOffsetsKokkos(const std::string &blockID, int fieldNum) const
int getNumGhosted() const
Get the number of indices ghosted for this processor.
std::vector< std::string > blockOrder_
std::vector< panzer::GlobalOrdinal > ghosted_
std::vector< FieldType > fieldTypes_
std::map< std::string, int > blockNameToID_
std::vector< int > fieldAIDOrder_
void getOwnedIndicesAsInt(std::vector< int > &indices) const
Get the set of indices owned by this processor.
void getGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const
Get the set of indices ghosted for this processor.
void getFieldOrder(std::vector< std::string > &fieldOrder) const
bool getOrientationsRequired() const
void setConnManager(const Teuchos::RCP< ConnManager > &connMngr, MPI_Comm mpiComm)
Adds a Connection Manager that will be associated with this DOFManager.
virtual int getElementBlockGIDCount(const std::size_t &blockIndex) const
How any GIDs are associate with a particular element block.
std::vector< panzer::GlobalOrdinal > owned_
virtual void fillGIDsFromOverlappedMV(const ElementBlockAccess &access, std::vector< std::vector< panzer::GlobalOrdinal > > &elementGIDs, const Tpetra::Map< panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > &overlapmap, const Tpetra::MultiVector< panzer::GlobalOrdinal, panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > &overlap_mv) const
void getElementOrientation(panzer::LocalOrdinal localElmtId, std::vector< double > &gidsOrientation) const
Get a vector containg the orientation of the GIDs relative to the neighbors.
Teuchos::RCP< const panzer::FieldPattern > ga_fp_
void buildLocalIdsFromOwnedAndGhostedElements()
Teuchos::RCP< ConnManager > connMngr_
void getOwnedAndGhostedIndicesAsInt(std::vector< int > &indices) const
Get the set of owned and ghosted indices for this processor.
Teuchos::RCP< const FieldPattern > getFieldPattern(const std::string &name) const
Find a field pattern stored for a particular block and field number. This will retrive the pattern ad...
virtual std::pair< Teuchos::RCP< Tpetra::MultiVector< panzer::GlobalOrdinal, panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > >, Teuchos::RCP< Tpetra::MultiVector< panzer::GlobalOrdinal, panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > > > buildGlobalUnknowns_GUN(const Tpetra::MultiVector< panzer::GlobalOrdinal, panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > &tagged_overlap_mv, Tpetra::MultiVector< panzer::GlobalOrdinal, panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > &overlap_mv) const
std::size_t getNumberElementGIDArrays() const
std::vector< std::vector< int > > blockToAssociatedFP_
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...
void setFieldOrder(const std::vector< std::string > &fieldOrder)
virtual Teuchos::RCP< Tpetra::MultiVector< panzer::GlobalOrdinal, panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > > buildTaggedMultiVector(const ElementBlockAccess &access)
const std::vector< panzer::LocalOrdinal > & getElementBlock(const std::string &blockId) const
Get the owned element block.
std::vector< std::vector< panzer::GlobalOrdinal > > elementGIDs_
std::vector< std::vector< signed char > > orientation_
Teuchos::RCP< ConnManager > resetIndices()
Reset the indices for this DOF manager.
Teuchos::RCP< const FieldPattern > getGeometricFieldPattern() const
std::size_t blockIdToIndex(const std::string &blockId) const
void getElementGIDsAsInt(panzer::LocalOrdinal localElementID, std::vector< int > &gids, const std::string &blockIdHint="") const
Get the global IDs for a particular element. This function overwrites the gids variable.
void enableTieBreak(bool enable)
virtual void buildGlobalUnknowns()
builds the global unknowns array
Teuchos::RCP< const Tpetra::Map< panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > > runLocalRCMReordering(const Teuchos::RCP< const Tpetra::Map< panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > > &)
Teuchos::RCP< Teuchos::Comm< int > > communicator_
std::vector< Teuchos::RCP< panzer::FieldAggPattern > > fa_fps_
void getOwnedIndices(std::vector< panzer::GlobalOrdinal > &indices) const
Get the set of indices owned by this processor.
Teuchos::RCP< const ConnManager > getConnManager() const
Returns the connection manager currently being used.
void useNeighbors(bool flag)
int getNumOwnedAndGhosted() const
Get the number of owned and ghosted indices for this processor.
void getElementBlockIds(std::vector< std::string > &elementBlockIds) const
void getElementGIDs(panzer::LocalOrdinal localElementID, std::vector< panzer::GlobalOrdinal > &gids, const std::string &blockIdHint="") const
get associated GIDs for a given local element
std::map< std::string, int > fieldNameToAID_
std::vector< std::string > fieldStringOrder_
void printFieldInformation(std::ostream &os) const
void getGhostedIndicesAsInt(std::vector< int > &indices) const
Get the set of indices ghosted for this processor.
int getFieldNum(const std::string &string) const
Get the number used for access to this field.
virtual int getElementBlockGIDCount(const std::string &blockId) const
How any GIDs are associate with a particular element block.
int getNumOwned() const
Get the number of indices owned by this processor.
const std::string & getFieldString(int num) const
Reverse lookup of the field string from a field number.
std::vector< Teuchos::RCP< const FieldPattern > > fieldPatterns_
bool fieldInBlock(const std::string &field, const std::string &block) const
int addField(const std::string &str, const Teuchos::RCP< const FieldPattern > &pattern, const panzer::FieldType &type=panzer::FieldType::CG)
Add a field to the DOF manager.
int getNumFields() const
gets the number of fields
void setOrientationsRequired(bool ro)
void getOwnedAndGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const
Get the set of owned and ghosted indices for this processor.
virtual Teuchos::RCP< const Tpetra::Map< panzer::LocalOrdinal, panzer::GlobalOrdinal, panzer::TpetraNodeType > > buildOverlapMapFromElements(const ElementBlockAccess &access) const
const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const
const std::vector< int > & getGIDFieldOffsets(const std::string &blockID, int fieldNum) const
FieldType
The type of discretization to use for a field pattern.