| 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_IPOUHARMONICCOARSEOPERATOR_DEF_HPP |
| 11 |
#define _FROSCH_IPOUHARMONICCOARSEOPERATOR_DEF_HPP |
| 12 |
|
| 13 |
#include <FROSch_IPOUHarmonicCoarseOperator_decl.hpp> |
| 14 |
|
| 15 |
|
| 16 |
namespace FROSch { |
| 17 |
|
| 18 |
using namespace std; |
| 19 |
using namespace Teuchos; |
| 20 |
using namespace Xpetra; |
| 21 |
|
| 22 |
template <class SC,class LO,class GO,class NO> |
| 23 |
IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::IPOUHarmonicCoarseOperator(ConstXMatrixPtr k, |
| 24 |
ParameterListPtr parameterList) : |
| 25 |
HarmonicCoarseOperator<SC,LO,GO,NO> (k,parameterList) |
| 26 |
{ |
| 27 |
FROSCH_DETAILTIMER_START_LEVELID(iPOUHarmonicCoarseOperatorTime,"IPOUHarmonicCoarseOperator::IPOUHarmonicCoarseOperator"); |
| 28 |
} |
| 29 |
|
| 30 |
template <class SC,class LO,class GO,class NO> |
| 31 |
int IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::initialize(UN dimension, |
| 32 |
UN dofsPerNode, |
| 33 |
ConstXMapPtr nodesMap, |
| 34 |
ConstXMapPtrVecPtr dofsMaps, |
| 35 |
ConstXMultiVectorPtr nullSpaceBasis, |
| 36 |
ConstXMultiVectorPtr nodeList, |
| 37 |
GOVecPtr dirichletBoundaryDofs) |
| 38 |
{ |
| 39 |
FROSCH_TIMER_START_LEVELID(initializeTime,"IPOUHarmonicCoarseOperator::initialize"); |
| 40 |
int ret = buildCoarseSpace(dimension,dofsPerNode,nodesMap,dofsMaps,nullSpaceBasis,dirichletBoundaryDofs,nodeList); |
| 41 |
this->CoarseMap_ = this->assembleCoarseMap(); |
| 42 |
this->assembleInterfaceCoarseSpace(); |
| 43 |
this->buildCoarseSolveMap(this->AssembledInterfaceCoarseSpace_->getBasisMapUnique()); |
| 44 |
this->extractLocalSubdomainMatrix_Symbolic(); |
| 45 |
this->IsInitialized_ = true; |
| 46 |
this->IsComputed_ = false; |
| 47 |
return ret; |
| 48 |
} |
| 49 |
|
| 50 |
template <class SC,class LO,class GO,class NO> |
| 51 |
int IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::initialize(UN dimension, |
| 52 |
UNVecPtr dofsPerNodeVec, |
| 53 |
ConstXMapPtrVecPtr repeatedNodesMapVec, |
| 54 |
ConstXMapPtrVecPtr2D repeatedDofMapsVec, |
| 55 |
ConstXMultiVectorPtrVecPtr nullSpaceBasisVec, |
| 56 |
ConstXMultiVectorPtrVecPtr nodeListVec, |
| 57 |
GOVecPtr2D dirichletBoundaryDofsVec) |
| 58 |
{ |
| 59 |
FROSCH_TIMER_START_LEVELID(initializeTime,"IPOUHarmonicCoarseOperator::initialize"); |
| 60 |
buildCoarseSpace(dimension,dofsPerNodeVec,repeatedNodesMapVec,repeatedDofMapsVec,nullSpaceBasisVec,dirichletBoundaryDofsVec,nodeListVec); |
| 61 |
this->CoarseMap_ = this->assembleCoarseMap(); |
| 62 |
this->assembleInterfaceCoarseSpace(); |
| 63 |
this->buildCoarseSolveMap(this->AssembledInterfaceCoarseSpace_->getBasisMapUnique()); |
| 64 |
this->IsInitialized_ = true; |
| 65 |
this->IsComputed_ = false; |
| 66 |
return 0; |
| 67 |
} |
| 68 |
|
| 69 |
template <class SC,class LO,class GO,class NO> |
| 70 |
void IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::describe(FancyOStream &out, |
| 71 |
const EVerbosityLevel verbLevel) const |
| 72 |
{ |
| 73 |
FROSCH_ASSERT(false,"describe() has to be implemented properly..."); |
| 74 |
} |
| 75 |
|
| 76 |
template <class SC,class LO,class GO,class NO> |
| 77 |
string IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::description() const |
| 78 |
{ |
| 79 |
return "Interface Partition of Unity Coarse Operator"; |
| 80 |
} |
| 81 |
|
| 82 |
template <class SC,class LO,class GO,class NO> |
| 83 |
typename IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::XMapPtr IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::BuildRepeatedMapCoarseLevel(ConstXMapPtr &nodesMap, |
| 84 |
UN dofsPerNode, |
| 85 |
ConstXMapPtrVecPtr dofsMaps, |
| 86 |
UN partition) |
| 87 |
{ |
| 88 |
//FROSCH_ASSERT(numVert+numEdg+numFac != nodesMap->getGlobalNumElements(),"ERROR: Map does not match number of Entities"); |
| 89 |
const GO INVALID = Teuchos::OrdinalTraits<GO>::invalid(); |
| 90 |
UN blockId = 1; //This is not implemented for Block Variant yet |
| 91 |
stringstream blockIdStringstream; |
| 92 |
blockIdStringstream << blockId+1; |
| 93 |
string blockIdString = blockIdStringstream.str(); |
| 94 |
RCP<ParameterList> coarseSpaceList = sublist(sublist(this->ParameterList_,"Blocks"),blockIdString.c_str()); |
| 95 |
|
| 96 |
Teuchos::Array<GO> nodeEle = nodesMap->getLocalElementList(); |
| 97 |
|
| 98 |
Teuchos::Array<GO> dofEle(nodeEle.size()*dofsPerNode); |
| 99 |
Teuchos::Array<GO> dmapEle(nodeEle.size()); |
| 100 |
//GDSW Type CoarseOperator |
| 101 |
if (partition == 0) { |
| 102 |
for (unsigned j = 0; j<dofsPerNode; j++) { |
| 103 |
for ( unsigned i = 0; i<nodeEle.size(); i++) { |
| 104 |
//vertices |
| 105 |
if (nodeEle[i]<NumEnt_[0]) { |
| 106 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[0]; |
| 107 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[0]; |
| 108 |
} |
| 109 |
//shortEdges |
| 110 |
else if (nodeEle[i]>=NumEnt_[0] && nodeEle[i]<NumEnt_[1]+NumEnt_[0]) { |
| 111 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[1]+(dofsPerNode-1)*NumEnt_[0]; |
| 112 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[1]+(dofsPerNode-1)*NumEnt_[0]; |
| 113 |
} |
| 114 |
//straightEdges |
| 115 |
else if (nodeEle[i]<NumEnt_[2]+NumEnt_[0]+NumEnt_[1] && nodeEle[i]>=NumEnt_[1]+NumEnt_[0]) { |
| 116 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[2]+(NumEnt_[0]*(dofsPerNode-1))+(NumEnt_[1]*(dofsPerNode-1)); |
| 117 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[2]+(NumEnt_[0]*(dofsPerNode-1))+(NumEnt_[1]*(dofsPerNode-1)); |
| 118 |
} |
| 119 |
//edges |
| 120 |
else if (nodeEle[i]<NumEnt_[3]+NumEnt_[2]+NumEnt_[0]+NumEnt_[1] && nodeEle[i]>=NumEnt_[1]+NumEnt_[0]+NumEnt_[2]) { |
| 121 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[3]+(NumEnt_[0]*(dofsPerNode-1))+(NumEnt_[1]*(dofsPerNode-1))+(NumEnt_[2]*(dofsPerNode-1)); |
| 122 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[3]+(NumEnt_[0]*(dofsPerNode-1))+(NumEnt_[1]*(dofsPerNode-1))+(NumEnt_[2]*(dofsPerNode-1)); |
| 123 |
} |
| 124 |
//faces |
| 125 |
else if (nodeEle[i]<NumEnt_[3]+NumEnt_[2]+NumEnt_[0]+NumEnt_[1]+NumEnt_[4] && nodeEle[i]>=NumEnt_[1]+NumEnt_[0]+NumEnt_[2]+NumEnt_[3]) { |
| 126 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[4]+(NumEnt_[0]*(dofsPerNode-1))+(NumEnt_[1]*(dofsPerNode-1))+(NumEnt_[2]*(dofsPerNode-1))+(NumEnt_[3]*(dofsPerNode-1)); |
| 127 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[4]+(NumEnt_[0]*(dofsPerNode-1))+(NumEnt_[1]*(dofsPerNode-1))+(NumEnt_[2]*(dofsPerNode-1))+(NumEnt_[3]*(dofsPerNode-1)); |
| 128 |
} else { |
| 129 |
if (nodesMap->getComm()->getRank() == 0) std::cout<<"This should never happen\n"; |
| 130 |
} |
| 131 |
} |
| 132 |
dofsMaps[j] = Xpetra::MapFactory<LO,GO,NO>::Build(Xpetra::UseTpetra,INVALID,dmapEle,0,nodesMap->getComm()); |
| 133 |
} |
| 134 |
} //RGDSW type CoarseOperator |
| 135 |
else if (partition == 1) { |
| 136 |
for (unsigned j = 0;j<dofsPerNode;j++) { |
| 137 |
for (unsigned i = 0; i<nodeEle.size(); i++) { |
| 138 |
//roots |
| 139 |
if (nodeEle[i]<NumEnt_[5]) { |
| 140 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[5]; |
| 141 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[5]; |
| 142 |
} |
| 143 |
else if (NumEnt_[6] !=-1 &&nodeEle[i]>=NumEnt_[5] && nodeEle[i]<NumEnt_[6]+NumEnt_[5]) { |
| 144 |
dofEle[i*dofsPerNode+j] = nodeEle[i]+j*NumEnt_[6]+(dofsPerNode-1)*NumEnt_[5]; |
| 145 |
dmapEle[i] = nodeEle[i]+j*NumEnt_[6]+(dofsPerNode-1)*NumEnt_[5]; |
| 146 |
} |
| 147 |
} |
| 148 |
dofsMaps[j] = Xpetra::MapFactory<LO,GO,NO>::Build(Xpetra::UseTpetra,INVALID,dmapEle,0,nodesMap->getComm()); |
| 149 |
} |
| 150 |
} else if (partition == 2) { |
| 151 |
FROSCH_ASSERT(false,"GDSWStar is not implemented yet!"); |
| 152 |
} |
| 153 |
Teuchos::RCP<Xpetra::Map<LO,GO,NO> > tmpMap = Xpetra::MapFactory<LO,GO,NO>::Build(Xpetra::UseTpetra,INVALID,dofEle,0,nodesMap->getComm()); |
| 154 |
return tmpMap; |
| 155 |
} |
| 156 |
|
| 157 |
template <class SC,class LO,class GO,class NO> |
| 158 |
int IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::buildCoarseSpace(UN dimension, |
| 159 |
UN dofsPerNode, |
| 160 |
ConstXMapPtr nodesMap, |
| 161 |
ConstXMapPtrVecPtr dofsMaps, |
| 162 |
ConstXMultiVectorPtr nullSpaceBasis, |
| 163 |
GOVecPtr dirichletBoundaryDofs, |
| 164 |
ConstXMultiVectorPtr nodeList) |
| 165 |
{ |
| 166 |
FROSCH_DETAILTIMER_START_LEVELID(buildCoarseSpaceTime,"IPOUHarmonicCoarseOperator::buildCoarseSpace"); |
| 167 |
FROSCH_ASSERT(dofsMaps.size()==dofsPerNode,"dofsMaps.size()!=dofsPerNode"); |
| 168 |
|
| 169 |
// Das könnte man noch ändern |
| 170 |
// Todo: Check the lengths of the vectors against NumberOfBlocks_ |
| 171 |
return resetCoarseSpaceBlock(this->NumberOfBlocks_,dimension,dofsPerNode,nodesMap,dofsMaps,nullSpaceBasis,dirichletBoundaryDofs,nodeList); |
| 172 |
} |
| 173 |
|
| 174 |
template <class SC,class LO,class GO,class NO> |
| 175 |
int IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::buildCoarseSpace(UN dimension, |
| 176 |
UNVecPtr dofsPerNodeVec, |
| 177 |
ConstXMapPtrVecPtr repeatedNodesMapVec, |
| 178 |
ConstXMapPtrVecPtr2D repeatedDofMapsVec, |
| 179 |
ConstXMultiVectorPtrVecPtr nullSpaceBasisVec, |
| 180 |
GOVecPtr2D dirichletBoundaryDofsVec, |
| 181 |
ConstXMultiVectorPtrVecPtr nodeListVec) |
| 182 |
{ |
| 183 |
FROSCH_DETAILTIMER_START_LEVELID(buildCoarseSpaceTime,"IPOUHarmonicCoarseOperator::buildCoarseSpace"); |
| 184 |
|
| 185 |
UN TotalNumberOfBlocks = repeatedNodesMapVec.size(); |
| 186 |
|
| 187 |
FROSCH_ASSERT(dofsPerNodeVec.size()==TotalNumberOfBlocks,"dofsPerNodeVec.size()!=TotalNumberOfBlocks"); |
| 188 |
FROSCH_ASSERT(repeatedDofMapsVec.size()==TotalNumberOfBlocks,"repeatedDofMapsVec.size()!=TotalNumberOfBlocks"); |
| 189 |
FROSCH_ASSERT(nullSpaceBasisVec.size()==TotalNumberOfBlocks,"nullSpaceBasisVec.size()!=TotalNumberOfBlocks"); |
| 190 |
FROSCH_ASSERT(dirichletBoundaryDofsVec.size()==TotalNumberOfBlocks,"dirichletBoundaryDofsVec.size()!=TotalNumberOfBlocks"); |
| 191 |
FROSCH_ASSERT(nodeListVec.size()==TotalNumberOfBlocks,"nodeListVec.size()!=TotalNumberOfBlocks"); |
| 192 |
|
| 193 |
// Todo: Move this to a function in HarmonicCoarseOperator at some point |
| 194 |
for (UN i=0; i<TotalNumberOfBlocks; i++) { |
| 195 |
FROSCH_ASSERT(!repeatedNodesMapVec[i].is_null(),"repeatedNodesMapVec[i].is_null()"); |
| 196 |
FROSCH_ASSERT(!repeatedDofMapsVec[i].is_null(),"repeatedDofMapsVec[i].is_null()"); |
| 197 |
FROSCH_ASSERT(!nullSpaceBasisVec[i].is_null(),"nullSpaceBasisVec[i].is_null()"); |
| 198 |
|
| 199 |
resetCoarseSpaceBlock(this->NumberOfBlocks_, |
| 200 |
dimension, |
| 201 |
dofsPerNodeVec[i], |
| 202 |
repeatedNodesMapVec[i], |
| 203 |
repeatedDofMapsVec[i], |
| 204 |
nullSpaceBasisVec[i], |
| 205 |
dirichletBoundaryDofsVec[i], |
| 206 |
nodeListVec[i]); |
| 207 |
} |
| 208 |
return 0; |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
template <class SC,class LO,class GO,class NO> |
| 213 |
int IPOUHarmonicCoarseOperator<SC,LO,GO,NO>::resetCoarseSpaceBlock(UN blockId, |
| 214 |
UN dimension, |
| 215 |
UN dofsPerNode, |
| 216 |
ConstXMapPtr nodesMap, |
| 217 |
ConstXMapPtrVecPtr dofsMaps, |
| 218 |
ConstXMultiVectorPtr nullSpaceBasis, |
| 219 |
GOVecPtr dirichletBoundaryDofs, |
| 220 |
ConstXMultiVectorPtr nodeList) |
| 221 |
{ |
| 222 |
FROSCH_DETAILTIMER_START_LEVELID(resetCoarseSpaceBlockTime,"IPOUHarmonicCoarseOperator::resetCoarseSpaceBlock"); |
| 223 |
FROSCH_ASSERT(dofsMaps.size()==dofsPerNode,"dofsMaps.size()!=dofsPerNode"); |
| 224 |
FROSCH_ASSERT(blockId<=this->NumberOfBlocks_,"Block does not exist yet and can therefore not be reset ("+to_string(blockId)+", "+to_string(this->NumberOfBlocks_)+")."); |
| 225 |
|
| 226 |
// Process the parameter list |
| 227 |
stringstream blockIdStringstream; |
| 228 |
blockIdStringstream << blockId+1; |
| 229 |
string blockIdString = blockIdStringstream.str(); |
| 230 |
RCP<ParameterList> coarseSpaceList = sublist(sublist(this->ParameterList_,"Blocks"),blockIdString.c_str()); |
| 231 |
|
| 232 |
Verbosity verbosity = All; |
| 233 |
if (!coarseSpaceList->get("Verbosity","All").compare("None")) { |
| 234 |
verbosity = None; |
| 235 |
} else if (!coarseSpaceList->get("Verbosity","All").compare("All")) { |
| 236 |
verbosity = All; |
| 237 |
} else { |
| 238 |
FROSCH_ASSERT(false,"FROSch::IPOUHarmonicCoarseOperator: Specify a valid verbosity level."); |
| 239 |
} |
| 240 |
|
| 241 |
bool useForCoarseSpace = coarseSpaceList->get("Use For Coarse Space",true); |
| 242 |
|
| 243 |
if (useForCoarseSpace) { |
| 244 |
this->GammaDofs_.resize(this->GammaDofs_.size()+1); |
| 245 |
this->IDofs_.resize(this->IDofs_.size()+1); |
| 246 |
this->InterfaceCoarseSpaces_.resize(this->InterfaceCoarseSpaces_.size()+1); |
| 247 |
this->DofsMaps_.resize(this->DofsMaps_.size()+1); |
| 248 |
this->DofsPerNode_.resize(this->DofsPerNode_.size()+1); |
| 249 |
this->NumberOfBlocks_++; |
| 250 |
|
| 251 |
if (this->Verbose_) { |
| 252 |
cout |
| 253 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 254 |
<< setw(89) << "-----------------------------------------------------------------------------------------" |
| 255 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 256 |
<< "| " |
| 257 |
<< left << setw(74) << "IPOUHarmonicCoarseOperator " << right << setw(8) << "(Level " << setw(2) << this->LevelID_ << ")" |
| 258 |
<< " |" |
| 259 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 260 |
<< setw(89) << "=========================================================================================" |
| 261 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 262 |
<< "| " << left << setw(41) << "Block" << right |
| 263 |
<< " | " << setw(41) << blockId |
| 264 |
<< " |" |
| 265 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 266 |
<< "| " << left << setw(41) << "Spatial dimensions" << right |
| 267 |
<< " | " << setw(41) << dimension |
| 268 |
<< " |" |
| 269 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 270 |
<< "| " << left << setw(41) << "Number of degrees of freedom per node" << right |
| 271 |
<< " | " << setw(41) << dofsPerNode |
| 272 |
<< " |" |
| 273 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 274 |
<< "| " << left << setw(41) << "Interface partition of unity type" << right |
| 275 |
<< " | " << setw(41) << coarseSpaceList->sublist("InterfacePartitionOfUnity").get("Type","GDSW") |
| 276 |
<< " |" |
| 277 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 278 |
<< "| " << left << setw(41) << "Dimension of the null space" << right |
| 279 |
<< " | " << setw(41) << nullSpaceBasis->getNumVectors() |
| 280 |
<< " |" |
| 281 |
<< "\n" << setw(FROSCH_OUTPUT_INDENT) << " " |
| 282 |
<< setw(89) << "-----------------------------------------------------------------------------------------" |
| 283 |
<< endl; |
| 284 |
} |
| 285 |
|
| 286 |
this->DofsMaps_[blockId] = dofsMaps; |
| 287 |
this->DofsPerNode_[blockId] = dofsPerNode; |
| 288 |
|
| 289 |
// Compute Interface Partition of Unity |
| 290 |
// AH: Can we get rid of the PartitionType_? |
| 291 |
InterfacePartitionOfUnityPtr interfacePartitionOfUnity; |
| 292 |
if (!coarseSpaceList->sublist("InterfacePartitionOfUnity").get("Type","GDSW").compare("GDSW")) { |
| 293 |
coarseSpaceList->sublist("InterfacePartitionOfUnity").sublist("GDSW").set("Test Unconnected Interface",this->ParameterList_->get("Test Unconnected Interface",true)); |
| 294 |
interfacePartitionOfUnity = InterfacePartitionOfUnityPtr(new GDSWInterfacePartitionOfUnity<SC,LO,GO,NO>(this->MpiComm_,this->SerialComm_,dimension,this->DofsPerNode_[blockId],nodesMap,this->DofsMaps_[blockId],sublist(sublist(coarseSpaceList,"InterfacePartitionOfUnity"),"GDSW"),verbosity,this->LevelID_)); |
| 295 |
this->PartitionType_ = 0; |
| 296 |
} else if (!coarseSpaceList->sublist("InterfacePartitionOfUnity").get("Type","GDSW").compare("GDSWStar")) { |
| 297 |
coarseSpaceList->sublist("InterfacePartitionOfUnity").sublist("GDSWStar").set("Test Unconnected Interface",this->ParameterList_->get("Test Unconnected Interface",true)); |
| 298 |
interfacePartitionOfUnity = InterfacePartitionOfUnityPtr(new GDSWStarInterfacePartitionOfUnity<SC,LO,GO,NO>(this->MpiComm_,this->SerialComm_,dimension,this->DofsPerNode_[blockId],nodesMap,this->DofsMaps_[blockId],sublist(sublist(coarseSpaceList,"InterfacePartitionOfUnity"),"GDSWStar"),verbosity,this->LevelID_)); |
| 299 |
this->PartitionType_ = 2; |
| 300 |
} else if (!coarseSpaceList->sublist("InterfacePartitionOfUnity").get("Type","GDSW").compare("RGDSW")) { |
| 301 |
coarseSpaceList->sublist("InterfacePartitionOfUnity").sublist("RGDSW").set("Test Unconnected Interface",this->ParameterList_->get("Test Unconnected Interface",true)); |
| 302 |
interfacePartitionOfUnity = InterfacePartitionOfUnityPtr(new RGDSWInterfacePartitionOfUnity<SC,LO,GO,NO>(this->MpiComm_,this->SerialComm_,dimension,this->DofsPerNode_[blockId],nodesMap,this->DofsMaps_[blockId],sublist(sublist(coarseSpaceList,"InterfacePartitionOfUnity"),"RGDSW"),verbosity,this->LevelID_)); |
| 303 |
this->PartitionType_ = 1; |
| 304 |
} else { |
| 305 |
FROSCH_ASSERT(false,"InterfacePartitionOfUnity Type is unknown."); |
| 306 |
} |
| 307 |
|
| 308 |
// Extract the interface and the interior from the DDInterface stored in the Interface Partition of Unity object |
| 309 |
InterfaceEntityPtr interface = interfacePartitionOfUnity->getDDInterface()->getInterface()->getEntity(0); |
| 310 |
InterfaceEntityPtr interior = interfacePartitionOfUnity->getDDInterface()->getInterior()->getEntity(0); |
| 311 |
|
| 312 |
// Check whether the interface is empty. If so, we use a ConstantPartitionOfUnity instead, because we assume that the subdomains are decoupled. |
| 313 |
if (interface->getNumNodes()==0) { |
| 314 |
FROSCH_NOTIFICATION("FROSch::IPOUHarmonicCoarseOperator",this->Verbose_,"No interface found => A Constant Partition of Unity will be used instead."); |
| 315 |
coarseSpaceList->sublist("InterfacePartitionOfUnity").sublist("RGDSW").set("Test Unconnected Interface",this->ParameterList_->get("Test Unconnected Interface",true)); |
| 316 |
PartitionOfUnity_ = PartitionOfUnityPtr(new ConstantPartitionOfUnity<SC,LO,GO,NO>(this->MpiComm_, |
| 317 |
this->SerialComm_, |
| 318 |
dimension, |
| 319 |
this->DofsPerNode_[blockId], |
| 320 |
nodesMap, |
| 321 |
this->DofsMaps_[blockId], |
| 322 |
sublist(sublist(coarseSpaceList,"PartitionOfUnity"),"Constant"), |
| 323 |
verbosity, |
| 324 |
this->LevelID_, |
| 325 |
interfacePartitionOfUnity->getDDInterfaceNonConst())); |
| 326 |
|
| 327 |
if (this->ParameterList_->get("Remove Dirichlet Nodes",true)) PartitionOfUnity_->removeDirichletNodes(dirichletBoundaryDofs()); |
| 328 |
|
| 329 |
interface = interior; |
| 330 |
|
| 331 |
// Construct Interface and Interior index sets |
| 332 |
this->GammaDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interface->getNumNodes()); |
| 333 |
this->IDofs_[blockId] = LOVecPtr(0); |
| 334 |
for (UN k=0; k<this->DofsPerNode_[blockId]; k++) { |
| 335 |
for (UN i=0; i<interface->getNumNodes(); i++) { |
| 336 |
this->GammaDofs_[blockId][interface->getGammaDofID(i,k)] = interface->getLocalDofID(i,k); |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 340 |
PartitionOfUnity_->computePartitionOfUnity(nodeList); |
| 341 |
} else { |
| 342 |
if (this->ParameterList_->get("Remove Dirichlet Nodes",true)) interfacePartitionOfUnity->removeDirichletNodes(dirichletBoundaryDofs(),nodeList); |
| 343 |
interfacePartitionOfUnity->sortInterface(this->K_,nodeList); |
| 344 |
|
| 345 |
// Construct Interface and Interior index sets |
| 346 |
this->GammaDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interface->getNumNodes()); |
| 347 |
this->IDofs_[blockId] = LOVecPtr(this->DofsPerNode_[blockId]*interior->getNumNodes()); |
| 348 |
for (UN k=0; k<this->DofsPerNode_[blockId]; k++) { |
| 349 |
for (UN i=0; i<interface->getNumNodes(); i++) { |
| 350 |
this->GammaDofs_[blockId][interface->getGammaDofID(i,k)] = interface->getLocalDofID(i,k); |
| 351 |
} |
| 352 |
for (UN i=0; i<interior->getNumNodes(); i++) { |
| 353 |
this->IDofs_[blockId][interior->getGammaDofID(i,k)] = interior->getLocalDofID(i,k); |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
interfacePartitionOfUnity->computePartitionOfUnity(nodeList); |
| 358 |
PartitionOfUnity_ = interfacePartitionOfUnity; |
| 359 |
} |
| 360 |
|
| 361 |
// Construct local Interface nullspace basis (in case the interface was empty before, it was replaced by the interior. Therfore, this should be correct as well) |
| 362 |
ConstXMapPtr nullSpaceBasisMap = nullSpaceBasis->getMap(); |
| 363 |
XMapPtr serialInterfaceMap = MapFactory<LO,GO,NO>::Build(nullSpaceBasisMap->lib(),this->GammaDofs_[blockId].size(),this->GammaDofs_[blockId].size(),0,this->SerialComm_); |
| 364 |
XMultiVectorPtr interfaceNullspaceBasis = MultiVectorFactory<SC,LO,GO,NO>::Build(serialInterfaceMap,nullSpaceBasis->getNumVectors()); |
| 365 |
for (UN i=0; i<nullSpaceBasis->getNumVectors(); i++) { |
| 366 |
SCVecPtr interfaceNullspaceBasisData = interfaceNullspaceBasis->getDataNonConst(i); |
| 367 |
ConstSCVecPtr nullSpaceBasisData = nullSpaceBasis->getData(i); |
| 368 |
for (UN k=0; k<this->DofsPerNode_[blockId]; k++) { |
| 369 |
for (UN j=0; j<interface->getNumNodes(); j++) { |
| 370 |
interfaceNullspaceBasisData[interface->getGammaDofID(j,k)] = nullSpaceBasisData[nullSpaceBasisMap->getLocalElement(interface->getGlobalDofID(j,k))]; |
| 371 |
} |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
PartitionOfUnity_->assembledPartitionOfUnityMaps(); |
| 376 |
|
| 377 |
// This is setup for the multilevel variant. Can this be moved inside the following if block? |
| 378 |
this->CoarseDofsPerNode_ = nullSpaceBasis->getNumVectors(); |
| 379 |
|
| 380 |
this->KRowMap_ = PartitionOfUnity_->getAssembledPartitionOfUnityMap(); |
| 381 |
NumEnt_ = interfacePartitionOfUnity->getDDInterface()->getNumEnt(); |
| 382 |
|
| 383 |
if (!this->DistributionList_->get("Type","linear").compare("ZoltanDual")) { |
| 384 |
FROSCH_ASSERT(this->NumberOfBlocks_==1,"Distribution Type ZoltanDual only works for one Block"); |
| 385 |
Teuchos::RCP<DDInterface<SC,LO,GO,NO> > theInterface =Teuchos::rcp_const_cast<DDInterface<SC,LO,GO,NO> >(interfacePartitionOfUnity->getDDInterface()); |
| 386 |
this->buildGlobalGraph(theInterface); |
| 387 |
int dim = dimension; |
| 388 |
sublist(this->ParameterList_,"CoarseSolver")->set("Dimension",dim); |
| 389 |
} |
| 390 |
|
| 391 |
// Build local basis |
| 392 |
LocalPartitionOfUnityBasis_ = LocalPartitionOfUnityBasisPtr(new LocalPartitionOfUnityBasis<SC,LO,GO,NO>(this->MpiComm_,this->SerialComm_,this->DofsPerNode_[blockId],sublist(coarseSpaceList,"LocalPartitionOfUnityBasis"),interfaceNullspaceBasis.getConst(),PartitionOfUnity_->getLocalPartitionOfUnity(),PartitionOfUnity_->getPartitionOfUnityMaps())); // sublist(coarseSpaceList,"LocalPartitionOfUnityBasis") testen |
| 393 |
|
| 394 |
LocalPartitionOfUnityBasis_->buildLocalPartitionOfUnityBasis(); |
| 395 |
|
| 396 |
this->InterfaceCoarseSpaces_[blockId] = LocalPartitionOfUnityBasis_->getLocalPartitionOfUnitySpace(); |
| 397 |
FROSCH_NOTIFICATION("FROSch::IPOUHarmonicCoarseOperator",this->Verbose_,"Need to build block coarse sizes for use in MueLu nullspace. This is not performed here yet."); |
| 398 |
//if (this->Verbose_) {RCP<FancyOStream> fancy = fancyOStream(rcpFromRef(cout)); this->MVPhiGamma_[blockId]->describe(*fancy,VERB_EXTREME);} |
| 399 |
} |
| 400 |
|
| 401 |
return 0; |
| 402 |
} |
| 403 |
|
| 404 |
} |
| 405 |
|
| 406 |
#endif |