mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: lduPrimitiveMesh: incorrect upper-triangular ordering
This commit is contained in:
@ -29,6 +29,14 @@ License
|
|||||||
#include "procLduInterface.H"
|
#include "procLduInterface.H"
|
||||||
#include "cyclicLduInterface.H"
|
#include "cyclicLduInterface.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(LUscalarMatrix, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix)
|
Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix)
|
||||||
@ -134,8 +142,39 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
convert(ldum, interfaceCoeffs, interfaces);
|
convert(ldum, interfaceCoeffs, interfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master(comm_))
|
if (debug && Pstream::master(comm_))
|
||||||
{
|
{
|
||||||
|
label nRows = n();
|
||||||
|
label nColumns = m();
|
||||||
|
|
||||||
|
Pout<< "LUscalarMatrix : size:" << nRows << endl;
|
||||||
|
for (label rowI = 0; rowI < nRows; rowI++)
|
||||||
|
{
|
||||||
|
const scalar* row = operator[](rowI);
|
||||||
|
|
||||||
|
Pout<< "cell:" << rowI << " diagCoeff:" << row[rowI] << endl;
|
||||||
|
|
||||||
|
Pout<< " connects to upper cells :";
|
||||||
|
for (label columnI = rowI+1; columnI < nColumns; columnI++)
|
||||||
|
{
|
||||||
|
if (mag(row[columnI]) > SMALL)
|
||||||
|
{
|
||||||
|
Pout<< ' ' << columnI << " (coeff:" << row[columnI] << ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pout<< endl;
|
||||||
|
Pout<< " connects to lower cells :";
|
||||||
|
for (label columnI = 0; columnI < rowI; columnI++)
|
||||||
|
{
|
||||||
|
if (mag(row[columnI]) > SMALL)
|
||||||
|
{
|
||||||
|
Pout<< ' ' << columnI << " (coeff:" << row[columnI] << ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Pout<< endl;
|
||||||
|
}
|
||||||
|
Pout<< endl;
|
||||||
|
|
||||||
pivotIndices_.setSize(n());
|
pivotIndices_.setSize(n());
|
||||||
LUDecompose(*this, pivotIndices_);
|
LUDecompose(*this, pivotIndices_);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,6 +87,9 @@ class LUscalarMatrix
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Declare name of the class and its debug switch
|
||||||
|
ClassName("LUscalarMatrix");
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from scalarSquareMatrix and perform LU decomposition
|
//- Construct from scalarSquareMatrix and perform LU decomposition
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -99,8 +99,20 @@ void Foam::GAMGPreconditioner::precondition
|
|||||||
// Create the smoothers for all levels
|
// Create the smoothers for all levels
|
||||||
PtrList<lduMatrix::smoother> smoothers;
|
PtrList<lduMatrix::smoother> smoothers;
|
||||||
|
|
||||||
|
// Scratch fields if processor-agglomerated coarse level meshes
|
||||||
|
// are bigger than original. Usually not needed
|
||||||
|
scalarField ApsiScratch;
|
||||||
|
scalarField finestCorrectionScratch;
|
||||||
|
|
||||||
// Initialise the above data structures
|
// Initialise the above data structures
|
||||||
initVcycle(coarseCorrFields, coarseSources, smoothers);
|
initVcycle
|
||||||
|
(
|
||||||
|
coarseCorrFields,
|
||||||
|
coarseSources,
|
||||||
|
smoothers,
|
||||||
|
ApsiScratch,
|
||||||
|
finestCorrectionScratch
|
||||||
|
);
|
||||||
|
|
||||||
for (label cycle=0; cycle<nVcycles_; cycle++)
|
for (label cycle=0; cycle<nVcycles_; cycle++)
|
||||||
{
|
{
|
||||||
@ -112,6 +124,14 @@ void Foam::GAMGPreconditioner::precondition
|
|||||||
AwA,
|
AwA,
|
||||||
finestCorrection,
|
finestCorrection,
|
||||||
finestResidual,
|
finestResidual,
|
||||||
|
|
||||||
|
(ApsiScratch.size() ? ApsiScratch : AwA),
|
||||||
|
(
|
||||||
|
finestCorrectionScratch.size()
|
||||||
|
? finestCorrectionScratch
|
||||||
|
: finestCorrection
|
||||||
|
),
|
||||||
|
|
||||||
coarseCorrFields,
|
coarseCorrFields,
|
||||||
coarseSources,
|
coarseSources,
|
||||||
cmpt
|
cmpt
|
||||||
|
|||||||
@ -270,12 +270,19 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
|
|||||||
interfaceLevels_[fineLevelIndex];
|
interfaceLevels_[fineLevelIndex];
|
||||||
|
|
||||||
// Create coarse-level interfaces
|
// Create coarse-level interfaces
|
||||||
|
primitiveInterfaces_.set
|
||||||
|
(
|
||||||
|
fineLevelIndex + 1,
|
||||||
|
new PtrList<const lduInterface>(fineInterfaces.size())
|
||||||
|
);
|
||||||
|
PtrList<const lduInterface>& coarsePrimInterfaces =
|
||||||
|
primitiveInterfaces_[fineLevelIndex + 1];
|
||||||
|
|
||||||
interfaceLevels_.set
|
interfaceLevels_.set
|
||||||
(
|
(
|
||||||
fineLevelIndex + 1,
|
fineLevelIndex + 1,
|
||||||
new lduInterfacePtrsList(fineInterfaces.size())
|
new lduInterfacePtrsList(fineInterfaces.size())
|
||||||
);
|
);
|
||||||
|
|
||||||
lduInterfacePtrsList& coarseInterfaces =
|
lduInterfacePtrsList& coarseInterfaces =
|
||||||
interfaceLevels_[fineLevelIndex + 1];
|
interfaceLevels_[fineLevelIndex + 1];
|
||||||
|
|
||||||
@ -317,7 +324,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
|
|||||||
{
|
{
|
||||||
if (fineInterfaces.set(inti))
|
if (fineInterfaces.set(inti))
|
||||||
{
|
{
|
||||||
coarseInterfaces.set
|
coarsePrimInterfaces.set
|
||||||
(
|
(
|
||||||
inti,
|
inti,
|
||||||
GAMGInterface::New
|
GAMGInterface::New
|
||||||
@ -336,6 +343,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing
|
|||||||
).ptr()
|
).ptr()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
coarseInterfaces.set(inti, &coarsePrimInterfaces[inti]);
|
||||||
coarseInterfaceAddr[inti] = coarseInterfaces[inti].faceCells();
|
coarseInterfaceAddr[inti] = coarseInterfaces[inti].faceCells();
|
||||||
nPatchFaces[inti] = coarseInterfaceAddr[inti].size();
|
nPatchFaces[inti] = coarseInterfaceAddr[inti].size();
|
||||||
patchFineToCoarse[inti] = refCast<const GAMGInterface>
|
patchFineToCoarse[inti] = refCast<const GAMGInterface>
|
||||||
@ -408,13 +416,13 @@ void Foam::GAMGAgglomeration::gatherMeshes
|
|||||||
// Combine all addressing
|
// Combine all addressing
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Pout<< "Own Mesh " << myMesh.lduAddr().size() << endl;
|
//Pout<< "Own Mesh " << myMesh.lduAddr().size() << endl;
|
||||||
forAll(otherMeshes, i)
|
//forAll(otherMeshes, i)
|
||||||
{
|
//{
|
||||||
Pout<< " otherMesh " << i << " "
|
// Pout<< " otherMesh " << i << " "
|
||||||
<< otherMeshes[i].lduAddr().size()
|
// << otherMeshes[i].lduAddr().size()
|
||||||
<< endl;
|
// << endl;
|
||||||
}
|
//}
|
||||||
|
|
||||||
labelList procFaceOffsets;
|
labelList procFaceOffsets;
|
||||||
|
|
||||||
@ -437,7 +445,7 @@ void Foam::GAMGAgglomeration::gatherMeshes
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Pout<< "** Agglomerated Mesh " << allMesh().info();
|
//Pout<< "** Agglomerated Mesh " << allMesh().info();
|
||||||
}
|
}
|
||||||
|
|
||||||
UPstream::warnComm = oldWarn;
|
UPstream::warnComm = oldWarn;
|
||||||
@ -459,7 +467,6 @@ void Foam::GAMGAgglomeration::procAgglomerateLduAddressing
|
|||||||
<< " havefinemesh:" << meshLevels_.set(levelIndex-1) << endl;
|
<< " havefinemesh:" << meshLevels_.set(levelIndex-1) << endl;
|
||||||
|
|
||||||
const lduMesh& myMesh = meshLevels_[levelIndex-1];
|
const lduMesh& myMesh = meshLevels_[levelIndex-1];
|
||||||
//label meshComm = myMesh.comm();
|
|
||||||
|
|
||||||
Pout<< "my mesh :" << myMesh.info();
|
Pout<< "my mesh :" << myMesh.info();
|
||||||
Pout<< "nCoarseCells :" << nCells_[levelIndex] << endl;
|
Pout<< "nCoarseCells :" << nCells_[levelIndex] << endl;
|
||||||
@ -510,8 +517,6 @@ void Foam::GAMGAgglomeration::procAgglomerateLduAddressing
|
|||||||
// These could only be set on the master procs but it is
|
// These could only be set on the master procs but it is
|
||||||
// quite convenient to also have them on the slaves
|
// quite convenient to also have them on the slaves
|
||||||
procCellOffsets_.set(levelIndex, new labelList(0));
|
procCellOffsets_.set(levelIndex, new labelList(0));
|
||||||
//procRestrictAddressing_.set(levelIndex, new labelField(0));
|
|
||||||
//procFaceRestrictAddressing_.set(levelIndex, new labelList(0));
|
|
||||||
procFaceMap_.set(levelIndex, new labelListList(0));
|
procFaceMap_.set(levelIndex, new labelListList(0));
|
||||||
procBoundaryMap_.set(levelIndex, new labelListList(0));
|
procBoundaryMap_.set(levelIndex, new labelListList(0));
|
||||||
procBoundaryFaceMap_.set(levelIndex, new labelListListList(0));
|
procBoundaryFaceMap_.set(levelIndex, new labelListListList(0));
|
||||||
@ -575,46 +580,16 @@ void Foam::GAMGAgglomeration::procAgglomerateLduAddressing
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const lduPrimitiveMesh& levelMesh = meshLevels_[levelIndex-1];
|
//const lduPrimitiveMesh& levelMesh = meshLevels_[levelIndex-1];
|
||||||
|
//Pout<< "** DONE GAMGAgglomeration:procAgglomerateLduAddressing **"
|
||||||
Pout<< "** DONE GAMGAgglomeration:procAgglomerateLduAddressing **"
|
// << endl;
|
||||||
<< endl;
|
//Pout<< "my mesh:" << levelMesh.info();
|
||||||
Pout<< "my mesh:" << levelMesh.info();
|
//Pout<< "nCoarseCells:" << nCells_[levelIndex] << endl;
|
||||||
Pout<< "nCoarseCells:" << nCells_[levelIndex] << endl;
|
//Pout<< "restrictAddressing_:"
|
||||||
Pout<< "restrictAddressing_:" << restrictAddressing_[levelIndex].size()
|
// << restrictAddressing_[levelIndex].size()
|
||||||
<< " max:" << max(restrictAddressing_[levelIndex]) << endl;
|
// << " max:" << max(restrictAddressing_[levelIndex]) << endl;
|
||||||
//Pout<< "faceRestrictAddressing_:"
|
//Pout<< "** DONE GAMGAgglomeration:procAgglomerateLduAddressing **"
|
||||||
// << faceRestrictAddressing_[levelIndex].size()
|
// << endl;
|
||||||
// << " max:" << max(faceRestrictAddressing_[levelIndex]) << endl;
|
|
||||||
//Pout<< "patchFaceRestrictAddressing_:" << endl;
|
|
||||||
//forAll(patchFaceRestrictAddressing_[levelIndex], patchI)
|
|
||||||
//{
|
|
||||||
// const labelList& map =
|
|
||||||
// patchFaceRestrictAddressing_[levelIndex][patchI];
|
|
||||||
//
|
|
||||||
// if (map.size())
|
|
||||||
// {
|
|
||||||
// Pout<< " patch:" << patchI
|
|
||||||
// << " size:" << map.size()
|
|
||||||
// << " max:" << max(map)
|
|
||||||
// << endl;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//Pout<< "interfaceLevels_:" << endl;
|
|
||||||
//forAll(interfaceLevels_[levelIndex], patchI)
|
|
||||||
//{
|
|
||||||
// if (interfaceLevels_[levelIndex].set(patchI))
|
|
||||||
// {
|
|
||||||
// Pout<< " patch:" << patchI
|
|
||||||
// << " interface:"
|
|
||||||
// << interfaceLevels_[levelIndex][patchI].type()
|
|
||||||
// << " size:"
|
|
||||||
// << interfaceLevels_[levelIndex][patchI].faceCells().size()
|
|
||||||
// << endl;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
Pout<< "** DONE GAMGAgglomeration:procAgglomerateLduAddressing **"
|
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UPstream::warnComm = oldWarn;
|
UPstream::warnComm = oldWarn;
|
||||||
@ -628,14 +603,15 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
const label levelIndex
|
const label levelIndex
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Pout<< "** GAMGAgglomeration:procAgglomerateRestrictAddressing **" << endl;
|
//Pout<< "** GAMGAgglomeration:procAgglomerateRestrictAddressing **"
|
||||||
Pout<< "level:" << levelIndex << endl;
|
// << endl;
|
||||||
Pout<< "procIDs:" << procIDs << endl;
|
//Pout<< "level:" << levelIndex << endl;
|
||||||
Pout<< "myProcNo:" << UPstream::myProcNo(comm) << endl;
|
//Pout<< "procIDs:" << procIDs << endl;
|
||||||
|
//Pout<< "myProcNo:" << UPstream::myProcNo(comm) << endl;
|
||||||
//Pout<< "procCellOffsets_:" << procCellOffsets_[levelIndex] << endl;
|
//Pout<< "procCellOffsets_:" << procCellOffsets_[levelIndex] << endl;
|
||||||
|
|
||||||
//const lduMesh& levelMesh = meshLevel(levelIndex);
|
//const lduMesh& levelMesh = meshLevel(levelIndex);
|
||||||
Pout<< "fine:" << restrictAddressing_[levelIndex].size() << endl;
|
//Pout<< "fine:" << restrictAddressing_[levelIndex].size() << endl;
|
||||||
|
|
||||||
// Collect number of cells
|
// Collect number of cells
|
||||||
labelList nFineCells;
|
labelList nFineCells;
|
||||||
@ -648,7 +624,7 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
);
|
);
|
||||||
//const labelList& offsets = procCellOffsets_[levelIndex];
|
//const labelList& offsets = procCellOffsets_[levelIndex];
|
||||||
//Pout<< "offsets:" << offsets << endl;
|
//Pout<< "offsets:" << offsets << endl;
|
||||||
Pout<< "nFineCells:" << nFineCells << endl;
|
//Pout<< "nFineCells:" << nFineCells << endl;
|
||||||
|
|
||||||
labelList offsets(nFineCells.size()+1);
|
labelList offsets(nFineCells.size()+1);
|
||||||
{
|
{
|
||||||
@ -658,10 +634,10 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
offsets[i+1] = offsets[i] + nFineCells[i];
|
offsets[i+1] = offsets[i] + nFineCells[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pout<< "offsets:" << offsets << endl;
|
//Pout<< "offsets:" << offsets << endl;
|
||||||
|
|
||||||
// Combine and renumber nCoarseCells
|
// Combine and renumber nCoarseCells
|
||||||
Pout<< "Starting nCells_ ..." << endl;
|
//Pout<< "Starting nCells_ ..." << endl;
|
||||||
labelList nCoarseCells;
|
labelList nCoarseCells;
|
||||||
gatherList
|
gatherList
|
||||||
(
|
(
|
||||||
@ -672,7 +648,7 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
);
|
);
|
||||||
|
|
||||||
// (cell)restrictAddressing
|
// (cell)restrictAddressing
|
||||||
Pout<< "Starting restrictAddressing_ ..." << endl;
|
//Pout<< "Starting restrictAddressing_ ..." << endl;
|
||||||
const globalIndex cellOffsetter(offsets);
|
const globalIndex cellOffsetter(offsets);
|
||||||
|
|
||||||
labelList procRestrictAddressing;
|
labelList procRestrictAddressing;
|
||||||
@ -695,12 +671,13 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
|
coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
label nOldCoarseCells = nCells_[levelIndex];
|
//label nOldCoarseCells = nCells_[levelIndex];
|
||||||
|
|
||||||
nCells_[levelIndex] = coarseCellOffsets.last();
|
nCells_[levelIndex] = coarseCellOffsets.last();
|
||||||
Pout<< "Finished nCoarseCells_ ..."
|
|
||||||
<< " was:" << nOldCoarseCells
|
//Pout<< "Finished nCoarseCells_ ..."
|
||||||
<< " now:" << nCells_[levelIndex] << endl;
|
// << " was:" << nOldCoarseCells
|
||||||
|
// << " now:" << nCells_[levelIndex] << endl;
|
||||||
|
|
||||||
|
|
||||||
// Renumber consecutively
|
// Renumber consecutively
|
||||||
@ -718,17 +695,17 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "coarseCellOffsets:" << coarseCellOffsets << endl;
|
//Pout<< "coarseCellOffsets:" << coarseCellOffsets << endl;
|
||||||
restrictAddressing_[levelIndex].transfer(procRestrictAddressing);
|
restrictAddressing_[levelIndex].transfer(procRestrictAddressing);
|
||||||
Pout<< "restrictAddressing_:"
|
//Pout<< "restrictAddressing_:"
|
||||||
<< restrictAddressing_[levelIndex].size()
|
// << restrictAddressing_[levelIndex].size()
|
||||||
<< " min:" << min(restrictAddressing_[levelIndex])
|
// << " min:" << min(restrictAddressing_[levelIndex])
|
||||||
<< " max:" << max(restrictAddressing_[levelIndex])
|
// << " max:" << max(restrictAddressing_[levelIndex])
|
||||||
<< endl;
|
// << endl;
|
||||||
Pout<< "Finished restrictAddressing_ ..." << endl;
|
//Pout<< "Finished restrictAddressing_ ..." << endl;
|
||||||
}
|
}
|
||||||
Pout<< "** DONE GAMGAgglomeration:procAgglomerateRestrictAddressing **"
|
//Pout<< "** DONE GAMGAgglomeration:procAgglomerateRestrictAddressing **"
|
||||||
<< endl;
|
// << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -777,4 +754,55 @@ void Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::GAMGAgglomeration::calculateRegionMaster
|
||||||
|
(
|
||||||
|
const label comm,
|
||||||
|
const labelList& procAgglomMap,
|
||||||
|
labelList& masterProcs,
|
||||||
|
List<int>& agglomProcIDs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Determine the master processors
|
||||||
|
Map<label> agglomToMaster(procAgglomMap.size());
|
||||||
|
|
||||||
|
forAll(procAgglomMap, procI)
|
||||||
|
{
|
||||||
|
label coarseI = procAgglomMap[procI];
|
||||||
|
|
||||||
|
Map<label>::iterator fnd = agglomToMaster.find(coarseI);
|
||||||
|
if (fnd == agglomToMaster.end())
|
||||||
|
{
|
||||||
|
agglomToMaster.insert(coarseI, procI);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fnd() = min(fnd(), procI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
masterProcs.setSize(agglomToMaster.size());
|
||||||
|
forAllConstIter(Map<label>, agglomToMaster, iter)
|
||||||
|
{
|
||||||
|
masterProcs[iter.key()] = iter();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Collect all the processors in my agglomeration
|
||||||
|
label myProcID = Pstream::myProcNo(comm);
|
||||||
|
label myAgglom = procAgglomMap[myProcID];
|
||||||
|
|
||||||
|
// Get all processors agglomerating to the same coarse
|
||||||
|
// processor
|
||||||
|
agglomProcIDs = findIndices(procAgglomMap, myAgglom);
|
||||||
|
// Make sure the master is the first element.
|
||||||
|
label index = findIndex
|
||||||
|
(
|
||||||
|
agglomProcIDs,
|
||||||
|
agglomToMaster[myAgglom]
|
||||||
|
);
|
||||||
|
Swap(agglomProcIDs[0], agglomProcIDs[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -52,6 +52,7 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
|
|||||||
nPatchFaces_.setSize(nCreatedLevels);
|
nPatchFaces_.setSize(nCreatedLevels);
|
||||||
patchFaceRestrictAddressing_.setSize(nCreatedLevels);
|
patchFaceRestrictAddressing_.setSize(nCreatedLevels);
|
||||||
meshLevels_.setSize(nCreatedLevels);
|
meshLevels_.setSize(nCreatedLevels);
|
||||||
|
primitiveInterfaces_.setSize(nCreatedLevels + 1);
|
||||||
interfaceLevels_.setSize(nCreatedLevels + 1);
|
interfaceLevels_.setSize(nCreatedLevels + 1);
|
||||||
|
|
||||||
// Have procCommunicator_ always, even if not procAgglomerating
|
// Have procCommunicator_ always, even if not procAgglomerating
|
||||||
@ -62,9 +63,6 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
|
|||||||
<< " to " << nCreatedLevels << " levels" << endl;
|
<< " to " << nCreatedLevels << " levels" << endl;
|
||||||
procAgglomMap_.setSize(nCreatedLevels);
|
procAgglomMap_.setSize(nCreatedLevels);
|
||||||
agglomProcIDs_.setSize(nCreatedLevels);
|
agglomProcIDs_.setSize(nCreatedLevels);
|
||||||
//procMeshLevels_.setSize(nCreatedLevels);
|
|
||||||
//procRestrictAddressing_.setSize(nCreatedLevels);
|
|
||||||
//procFaceRestrictAddressing_.setSize(nCreatedLevels);
|
|
||||||
procCellOffsets_.setSize(nCreatedLevels);
|
procCellOffsets_.setSize(nCreatedLevels);
|
||||||
procFaceMap_.setSize(nCreatedLevels);
|
procFaceMap_.setSize(nCreatedLevels);
|
||||||
procBoundaryMap_.setSize(nCreatedLevels);
|
procBoundaryMap_.setSize(nCreatedLevels);
|
||||||
@ -165,60 +163,34 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
|
|||||||
|
|
||||||
// Processor restriction map: per processor the coarse processor
|
// Processor restriction map: per processor the coarse processor
|
||||||
labelList procAgglomMap(UPstream::nProcs(levelComm));
|
labelList procAgglomMap(UPstream::nProcs(levelComm));
|
||||||
|
{
|
||||||
|
label half = (procAgglomMap.size()+1)/2;
|
||||||
|
for (label i = 0; i < half; i++)
|
||||||
|
{
|
||||||
|
procAgglomMap[i] = 0;
|
||||||
|
}
|
||||||
|
for (label i = half; i < procAgglomMap.size(); i++)
|
||||||
|
{
|
||||||
|
procAgglomMap[i] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Master processor
|
// Master processor
|
||||||
labelList masterProcs;
|
labelList masterProcs;
|
||||||
// Local processors that agglomerate. agglomProcIDs[0] is in
|
// Local processors that agglomerate. agglomProcIDs[0] is in
|
||||||
// masterProc.
|
// masterProc.
|
||||||
List<int> agglomProcIDs;
|
List<int> agglomProcIDs;
|
||||||
|
calculateRegionMaster
|
||||||
|
(
|
||||||
|
levelComm,
|
||||||
|
procAgglomMap,
|
||||||
|
masterProcs,
|
||||||
|
agglomProcIDs
|
||||||
|
);
|
||||||
|
|
||||||
{
|
|
||||||
procAgglomMap[0] = 0;
|
|
||||||
procAgglomMap[1] = 0;
|
|
||||||
procAgglomMap[2] = 1;
|
|
||||||
//procAgglomMap[3] = 1;
|
|
||||||
|
|
||||||
// Determine the master processors
|
|
||||||
Map<label> agglomToMaster(procAgglomMap.size());
|
|
||||||
|
|
||||||
forAll(procAgglomMap, procI)
|
|
||||||
{
|
|
||||||
label coarseI = procAgglomMap[procI];
|
|
||||||
|
|
||||||
Map<label>::iterator fnd = agglomToMaster.find(coarseI);
|
|
||||||
if (fnd == agglomToMaster.end())
|
|
||||||
{
|
|
||||||
agglomToMaster.insert(coarseI, procI);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fnd() = max(fnd(), procI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
masterProcs.setSize(agglomToMaster.size());
|
|
||||||
forAllConstIter(Map<label>, agglomToMaster, iter)
|
|
||||||
{
|
|
||||||
masterProcs[iter.key()] = iter();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Collect all the processors in my agglomeration
|
|
||||||
label myProcID = Pstream::myProcNo(levelComm);
|
|
||||||
label myAgglom = procAgglomMap[myProcID];
|
|
||||||
|
|
||||||
// Get all processors agglomerating to the same coarse
|
|
||||||
// processor
|
|
||||||
agglomProcIDs = findIndices(procAgglomMap, myAgglom);
|
|
||||||
// Make sure the master is the first element.
|
|
||||||
label index = findIndex
|
|
||||||
(
|
|
||||||
agglomProcIDs,
|
|
||||||
agglomToMaster[myAgglom]
|
|
||||||
);
|
|
||||||
Swap(agglomProcIDs[0], agglomProcIDs[index]);
|
|
||||||
}
|
|
||||||
Pout<< "procAgglomMap:" << procAgglomMap << endl;
|
Pout<< "procAgglomMap:" << procAgglomMap << endl;
|
||||||
Pout<< "agglomProcIDs:" << agglomProcIDs << endl;
|
Pout<< "agglomProcIDs:" << agglomProcIDs << endl;
|
||||||
|
Pout<< "masterProcs:" << masterProcs << endl;
|
||||||
|
|
||||||
|
|
||||||
// Allocate a communicator for the processor-agglomerated matrix
|
// Allocate a communicator for the processor-agglomerated matrix
|
||||||
@ -259,10 +231,6 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
|
|||||||
Pout<< "Starting procAgglomerateRestrictAddressing level:"
|
Pout<< "Starting procAgglomerateRestrictAddressing level:"
|
||||||
<< levelI << endl;
|
<< levelI << endl;
|
||||||
|
|
||||||
//procAgglomMap_.set(levelI, new labelList(procAgglomMap));
|
|
||||||
//agglomProcIDs_.set(levelI, new labelList(agglomProcIDs));
|
|
||||||
//procCommunicator_[levelI] = procAgglomComm;
|
|
||||||
|
|
||||||
procAgglomerateRestrictAddressing
|
procAgglomerateRestrictAddressing
|
||||||
(
|
(
|
||||||
levelComm,
|
levelComm,
|
||||||
@ -335,6 +303,9 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pout<< fineMesh.info() << endl;
|
||||||
|
|
||||||
Pout<< endl;
|
Pout<< endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -445,6 +416,7 @@ Foam::GAMGAgglomeration::GAMGAgglomeration
|
|||||||
patchFaceRestrictAddressing_(maxLevels_),
|
patchFaceRestrictAddressing_(maxLevels_),
|
||||||
|
|
||||||
meshLevels_(maxLevels_),
|
meshLevels_(maxLevels_),
|
||||||
|
primitiveInterfaces_(maxLevels_ + 1),
|
||||||
interfaceLevels_(maxLevels_ + 1)
|
interfaceLevels_(maxLevels_ + 1)
|
||||||
{
|
{
|
||||||
procCommunicator_.setSize(maxLevels_ + 1, -1);
|
procCommunicator_.setSize(maxLevels_ + 1, -1);
|
||||||
@ -454,9 +426,6 @@ Foam::GAMGAgglomeration::GAMGAgglomeration
|
|||||||
<< " levels" << endl;
|
<< " levels" << endl;
|
||||||
procAgglomMap_.setSize(maxLevels_);
|
procAgglomMap_.setSize(maxLevels_);
|
||||||
agglomProcIDs_.setSize(maxLevels_);
|
agglomProcIDs_.setSize(maxLevels_);
|
||||||
//procMeshLevels_.setSize(maxLevels_);
|
|
||||||
//procRestrictAddressing_.setSize(maxLevels_);
|
|
||||||
//procFaceRestrictAddressing_.setSize(maxLevels_);
|
|
||||||
procCellOffsets_.setSize(maxLevels_);
|
procCellOffsets_.setSize(maxLevels_);
|
||||||
procFaceMap_.setSize(maxLevels_);
|
procFaceMap_.setSize(maxLevels_);
|
||||||
procBoundaryMap_.setSize(maxLevels_);
|
procBoundaryMap_.setSize(maxLevels_);
|
||||||
@ -573,42 +542,6 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
|
|||||||
|
|
||||||
Foam::GAMGAgglomeration::~GAMGAgglomeration()
|
Foam::GAMGAgglomeration::~GAMGAgglomeration()
|
||||||
{
|
{
|
||||||
// // Temporary store the user-defined communicators so we can delete them
|
|
||||||
// labelHashSet communicators(meshLevels_.size());
|
|
||||||
// forAll(meshLevels_, leveli)
|
|
||||||
// {
|
|
||||||
// communicators.insert(meshLevels_[leveli].comm());
|
|
||||||
// }
|
|
||||||
//forAll(procMeshLevels_, leveli)
|
|
||||||
//{
|
|
||||||
// if (procMeshLevels_.set(leveli))
|
|
||||||
// {
|
|
||||||
// communicators.insert(procMeshLevels_[leveli].comm());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Pout<< "~GAMGAgglomeration() : current communicators:" << communicators
|
|
||||||
// << endl;
|
|
||||||
|
|
||||||
// Clear the interface storage by hand.
|
|
||||||
// It is a list of ptrs not a PtrList for consistency of the interface
|
|
||||||
for (label leveli=1; leveli<interfaceLevels_.size(); leveli++)
|
|
||||||
{
|
|
||||||
lduInterfacePtrsList& curLevel = interfaceLevels_[leveli];
|
|
||||||
|
|
||||||
forAll(curLevel, i)
|
|
||||||
{
|
|
||||||
if (curLevel.set(i))
|
|
||||||
{
|
|
||||||
delete curLevel(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// forAllConstIter(labelHashSet, communicators, iter)
|
|
||||||
// {
|
|
||||||
// UPstream::freeCommunicator(iter.key());
|
|
||||||
// }
|
|
||||||
forAllReverse(procCommunicator_, i)
|
forAllReverse(procCommunicator_, i)
|
||||||
{
|
{
|
||||||
if (procCommunicator_[i] != -1)
|
if (procCommunicator_[i] != -1)
|
||||||
@ -676,7 +609,8 @@ void Foam::GAMGAgglomeration::clearLevel(const label i)
|
|||||||
faceFlipMap_.set(i, NULL);
|
faceFlipMap_.set(i, NULL);
|
||||||
nPatchFaces_.set(i, NULL);
|
nPatchFaces_.set(i, NULL);
|
||||||
patchFaceRestrictAddressing_.set(i, NULL);
|
patchFaceRestrictAddressing_.set(i, NULL);
|
||||||
interfaceLevels_.set(i, NULL); // TBD: delete storage
|
primitiveInterfaces_.set(i, NULL);
|
||||||
|
interfaceLevels_.set(i, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -706,13 +640,6 @@ bool Foam::GAMGAgglomeration::hasProcMesh(const label leveli) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//const Foam::lduMesh& Foam::GAMGAgglomeration::procMeshLevel
|
|
||||||
//(const label leveli) const
|
|
||||||
//{
|
|
||||||
// return procMeshLevels_[leveli];
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::GAMGAgglomeration::procCommunicator(const label leveli) const
|
Foam::label Foam::GAMGAgglomeration::procCommunicator(const label leveli) const
|
||||||
{
|
{
|
||||||
return procCommunicator_[leveli];
|
return procCommunicator_[leveli];
|
||||||
|
|||||||
@ -62,8 +62,7 @@ class GAMGAgglomeration
|
|||||||
:
|
:
|
||||||
public MeshObject<lduMesh, GAMGAgglomeration>
|
public MeshObject<lduMesh, GAMGAgglomeration>
|
||||||
{
|
{
|
||||||
//protected:
|
protected:
|
||||||
public:
|
|
||||||
|
|
||||||
// Protected data types
|
// Protected data types
|
||||||
|
|
||||||
@ -86,6 +85,7 @@ public:
|
|||||||
//- Whether to agglomerate across processors
|
//- Whether to agglomerate across processors
|
||||||
const bool processorAgglomerate_;
|
const bool processorAgglomerate_;
|
||||||
|
|
||||||
|
|
||||||
//- The number of cells in each level
|
//- The number of cells in each level
|
||||||
labelList nCells_;
|
labelList nCells_;
|
||||||
|
|
||||||
@ -122,8 +122,10 @@ public:
|
|||||||
//- Hierarchy of mesh addressing
|
//- Hierarchy of mesh addressing
|
||||||
PtrList<lduPrimitiveMesh> meshLevels_;
|
PtrList<lduPrimitiveMesh> meshLevels_;
|
||||||
|
|
||||||
//- Hierarchy interfaces.
|
//- Hierarchy of interfaces
|
||||||
// Warning: Needs to be deleted explicitly.
|
PtrList<PtrList<const lduInterface> > primitiveInterfaces_;
|
||||||
|
|
||||||
|
//- Hierarchy of interfaces in lduInterfacePtrsList form
|
||||||
PtrList<lduInterfacePtrsList> interfaceLevels_;
|
PtrList<lduInterfacePtrsList> interfaceLevels_;
|
||||||
|
|
||||||
|
|
||||||
@ -136,13 +138,6 @@ public:
|
|||||||
// the 'master' of the cluster.
|
// the 'master' of the cluster.
|
||||||
mutable PtrList<labelList> agglomProcIDs_;
|
mutable PtrList<labelList> agglomProcIDs_;
|
||||||
|
|
||||||
//- Combined mesh for all processors
|
|
||||||
//mutable PtrList<lduPrimitiveMesh> procMeshLevels_;
|
|
||||||
|
|
||||||
//mutable PtrList<labelField> procRestrictAddressing_;
|
|
||||||
|
|
||||||
//mutable PtrList<labelList> procFaceRestrictAddressing_;
|
|
||||||
|
|
||||||
//- Communicator for given level
|
//- Communicator for given level
|
||||||
mutable labelList procCommunicator_;
|
mutable labelList procCommunicator_;
|
||||||
|
|
||||||
@ -185,17 +180,6 @@ public:
|
|||||||
labelListListList& procBoundaryFaceMap
|
labelListListList& procBoundaryFaceMap
|
||||||
);
|
);
|
||||||
|
|
||||||
////- Gather value from all procIDs onto procIDs[0]
|
|
||||||
//static void gatherList
|
|
||||||
//(
|
|
||||||
// const label comm,
|
|
||||||
// const labelList& procIDs,
|
|
||||||
//
|
|
||||||
// const label myVal,
|
|
||||||
// labelList& vals,
|
|
||||||
// const int tag = Pstream::msgType()
|
|
||||||
//);
|
|
||||||
|
|
||||||
//- Gather value from all procIDs onto procIDs[0]
|
//- Gather value from all procIDs onto procIDs[0]
|
||||||
template<class Type>
|
template<class Type>
|
||||||
static void gatherList
|
static void gatherList
|
||||||
@ -420,7 +404,18 @@ public:
|
|||||||
return processorAgglomerate_;
|
return processorAgglomerate_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Given fine to coarse processor map determine:
|
||||||
|
// - for each coarse processor a master (minimum of the fine
|
||||||
|
// processors)
|
||||||
|
// - for each coarse processor the set of fine processors
|
||||||
|
// (element 0 is the master processor)
|
||||||
|
static void calculateRegionMaster
|
||||||
|
(
|
||||||
|
const label comm,
|
||||||
|
const labelList& procAgglomMap,
|
||||||
|
labelList& masterProcs,
|
||||||
|
List<int>& agglomProcIDs
|
||||||
|
);
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
static void mapField
|
static void mapField
|
||||||
@ -488,18 +483,14 @@ public:
|
|||||||
const labelList& procAgglomMap(const label fineLeveli) const;
|
const labelList& procAgglomMap(const label fineLeveli) const;
|
||||||
|
|
||||||
//- Set of processors to agglomerate. Element 0 is the
|
//- Set of processors to agglomerate. Element 0 is the
|
||||||
// master processor. (local, same only on those processor that
|
// master processor. (local, same only on those processors that
|
||||||
// agglomerate)
|
// agglomerate)
|
||||||
const labelList& agglomProcIDs(const label fineLeveli) const;
|
const labelList& agglomProcIDs(const label fineLeveli) const;
|
||||||
|
|
||||||
//- Check that level has combined mesh
|
//- Check that level has combined mesh
|
||||||
bool hasProcMesh(const label fineLeveli) const;
|
bool hasProcMesh(const label fineLeveli) const;
|
||||||
|
|
||||||
//- Combined mesh
|
//- Communicator for current level or -1
|
||||||
//const lduMesh& procMeshLevel(const label leveli) const;
|
|
||||||
|
|
||||||
//- Communicator for procMesh (stored separately so also works
|
|
||||||
// even if no mesh is stored on this processor)
|
|
||||||
label procCommunicator(const label fineLeveli) const;
|
label procCommunicator(const label fineLeveli) const;
|
||||||
|
|
||||||
//- Mapping from processor to procMesh cells
|
//- Mapping from processor to procMesh cells
|
||||||
|
|||||||
@ -78,22 +78,13 @@ Foam::GAMGSolver::GAMGSolver
|
|||||||
agglomeration_(GAMGAgglomeration::New(matrix_, controlDict_)),
|
agglomeration_(GAMGAgglomeration::New(matrix_, controlDict_)),
|
||||||
|
|
||||||
matrixLevels_(agglomeration_.size()),
|
matrixLevels_(agglomeration_.size()),
|
||||||
interfaceLevels_(agglomeration_.size()),
|
|
||||||
primitiveInterfaceLevels_(agglomeration_.size()),
|
primitiveInterfaceLevels_(agglomeration_.size()),
|
||||||
|
interfaceLevels_(agglomeration_.size()),
|
||||||
interfaceLevelsBouCoeffs_(agglomeration_.size()),
|
interfaceLevelsBouCoeffs_(agglomeration_.size()),
|
||||||
interfaceLevelsIntCoeffs_(agglomeration_.size())
|
interfaceLevelsIntCoeffs_(agglomeration_.size())
|
||||||
{
|
{
|
||||||
readControls();
|
readControls();
|
||||||
|
|
||||||
//if (agglomeration_.processorAgglomerate())
|
|
||||||
//{
|
|
||||||
// procMatrixLevels_.setSize(agglomeration_.size());
|
|
||||||
// procInterfaceLevels_.setSize(agglomeration_.size());
|
|
||||||
// procPrimitiveInterfaces_.setSize(agglomeration_.size());
|
|
||||||
// procInterfaceLevelsBouCoeffs_.setSize(agglomeration_.size());
|
|
||||||
// procInterfaceLevelsIntCoeffs_.setSize(agglomeration_.size());
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (agglomeration_.processorAgglomerate())
|
if (agglomeration_.processorAgglomerate())
|
||||||
{
|
{
|
||||||
forAll(agglomeration_, fineLevelIndex)
|
forAll(agglomeration_, fineLevelIndex)
|
||||||
@ -105,15 +96,9 @@ Foam::GAMGSolver::GAMGSolver
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
// !agglomeration_.hasMeshLevel(fineLevelIndex+1)
|
(fineLevelIndex+1) < agglomeration_.size()
|
||||||
//|| (
|
//&& agglomeration_.procBoundaryMap_.set(fineLevelIndex+1)
|
||||||
// agglomeration_.nCells(fineLevelIndex)
|
&& agglomeration_.hasProcMesh(fineLevelIndex+1)
|
||||||
// != agglomeration_.meshLevel(fineLevelIndex+1).
|
|
||||||
// lduAddr().size()
|
|
||||||
// )
|
|
||||||
|
|
||||||
(fineLevelIndex+1) < agglomeration_.procBoundaryMap_.size()
|
|
||||||
&& agglomeration_.procBoundaryMap_.set(fineLevelIndex+1)
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Pout<< "Level:" << fineLevelIndex
|
Pout<< "Level:" << fineLevelIndex
|
||||||
@ -291,29 +276,33 @@ Foam::GAMGSolver::GAMGSolver
|
|||||||
Pout<< "GAMGSolver :"
|
Pout<< "GAMGSolver :"
|
||||||
<< " coarsestLevel:" << coarsestLevel << endl;
|
<< " coarsestLevel:" << coarsestLevel << endl;
|
||||||
|
|
||||||
const lduMesh& coarsestMesh = matrixLevels_[coarsestLevel].mesh();
|
if (matrixLevels_.set(coarsestLevel))
|
||||||
|
{
|
||||||
|
const lduMesh& coarsestMesh =
|
||||||
|
matrixLevels_[coarsestLevel].mesh();
|
||||||
|
|
||||||
label coarseComm = coarsestMesh.comm();
|
label coarseComm = coarsestMesh.comm();
|
||||||
label oldWarn = UPstream::warnComm;
|
label oldWarn = UPstream::warnComm;
|
||||||
UPstream::warnComm = coarseComm;
|
UPstream::warnComm = coarseComm;
|
||||||
|
|
||||||
Pout<< "Solve direct on coasestmesh (level=" << coarsestLevel
|
Pout<< "Solve direct on coasestmesh (level=" << coarsestLevel
|
||||||
<< ") using communicator " << coarseComm << endl;
|
<< ") using communicator " << coarseComm << endl;
|
||||||
|
|
||||||
coarsestLUMatrixPtr_.set
|
coarsestLUMatrixPtr_.set
|
||||||
(
|
|
||||||
new LUscalarMatrix
|
|
||||||
(
|
(
|
||||||
matrixLevels_[coarsestLevel],
|
new LUscalarMatrix
|
||||||
interfaceLevelsBouCoeffs_[coarsestLevel],
|
(
|
||||||
interfaceLevels_[coarsestLevel]
|
matrixLevels_[coarsestLevel],
|
||||||
)
|
interfaceLevelsBouCoeffs_[coarsestLevel],
|
||||||
);
|
interfaceLevels_[coarsestLevel]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
UPstream::warnComm = oldWarn;
|
UPstream::warnComm = oldWarn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (agglomeration_.processorAgglomerate())
|
//else if (agglomeration_.processorAgglomerate())
|
||||||
{
|
//{
|
||||||
//// Pick a level to processor agglomerate
|
//// Pick a level to processor agglomerate
|
||||||
//label agglomLevel = matrixLevels_.size() - 1;//1;
|
//label agglomLevel = matrixLevels_.size() - 1;//1;
|
||||||
//
|
//
|
||||||
@ -424,7 +413,7 @@ Foam::GAMGSolver::GAMGSolver
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//UPstream::warnComm = oldWarn;
|
//UPstream::warnComm = oldWarn;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -109,9 +109,6 @@ class GAMGSolver
|
|||||||
//- Direct or iteratively solve the coarsest level
|
//- Direct or iteratively solve the coarsest level
|
||||||
bool directSolveCoarsest_;
|
bool directSolveCoarsest_;
|
||||||
|
|
||||||
//- Agglomerate processors
|
|
||||||
bool processorAgglomerate_;
|
|
||||||
|
|
||||||
//- The agglomeration
|
//- The agglomeration
|
||||||
const GAMGAgglomeration& agglomeration_;
|
const GAMGAgglomeration& agglomeration_;
|
||||||
|
|
||||||
@ -119,11 +116,11 @@ class GAMGSolver
|
|||||||
PtrList<lduMatrix> matrixLevels_;
|
PtrList<lduMatrix> matrixLevels_;
|
||||||
|
|
||||||
//- Hierarchy of interfaces.
|
//- Hierarchy of interfaces.
|
||||||
// Warning: Needs to be deleted explicitly.
|
|
||||||
PtrList<lduInterfaceFieldPtrsList> interfaceLevels_;
|
|
||||||
|
|
||||||
PtrList<PtrList<lduInterfaceField> > primitiveInterfaceLevels_;
|
PtrList<PtrList<lduInterfaceField> > primitiveInterfaceLevels_;
|
||||||
|
|
||||||
|
//- Hierarchy of interfaces in lduInterfaceFieldPtrs form
|
||||||
|
PtrList<lduInterfaceFieldPtrsList> interfaceLevels_;
|
||||||
|
|
||||||
//- Hierarchy of interface boundary coefficients
|
//- Hierarchy of interface boundary coefficients
|
||||||
PtrList<FieldField<Field, scalar> > interfaceLevelsBouCoeffs_;
|
PtrList<FieldField<Field, scalar> > interfaceLevelsBouCoeffs_;
|
||||||
|
|
||||||
@ -133,15 +130,6 @@ class GAMGSolver
|
|||||||
//- LU decompsed coarsest matrix
|
//- LU decompsed coarsest matrix
|
||||||
autoPtr<LUscalarMatrix> coarsestLUMatrixPtr_;
|
autoPtr<LUscalarMatrix> coarsestLUMatrixPtr_;
|
||||||
|
|
||||||
//// Processor matrix agglomeration
|
|
||||||
|
|
||||||
////- Combined coarsest level matrix for all processors
|
|
||||||
//PtrList<lduMatrix> procMatrixLevels_;
|
|
||||||
//PtrList<lduInterfaceFieldPtrsList> procInterfaceLevels_;
|
|
||||||
//PtrList<PtrList<lduInterfaceField> > procPrimitiveInterfaces_;
|
|
||||||
//PtrList<FieldField<Field, scalar> > procInterfaceLevelsBouCoeffs_;
|
|
||||||
//PtrList<FieldField<Field, scalar> > procInterfaceLevelsIntCoeffs_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -184,6 +172,7 @@ class GAMGSolver
|
|||||||
(
|
(
|
||||||
const label fineLevelIndex,
|
const label fineLevelIndex,
|
||||||
const lduInterfacePtrsList& coarseMeshInterfaces,
|
const lduInterfacePtrsList& coarseMeshInterfaces,
|
||||||
|
PtrList<lduInterfaceField>& coarsePrimInterfaces,
|
||||||
lduInterfaceFieldPtrsList& coarseInterfaces,
|
lduInterfaceFieldPtrsList& coarseInterfaces,
|
||||||
FieldField<Field, scalar>& coarseInterfaceBouCoeffs,
|
FieldField<Field, scalar>& coarseInterfaceBouCoeffs,
|
||||||
FieldField<Field, scalar>& coarseInterfaceIntCoeffs
|
FieldField<Field, scalar>& coarseInterfaceIntCoeffs
|
||||||
@ -255,7 +244,6 @@ class GAMGSolver
|
|||||||
scalarField& field,
|
scalarField& field,
|
||||||
scalarField& Acf,
|
scalarField& Acf,
|
||||||
const lduMatrix& A,
|
const lduMatrix& A,
|
||||||
const int comm,
|
|
||||||
const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
|
const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaceLevel,
|
const lduInterfaceFieldPtrsList& interfaceLevel,
|
||||||
const scalarField& source,
|
const scalarField& source,
|
||||||
@ -267,7 +255,9 @@ class GAMGSolver
|
|||||||
(
|
(
|
||||||
PtrList<scalarField>& coarseCorrFields,
|
PtrList<scalarField>& coarseCorrFields,
|
||||||
PtrList<scalarField>& coarseSources,
|
PtrList<scalarField>& coarseSources,
|
||||||
PtrList<lduMatrix::smoother>& smoothers
|
PtrList<lduMatrix::smoother>& smoothers,
|
||||||
|
scalarField& scratch1,
|
||||||
|
scalarField& scratch2
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -280,6 +270,10 @@ class GAMGSolver
|
|||||||
scalarField& Apsi,
|
scalarField& Apsi,
|
||||||
scalarField& finestCorrection,
|
scalarField& finestCorrection,
|
||||||
scalarField& finestResidual,
|
scalarField& finestResidual,
|
||||||
|
|
||||||
|
scalarField& scratch1,
|
||||||
|
scalarField& scratch2,
|
||||||
|
|
||||||
PtrList<scalarField>& coarseCorrFields,
|
PtrList<scalarField>& coarseCorrFields,
|
||||||
PtrList<scalarField>& coarseSources,
|
PtrList<scalarField>& coarseSources,
|
||||||
const direction cmpt=0
|
const direction cmpt=0
|
||||||
|
|||||||
@ -46,7 +46,6 @@ void Foam::GAMGSolver::agglomerateMatrix
|
|||||||
const label nCoarseCells = agglomeration_.nCells(fineLevelIndex);
|
const label nCoarseCells = agglomeration_.nCells(fineLevelIndex);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Pout<< "agglomerateMatrix : I have fine mesh:"
|
Pout<< "agglomerateMatrix : I have fine mesh:"
|
||||||
<< fineMatrix.mesh().lduAddr().size()
|
<< fineMatrix.mesh().lduAddr().size()
|
||||||
<< " at fine level:" << fineLevelIndex
|
<< " at fine level:" << fineLevelIndex
|
||||||
@ -82,6 +81,15 @@ void Foam::GAMGSolver::agglomerateMatrix
|
|||||||
interfaceLevel(fineLevelIndex);
|
interfaceLevel(fineLevelIndex);
|
||||||
|
|
||||||
// Create coarse-level interfaces
|
// Create coarse-level interfaces
|
||||||
|
primitiveInterfaceLevels_.set
|
||||||
|
(
|
||||||
|
fineLevelIndex,
|
||||||
|
new PtrList<lduInterfaceField>(fineInterfaces.size())
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<lduInterfaceField>& coarsePrimInterfaces =
|
||||||
|
primitiveInterfaceLevels_[fineLevelIndex];
|
||||||
|
|
||||||
interfaceLevels_.set
|
interfaceLevels_.set
|
||||||
(
|
(
|
||||||
fineLevelIndex,
|
fineLevelIndex,
|
||||||
@ -114,6 +122,7 @@ void Foam::GAMGSolver::agglomerateMatrix
|
|||||||
(
|
(
|
||||||
fineLevelIndex,
|
fineLevelIndex,
|
||||||
coarseMeshInterfaces,
|
coarseMeshInterfaces,
|
||||||
|
coarsePrimInterfaces,
|
||||||
coarseInterfaces,
|
coarseInterfaces,
|
||||||
coarseInterfaceBouCoeffs,
|
coarseInterfaceBouCoeffs,
|
||||||
coarseInterfaceIntCoeffs
|
coarseInterfaceIntCoeffs
|
||||||
@ -192,12 +201,12 @@ void Foam::GAMGSolver::agglomerateMatrix
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//XXXXX
|
|
||||||
// Agglomerate only the interface coefficients.
|
// Agglomerate only the interface coefficients.
|
||||||
void Foam::GAMGSolver::agglomerateInterfaceCoefficients
|
void Foam::GAMGSolver::agglomerateInterfaceCoefficients
|
||||||
(
|
(
|
||||||
const label fineLevelIndex,
|
const label fineLevelIndex,
|
||||||
const lduInterfacePtrsList& coarseMeshInterfaces,
|
const lduInterfacePtrsList& coarseMeshInterfaces,
|
||||||
|
PtrList<lduInterfaceField>& coarsePrimInterfaces,
|
||||||
lduInterfaceFieldPtrsList& coarseInterfaces,
|
lduInterfaceFieldPtrsList& coarseInterfaces,
|
||||||
FieldField<Field, scalar>& coarseInterfaceBouCoeffs,
|
FieldField<Field, scalar>& coarseInterfaceBouCoeffs,
|
||||||
FieldField<Field, scalar>& coarseInterfaceIntCoeffs
|
FieldField<Field, scalar>& coarseInterfaceIntCoeffs
|
||||||
@ -233,7 +242,7 @@ void Foam::GAMGSolver::agglomerateInterfaceCoefficients
|
|||||||
coarseMeshInterfaces[inti]
|
coarseMeshInterfaces[inti]
|
||||||
);
|
);
|
||||||
|
|
||||||
coarseInterfaces.set
|
coarsePrimInterfaces.set
|
||||||
(
|
(
|
||||||
inti,
|
inti,
|
||||||
GAMGInterfaceField::New
|
GAMGInterfaceField::New
|
||||||
@ -242,6 +251,11 @@ void Foam::GAMGSolver::agglomerateInterfaceCoefficients
|
|||||||
fineInterfaces[inti]
|
fineInterfaces[inti]
|
||||||
).ptr()
|
).ptr()
|
||||||
);
|
);
|
||||||
|
coarseInterfaces.set
|
||||||
|
(
|
||||||
|
inti,
|
||||||
|
&coarsePrimInterfaces[inti]
|
||||||
|
);
|
||||||
|
|
||||||
const labelList& faceRestrictAddressing = patchFineToCoarse[inti];
|
const labelList& faceRestrictAddressing = patchFineToCoarse[inti];
|
||||||
|
|
||||||
@ -364,9 +378,9 @@ void Foam::GAMGSolver::gatherMatrices
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pout<< "GAMGSolver::gatherMatrices :"
|
//Pout<< "GAMGSolver::gatherMatrices :"
|
||||||
<< " sending from:" << Pstream::myProcNo(meshComm)
|
// << " sending from:" << Pstream::myProcNo(meshComm)
|
||||||
<< " to master:" << procIDs[0] << endl;
|
// << " to master:" << procIDs[0] << endl;
|
||||||
|
|
||||||
// Send to master
|
// Send to master
|
||||||
|
|
||||||
@ -503,7 +517,6 @@ void Foam::GAMGSolver::procAgglomerateMatrix
|
|||||||
|
|
||||||
Pout<< "Agglomerating onto mesh:" << allMesh.info() << endl;
|
Pout<< "Agglomerating onto mesh:" << allMesh.info() << endl;
|
||||||
|
|
||||||
|
|
||||||
allMatrixPtr.reset(new lduMatrix(allMesh));
|
allMatrixPtr.reset(new lduMatrix(allMesh));
|
||||||
lduMatrix& allMatrix = allMatrixPtr();
|
lduMatrix& allMatrix = allMatrixPtr();
|
||||||
|
|
||||||
@ -666,8 +679,9 @@ Pout<< "Agglomerating onto mesh:" << allMesh.info() << endl;
|
|||||||
|
|
||||||
const labelList& map = boundaryFaceMap[procI][procIntI];
|
const labelList& map = boundaryFaceMap[procI][procIntI];
|
||||||
|
|
||||||
Pout<< " from proc:" << procI << " interface:" << procIntI
|
//Pout<< " from proc:" << procI
|
||||||
<< " mapped to faces:" << map << endl;
|
//<< " interface:" << procIntI
|
||||||
|
//<< " mapped to faces:" << map << endl;
|
||||||
|
|
||||||
const scalarField& procBou = procBouCoeffs[procIntI];
|
const scalarField& procBou = procBouCoeffs[procIntI];
|
||||||
const scalarField& procInt = procIntCoeffs[procIntI];
|
const scalarField& procInt = procIntCoeffs[procIntI];
|
||||||
@ -697,6 +711,7 @@ Pout<< " from proc:" << procI << " interface:" << procIntI
|
|||||||
const scalarField& procBou = procBouCoeffs[procIntI];
|
const scalarField& procBou = procBouCoeffs[procIntI];
|
||||||
const scalarField& procInt = procIntCoeffs[procIntI];
|
const scalarField& procInt = procIntCoeffs[procIntI];
|
||||||
|
|
||||||
|
|
||||||
forAll(map, i)
|
forAll(map, i)
|
||||||
{
|
{
|
||||||
if (map[i] >= 0)
|
if (map[i] >= 0)
|
||||||
@ -779,22 +794,21 @@ Pout<< " from proc:" << procI << " interface:" << procIntI
|
|||||||
<< allInterfaces[intI].interface().
|
<< allInterfaces[intI].interface().
|
||||||
faceCells().size()
|
faceCells().size()
|
||||||
<< endl;
|
<< endl;
|
||||||
const scalarField& bouCoeffs = allInterfaceBouCoeffs[intI];
|
|
||||||
const scalarField& intCoeffs = allInterfaceIntCoeffs[intI];
|
|
||||||
|
|
||||||
forAll(bouCoeffs, faceI)
|
//const scalarField& bouCoeffs = allInterfaceBouCoeffs[intI];
|
||||||
{
|
//const scalarField& intCoeffs = allInterfaceIntCoeffs[intI];
|
||||||
Pout<< " " << faceI
|
//forAll(bouCoeffs, faceI)
|
||||||
<< "\tbou:" << bouCoeffs[faceI]
|
//{
|
||||||
<< "\tint:" << intCoeffs[faceI]
|
// Pout<< " " << faceI
|
||||||
<< endl;
|
// << "\tbou:" << bouCoeffs[faceI]
|
||||||
}
|
// << "\tint:" << intCoeffs[faceI]
|
||||||
|
// << endl;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UPstream::warnComm = oldWarn;
|
UPstream::warnComm = oldWarn;
|
||||||
}
|
}
|
||||||
//XXXX
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::GAMGSolver::procAgglomerateMatrix
|
void Foam::GAMGSolver::procAgglomerateMatrix
|
||||||
|
|||||||
@ -33,7 +33,6 @@ void Foam::GAMGSolver::scale
|
|||||||
scalarField& field,
|
scalarField& field,
|
||||||
scalarField& Acf,
|
scalarField& Acf,
|
||||||
const lduMatrix& A,
|
const lduMatrix& A,
|
||||||
const int comm,
|
|
||||||
const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
|
const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
|
||||||
const lduInterfaceFieldPtrsList& interfaceLevel,
|
const lduInterfaceFieldPtrsList& interfaceLevel,
|
||||||
const scalarField& source,
|
const scalarField& source,
|
||||||
@ -59,12 +58,7 @@ void Foam::GAMGSolver::scale
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector2D scalingVector(scalingFactorNum, scalingFactorDenom);
|
vector2D scalingVector(scalingFactorNum, scalingFactorDenom);
|
||||||
//A.mesh().reduce
|
A.mesh().reduce(scalingVector, sumOp<vector2D>());
|
||||||
//(
|
|
||||||
// scalingVector,
|
|
||||||
// sumOp<vector2D>()
|
|
||||||
//);
|
|
||||||
Foam::reduce(scalingVector, sumOp<vector2D>(), Pstream::msgType(), comm);
|
|
||||||
|
|
||||||
scalar sf = scalingVector.x()/stabilise(scalingVector.y(), VSMALL);
|
scalar sf = scalingVector.x()/stabilise(scalingVector.y(), VSMALL);
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,6 @@ License
|
|||||||
#include "ICCG.H"
|
#include "ICCG.H"
|
||||||
#include "BICCG.H"
|
#include "BICCG.H"
|
||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "globalIndex.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -81,8 +80,20 @@ Foam::solverPerformance Foam::GAMGSolver::solve
|
|||||||
// Create the smoothers for all levels
|
// Create the smoothers for all levels
|
||||||
PtrList<lduMatrix::smoother> smoothers;
|
PtrList<lduMatrix::smoother> smoothers;
|
||||||
|
|
||||||
|
// Scratch fields if processor-agglomerated coarse level meshes
|
||||||
|
// are bigger than original. Usually not needed
|
||||||
|
scalarField scratch1;
|
||||||
|
scalarField scratch2;
|
||||||
|
|
||||||
// Initialise the above data structures
|
// Initialise the above data structures
|
||||||
initVcycle(coarseCorrFields, coarseSources, smoothers);
|
initVcycle
|
||||||
|
(
|
||||||
|
coarseCorrFields,
|
||||||
|
coarseSources,
|
||||||
|
smoothers,
|
||||||
|
scratch1,
|
||||||
|
scratch2
|
||||||
|
);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -94,11 +105,22 @@ Foam::solverPerformance Foam::GAMGSolver::solve
|
|||||||
Apsi,
|
Apsi,
|
||||||
finestCorrection,
|
finestCorrection,
|
||||||
finestResidual,
|
finestResidual,
|
||||||
|
|
||||||
|
(scratch1.size() ? scratch1 : Apsi),
|
||||||
|
(scratch2.size() ? scratch2 : finestCorrection),
|
||||||
|
|
||||||
coarseCorrFields,
|
coarseCorrFields,
|
||||||
coarseSources,
|
coarseSources,
|
||||||
cmpt
|
cmpt
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//Pout<< "finestCorrection:" << finestCorrection << endl;
|
||||||
|
//Pout<< "finestResidual:" << finestResidual << endl;
|
||||||
|
//Pout<< "psi:" << psi << endl;
|
||||||
|
//Pout<< "Apsi:" << Apsi << endl;
|
||||||
|
|
||||||
|
|
||||||
// Calculate finest level residual field
|
// Calculate finest level residual field
|
||||||
matrix_.Amul(Apsi, psi, interfaceBouCoeffs_, interfaces_, cmpt);
|
matrix_.Amul(Apsi, psi, interfaceBouCoeffs_, interfaces_, cmpt);
|
||||||
finestResidual = source;
|
finestResidual = source;
|
||||||
@ -133,6 +155,10 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
scalarField& Apsi,
|
scalarField& Apsi,
|
||||||
scalarField& finestCorrection,
|
scalarField& finestCorrection,
|
||||||
scalarField& finestResidual,
|
scalarField& finestResidual,
|
||||||
|
|
||||||
|
scalarField& scratch1,
|
||||||
|
scalarField& scratch2,
|
||||||
|
|
||||||
PtrList<scalarField>& coarseCorrFields,
|
PtrList<scalarField>& coarseCorrFields,
|
||||||
PtrList<scalarField>& coarseSources,
|
PtrList<scalarField>& coarseSources,
|
||||||
const direction cmpt
|
const direction cmpt
|
||||||
@ -154,8 +180,6 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
// Residual restriction (going to coarser levels)
|
// Residual restriction (going to coarser levels)
|
||||||
for (label leveli = 0; leveli < coarsestLevel; leveli++)
|
for (label leveli = 0; leveli < coarsestLevel; leveli++)
|
||||||
{
|
{
|
||||||
Pout<< "Restriction for level:" << leveli << endl;
|
|
||||||
|
|
||||||
if (coarseSources.set(leveli + 1))
|
if (coarseSources.set(leveli + 1))
|
||||||
{
|
{
|
||||||
// If the optional pre-smoothing sweeps are selected
|
// If the optional pre-smoothing sweeps are selected
|
||||||
@ -178,16 +202,15 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
|
|
||||||
scalarField::subField ACf
|
scalarField::subField ACf
|
||||||
(
|
(
|
||||||
Apsi,
|
scratch1,
|
||||||
coarseCorrFields[leveli].size()
|
coarseCorrFields[leveli].size()
|
||||||
);
|
);
|
||||||
|
//scalarField ACf(coarseCorrFields[leveli].size(), VGREAT);
|
||||||
|
|
||||||
// Scale coarse-grid correction field
|
// Scale coarse-grid correction field
|
||||||
// but not on the coarsest level because it evaluates to 1
|
// but not on the coarsest level because it evaluates to 1
|
||||||
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
||||||
{
|
{
|
||||||
int comm = matrixLevels_[leveli].mesh().comm();
|
|
||||||
|
|
||||||
scale
|
scale
|
||||||
(
|
(
|
||||||
coarseCorrFields[leveli],
|
coarseCorrFields[leveli],
|
||||||
@ -195,8 +218,9 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
(
|
(
|
||||||
ACf.operator const scalarField&()
|
ACf.operator const scalarField&()
|
||||||
),
|
),
|
||||||
|
//ACf,
|
||||||
|
|
||||||
matrixLevels_[leveli],
|
matrixLevels_[leveli],
|
||||||
comm,
|
|
||||||
interfaceLevelsBouCoeffs_[leveli],
|
interfaceLevelsBouCoeffs_[leveli],
|
||||||
interfaceLevels_[leveli],
|
interfaceLevels_[leveli],
|
||||||
coarseSources[leveli],
|
coarseSources[leveli],
|
||||||
@ -211,6 +235,7 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
(
|
(
|
||||||
ACf.operator const scalarField&()
|
ACf.operator const scalarField&()
|
||||||
),
|
),
|
||||||
|
//ACf,
|
||||||
coarseCorrFields[leveli],
|
coarseCorrFields[leveli],
|
||||||
interfaceLevelsBouCoeffs_[leveli],
|
interfaceLevelsBouCoeffs_[leveli],
|
||||||
interfaceLevels_[leveli],
|
interfaceLevels_[leveli],
|
||||||
@ -240,7 +265,6 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
// Solve Coarsest level with either an iterative or direct solver
|
// Solve Coarsest level with either an iterative or direct solver
|
||||||
if (coarseCorrFields.set(coarsestLevel))
|
if (coarseCorrFields.set(coarsestLevel))
|
||||||
{
|
{
|
||||||
Pout<< "Coarsest solve for level:" << coarsestLevel << endl;
|
|
||||||
solveCoarsestLevel
|
solveCoarsestLevel
|
||||||
(
|
(
|
||||||
coarseCorrFields[coarsestLevel],
|
coarseCorrFields[coarsestLevel],
|
||||||
@ -260,28 +284,27 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
|
|
||||||
for (label leveli = coarsestLevel - 1; leveli >= 0; leveli--)
|
for (label leveli = coarsestLevel - 1; leveli >= 0; leveli--)
|
||||||
{
|
{
|
||||||
Pout<< "Smoothing and prolongation for level:" << leveli << endl;
|
|
||||||
|
|
||||||
if (coarseCorrFields.set(leveli))
|
if (coarseCorrFields.set(leveli))
|
||||||
{
|
{
|
||||||
Pout<< "Prolonging from " << leveli + 1 << " up to "
|
// Create a field for the pre-smoothed correction field
|
||||||
<< leveli << endl;
|
// as a sub-field of the finestCorrection which is not
|
||||||
//// Create a field for the pre-smoothed correction field
|
// currently being used
|
||||||
//// as a sub-field of the finestCorrection which is not
|
scalarField::subField preSmoothedCoarseCorrField
|
||||||
//// currently being used
|
(
|
||||||
//scalarField::subField preSmoothedCoarseCorrField
|
scratch2,
|
||||||
|
coarseCorrFields[leveli].size()
|
||||||
|
);
|
||||||
|
//scalarField preSmoothedCoarseCorrField
|
||||||
//(
|
//(
|
||||||
// finestCorrection,
|
// coarseCorrFields[leveli].size(),
|
||||||
// coarseCorrFields[leveli].size()
|
// VGREAT
|
||||||
//);
|
//);
|
||||||
scalarField preSmoothedCoarseCorrField;
|
|
||||||
|
|
||||||
// Only store the preSmoothedCoarseCorrField if pre-smoothing is
|
// Only store the preSmoothedCoarseCorrField if pre-smoothing is
|
||||||
// used
|
// used
|
||||||
if (nPreSweeps_)
|
if (nPreSweeps_)
|
||||||
{
|
{
|
||||||
//preSmoothedCoarseCorrField.assign(coarseCorrFields[leveli]);
|
preSmoothedCoarseCorrField.assign(coarseCorrFields[leveli]);
|
||||||
preSmoothedCoarseCorrField = coarseCorrFields[leveli];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
agglomeration_.prolongField
|
agglomeration_.prolongField
|
||||||
@ -296,22 +319,24 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
Pout<< "Doing stuff at level " << leveli << endl;
|
|
||||||
|
|
||||||
//// Create A.psi for this coarse level as a sub-field of Apsi
|
// Create A.psi for this coarse level as a sub-field of Apsi
|
||||||
//scalarField::subField ACf
|
scalarField::subField ACf
|
||||||
|
(
|
||||||
|
scratch1,
|
||||||
|
coarseCorrFields[leveli].size()
|
||||||
|
);
|
||||||
|
scalarField& ACfRef =
|
||||||
|
const_cast<scalarField&>(ACf.operator const scalarField&());
|
||||||
|
//scalarField ACfRef
|
||||||
//(
|
//(
|
||||||
// Apsi,
|
// coarseCorrFields[leveli].size(),
|
||||||
// coarseCorrFields[leveli].size()
|
// VGREAT
|
||||||
//);
|
//);
|
||||||
//scalarField& ACfRef =
|
|
||||||
// const_cast<scalarField&>(ACf.operator const scalarField&());
|
|
||||||
scalarField ACfRef(coarseCorrFields[leveli].size());
|
|
||||||
|
|
||||||
|
|
||||||
if (interpolateCorrection_)
|
if (interpolateCorrection_)
|
||||||
{
|
{
|
||||||
Pout<< "doing interpolate." << endl;
|
|
||||||
interpolate
|
interpolate
|
||||||
(
|
(
|
||||||
coarseCorrFields[leveli],
|
coarseCorrFields[leveli],
|
||||||
@ -322,35 +347,22 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
coarseSources[leveli],
|
coarseSources[leveli],
|
||||||
cmpt
|
cmpt
|
||||||
);
|
);
|
||||||
Pout<< "done interpolate." << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale coarse-grid correction field
|
// Scale coarse-grid correction field
|
||||||
// but not on the coarsest level because it evaluates to 1
|
// but not on the coarsest level because it evaluates to 1
|
||||||
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
if (scaleCorrection_ && leveli < coarsestLevel - 1)
|
||||||
{
|
{
|
||||||
//int comm =
|
|
||||||
//(
|
|
||||||
// matrixLevels_.set(leveli+1)
|
|
||||||
// ? matrixLevels_[leveli+1].mesh().comm()
|
|
||||||
// : matrixLevels_[leveli].mesh().comm()
|
|
||||||
//);
|
|
||||||
int comm = matrixLevels_[leveli].mesh().comm();
|
|
||||||
|
|
||||||
|
|
||||||
Pout<< "doing scale with comm:" << comm << endl;
|
|
||||||
scale
|
scale
|
||||||
(
|
(
|
||||||
coarseCorrFields[leveli],
|
coarseCorrFields[leveli],
|
||||||
ACfRef,
|
ACfRef,
|
||||||
matrixLevels_[leveli],
|
matrixLevels_[leveli],
|
||||||
comm,
|
|
||||||
interfaceLevelsBouCoeffs_[leveli],
|
interfaceLevelsBouCoeffs_[leveli],
|
||||||
interfaceLevels_[leveli],
|
interfaceLevels_[leveli],
|
||||||
coarseSources[leveli],
|
coarseSources[leveli],
|
||||||
cmpt
|
cmpt
|
||||||
);
|
);
|
||||||
Pout<< "done scale with comm:" << comm << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add the preSmoothedCoarseCorrField if pre-smoothing is
|
// Only add the preSmoothedCoarseCorrField if pre-smoothing is
|
||||||
@ -360,7 +372,6 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
coarseCorrFields[leveli] += preSmoothedCoarseCorrField;
|
coarseCorrFields[leveli] += preSmoothedCoarseCorrField;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "doing smooth." << endl;
|
|
||||||
smoothers[leveli + 1].smooth
|
smoothers[leveli + 1].smooth
|
||||||
(
|
(
|
||||||
coarseCorrFields[leveli],
|
coarseCorrFields[leveli],
|
||||||
@ -372,24 +383,20 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
maxPostSweeps_
|
maxPostSweeps_
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
Pout<< "done smooth." << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prolong the finest level correction
|
// Prolong the finest level correction
|
||||||
Pout<< "Doing Prolong to finest level" << endl;
|
|
||||||
agglomeration_.prolongField
|
agglomeration_.prolongField
|
||||||
(
|
(
|
||||||
finestCorrection,
|
finestCorrection,
|
||||||
coarseCorrFields[0],
|
coarseCorrFields[0],
|
||||||
0,
|
0,
|
||||||
true //false // no proc agglomeration for now
|
true
|
||||||
);
|
);
|
||||||
Pout<< "Done Prolong to finest level" << endl;
|
|
||||||
|
|
||||||
if (interpolateCorrection_)
|
if (interpolateCorrection_)
|
||||||
{
|
{
|
||||||
Pout<< "doing interpolate on finest level" << endl;
|
|
||||||
interpolate
|
interpolate
|
||||||
(
|
(
|
||||||
finestCorrection,
|
finestCorrection,
|
||||||
@ -400,26 +407,21 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
finestResidual,
|
finestResidual,
|
||||||
cmpt
|
cmpt
|
||||||
);
|
);
|
||||||
Pout<< "done interpolate on finest level" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scaleCorrection_)
|
if (scaleCorrection_)
|
||||||
{
|
{
|
||||||
// Scale the finest level correction
|
// Scale the finest level correction
|
||||||
int comm = matrix_.mesh().comm();
|
|
||||||
Pout<< "doing scale on finest level with comm:" << comm << endl;
|
|
||||||
scale
|
scale
|
||||||
(
|
(
|
||||||
finestCorrection,
|
finestCorrection,
|
||||||
Apsi,
|
Apsi,
|
||||||
matrix_,
|
matrix_,
|
||||||
comm,
|
|
||||||
interfaceBouCoeffs_,
|
interfaceBouCoeffs_,
|
||||||
interfaces_,
|
interfaces_,
|
||||||
finestResidual,
|
finestResidual,
|
||||||
cmpt
|
cmpt
|
||||||
);
|
);
|
||||||
Pout<< "done scale on finest level with comm:" << comm << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(psi, i)
|
forAll(psi, i)
|
||||||
@ -427,7 +429,6 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
psi[i] += finestCorrection[i];
|
psi[i] += finestCorrection[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "Doing smooth on finest level" << endl;
|
|
||||||
smoothers[0].smooth
|
smoothers[0].smooth
|
||||||
(
|
(
|
||||||
psi,
|
psi,
|
||||||
@ -435,7 +436,6 @@ void Foam::GAMGSolver::Vcycle
|
|||||||
cmpt,
|
cmpt,
|
||||||
nFinestSweeps_
|
nFinestSweeps_
|
||||||
);
|
);
|
||||||
Pout<< "Done smooth on finest level" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,9 +443,13 @@ void Foam::GAMGSolver::initVcycle
|
|||||||
(
|
(
|
||||||
PtrList<scalarField>& coarseCorrFields,
|
PtrList<scalarField>& coarseCorrFields,
|
||||||
PtrList<scalarField>& coarseSources,
|
PtrList<scalarField>& coarseSources,
|
||||||
PtrList<lduMatrix::smoother>& smoothers
|
PtrList<lduMatrix::smoother>& smoothers,
|
||||||
|
scalarField& scratch1,
|
||||||
|
scalarField& scratch2
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
label maxSize = matrix_.diag().size();
|
||||||
|
|
||||||
coarseCorrFields.setSize(matrixLevels_.size());
|
coarseCorrFields.setSize(matrixLevels_.size());
|
||||||
coarseSources.setSize(matrixLevels_.size());
|
coarseSources.setSize(matrixLevels_.size());
|
||||||
smoothers.setSize(matrixLevels_.size() + 1);
|
smoothers.setSize(matrixLevels_.size() + 1);
|
||||||
@ -471,15 +475,7 @@ void Foam::GAMGSolver::initVcycle
|
|||||||
{
|
{
|
||||||
label nCoarseCells = agglomeration_.nCells(leveli);
|
label nCoarseCells = agglomeration_.nCells(leveli);
|
||||||
|
|
||||||
Pout<< "initVCucle level:" << leveli << " nCoarseCells:"
|
|
||||||
<< nCoarseCells << endl;
|
|
||||||
|
|
||||||
coarseSources.set(leveli, new scalarField(nCoarseCells));
|
coarseSources.set(leveli, new scalarField(nCoarseCells));
|
||||||
|
|
||||||
//if (!matrixLevels_.set(leveli))
|
|
||||||
//{
|
|
||||||
// coarseCorrFields.set(leveli, new scalarField(nCoarseCells));
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matrixLevels_.set(leveli))
|
if (matrixLevels_.set(leveli))
|
||||||
@ -487,12 +483,10 @@ void Foam::GAMGSolver::initVcycle
|
|||||||
const lduMatrix& mat = matrixLevels_[leveli];
|
const lduMatrix& mat = matrixLevels_[leveli];
|
||||||
|
|
||||||
label nCoarseCells = mat.diag().size();
|
label nCoarseCells = mat.diag().size();
|
||||||
Pout<< "initVCucle level:" << leveli << " matrix size:"
|
|
||||||
<< nCoarseCells << endl;
|
maxSize = max(maxSize, nCoarseCells);
|
||||||
|
|
||||||
coarseCorrFields.set(leveli, new scalarField(nCoarseCells));
|
coarseCorrFields.set(leveli, new scalarField(nCoarseCells));
|
||||||
//coarseCorrFields.set(leveli, new scalarField(nCoarseCells));
|
|
||||||
//coarseSources.set(leveli, new scalarField(nCoarseCells));
|
|
||||||
|
|
||||||
smoothers.set
|
smoothers.set
|
||||||
(
|
(
|
||||||
@ -509,6 +503,13 @@ void Foam::GAMGSolver::initVcycle
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (maxSize > matrix_.diag().size())
|
||||||
|
{
|
||||||
|
// Allocate some scratch storage
|
||||||
|
scratch1.setSize(maxSize);
|
||||||
|
scratch2.setSize(maxSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -520,10 +521,6 @@ void Foam::GAMGSolver::solveCoarsestLevel
|
|||||||
{
|
{
|
||||||
const label coarsestLevel = matrixLevels_.size() - 1;
|
const label coarsestLevel = matrixLevels_.size() - 1;
|
||||||
|
|
||||||
Pout<< "solveCoarsestLevel :"
|
|
||||||
<< " coarsestLevel:" << coarsestLevel << endl;
|
|
||||||
|
|
||||||
|
|
||||||
label coarseComm = matrixLevels_[coarsestLevel].mesh().comm();
|
label coarseComm = matrixLevels_[coarsestLevel].mesh().comm();
|
||||||
label oldWarn = UPstream::warnComm;
|
label oldWarn = UPstream::warnComm;
|
||||||
UPstream::warnComm = coarseComm;
|
UPstream::warnComm = coarseComm;
|
||||||
@ -682,9 +679,6 @@ void Foam::GAMGSolver::solveCoarsestLevel
|
|||||||
{
|
{
|
||||||
coarseSolverPerf.print(Info(coarseComm));
|
coarseSolverPerf.print(Info(coarseComm));
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< "GC: coarsestSource :" << coarsestSource << endl;
|
|
||||||
Pout<< "GC: coarsestCorrField:" << coarsestCorrField << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UPstream::warnComm = oldWarn;
|
UPstream::warnComm = oldWarn;
|
||||||
|
|||||||
@ -67,15 +67,13 @@ void Foam::lduPrimitiveMesh::checkUpperTriangular
|
|||||||
{
|
{
|
||||||
if (u[faceI] < l[faceI])
|
if (u[faceI] < l[faceI])
|
||||||
{
|
{
|
||||||
//FatalErrorIn
|
FatalErrorIn
|
||||||
WarningIn
|
|
||||||
(
|
(
|
||||||
"checkUpperTriangular"
|
"checkUpperTriangular"
|
||||||
"(const label, const labelUList&, const labelUList&)"
|
"(const label, const labelUList&, const labelUList&)"
|
||||||
) << "Reversed face. Problem at face " << faceI
|
) << "Reversed face. Problem at face " << faceI
|
||||||
<< " l:" << l[faceI] << " u:" << u[faceI]
|
<< " l:" << l[faceI] << " u:" << u[faceI]
|
||||||
//<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
if (l[faceI] < 0 || u[faceI] < 0 || u[faceI] >= size)
|
if (l[faceI] < 0 || u[faceI] < 0 || u[faceI] >= size)
|
||||||
{
|
{
|
||||||
@ -93,8 +91,7 @@ void Foam::lduPrimitiveMesh::checkUpperTriangular
|
|||||||
{
|
{
|
||||||
if (l[faceI-1] > l[faceI])
|
if (l[faceI-1] > l[faceI])
|
||||||
{
|
{
|
||||||
//FatalErrorIn
|
FatalErrorIn
|
||||||
WarningIn
|
|
||||||
(
|
(
|
||||||
"checkUpperTriangular"
|
"checkUpperTriangular"
|
||||||
"(const label, const labelUList&, const labelUList&)"
|
"(const label, const labelUList&, const labelUList&)"
|
||||||
@ -102,16 +99,14 @@ void Foam::lduPrimitiveMesh::checkUpperTriangular
|
|||||||
<< " Problem at face " << faceI
|
<< " Problem at face " << faceI
|
||||||
<< " l:" << l[faceI] << " u:" << u[faceI]
|
<< " l:" << l[faceI] << " u:" << u[faceI]
|
||||||
<< " previous l:" << l[faceI-1]
|
<< " previous l:" << l[faceI-1]
|
||||||
//<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
else if (l[faceI-1] == l[faceI])
|
else if (l[faceI-1] == l[faceI])
|
||||||
{
|
{
|
||||||
// Same cell.
|
// Same cell.
|
||||||
if (u[faceI-1] > u[faceI])
|
if (u[faceI-1] > u[faceI])
|
||||||
{
|
{
|
||||||
//FatalErrorIn
|
FatalErrorIn
|
||||||
WarningIn
|
|
||||||
(
|
(
|
||||||
"checkUpperTriangular"
|
"checkUpperTriangular"
|
||||||
"(const label, const labelUList&, const labelUList&)"
|
"(const label, const labelUList&, const labelUList&)"
|
||||||
@ -119,8 +114,7 @@ void Foam::lduPrimitiveMesh::checkUpperTriangular
|
|||||||
<< " Problem at face " << faceI
|
<< " Problem at face " << faceI
|
||||||
<< " l:" << l[faceI] << " u:" << u[faceI]
|
<< " l:" << l[faceI] << " u:" << u[faceI]
|
||||||
<< " previous u:" << u[faceI-1]
|
<< " previous u:" << u[faceI-1]
|
||||||
//<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,6 +133,79 @@ Foam::label Foam::lduPrimitiveMesh::size(const PtrList<lduMesh>& meshes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::labelList Foam::lduPrimitiveMesh::upperTriOrder
|
||||||
|
(
|
||||||
|
const label nCells,
|
||||||
|
const labelUList& lower,
|
||||||
|
const labelUList& upper
|
||||||
|
)
|
||||||
|
{
|
||||||
|
labelList nNbrs(nCells, 0);
|
||||||
|
|
||||||
|
// Count number of upper neighbours
|
||||||
|
forAll(lower, faceI)
|
||||||
|
{
|
||||||
|
if (upper[faceI] < lower[faceI])
|
||||||
|
{
|
||||||
|
FatalErrorIn("lduPrimitiveMesh::upperTriOrder(..)")
|
||||||
|
<< "Problem at face:" << faceI
|
||||||
|
<< " lower:" << lower[faceI]
|
||||||
|
<< " upper:" << upper[faceI]
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
nNbrs[lower[faceI]]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct cell-upper cell addressing
|
||||||
|
labelList offsets(nCells+1);
|
||||||
|
offsets[0] = 0;
|
||||||
|
forAll(nNbrs, cellI)
|
||||||
|
{
|
||||||
|
offsets[cellI+1] = offsets[cellI]+nNbrs[cellI];
|
||||||
|
}
|
||||||
|
|
||||||
|
nNbrs = offsets;
|
||||||
|
|
||||||
|
labelList cellToFaces(offsets.last());
|
||||||
|
forAll(upper, faceI)
|
||||||
|
{
|
||||||
|
label cellI = lower[faceI];
|
||||||
|
cellToFaces[nNbrs[cellI]++] = faceI;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort
|
||||||
|
|
||||||
|
labelList oldToNew(lower.size());
|
||||||
|
|
||||||
|
labelList order;
|
||||||
|
labelList nbr;
|
||||||
|
|
||||||
|
label newFaceI = 0;
|
||||||
|
|
||||||
|
for (label cellI = 0; cellI < nCells; cellI++)
|
||||||
|
{
|
||||||
|
label startOfCell = offsets[cellI];
|
||||||
|
label nNbr = offsets[cellI+1] - startOfCell;
|
||||||
|
|
||||||
|
nbr.setSize(nNbr);
|
||||||
|
order.setSize(nNbr);
|
||||||
|
forAll(order, i)
|
||||||
|
{
|
||||||
|
nbr[i] = upper[cellToFaces[offsets[cellI]+i]];
|
||||||
|
}
|
||||||
|
sortedOrder(nbr, order);
|
||||||
|
|
||||||
|
forAll(order, i)
|
||||||
|
{
|
||||||
|
label index = order[i];
|
||||||
|
oldToNew[cellToFaces[startOfCell + index]] = newFaceI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return oldToNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
||||||
@ -159,36 +226,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
interfaces_(interfaces),
|
interfaces_(interfaces),
|
||||||
patchSchedule_(ps),
|
patchSchedule_(ps),
|
||||||
comm_(comm)
|
comm_(comm)
|
||||||
{
|
{}
|
||||||
//Pout<< "lduPrimitiveMesh :"
|
|
||||||
// << " nCells:" << nCells
|
|
||||||
// << " l:" << lowerAddr_.size()
|
|
||||||
// << " u:" << upperAddr_.size()
|
|
||||||
// << " pa:" << patchAddr_.size()
|
|
||||||
// << " interfaces:" << interfaces_.size()
|
|
||||||
// << " comm:" << comm_
|
|
||||||
// << endl;
|
|
||||||
//forAll(interfaces_, i)
|
|
||||||
//{
|
|
||||||
// if (interfaces_.set(i))
|
|
||||||
// {
|
|
||||||
// if (isA<processorLduInterface>(interfaces_[i]))
|
|
||||||
// {
|
|
||||||
// const processorLduInterface& pi = refCast
|
|
||||||
// <
|
|
||||||
// const processorLduInterface
|
|
||||||
// >(interfaces_[i]);
|
|
||||||
//
|
|
||||||
// Pout<< " patch:" << i
|
|
||||||
// << " size:" << patchAddr_[i].size()
|
|
||||||
// << " myProcNo:" << pi.myProcNo()
|
|
||||||
// << " neighbProcNo:" << pi.neighbProcNo()
|
|
||||||
// << " comm:" << pi.comm()
|
|
||||||
// << endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
||||||
@ -210,95 +248,40 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
interfaces_(interfaces, reUse),
|
interfaces_(interfaces, reUse),
|
||||||
patchSchedule_(ps),
|
patchSchedule_(ps),
|
||||||
comm_(comm)
|
comm_(comm)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
||||||
|
(
|
||||||
|
const label nCells,
|
||||||
|
labelList& l,
|
||||||
|
labelList& u,
|
||||||
|
labelListList& pa,
|
||||||
|
const Xfer<PtrList<const lduInterface> >& primitiveInterfaces,
|
||||||
|
const lduSchedule& ps,
|
||||||
|
const label comm
|
||||||
|
)
|
||||||
|
:
|
||||||
|
lduAddressing(nCells),
|
||||||
|
lowerAddr_(l, true),
|
||||||
|
upperAddr_(u, true),
|
||||||
|
patchAddr_(pa, true),
|
||||||
|
primitiveInterfaces_(primitiveInterfaces),
|
||||||
|
patchSchedule_(ps),
|
||||||
|
comm_(comm)
|
||||||
{
|
{
|
||||||
//Pout<< "lduPrimitiveMesh :"
|
// Create interfaces
|
||||||
// << " nCells:" << nCells
|
interfaces_.setSize(primitiveInterfaces_.size());
|
||||||
// << " l:" << lowerAddr_.size()
|
forAll(primitiveInterfaces_, i)
|
||||||
// << " u:" << upperAddr_.size()
|
{
|
||||||
// << " pa:" << patchAddr_.size()
|
if (primitiveInterfaces_.set(i))
|
||||||
// << " interfaces:" << interfaces_.size()
|
{
|
||||||
// << " comm:" << comm_
|
interfaces_.set(i, &primitiveInterfaces_[i]);
|
||||||
// << endl;
|
}
|
||||||
//forAll(interfaces_, i)
|
}
|
||||||
//{
|
|
||||||
// if (interfaces_.set(i))
|
|
||||||
// {
|
|
||||||
// if (isA<processorLduInterface>(interfaces_[i]))
|
|
||||||
// {
|
|
||||||
// const processorLduInterface& pi = refCast
|
|
||||||
// <
|
|
||||||
// const processorLduInterface
|
|
||||||
// >(interfaces_[i]);
|
|
||||||
//
|
|
||||||
// Pout<< " patch:" << i
|
|
||||||
// << " size:" << patchAddr_[i].size()
|
|
||||||
// << " myProcNo:" << pi.myProcNo()
|
|
||||||
// << " neighbProcNo:" << pi.neighbProcNo()
|
|
||||||
// << " comm:" << pi.comm()
|
|
||||||
// << endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|
||||||
//(
|
|
||||||
// const label nCells,
|
|
||||||
// labelList& l,
|
|
||||||
// labelList& u,
|
|
||||||
// labelListList& pa,
|
|
||||||
// PtrList<const lduInterface>& primitiveInterfaces,
|
|
||||||
// const lduSchedule& ps,
|
|
||||||
// const label comm,
|
|
||||||
// bool reUse
|
|
||||||
//)
|
|
||||||
//:
|
|
||||||
// lduAddressing(nCells),
|
|
||||||
// lowerAddr_(l, reUse),
|
|
||||||
// upperAddr_(u, reUse),
|
|
||||||
// patchAddr_(pa, reUse),
|
|
||||||
// primitiveInterfaces_(primitiveInterfaces, reUse),
|
|
||||||
// patchSchedule_(ps),
|
|
||||||
// comm_(comm)
|
|
||||||
//{
|
|
||||||
// interfaces_.setSize(primitiveInterfaces_.size());
|
|
||||||
// forAll(primitiveInterfaces, intI)
|
|
||||||
// {
|
|
||||||
// interfaces_.set(intI, &primitiveInterfaces_[intI]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //Pout<< "lduPrimitiveMesh :"
|
|
||||||
// // << " nCells:" << nCells
|
|
||||||
// // << " l:" << lowerAddr_.size()
|
|
||||||
// // << " u:" << upperAddr_.size()
|
|
||||||
// // << " pa:" << patchAddr_.size()
|
|
||||||
// // << " interfaces:" << interfaces_.size()
|
|
||||||
// // << " comm:" << comm_
|
|
||||||
// // << endl;
|
|
||||||
// //forAll(interfaces_, i)
|
|
||||||
// //{
|
|
||||||
// // if (interfaces_.set(i))
|
|
||||||
// // {
|
|
||||||
// // if (isA<processorLduInterface>(interfaces_[i]))
|
|
||||||
// // {
|
|
||||||
// // const processorLduInterface& pi = refCast
|
|
||||||
// // <
|
|
||||||
// // const processorLduInterface
|
|
||||||
// // >(interfaces_[i]);
|
|
||||||
// //
|
|
||||||
// // Pout<< " patch:" << i
|
|
||||||
// // << " size:" << patchAddr_[i].size()
|
|
||||||
// // << " myProcNo:" << pi.myProcNo()
|
|
||||||
// // << " neighbProcNo:" << pi.neighbProcNo()
|
|
||||||
// // << " comm:" << pi.comm()
|
|
||||||
// // << endl;
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// //}
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
||||||
(
|
(
|
||||||
const label comm,
|
const label comm,
|
||||||
@ -343,10 +326,14 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
const label nMeshes = otherMeshes.size()+1;
|
const label nMeshes = otherMeshes.size()+1;
|
||||||
|
|
||||||
const label myAgglom = procAgglomMap[UPstream::myProcNo(currentComm)];
|
const label myAgglom = procAgglomMap[UPstream::myProcNo(currentComm)];
|
||||||
Pout<< "I am " << UPstream::myProcNo(currentComm)
|
|
||||||
<< " agglomerating into " << myAgglom
|
if (lduPrimitiveMesh::debug)
|
||||||
<< " as are " << findIndices(procAgglomMap, myAgglom)
|
{
|
||||||
<< endl;
|
Pout<< "I am " << UPstream::myProcNo(currentComm)
|
||||||
|
<< " agglomerating into " << myAgglom
|
||||||
|
<< " as are " << findIndices(procAgglomMap, myAgglom)
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
forAll(procIDs, i)
|
forAll(procIDs, i)
|
||||||
@ -448,11 +435,14 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
else if (agglom0 == myAgglom && agglom1 == myAgglom)
|
else if (agglom0 == myAgglom && agglom1 == myAgglom)
|
||||||
{
|
{
|
||||||
// Merged interface
|
// Merged interface
|
||||||
Pout<< "merged interface: myProcNo:"
|
if (debug)
|
||||||
<< pldui.myProcNo()
|
{
|
||||||
<< " nbr:" << pldui.neighbProcNo()
|
Pout<< "merged interface: myProcNo:"
|
||||||
<< " size:" << ldui.faceCells().size()
|
<< pldui.myProcNo()
|
||||||
<< endl;
|
<< " nbr:" << pldui.neighbProcNo()
|
||||||
|
<< " size:" << ldui.faceCells().size()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
label nbrProcMeshI = findIndex
|
label nbrProcMeshI = findIndex
|
||||||
(
|
(
|
||||||
@ -484,11 +474,14 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pout<< "external interface: myProcNo:"
|
if (debug)
|
||||||
<< pldui.myProcNo()
|
{
|
||||||
<< " nbr:" << pldui.neighbProcNo()
|
Pout<< "external interface: myProcNo:"
|
||||||
<< " size:" << ldui.faceCells().size()
|
<< pldui.myProcNo()
|
||||||
<< endl;
|
<< " nbr:" << pldui.neighbProcNo()
|
||||||
|
<< " size:" << ldui.faceCells().size()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
EdgeMap<labelPairList>::iterator iter =
|
EdgeMap<labelPairList>::iterator iter =
|
||||||
unmergedMap.find(procEdge);
|
unmergedMap.find(procEdge);
|
||||||
@ -524,7 +517,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "Remaining interfaces:" << endl;
|
Pout<< "Remaining interfaces:" << endl;
|
||||||
forAllConstIter(EdgeMap<labelPairList>, unmergedMap, iter)
|
forAllConstIter(EdgeMap<labelPairList>, unmergedMap, iter)
|
||||||
@ -553,7 +546,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
Pout<< endl;
|
Pout<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "Merged interfaces:" << endl;
|
Pout<< "Merged interfaces:" << endl;
|
||||||
forAllConstIter(EdgeMap<labelPairList>, mergedMap, iter)
|
forAllConstIter(EdgeMap<labelPairList>, mergedMap, iter)
|
||||||
@ -632,6 +625,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
allFaceI++;
|
allFaceI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add merged interfaces
|
// Add merged interfaces
|
||||||
const lduInterfacePtrsList interfaces = procMesh.interfaces();
|
const lduInterfacePtrsList interfaces = procMesh.interfaces();
|
||||||
|
|
||||||
@ -670,7 +664,26 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
label nbrIntI = -1;
|
label nbrIntI = -1;
|
||||||
forAll(elems, i)
|
forAll(elems, i)
|
||||||
{
|
{
|
||||||
if (elems[i][0] == nbrProcMeshI)
|
label procI = elems[i][0];
|
||||||
|
label interfaceI = elems[i][1];
|
||||||
|
const lduInterfacePtrsList interfaces =
|
||||||
|
mesh
|
||||||
|
(
|
||||||
|
myMesh,
|
||||||
|
otherMeshes,
|
||||||
|
procI
|
||||||
|
).interfaces();
|
||||||
|
const processorLduInterface& pldui =
|
||||||
|
refCast<const processorLduInterface>
|
||||||
|
(
|
||||||
|
interfaces[interfaceI]
|
||||||
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
elems[i][0] == nbrProcMeshI
|
||||||
|
&& pldui.neighbProcNo() == procMeshI
|
||||||
|
)
|
||||||
{
|
{
|
||||||
nbrIntI = elems[i][1];
|
nbrIntI = elems[i][1];
|
||||||
break;
|
break;
|
||||||
@ -700,6 +713,17 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
const labelUList& nbrFaceCells =
|
const labelUList& nbrFaceCells =
|
||||||
nbrInterfaces[nbrIntI].faceCells();
|
nbrInterfaces[nbrIntI].faceCells();
|
||||||
|
|
||||||
|
if (faceCells.size() != nbrFaceCells.size())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"lduPrimitiveMesh::lduPrimitiveMesh(..)"
|
||||||
|
) << "faceCells:" << faceCells
|
||||||
|
<< " nbrFaceCells:" << nbrFaceCells
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
labelList& bfMap =
|
labelList& bfMap =
|
||||||
boundaryFaceMap[procMeshI][intI];
|
boundaryFaceMap[procMeshI][intI];
|
||||||
labelList& nbrBfMap =
|
labelList& nbrBfMap =
|
||||||
@ -726,6 +750,67 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Sort upper-tri order
|
||||||
|
{
|
||||||
|
labelList oldToNew
|
||||||
|
(
|
||||||
|
upperTriOrder
|
||||||
|
(
|
||||||
|
cellOffsets.last(), //nCells
|
||||||
|
lowerAddr_,
|
||||||
|
upperAddr_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(faceMap, procMeshI)
|
||||||
|
{
|
||||||
|
labelList& map = faceMap[procMeshI];
|
||||||
|
forAll(map, i)
|
||||||
|
{
|
||||||
|
if (map[i] >= 0)
|
||||||
|
{
|
||||||
|
map[i] = oldToNew[map[i]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label allFaceI = -map[i]-1;
|
||||||
|
map[i] = -oldToNew[allFaceI]-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inplaceReorder(oldToNew, lowerAddr_);
|
||||||
|
inplaceReorder(oldToNew, upperAddr_);
|
||||||
|
|
||||||
|
forAll(boundaryFaceMap, procI)
|
||||||
|
{
|
||||||
|
const labelList& bMap = boundaryMap[procI];
|
||||||
|
forAll(bMap, intI)
|
||||||
|
{
|
||||||
|
if (bMap[intI] == -1)
|
||||||
|
{
|
||||||
|
// Merged interface
|
||||||
|
labelList& bfMap = boundaryFaceMap[procI][intI];
|
||||||
|
|
||||||
|
forAll(bfMap, i)
|
||||||
|
{
|
||||||
|
if (bfMap[i] >= 0)
|
||||||
|
{
|
||||||
|
bfMap[i] = oldToNew[bfMap[i]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label allFaceI = -bfMap[i]-1;
|
||||||
|
bfMap[i] = (-oldToNew[allFaceI]-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Kept interfaces
|
// Kept interfaces
|
||||||
// ~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -736,7 +821,6 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
|
|
||||||
forAllConstIter(EdgeMap<labelPairList>, unmergedMap, iter)
|
forAllConstIter(EdgeMap<labelPairList>, unmergedMap, iter)
|
||||||
{
|
{
|
||||||
Pout<< "agglom procEdge:" << iter.key() << endl;
|
|
||||||
const labelPairList& elems = iter();
|
const labelPairList& elems = iter();
|
||||||
|
|
||||||
// Sort processors in increasing order
|
// Sort processors in increasing order
|
||||||
@ -758,10 +842,10 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
procMeshI
|
procMeshI
|
||||||
).interfaces();
|
).interfaces();
|
||||||
|
|
||||||
Pout<< " adding interface:" << " procMeshI:" << procMeshI
|
//Pout<< " adding interface:" << " procMeshI:" << procMeshI
|
||||||
<< " interface:" << interfaceI
|
// << " interface:" << interfaceI
|
||||||
<< " size:" << interfaces[interfaceI].faceCells().size()
|
// << " size:" << interfaces[interfaceI].faceCells().size()
|
||||||
<< endl;
|
// << endl;
|
||||||
|
|
||||||
n += interfaces[interfaceI].faceCells().size();
|
n += interfaces[interfaceI].faceCells().size();
|
||||||
}
|
}
|
||||||
@ -850,13 +934,16 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
|
|||||||
);
|
);
|
||||||
interfaces_.set(allInterfaceI, &primitiveInterfaces_[allInterfaceI]);
|
interfaces_.set(allInterfaceI, &primitiveInterfaces_[allInterfaceI]);
|
||||||
|
|
||||||
Pout<< "Created " << interfaces_[allInterfaceI].type()
|
if (debug)
|
||||||
<< " interface at " << allInterfaceI
|
{
|
||||||
<< " comm:" << comm_
|
Pout<< "Created " << interfaces_[allInterfaceI].type()
|
||||||
<< " myProcNo:" << myAgglom
|
<< " interface at " << allInterfaceI
|
||||||
<< " neighbProcNo:" << neighbProcNo
|
<< " comm:" << comm_
|
||||||
<< " nFaces:" << allFaceCells.size()
|
<< " myProcNo:" << myAgglom
|
||||||
<< endl;
|
<< " neighbProcNo:" << neighbProcNo
|
||||||
|
<< " nFaces:" << allFaceCells.size()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
allInterfaceI++;
|
allInterfaceI++;
|
||||||
@ -992,12 +1079,6 @@ void Foam::lduPrimitiveMesh::gather
|
|||||||
comm
|
comm
|
||||||
);
|
);
|
||||||
|
|
||||||
//Pout<< "sent nCells:" << addressing.size()
|
|
||||||
// << "sent lowerAddr:" << addressing.lowerAddr().size()
|
|
||||||
// << "sent upperAddr:" << addressing.upperAddr()
|
|
||||||
// << "sent validInterface:" << validInterface
|
|
||||||
// << endl;
|
|
||||||
|
|
||||||
toMaster
|
toMaster
|
||||||
<< addressing.size()
|
<< addressing.size()
|
||||||
<< addressing.lowerAddr()
|
<< addressing.lowerAddr()
|
||||||
|
|||||||
@ -81,6 +81,13 @@ class lduPrimitiveMesh
|
|||||||
//- Get size of all meshes
|
//- Get size of all meshes
|
||||||
static label size(const PtrList<lduMesh>&);
|
static label size(const PtrList<lduMesh>&);
|
||||||
|
|
||||||
|
static labelList upperTriOrder
|
||||||
|
(
|
||||||
|
const label nCells,
|
||||||
|
const labelUList& lower,
|
||||||
|
const labelUList& upper
|
||||||
|
);
|
||||||
|
|
||||||
//- Check if in upper-triangular ordering
|
//- Check if in upper-triangular ordering
|
||||||
static void checkUpperTriangular
|
static void checkUpperTriangular
|
||||||
(
|
(
|
||||||
@ -129,6 +136,18 @@ public:
|
|||||||
bool reUse
|
bool reUse
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct from components and re-use storage.
|
||||||
|
lduPrimitiveMesh
|
||||||
|
(
|
||||||
|
const label nCells,
|
||||||
|
labelList& l,
|
||||||
|
labelList& u,
|
||||||
|
labelListList& pa,
|
||||||
|
const Xfer<PtrList<const lduInterface> >& primitiveInterfaces,
|
||||||
|
const lduSchedule& ps,
|
||||||
|
const label comm
|
||||||
|
);
|
||||||
|
|
||||||
//- Construct by combining multiple meshes. The meshes come from
|
//- Construct by combining multiple meshes. The meshes come from
|
||||||
// processors procIDs:
|
// processors procIDs:
|
||||||
// procIDs[0] : local processor (myMesh)
|
// procIDs[0] : local processor (myMesh)
|
||||||
|
|||||||
Reference in New Issue
Block a user