9 #ifndef TpetraLinearSystem_h 10 #define TpetraLinearSystem_h 16 #include <Tpetra_DefaultPlatform.hpp> 17 #include <Kokkos_DefaultNode.hpp> 18 #include <Tpetra_Vector.hpp> 19 #include <Tpetra_DefaultPlatform.hpp> 20 #include <Tpetra_CrsMatrix.hpp> 22 #include <stk_mesh/base/Types.hpp> 23 #include <stk_mesh/base/Entity.hpp> 24 #include <stk_mesh/base/FieldBase.hpp> 28 #include <boost/unordered_map.hpp> 30 #include <Kokkos_UnorderedMap.hpp> 39 typedef boost::unordered_map<stk::mesh::EntityId, size_t>
MyLIDMapType;
41 typedef std::pair<stk::mesh::Entity, stk::mesh::Entity>
Connection;
74 const stk::mesh::Entity* entities,
79 const char * trace_tag);
82 const std::vector<stk::mesh::Entity> & entities,
83 std::vector<int> &scratchIds,
84 std::vector<double> &scratchVals,
85 const std::vector<double> &
rhs,
86 const std::vector<double> &
lhs,
87 const char *trace_tag=0
91 stk::mesh::FieldBase * solutionField,
92 stk::mesh::FieldBase * bcValuesField,
94 const unsigned beginPos,
95 const unsigned endPos);
98 const unsigned beginPos,
99 const unsigned endPos);
108 const std::vector<stk::mesh::Entity> nodeList,
109 const unsigned beginPos,
110 const unsigned endPos);
113 int solve(stk::mesh::FieldBase * linearSolutionField);
115 void writeToFile(
const char * filename,
bool useOwned=
true);
118 size_t lookup_myLID(MyLIDMapType& myLIDs, stk::mesh::EntityId entityId,
const char* msg=
nullptr, stk::mesh::Entity entity = stk::mesh::Entity())
120 return myLIDs[entityId];
142 ConnectionVec& connectionVec);
150 int ownedOrSharedMask);
155 const Teuchos::RCP<LinSys::Vector> tpetraVector,
156 stk::mesh::FieldBase * stkField);
161 const Teuchos::RCP<LinSys::MultiVector> tpetraVector);
163 int addConnections(
const stk::mesh::Entity* entities,
const size_t&);
194 Teuchos::RCP<LinSys::Vector>
sln_;
207 template<
typename T1,
typename T2>
209 Kokkos::UnorderedMap<T1,T2>& dest)
211 if (src.capacity() > dest.capacity()) {
212 dest = Kokkos::UnorderedMap<T1,T2>(src.capacity());
215 unsigned capacity = src.capacity();
216 unsigned fail_count = 0;
217 for(
unsigned i=0; i<capacity; ++i) {
218 if (src.valid_at(i)) {
219 auto insert_result = dest.insert(src.key_at(i));
220 fail_count += insert_result.failed() ? 1 : 0;
223 ThrowRequire(fail_count == 0);
Teuchos::RCP< LinSys::Export > exporter_
Definition: TpetraLinearSystem.h:196
void copy_kokkos_unordered_map(const Kokkos::UnorderedMap< T1, T2 > &src, Kokkos::UnorderedMap< T1, T2 > &dest)
Definition: TpetraLinearSystem.h:208
LinSys::GlobalOrdinal GlobalOrdinal
Definition: TpetraLinearSystem.h:48
std::vector< GlobalOrdinal > totalGids_
Definition: TpetraLinearSystem.h:169
DOFStatus
Definition: TpetraLinearSystem.h:124
Definition: TpetraLinearSystem.h:45
std::vector< Part * > PartVector
Definition: Algorithm.h:16
void compute_graph_row_lengths(const ConnectionVec &connectionVec, LinSys::RowLengths &globallyOwnedRowLengths, LinSys::RowLengths &locallyOwnedRowLengths)
Definition: TpetraLinearSystem.C:847
Definition: ABLForcingAlgorithm.C:26
std::vector< Connection > ConnectionVec
Definition: TpetraLinearSystem.h:43
void prepareConstraints(const unsigned beginPos, const unsigned endPos)
Definition: TpetraLinearSystem.C:1331
boost::unordered_map< stk::mesh::EntityId, size_t > MyLIDMapType
Definition: TpetraLinearSystem.h:37
void checkForNaN(bool useOwned)
Definition: TpetraLinearSystem.C:1528
void copy_kokkos_unordered_map_to_sorted_vector(const ConnectionSetKK &connectionSetKK, ConnectionVec &connectionVec)
Definition: TpetraLinearSystem.C:823
Kokkos::UnorderedMap< Connection, void > ConnectionSetKK
Definition: TpetraLinearSystem.h:42
Teuchos::RCP< LinSys::Matrix > globallyOwnedMatrix_
Definition: TpetraLinearSystem.h:191
size_t lookup_myLID(MyLIDMapType &myLIDs, stk::mesh::EntityId entityId, const char *msg=nullptr, stk::mesh::Entity entity=stk::mesh::Entity())
Definition: TpetraLinearSystem.h:118
long GlobalOrdinal
Definition: LinearSolverTypes.h:80
Teuchos::RCP< LinSys::Import > importer_
Definition: TpetraLinearSystem.h:197
TpetraLinearSystem(Realm &realm, const unsigned numDof, EquationSystem *eqSys, LinearSolver *linearSolver)
=====================================================================================================...
Definition: TpetraLinearSystem.C:84
std::pair< stk::mesh::Entity, stk::mesh::Entity > Connection
Definition: TpetraLinearSystem.h:41
Teuchos::RCP< LinSys::Vector > globallyOwnedRhs_
Definition: TpetraLinearSystem.h:192
MyLIDMapType myLIDs_
Definition: TpetraLinearSystem.h:199
void copy_tpetra_to_stk(const Teuchos::RCP< LinSys::Vector > tpetraVector, stk::mesh::FieldBase *stkField)
Definition: TpetraLinearSystem.C:1797
ConnectionSetKK connectionSetKK_
Definition: TpetraLinearSystem.h:168
void buildEdgeToNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:460
std::vector< int > sortPermutation_
Definition: TpetraLinearSystem.h:204
unsigned numDof() const
Definition: LinearSystem.h:117
void loadComplete()
Definition: TpetraLinearSystem.C:1433
Definition: TpetraLinearSystem.h:126
~TpetraLinearSystem()
Definition: TpetraLinearSystem.C:95
static constexpr double lhs[8][8]
Definition: UnitTestContinuityAdvElem.C:25
Teuchos::RCP< LinSys::Vector > globalSln_
Definition: TpetraLinearSystem.h:195
void buildNonConformalNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:661
Base class representation of a PDE.
Definition: EquationSystem.h:46
LinSys::LocalOrdinal LocalOrdinal
Definition: TpetraLinearSystem.h:49
Definition: TpetraLinearSystem.h:127
void buildNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:429
void fill_entity_to_LID_mapping()
Definition: TpetraLinearSystem.C:960
Definition: TpetraLinearSystem.h:129
void writeToFile(const char *filename, bool useOwned=true)
Definition: TpetraLinearSystem.C:1647
void finalizeLinearSystem()
Definition: TpetraLinearSystem.C:977
void buildFaceElemToNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:613
Teuchos::RCP< LinSys::Map > ownedPlusGloballyOwnedRowsMap_
Definition: TpetraLinearSystem.h:180
static constexpr double rhs[8]
Definition: UnitTestContinuityAdvElem.C:18
int getDofStatus(stk::mesh::Entity node)
Definition: TpetraLinearSystem.C:135
Teuchos::RCP< LinSys::Map > ownedRowsMap_
Definition: TpetraLinearSystem.h:177
Teuchos::RCP< LinSys::Vector > ownedRhs_
Definition: TpetraLinearSystem.h:189
LocalOrdinal maxOwnedRowId_
Definition: TpetraLinearSystem.h:201
Teuchos::RCP< LinSys::Map > totalColsMap_
Definition: TpetraLinearSystem.h:174
void zeroSystem()
Definition: TpetraLinearSystem.C:1068
void copy_stk_to_tpetra(stk::mesh::FieldBase *stkField, const Teuchos::RCP< LinSys::MultiVector > tpetraVector)
Definition: TpetraLinearSystem.C:775
LocalOrdinal maxGloballyOwnedRowId_
Definition: TpetraLinearSystem.h:202
Definition: TpetraLinearSystem.h:125
Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > Graph
Definition: LinearSolverTypes.h:90
Teuchos::RCP< LinSys::Graph > ownedGraph_
Definition: TpetraLinearSystem.h:185
Teuchos::RCP< LinSys::Map > globallyOwnedRowsMap_
Definition: TpetraLinearSystem.h:183
std::vector< LocalOrdinal > entityToLID_
Definition: TpetraLinearSystem.h:200
void buildElemToNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:530
Kokkos::View< T, Kokkos::LayoutRight, DeviceShmem, Kokkos::MemoryUnmanaged > SharedMemView
Definition: KokkosInterface.h:25
void buildFaceToNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:498
void applyDirichletBCs(stk::mesh::FieldBase *solutionField, stk::mesh::FieldBase *bcValuesField, const stk::mesh::PartVector &parts, const unsigned beginPos, const unsigned endPos)
Definition: TpetraLinearSystem.C:1252
Teuchos::RCP< LinSys::Matrix > ownedMatrix_
Definition: TpetraLinearSystem.h:188
Teuchos::RCP< LinSys::Node > node_
Definition: TpetraLinearSystem.h:171
void checkError(const int err_code, const char *msg)
Definition: TpetraLinearSystem.h:137
void expand_unordered_map(unsigned newCapacityNeeded)
Definition: TpetraLinearSystem.C:421
Definition: LinearSolver.h:55
int solve(stk::mesh::FieldBase *linearSolutionField)
Definition: TpetraLinearSystem.C:1456
Teuchos::RCP< LinSys::Graph > globallyOwnedGraph_
Definition: TpetraLinearSystem.h:186
void sumInto(unsigned numEntities, const stk::mesh::Entity *entities, const SharedMemView< const double * > &rhs, const SharedMemView< const double ** > &lhs, const SharedMemView< int * > &localIds, const SharedMemView< int * > &sortPermutation, const char *trace_tag)
Definition: TpetraLinearSystem.C:1124
int addConnections(const stk::mesh::Entity *entities, const size_t &)
Definition: TpetraLinearSystem.C:395
virtual void resetRows(const std::vector< stk::mesh::Entity > nodeList, const unsigned beginPos, const unsigned endPos)
Reset LHS and RHS for the given set of nodes to 0.
Definition: TpetraLinearSystem.C:1384
bool checkForZeroRow(bool useOwned, bool doThrow, bool doPrint=false)
Definition: TpetraLinearSystem.C:1560
Kokkos::DualView< size_t *, DeviceSpace > RowLengths
Definition: LinearSolverTypes.h:84
void buildOversetNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:727
Teuchos::RCP< LinSys::Vector > sln_
Definition: TpetraLinearSystem.h:194
void beginLinearSystemConstruction()
Definition: TpetraLinearSystem.C:246
void buildReducedElemToNodeGraph(const stk::mesh::PartVector &parts)
Definition: TpetraLinearSystem.C:563
Definition: LinearSystem.h:40
int LocalOrdinal
Definition: LinearSolverTypes.h:81
void writeSolutionToFile(const char *filename, bool useOwned=true)
Definition: TpetraLinearSystem.C:1748
void insert_graph_connections(const ConnectionVec &connectionVec, LinSys::Graph &ownedGraph, int ownedOrSharedMask)
Definition: TpetraLinearSystem.C:895
void printInfo(bool useOwned=true)
Definition: TpetraLinearSystem.C:1723
Definition: TpetraLinearSystem.h:128