| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// ShyLU: Scalable Hybrid LU Preconditioner and Solver |
| 4 |
// |
| 5 |
// Copyright 2011 NTESS and the ShyLU contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef _FROSCH_INTERFACEENTITY_DECL_HPP |
| 11 |
#define _FROSCH_INTERFACEENTITY_DECL_HPP |
| 12 |
|
| 13 |
#include <Xpetra_VectorFactory_fwd.hpp> |
| 14 |
|
| 15 |
#include <FROSch_ExtractSubmatrices_def.hpp> |
| 16 |
#include <FROSch_Tools_def.hpp> |
| 17 |
|
| 18 |
|
| 19 |
namespace FROSch { |
| 20 |
|
| 21 |
using namespace Teuchos; |
| 22 |
using namespace Xpetra; |
| 23 |
|
| 24 |
template <class SC = double, |
| 25 |
class LO = int, |
| 26 |
class GO = DefaultGlobalOrdinal, |
| 27 |
class NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType> |
| 28 |
class EntitySet; |
| 29 |
|
| 30 |
enum EntityType {DefaultType,VertexType,EdgeType,FaceType,InteriorType,InterfaceType}; |
| 31 |
enum EntityFlag {DefaultFlag,StraightFlag,ShortFlag,NodeFlag}; |
| 32 |
enum DistanceFunction {ConstantDistanceFunction,InverseEuclideanDistanceFunction}; |
| 33 |
|
| 34 |
template <class SC = double, |
| 35 |
class LO = int, |
| 36 |
class GO = DefaultGlobalOrdinal> |
| 37 |
struct Node { |
| 38 |
LO NodeIDGamma_; |
| 39 |
LO NodeIDLocal_; |
| 40 |
GO NodeIDGlobal_; |
| 41 |
|
| 42 |
ArrayRCP<LO> DofsGamma_; |
| 43 |
ArrayRCP<LO> DofsLocal_; |
| 44 |
ArrayRCP<GO> DofsGlobal_; |
| 45 |
|
| 46 |
bool operator< (const Node &n) const; |
| 47 |
|
| 48 |
bool operator== (const Node &n) const; |
| 49 |
}; |
| 50 |
|
| 51 |
template <class SC = double, |
| 52 |
class LO = int, |
| 53 |
class GO = DefaultGlobalOrdinal, |
| 54 |
class NO = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType> |
| 55 |
class InterfaceEntity { |
| 56 |
|
| 57 |
protected: |
| 58 |
|
| 59 |
using XMatrix = Xpetra::Matrix<SC,LO,GO,NO>; |
| 60 |
using XMatrixPtr = RCP<XMatrix>; |
| 61 |
using ConstXMatrixPtr = RCP<const XMatrix>; |
| 62 |
|
| 63 |
using XVector = Xpetra::Vector<SC,LO,GO,NO>; |
| 64 |
using XVectorPtr = RCP<XVector>; |
| 65 |
|
| 66 |
using XMultiVector = Xpetra::MultiVector<SC,LO,GO,NO>; |
| 67 |
using XMultiVectorPtr = RCP<XMultiVector>; |
| 68 |
using ConstXMultiVectorPtr = RCP<const XMultiVector>; |
| 69 |
|
| 70 |
using EntitySetPtr = RCP<EntitySet<SC,LO,GO,NO> >; |
| 71 |
|
| 72 |
using InterfaceEntityPtr = RCP<InterfaceEntity<SC,LO,GO,NO> >; |
| 73 |
|
| 74 |
using NodeVec = Array<Node<SC,LO,GO> >; |
| 75 |
using NodePtr = RCP<Node<SC,LO,GO> >; |
| 76 |
using NodePtrVec = Array<NodePtr>; |
| 77 |
|
| 78 |
using UN = unsigned; |
| 79 |
|
| 80 |
using IntVec = Array<int>; |
| 81 |
|
| 82 |
using LOVecPtr = ArrayRCP<LO>; |
| 83 |
|
| 84 |
using GOVec = Array<GO>; |
| 85 |
using GOVecPtr = ArrayRCP<GO>; |
| 86 |
|
| 87 |
using SCVecPtr = ArrayRCP<SC>; |
| 88 |
using SCVecPtrVec = Array<SCVecPtr>; |
| 89 |
|
| 90 |
public: |
| 91 |
|
| 92 |
InterfaceEntity(EntityType type, |
| 93 |
UN dofsPerNode, |
| 94 |
UN multiplicity, |
| 95 |
const int *subdomains, |
| 96 |
EntityFlag flag = DefaultFlag); |
| 97 |
|
| 98 |
~InterfaceEntity(); |
| 99 |
|
| 100 |
int addNode(LO nodeIDGamma, |
| 101 |
LO nodeIDLocal, |
| 102 |
GO nodeIDGlobal, |
| 103 |
UN nDofs, |
| 104 |
const LOVecPtr dofsGamma, |
| 105 |
const LOVecPtr dofsLocal, |
| 106 |
const GOVecPtr dofsGlobal); |
| 107 |
|
| 108 |
int addNode(const NodePtr &node); |
| 109 |
|
| 110 |
int addNode(const Node<SC,LO,GO> &node); |
| 111 |
|
| 112 |
int resetGlobalDofs(UN iD, |
| 113 |
UN nDofs, |
| 114 |
UN *dofIDs, |
| 115 |
GO *dofsGlobal); |
| 116 |
|
| 117 |
int removeNode(UN iD); |
| 118 |
|
| 119 |
int sortByGlobalID(); |
| 120 |
|
| 121 |
int setUniqueID(GO uniqueID); |
| 122 |
|
| 123 |
int setLocalID(LO localID); |
| 124 |
|
| 125 |
int setRootID(LO rootID); |
| 126 |
|
| 127 |
int setLeafID(LO leafID); |
| 128 |
|
| 129 |
int setUniqueIDToFirstGlobalID(); |
| 130 |
|
| 131 |
int resetEntityType(EntityType type); |
| 132 |
|
| 133 |
int resetEntityFlag(EntityFlag flag); |
| 134 |
|
| 135 |
int findAncestorsInSet(EntitySetPtr entitySet); |
| 136 |
|
| 137 |
int clearAncestors(); |
| 138 |
|
| 139 |
int addOffspring(InterfaceEntityPtr interfaceEntity); |
| 140 |
|
| 141 |
int clearOffspring(); |
| 142 |
|
| 143 |
EntitySetPtr findRoots(); |
| 144 |
|
| 145 |
int clearRoots(); |
| 146 |
|
| 147 |
int computeDistancesToRoots(UN dimension, |
| 148 |
ConstXMultiVectorPtr &nodeList = null, |
| 149 |
DistanceFunction distanceFunction = ConstantDistanceFunction); |
| 150 |
|
| 151 |
InterfaceEntityPtr divideEntity(ConstXMatrixPtr matrix, |
| 152 |
int pID); |
| 153 |
|
| 154 |
///////////////// |
| 155 |
// Get Methods // |
| 156 |
///////////////// |
| 157 |
|
| 158 |
EntityType getEntityType() const; |
| 159 |
|
| 160 |
EntityFlag getEntityFlag() const; |
| 161 |
|
| 162 |
UN getDofsPerNode() const; |
| 163 |
|
| 164 |
UN getMultiplicity() const; |
| 165 |
|
| 166 |
GO getUniqueID() const; |
| 167 |
|
| 168 |
LO getLocalID() const; |
| 169 |
|
| 170 |
LO getRootID() const; |
| 171 |
|
| 172 |
LO getLeafID() const; |
| 173 |
|
| 174 |
const Node<SC,LO,GO>& getNode(UN iDNode) const; |
| 175 |
|
| 176 |
LO getGammaNodeID(UN iDNode) const; |
| 177 |
|
| 178 |
LO getLocalNodeID(UN iDNode) const; |
| 179 |
|
| 180 |
GO getGlobalNodeID(UN iDNode) const; |
| 181 |
|
| 182 |
LO getGammaDofID(UN iDNode, UN iDDof) const; |
| 183 |
|
| 184 |
LO getLocalDofID(UN iDNode, UN iDDof) const; |
| 185 |
|
| 186 |
GO getGlobalDofID(UN iDNode, UN iDDof) const; |
| 187 |
|
| 188 |
const IntVec & getSubdomainsVector() const; |
| 189 |
|
| 190 |
UN getNumNodes() const; |
| 191 |
|
| 192 |
const EntitySetPtr getAncestors() const; |
| 193 |
|
| 194 |
const EntitySetPtr getOffspring() const; |
| 195 |
|
| 196 |
const EntitySetPtr getRoots() const; |
| 197 |
|
| 198 |
SC getDistanceToRoot(UN iDNode, |
| 199 |
UN iDRoot) const; |
| 200 |
|
| 201 |
protected: |
| 202 |
|
| 203 |
EntityType Type_ = DefaultType; |
| 204 |
|
| 205 |
EntityFlag Flag_ = DefaultFlag; |
| 206 |
|
| 207 |
NodeVec NodeVector_ = NodeVec(0); |
| 208 |
|
| 209 |
IntVec SubdomainsVector_ = IntVec(0); |
| 210 |
|
| 211 |
EntitySetPtr Ancestors_; |
| 212 |
EntitySetPtr Offspring_; |
| 213 |
EntitySetPtr Roots_; |
| 214 |
|
| 215 |
SCVecPtrVec DistancesVector_ = SCVecPtrVec(0); // AH 08/08/2019 TODO: make a MultiVector out of this |
| 216 |
|
| 217 |
UN DofsPerNode_ = 1; |
| 218 |
UN Multiplicity_ = 1; |
| 219 |
GO UniqueID_ = -1; |
| 220 |
LO LocalID_ = -1; |
| 221 |
LO RootID_ = -1; |
| 222 |
LO LeafID_ = -1; |
| 223 |
}; |
| 224 |
|
| 225 |
template <class SC,class LO,class GO,class NO> |
| 226 |
bool compareInterfaceEntities(RCP<InterfaceEntity<SC,LO,GO,NO> > iEa, |
| 227 |
RCP<InterfaceEntity<SC,LO,GO,NO> > iEb); |
| 228 |
|
| 229 |
template <class SC,class LO,class GO,class NO> |
| 230 |
bool equalInterfaceEntities(RCP<InterfaceEntity<SC,LO,GO,NO> > iEa, |
| 231 |
RCP<InterfaceEntity<SC,LO,GO,NO> > iEb); |
| 232 |
|
| 233 |
} |
| 234 |
|
| 235 |
#endif |