Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_DOFManager.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_DOFManager_hpp__
44#define __Panzer_DOFManager_hpp__
45#include <map>
46
47#include <mpi.h>
48
49#include "PanzerDofMgr_config.hpp"
55#include "Panzer_NodeType.hpp"
56#include "Panzer_FieldType.hpp"
57#include "Phalanx_KokkosDeviceTypes.hpp"
58#include "Phalanx_KokkosViewOfViews.hpp"
59
60#include "Teuchos_RCP.hpp"
61
62#include "Tpetra_Map.hpp"
63#include "Tpetra_MultiVector.hpp"
64
65namespace panzer {
66
67class DOFManager : public GlobalIndexer {
68public:
69
70 virtual ~DOFManager() {}
71
72 DOFManager();
73
78 DOFManager(const Teuchos::RCP<ConnManager> & connMngr, MPI_Comm mpiComm);
79
81 void setConnManager(const Teuchos::RCP<ConnManager> & connMngr, MPI_Comm mpiComm);
82
83 Teuchos::RCP<const ConnManager> getConnManager() const
84 { return connMngr_; }
85
99 int addField(const std::string & str, const Teuchos::RCP<const FieldPattern> & pattern,
101
116 int addField(const std::string & blockID, const std::string & str,
117 const Teuchos::RCP<const FieldPattern> & pattern,
119
133 Teuchos::RCP<const FieldPattern> getFieldPattern(const std::string & name) const;
134
148 Teuchos::RCP<const FieldPattern> getFieldPattern(const std::string & blockId, const std::string & fieldName) const;
149
156 void getOwnedIndices(std::vector<panzer::GlobalOrdinal>& indices) const;
157
164 void getGhostedIndices(std::vector<panzer::GlobalOrdinal>& indices) const;
165
172 void getOwnedAndGhostedIndices(std::vector<panzer::GlobalOrdinal>& indices) const;
173
174 // Epetra specifiic interfaces. Will be deprecated.
175 void getElementGIDsAsInt(panzer::LocalOrdinal localElementID, std::vector<int> & gids, const std::string & blockIdHint="") const;
176 void getOwnedIndicesAsInt(std::vector<int>& indices) const;
177 void getGhostedIndicesAsInt(std::vector<int>& indices) const;
178 void getOwnedAndGhostedIndicesAsInt(std::vector<int>& indices) const;
179
185 int
186 getNumOwned() const;
187
193 int
194 getNumGhosted() const;
195
201 int
202 getNumOwnedAndGhosted() const;
203
205 int getNumFields() const;
206
211 const std::vector<int> & getGIDFieldOffsets(const std::string & blockID, int fieldNum) const;
212
217 const PHX::View<const int*> getGIDFieldOffsetsKokkos(const std::string & blockID, int fieldNum) const;
218
219
224 const PHX::ViewOfViews3<1,PHX::View<const int*>> getGIDFieldOffsetsKokkos(const std::string & blockID, const std::vector<int> & fieldNum) const;
225
227 void getElementGIDs(panzer::LocalOrdinal localElementID, std::vector<panzer::GlobalOrdinal> & gids, const std::string & blockIdHint="") const;
228
230 void buildGlobalUnknowns();
231
233 void buildGlobalUnknowns(const Teuchos::RCP<const FieldPattern> & geomPattern);
234
235 int getFieldNum(const std::string & string) const;
236
237 Teuchos::RCP<Teuchos::Comm<int> > getComm() const
238 { return communicator_; }
239
240 Teuchos::RCP<const FieldPattern> getGeometricFieldPattern() const
241 { return ga_fp_; }
242
243 void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
244 { connMngr_->getElementBlockIds(elementBlockIds); }
245
246 bool fieldInBlock(const std::string & field, const std::string & block) const;
247
248 const std::vector<int> & getBlockFieldNumbers(const std::string & blockId) const;
249
250//************************************************************************
251
264 const std::pair<std::vector<int>,std::vector<int> > &
265 getGIDFieldOffsets_closure(const std::string & blockId, int fieldNum, int subcellDim,int subcellId) const;
266
268 const std::vector<panzer::LocalOrdinal> & getElementBlock(const std::string & blockId) const
269 { return connMngr_->getElementBlock(blockId); }
270
271 void ownedIndices(const std::vector<panzer::GlobalOrdinal> & indices,std::vector<bool> & isOwned) const;
272
273 void setFieldOrder(const std::vector<std::string> & fieldOrder );
274
275 void getFieldOrder(std::vector<std::string> & fieldOrder) const;
276
277 bool validFieldOrder(const std::vector<std::string> & proposed_fieldOrder);
278
279 //TODO:this
281
283 { return requireOrientations_; }
284
287
290 void getElementOrientation(panzer::LocalOrdinal localElmtId,std::vector<double> & gidsOrientation) const;
291
292 const std::string & getFieldString(int num) const;
293
302 Teuchos::RCP<ConnManager> resetIndices();
303
309 virtual int getElementBlockGIDCount(const std::string & blockId) const
310 { return getElementBlockGIDCount(blockIdToIndex(blockId)); }
311
317 virtual int getElementBlockGIDCount(const std::size_t & blockIndex) const
318 { return elementBlockGIDCount_[blockIndex]; }
319
323 void printFieldInformation(std::ostream & os) const;
324
329 void enableTieBreak(bool enable)
330 { useTieBreak_ = enable; }
331
337 void useNeighbors(bool flag)
338 { useNeighbors_ = flag; }
339
340 // These functions are primarily for testing purposes
341 // they are not intended to be useful otherwise (thus they are not
342 // documented in the Doxygen style
343
344 // Return the number of elemnts as measured by the count of GID arrays.
345 // note that this will include ghosted elements!
346 std::size_t getNumberElementGIDArrays() const
347 { return elementGIDs_.size(); }
348
349protected:
350
353 Teuchos::RCP<const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >
354 runLocalRCMReordering(const Teuchos::RCP<const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> > &);
355
359 std::size_t blockIdToIndex(const std::string & blockId) const;
360
368 Teuchos::RCP<const ConnManager> connMngr_;
369 public:
370 ElementBlockAccess(bool owned,const Teuchos::RCP<const ConnManager> & connMngr)
371 : useOwned_(owned), connMngr_(connMngr) {}
372
373 const std::vector<panzer::LocalOrdinal> & getElementBlock(const std::string & eBlock) const
374 {
375 if(useOwned_==true)
376 return connMngr_->getElementBlock(eBlock);
377 else
378 return connMngr_->getNeighborElementBlock(eBlock);
379 }
380 };
381
386 Teuchos::RCP<const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >
387 buildOverlapMapFromElements(const ElementBlockAccess & access) const;
388
392 Teuchos::RCP<Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >
393 buildTaggedMultiVector(const ElementBlockAccess & access);
394
400 std::pair<Teuchos::RCP<Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> >,
401 Teuchos::RCP<Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> > >
402 buildGlobalUnknowns_GUN(const Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & tagged_overlap_mv,
403 Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & overlap_mv) const;
404
405 void fillGIDsFromOverlappedMV(const ElementBlockAccess & access,
406 std::vector<std::vector< panzer::GlobalOrdinal > > & elementGIDs,
407 const Tpetra::Map<panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & overlapmap,
408 const Tpetra::MultiVector<panzer::GlobalOrdinal,panzer::LocalOrdinal,panzer::GlobalOrdinal,panzer::TpetraNodeType> & overlap_mv) const;
410
411 Teuchos::RCP<ConnManager> connMngr_;
412 Teuchos::RCP<Teuchos::Comm<int> > communicator_;
413
414 //Please note: AID=absolute ID. This is an attempt to remember that
415 // fieldPatterns_ is unchanging storage for FPs.
416 std::vector<Teuchos::RCP<const FieldPattern> > fieldPatterns_;
417 std::vector<FieldType> fieldTypes_; // FieldType for a Field Pattern. Use AID to access just like fieldPatterns_.
418 std::map<std::string,int> fieldNameToAID_;
419
420 std::vector<std::string> blockOrder_; // Get this from the ConnManager.
421 std::map<std::string,int> blockNameToID_; // I'm not sure the above vector is needed, this might suffice.
422 std::vector<std::vector<int> > blockToAssociatedFP_; // each sub-vector is associated by
423 // a block, with ordering given in blockOrder_. ints refer to the order in fieldPatterns_;
424 std::vector<std::string> fieldStringOrder_;
425 std::vector<int> fieldAIDOrder_; // Both of these must be updated and edited together.
426 // The AID offers a simpler way to manage FPs internally.
427
428 Teuchos::RCP<const panzer::FieldPattern> ga_fp_; // geometric aggregate field pattern
429 std::vector<Teuchos::RCP<panzer::FieldAggPattern> > fa_fps_; //Ordered by blockOrder_;
430
431 std::vector<panzer::GlobalOrdinal> owned_;
432 std::vector<panzer::GlobalOrdinal> ghosted_;
433
434 // Element GIDS ordered by LID.
435 std::vector<std::vector< panzer::GlobalOrdinal > > elementGIDs_;
436
437 // Mimics the functionality of the getElemenentBlockGIDCount in
438 // the original DOFManager. Indexed according to blockOrder_.
439 std::vector<int> elementBlockGIDCount_;
440
442
444
446 std::vector<std::vector<signed char> > orientation_;
447
450};
451
452}
453
454#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_
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...
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)
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)
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.
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.