mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: GAMGProcAgglomeration methods
This commit is contained in:
@ -324,8 +324,14 @@ GAMGProcAgglomerations = $(GAMG)/GAMGProcAgglomerations
|
|||||||
|
|
||||||
GAMGProcAgglomeration = $(GAMGProcAgglomerations)/GAMGProcAgglomeration
|
GAMGProcAgglomeration = $(GAMGProcAgglomerations)/GAMGProcAgglomeration
|
||||||
$(GAMGProcAgglomeration)/GAMGProcAgglomeration.C
|
$(GAMGProcAgglomeration)/GAMGProcAgglomeration.C
|
||||||
masterCoarsest = $(GAMGProcAgglomerations)/masterCoarsest
|
masterCoarsestGAMGProcAgglomeration = $(GAMGProcAgglomerations)/masterCoarsestGAMGProcAgglomeration
|
||||||
$(masterCoarsest)/masterCoarsest.C
|
$(masterCoarsestGAMGProcAgglomeration)/masterCoarsestGAMGProcAgglomeration.C
|
||||||
|
manualGAMGProcAgglomeration = $(GAMGProcAgglomerations)/manualGAMGProcAgglomeration
|
||||||
|
$(manualGAMGProcAgglomeration)/manualGAMGProcAgglomeration.C
|
||||||
|
/*
|
||||||
|
cellFaceRatioGAMGProcAgglomeration = $(GAMGProcAgglomerations)/cellFaceRatioGAMGProcAgglomeration
|
||||||
|
$(cellFaceRatioGAMGProcAgglomeration)/cellFaceRatioGAMGProcAgglomeration.C
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
meshes/lduMesh/lduMesh.C
|
meshes/lduMesh/lduMesh.C
|
||||||
|
|||||||
@ -38,6 +38,7 @@ namespace Foam
|
|||||||
defineTypeNameAndDebug(GAMGAgglomeration, 0);
|
defineTypeNameAndDebug(GAMGAgglomeration, 0);
|
||||||
defineRunTimeSelectionTable(GAMGAgglomeration, lduMesh);
|
defineRunTimeSelectionTable(GAMGAgglomeration, lduMesh);
|
||||||
defineRunTimeSelectionTable(GAMGAgglomeration, lduMatrix);
|
defineRunTimeSelectionTable(GAMGAgglomeration, lduMatrix);
|
||||||
|
defineRunTimeSelectionTable(GAMGAgglomeration, geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,6 +70,24 @@ void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
|
|||||||
|
|
||||||
procAgglomeratorPtr_().agglomerate();
|
procAgglomeratorPtr_().agglomerate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
for (label levelI = 0; levelI <= size(); levelI++)
|
||||||
|
{
|
||||||
|
if (hasMeshLevel(levelI))
|
||||||
|
{
|
||||||
|
const lduMesh& fineMesh = meshLevel(levelI);
|
||||||
|
Pout<< "Level " << levelI << " fine mesh:"<< nl;
|
||||||
|
Pout<< fineMesh.info() << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pout<< "Level " << levelI << " has no fine mesh:" << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -241,18 +260,56 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::GAMGAgglomeration> Foam::GAMGAgglomeration::New
|
||||||
|
(
|
||||||
|
const lduMesh& mesh,
|
||||||
|
const scalarField& cellVolumes,
|
||||||
|
const vectorField& faceAreas,
|
||||||
|
const dictionary& controlDict
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const word agglomeratorType(controlDict.lookup("agglomerator"));
|
||||||
|
|
||||||
|
const_cast<Time&>(mesh.thisDb().time()).libs().open
|
||||||
|
(
|
||||||
|
controlDict,
|
||||||
|
"geometricGAMGAgglomerationLibs",
|
||||||
|
geometryConstructorTablePtr_
|
||||||
|
);
|
||||||
|
|
||||||
|
geometryConstructorTable::iterator cstrIter =
|
||||||
|
geometryConstructorTablePtr_->find(agglomeratorType);
|
||||||
|
|
||||||
|
if (cstrIter == geometryConstructorTablePtr_->end())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"GAMGAgglomeration::New"
|
||||||
|
"(const lduMesh& mesh, const dictionary& controlDict)"
|
||||||
|
) << "Unknown GAMGAgglomeration type "
|
||||||
|
<< agglomeratorType << ".\n"
|
||||||
|
<< "Valid geometric GAMGAgglomeration types are :"
|
||||||
|
<< geometryConstructorTablePtr_->sortedToc()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return autoPtr<GAMGAgglomeration>
|
||||||
|
(
|
||||||
|
cstrIter()
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
cellVolumes,
|
||||||
|
faceAreas,
|
||||||
|
controlDict
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::GAMGAgglomeration::~GAMGAgglomeration()
|
Foam::GAMGAgglomeration::~GAMGAgglomeration()
|
||||||
{
|
{}
|
||||||
forAllReverse(procCommunicator_, i)
|
|
||||||
{
|
|
||||||
if (procCommunicator_[i] != -1)
|
|
||||||
{
|
|
||||||
UPstream::freeCommunicator(procCommunicator_[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -253,6 +253,27 @@ public:
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Runtime selection table for matrix or mixed geometric/matrix
|
||||||
|
// agglomerators
|
||||||
|
declareRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
autoPtr,
|
||||||
|
GAMGAgglomeration,
|
||||||
|
geometry,
|
||||||
|
(
|
||||||
|
const lduMesh& mesh,
|
||||||
|
const scalarField& cellVolumes,
|
||||||
|
const vectorField& faceAreas,
|
||||||
|
const dictionary& controlDict
|
||||||
|
),
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
cellVolumes,
|
||||||
|
faceAreas,
|
||||||
|
controlDict
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
@ -280,6 +301,15 @@ public:
|
|||||||
const dictionary& controlDict
|
const dictionary& controlDict
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Return the selected geometric agglomerator
|
||||||
|
static autoPtr<GAMGAgglomeration> New
|
||||||
|
(
|
||||||
|
const lduMesh& mesh,
|
||||||
|
const scalarField& cellVolumes,
|
||||||
|
const vectorField& faceAreas,
|
||||||
|
const dictionary& controlDict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~GAMGAgglomeration();
|
~GAMGAgglomeration();
|
||||||
|
|||||||
@ -47,36 +47,11 @@ void Foam::GAMGProcAgglomeration::printStats
|
|||||||
{
|
{
|
||||||
if (agglom.hasMeshLevel(levelI))
|
if (agglom.hasMeshLevel(levelI))
|
||||||
{
|
{
|
||||||
const lduMesh& fineMesh = agglom.meshLevel(levelI);
|
os << agglom.meshLevel(levelI).info() << endl;
|
||||||
const lduInterfacePtrsList& interfaces =
|
|
||||||
agglom.interfaceLevel(levelI);
|
|
||||||
|
|
||||||
os << "Level " << levelI << " fine mesh:"<< nl
|
|
||||||
<< " nCells:"
|
|
||||||
<< fineMesh.lduAddr().size() << nl
|
|
||||||
<< " nFaces:"
|
|
||||||
<< fineMesh.lduAddr().lowerAddr().size() << nl
|
|
||||||
<< " nInterfaces:" << interfaces.size()
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
forAll(interfaces, i)
|
|
||||||
{
|
|
||||||
if (interfaces.set(i))
|
|
||||||
{
|
|
||||||
os << " " << i
|
|
||||||
<< "\tsize:" << interfaces[i].faceCells().size()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
os << fineMesh.info() << endl;
|
|
||||||
|
|
||||||
os << endl;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << "Level " << levelI << " has no fine mesh:" << nl
|
os << "Level " << levelI << " has no fine mesh:" << endl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
|
|||||||
@ -0,0 +1,170 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "manualGAMGProcAgglomeration.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "GAMGAgglomeration.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(manualGAMGProcAgglomeration, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
GAMGProcAgglomeration,
|
||||||
|
manualGAMGProcAgglomeration,
|
||||||
|
GAMGAgglomeration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::manualGAMGProcAgglomeration::manualGAMGProcAgglomeration
|
||||||
|
(
|
||||||
|
GAMGAgglomeration& agglom,
|
||||||
|
const dictionary& controlDict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
GAMGProcAgglomeration(agglom, controlDict),
|
||||||
|
procAgglomMaps_(controlDict.lookup("processorAgglomeration"))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::manualGAMGProcAgglomeration::
|
||||||
|
~manualGAMGProcAgglomeration()
|
||||||
|
{
|
||||||
|
forAllReverse(comms_, i)
|
||||||
|
{
|
||||||
|
if (comms_[i] != -1)
|
||||||
|
{
|
||||||
|
UPstream::freeCommunicator(comms_[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::manualGAMGProcAgglomeration::agglomerate()
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< nl << "Starting mesh overview" << endl;
|
||||||
|
printStats(Pout, agglom_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (agglom_.size() >= 1)
|
||||||
|
{
|
||||||
|
forAll(procAgglomMaps_, i)
|
||||||
|
{
|
||||||
|
const label fineLevelIndex = procAgglomMaps_[i].first();
|
||||||
|
|
||||||
|
if (fineLevelIndex >= agglom_.size())
|
||||||
|
{
|
||||||
|
WarningIn("manualGAMGProcAgglomeration::agglomerate()")
|
||||||
|
<< "Ignoring specification for level " << fineLevelIndex
|
||||||
|
<< " since outside agglomeration." << endl;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (agglom_.hasMeshLevel(fineLevelIndex))
|
||||||
|
{
|
||||||
|
const labelList& procAgglomMap = procAgglomMaps_[i].second();
|
||||||
|
// Get the fine mesh
|
||||||
|
const lduMesh& levelMesh = agglom_.meshLevel(fineLevelIndex);
|
||||||
|
|
||||||
|
|
||||||
|
if (procAgglomMap.size() != Pstream::nProcs(levelMesh.comm()))
|
||||||
|
{
|
||||||
|
FatalErrorIn("manualGAMGProcAgglomeration::agglomerate()")
|
||||||
|
<< "At level " << fineLevelIndex
|
||||||
|
<< "The fine-to-coarse agglomeration map size "
|
||||||
|
<< procAgglomMap.size() << " differs from the"
|
||||||
|
<< " number of processors "
|
||||||
|
<< Pstream::nProcs(levelMesh.comm())
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Master processor
|
||||||
|
labelList masterProcs;
|
||||||
|
// Local processors that agglomerate. agglomProcIDs[0] is in
|
||||||
|
// masterProc.
|
||||||
|
List<int> agglomProcIDs;
|
||||||
|
GAMGAgglomeration::calculateRegionMaster
|
||||||
|
(
|
||||||
|
levelMesh.comm(),
|
||||||
|
procAgglomMap,
|
||||||
|
masterProcs,
|
||||||
|
agglomProcIDs
|
||||||
|
);
|
||||||
|
|
||||||
|
// Allocate a communicator for the processor-agglomerated matrix
|
||||||
|
comms_.append
|
||||||
|
(
|
||||||
|
UPstream::allocateCommunicator
|
||||||
|
(
|
||||||
|
levelMesh.comm(),
|
||||||
|
masterProcs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Use procesor agglomeration maps to do the actual collecting.
|
||||||
|
if (Pstream::myProcNo(levelMesh.comm()) != -1)
|
||||||
|
{
|
||||||
|
GAMGProcAgglomeration::agglomerate
|
||||||
|
(
|
||||||
|
fineLevelIndex,
|
||||||
|
procAgglomMap,
|
||||||
|
masterProcs,
|
||||||
|
agglomProcIDs,
|
||||||
|
comms_.last()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print a bit
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< nl << "Agglomerated mesh overview" << endl;
|
||||||
|
printStats(Pout, agglom_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,114 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::manualGAMGProcAgglomeration
|
||||||
|
|
||||||
|
Description
|
||||||
|
Manual processor agglomeration of GAMGAgglomerations.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
manualGAMGProcAgglomeration.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef manualGAMGProcAgglomeration_H
|
||||||
|
#define manualGAMGProcAgglomeration_H
|
||||||
|
|
||||||
|
#include "GAMGProcAgglomeration.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class GAMGAgglomeration;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class manualGAMGProcAgglomeration Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class manualGAMGProcAgglomeration
|
||||||
|
:
|
||||||
|
public GAMGProcAgglomeration
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Per level the agglomeration map
|
||||||
|
const List<Tuple2<label, labelList> > procAgglomMaps_;
|
||||||
|
|
||||||
|
//- Any allocated communicators
|
||||||
|
DynamicList<label> comms_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
manualGAMGProcAgglomeration
|
||||||
|
(
|
||||||
|
const manualGAMGProcAgglomeration&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const manualGAMGProcAgglomeration&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("manual");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct given agglomerator and controls
|
||||||
|
manualGAMGProcAgglomeration
|
||||||
|
(
|
||||||
|
GAMGAgglomeration& agglom,
|
||||||
|
const dictionary& controlDict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~manualGAMGProcAgglomeration();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Modify agglomeration. Return true if modified
|
||||||
|
virtual bool agglomerate();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -23,7 +23,7 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "masterCoarsest.H"
|
#include "masterCoarsestGAMGProcAgglomeration.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "GAMGAgglomeration.H"
|
#include "GAMGAgglomeration.H"
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(masterCoarsest, 0);
|
defineTypeNameAndDebug(masterCoarsestGAMGProcAgglomeration, 0);
|
||||||
|
|
||||||
addToRunTimeSelectionTable
|
addToRunTimeSelectionTable
|
||||||
(
|
(
|
||||||
GAMGProcAgglomeration,
|
GAMGProcAgglomeration,
|
||||||
masterCoarsest,
|
masterCoarsestGAMGProcAgglomeration,
|
||||||
GAMGAgglomeration
|
GAMGAgglomeration
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::masterCoarsest::masterCoarsest
|
Foam::masterCoarsestGAMGProcAgglomeration::masterCoarsestGAMGProcAgglomeration
|
||||||
(
|
(
|
||||||
GAMGAgglomeration& agglom,
|
GAMGAgglomeration& agglom,
|
||||||
const dictionary& controlDict
|
const dictionary& controlDict
|
||||||
@ -59,10 +59,22 @@ Foam::masterCoarsest::masterCoarsest
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::masterCoarsestGAMGProcAgglomeration::
|
||||||
|
~masterCoarsestGAMGProcAgglomeration()
|
||||||
|
{
|
||||||
|
forAllReverse(comms_, i)
|
||||||
|
{
|
||||||
|
if (comms_[i] != -1)
|
||||||
|
{
|
||||||
|
UPstream::freeCommunicator(comms_[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::masterCoarsest::agglomerate()
|
bool Foam::masterCoarsestGAMGProcAgglomeration::agglomerate()
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -76,60 +88,50 @@ bool Foam::masterCoarsest::agglomerate()
|
|||||||
// restrictAddressing)
|
// restrictAddressing)
|
||||||
label fineLevelIndex = agglom_.size()-1;
|
label fineLevelIndex = agglom_.size()-1;
|
||||||
|
|
||||||
// Get the coarse mesh
|
if (agglom_.hasMeshLevel(fineLevelIndex))
|
||||||
const lduMesh& levelMesh = agglom_.meshLevel(fineLevelIndex-1);
|
|
||||||
label levelComm = levelMesh.comm();
|
|
||||||
|
|
||||||
// Processor restriction map: per processor the coarse processor
|
|
||||||
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;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
procAgglomMap = 0;
|
|
||||||
|
|
||||||
// Master processor
|
|
||||||
labelList masterProcs;
|
|
||||||
// Local processors that agglomerate. agglomProcIDs[0] is in
|
|
||||||
// masterProc.
|
|
||||||
List<int> agglomProcIDs;
|
|
||||||
GAMGAgglomeration::calculateRegionMaster
|
|
||||||
(
|
|
||||||
levelComm,
|
|
||||||
procAgglomMap,
|
|
||||||
masterProcs,
|
|
||||||
agglomProcIDs
|
|
||||||
);
|
|
||||||
|
|
||||||
// Allocate a communicator for the processor-agglomerated matrix
|
|
||||||
label procAgglomComm = UPstream::allocateCommunicator
|
|
||||||
(
|
|
||||||
levelComm,
|
|
||||||
masterProcs
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Above should really be determined by a procesor-agglomeration
|
|
||||||
// engine. Use procesor agglomeration maps to do the actual
|
|
||||||
// collecting.
|
|
||||||
|
|
||||||
if (Pstream::myProcNo(levelComm) != -1)
|
|
||||||
{
|
{
|
||||||
GAMGProcAgglomeration::agglomerate
|
// Get the fine mesh
|
||||||
|
const lduMesh& levelMesh = agglom_.meshLevel(fineLevelIndex);
|
||||||
|
label levelComm = levelMesh.comm();
|
||||||
|
|
||||||
|
// Processor restriction map: per processor the coarse processor
|
||||||
|
labelList procAgglomMap(UPstream::nProcs(levelComm), 0);
|
||||||
|
|
||||||
|
// Master processor
|
||||||
|
labelList masterProcs;
|
||||||
|
// Local processors that agglomerate. agglomProcIDs[0] is in
|
||||||
|
// masterProc.
|
||||||
|
List<int> agglomProcIDs;
|
||||||
|
GAMGAgglomeration::calculateRegionMaster
|
||||||
(
|
(
|
||||||
fineLevelIndex,
|
levelComm,
|
||||||
procAgglomMap,
|
procAgglomMap,
|
||||||
masterProcs,
|
masterProcs,
|
||||||
agglomProcIDs,
|
agglomProcIDs
|
||||||
procAgglomComm
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Allocate a communicator for the processor-agglomerated matrix
|
||||||
|
comms_.append
|
||||||
|
(
|
||||||
|
UPstream::allocateCommunicator
|
||||||
|
(
|
||||||
|
levelComm,
|
||||||
|
masterProcs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Use procesor agglomeration maps to do the actual collecting.
|
||||||
|
if (Pstream::myProcNo(levelComm) != -1)
|
||||||
|
{
|
||||||
|
GAMGProcAgglomeration::agglomerate
|
||||||
|
(
|
||||||
|
fineLevelIndex,
|
||||||
|
procAgglomMap,
|
||||||
|
masterProcs,
|
||||||
|
agglomProcIDs,
|
||||||
|
comms_.last()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,20 +22,21 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::masterCoarsest
|
Foam::masterCoarsestGAMGProcAgglomeration
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Processor agglomeration of GAMGAgglomerations.
|
Processor agglomeration of GAMGAgglomerations.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
masterCoarsest.C
|
masterCoarsestGAMGProcAgglomeration.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef masterCoarsest_H
|
#ifndef masterCoarsestGAMGProcAgglomeration_H
|
||||||
#define masterCoarsest_H
|
#define masterCoarsestGAMGProcAgglomeration_H
|
||||||
|
|
||||||
#include "GAMGProcAgglomeration.H"
|
#include "GAMGProcAgglomeration.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -45,22 +46,27 @@ namespace Foam
|
|||||||
class GAMGAgglomeration;
|
class GAMGAgglomeration;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class masterCoarsest Declaration
|
Class masterCoarsestGAMGProcAgglomeration Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class masterCoarsest
|
class masterCoarsestGAMGProcAgglomeration
|
||||||
:
|
:
|
||||||
public GAMGProcAgglomeration
|
public GAMGProcAgglomeration
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
|
DynamicList<label> comms_;
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
masterCoarsest(const masterCoarsest&);
|
masterCoarsestGAMGProcAgglomeration
|
||||||
|
(
|
||||||
|
const masterCoarsestGAMGProcAgglomeration&
|
||||||
|
);
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const masterCoarsest&);
|
void operator=(const masterCoarsestGAMGProcAgglomeration&);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -72,7 +78,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given agglomerator and controls
|
//- Construct given agglomerator and controls
|
||||||
masterCoarsest
|
masterCoarsestGAMGProcAgglomeration
|
||||||
(
|
(
|
||||||
GAMGAgglomeration& agglom,
|
GAMGAgglomeration& agglom,
|
||||||
const dictionary& controlDict
|
const dictionary& controlDict
|
||||||
@ -80,8 +86,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~masterCoarsest()
|
virtual ~masterCoarsestGAMGProcAgglomeration();
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -98,12 +103,6 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//#ifdef NoRepository
|
|
||||||
//# include "masterCoarsestTemplates.C"
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -96,10 +96,6 @@ class lduPrimitiveMesh
|
|||||||
const labelUList& u
|
const labelUList& u
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Get non-scheduled send/receive schedule
|
|
||||||
template<class ProcPatch>
|
|
||||||
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
lduPrimitiveMesh(const lduPrimitiveMesh&);
|
lduPrimitiveMesh(const lduPrimitiveMesh&);
|
||||||
|
|
||||||
@ -271,6 +267,11 @@ public:
|
|||||||
const labelList& procIDs,
|
const labelList& procIDs,
|
||||||
PtrList<lduMesh>& otherMeshes
|
PtrList<lduMesh>& otherMeshes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Get non-scheduled send/receive schedule
|
||||||
|
template<class ProcPatch>
|
||||||
|
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
@ -40,6 +40,13 @@ namespace Foam
|
|||||||
faceAreaPairGAMGAgglomeration,
|
faceAreaPairGAMGAgglomeration,
|
||||||
lduMesh
|
lduMesh
|
||||||
);
|
);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
GAMGAgglomeration,
|
||||||
|
faceAreaPairGAMGAgglomeration,
|
||||||
|
geometry
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,4 +80,33 @@ Foam::faceAreaPairGAMGAgglomeration::faceAreaPairGAMGAgglomeration
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::faceAreaPairGAMGAgglomeration::faceAreaPairGAMGAgglomeration
|
||||||
|
(
|
||||||
|
const lduMesh& mesh,
|
||||||
|
const scalarField& cellVolumes,
|
||||||
|
const vectorField& faceAreas,
|
||||||
|
const dictionary& controlDict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
pairGAMGAgglomeration(mesh, controlDict)
|
||||||
|
{
|
||||||
|
vectorField n(faceAreas/mag(faceAreas));
|
||||||
|
|
||||||
|
//agglomerate(mesh, sqrt(mag(faceAreas)));
|
||||||
|
agglomerate
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
mag
|
||||||
|
(
|
||||||
|
cmptMultiply
|
||||||
|
(
|
||||||
|
n,
|
||||||
|
vector(1, 1.01, 1.02)
|
||||||
|
//vector::one
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -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
|
||||||
@ -65,6 +65,15 @@ public:
|
|||||||
const lduMesh& mesh,
|
const lduMesh& mesh,
|
||||||
const dictionary& controlDict
|
const dictionary& controlDict
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Construct given mesh and controls
|
||||||
|
faceAreaPairGAMGAgglomeration
|
||||||
|
(
|
||||||
|
const lduMesh& mesh,
|
||||||
|
const scalarField& cellVolumes,
|
||||||
|
const vectorField& faceAreas,
|
||||||
|
const dictionary& controlDict
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user