Commit 6b22ab90 authored by mattijs's avatar mattijs
Browse files

ENH: GAMGInterface: simplify stored data. Do not store processor-local data

parent 4e6c2583
......@@ -317,6 +317,7 @@ algebraicPairGAMGAgglomeration = $(GAMGAgglomerations)/algebraicPairGAMGAgglomer
$(algebraicPairGAMGAgglomeration)/algebraicPairGAMGAgglomeration.C
meshes/lduMesh/lduMesh.C
meshes/lduMesh/lduPrimitiveMesh.C
LduMatrix = matrices/LduMatrix
$(LduMatrix)/LduMatrix/lduMatrices.C
......
......@@ -355,7 +355,7 @@ int Foam::UPstream::baseProcNo(const label myComm, const int myProcID)
}
Foam::label Foam::UPstream::myProcNo(const label myComm, const int baseProcID)
Foam::label Foam::UPstream::procNo(const label myComm, const int baseProcID)
{
const List<int>& parentRanks = procID(myComm);
label parentComm = parent(myComm);
......@@ -366,12 +366,24 @@ Foam::label Foam::UPstream::myProcNo(const label myComm, const int baseProcID)
}
else
{
label parentRank = myProcNo(parentComm, baseProcID);
label parentRank = procNo(parentComm, baseProcID);
return findIndex(parentRanks, parentRank);
}
}
Foam::label Foam::UPstream::procNo
(
const label myComm,
const label currentComm,
const int currentProcID
)
{
label physProcID = UPstream::baseProcNo(currentComm, currentProcID);
return procNo(myComm, physProcID);
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// By default this is not a parallel run
......
......@@ -336,12 +336,20 @@ public:
//- Return physical processor number (i.e. processor number in
// worldComm) given communicator and procssor
static int baseProcNo(const label myComm, const int myProcID);
static int baseProcNo(const label myComm, const int procID);
//- Return processor number in communicator (given physical processor
// number) (= reverse of baseProcNo)
static label myProcNo(const label myComm, const int baseProcID);
static label procNo(const label comm, const int baseProcID);
//- Return processor number in communicator (given processor number
// and communicator)
static label procNo
(
const label myComm,
const label currentComm,
const int currentProcID
);
//- Add the valid option this type of communications library
// adds/requires on the command line
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -39,7 +39,7 @@ Description
order but only for groups of edges belonging to each point. An example
is given below:
\verbatim
owner eighbour
owner neighbour
0 1
0 20
1 2
......
......@@ -65,10 +65,10 @@ protected:
const lduInterfacePtrsList& coarseInterfaces_;
//- Face-cell addressing
labelField faceCells_;
labelList faceCells_;
//- Face restrict addressing
labelField faceRestrictAddressing_;
labelList faceRestrictAddressing_;
private:
......@@ -134,17 +134,11 @@ public:
// Constructors
//- Construct from fine-level interface,
// local and neighbour restrict addressing
//- Construct from interfaces, restrict addressing set later on
GAMGInterface
(
const label index,
const lduInterfacePtrsList& coarseInterfaces,
const lduInterface&,
const labelField&,
const labelField&,
const label fineLevelIndex = -1,
const label coarseComm = UPstream::worldComm
const lduInterfacePtrsList& coarseInterfaces
)
:
index_(index),
......@@ -152,6 +146,22 @@ public:
{}
//- Construct from interfaces and restrict addressing
GAMGInterface
(
const label index,
const lduInterfacePtrsList& coarseInterfaces,
const labelUList& faceCells,
const labelUList& faceRestrictAddressing
)
:
index_(index),
coarseInterfaces_(coarseInterfaces),
faceCells_(faceCells),
faceRestrictAddressing_(faceRestrictAddressing)
{}
// Member Functions
// Access
......
......@@ -58,10 +58,10 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
GAMGInterface
(
index,
coarseInterfaces,
fineInterface,
localRestrictAddressing,
neighbourRestrictAddressing
coarseInterfaces
// fineInterface,
// localRestrictAddressing,
// neighbourRestrictAddressing
),
fineCyclicInterface_(refCast<const cyclicLduInterface>(fineInterface))
{
......
......@@ -58,13 +58,20 @@ Foam::processorGAMGInterface::processorGAMGInterface
GAMGInterface
(
index,
coarseInterfaces,
fineInterface,
localRestrictAddressing,
neighbourRestrictAddressing
coarseInterfaces
// fineInterface,
// localRestrictAddressing,
// neighbourRestrictAddressing
),
// fineProcInterface_(refCast<const processorLduInterface>(fineInterface)),
comm_(coarseComm),
myProcNo_(refCast<const processorLduInterface>(fineInterface).myProcNo()),
neighbProcNo_
(
refCast<const processorLduInterface>(fineInterface).neighbProcNo()
),
fineProcInterface_(refCast<const processorLduInterface>(fineInterface)),
comm_(coarseComm)
forwardT_(refCast<const processorLduInterface>(fineInterface).forwardT()),
tag_(refCast<const processorLduInterface>(fineInterface).tag())
{
// From coarse face to coarse cell
DynamicList<label> dynFaceCells(localRestrictAddressing.size());
......@@ -128,7 +135,37 @@ Foam::processorGAMGInterface::processorGAMGInterface
}
// * * * * * * * * * * * * * * * * Desstructor * * * * * * * * * * * * * * * //
Foam::processorGAMGInterface::processorGAMGInterface
(
const label index,
const lduInterfacePtrsList& coarseInterfaces,
// const lduInterface& fineInterface,
const labelUList& faceCells,
const labelUList& faceRestrictAddresssing,
const label coarseComm,
const label myProcNo,
const label neighbProcNo,
const tensorField& forwardT,
const int tag
)
:
GAMGInterface
(
index,
coarseInterfaces,
faceCells,
faceRestrictAddresssing
),
//fineProcInterface_(refCast<const processorLduInterface>(fineInterface)),
comm_(coarseComm),
myProcNo_(myProcNo),
neighbProcNo_(neighbProcNo),
forwardT_(forwardT),
tag_(tag)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::processorGAMGInterface::~processorGAMGInterface()
{}
......
......@@ -55,13 +55,25 @@ class processorGAMGInterface
{
// Private data
//- Reference for the processorLduInterface from which this is
// agglomerated
const processorLduInterface& fineProcInterface_;
// //- Reference to the processorLduInterface from which this is
// // agglomerated
// const processorLduInterface& fineProcInterface_;
//- Communicator to use for parallel communication
const label comm_;
//- My processor rank in communicator
label myProcNo_;
//- Neighbouring processor rank in communicator
label neighbProcNo_;
//- Transformation tensor
tensorField forwardT_;
//- Message tag used for sending
int tag_;
// Private Member Functions
......@@ -92,6 +104,21 @@ public:
const label coarseComm
);
//- Construct from components
processorGAMGInterface
(
const label index,
const lduInterfacePtrsList& coarseInterfaces,
//const lduInterface& fineInterface,
const labelUList& faceCells,
const labelUList& faceRestrictAddresssing,
const label coarseComm,
const label myProcNo,
const label neighbProcNo,
const tensorField& forwardT,
const int tag
);
//- Destructor
virtual ~processorGAMGInterface();
......@@ -118,34 +145,34 @@ public:
//- Processor interface functions
//- Return processor number
//- Return communicator used for sending
virtual int comm() const
{
return comm_;
}
//- Return processor number (rank in communicator)
virtual int myProcNo() const
{
return fineProcInterface_.myProcNo();
return myProcNo_;
}
//- Return neigbour processor number
//- Return neigbour processor number (rank in communicator)
virtual int neighbProcNo() const
{
return fineProcInterface_.neighbProcNo();
return neighbProcNo_;
}
//- Return face transformation tensor
virtual const tensorField& forwardT() const
{
return fineProcInterface_.forwardT();
return forwardT_;
}
//- Return message tag used for sending
virtual int tag() const
{
return fineProcInterface_.tag();
}
//- Return communicator used for sending
virtual int comm() const
{
return comm_;
return tag_;
}
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -31,11 +31,11 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Patch, class ProcPatch>
Foam::labelList Foam::ProcessorTopology<Patch, ProcPatch>::procNeighbours
template<class Container, class ProcPatch>
Foam::labelList Foam::ProcessorTopology<Container, ProcPatch>::procNeighbours
(
const label nProcs,
const PtrList<Patch>& patches
const Container& patches
)
{
// Determine number of processor neighbours and max neighbour id.
......@@ -48,7 +48,7 @@ Foam::labelList Foam::ProcessorTopology<Patch, ProcPatch>::procNeighbours
forAll(patches, patchi)
{
const Patch& patch = patches[patchi];
const typename Container::const_reference patch = patches[patchi];
if (isA<ProcPatch>(patch))
{
......@@ -85,7 +85,7 @@ Foam::labelList Foam::ProcessorTopology<Patch, ProcPatch>::procNeighbours
forAll(patches, patchi)
{
const Patch& patch = patches[patchi];
const typename Container::const_reference patch = patches[patchi];
if (isA<ProcPatch>(patch))
{
......@@ -104,10 +104,10 @@ Foam::labelList Foam::ProcessorTopology<Patch, ProcPatch>::procNeighbours
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Patch, class ProcPatch>
Foam::ProcessorTopology<Patch, ProcPatch>::ProcessorTopology
template<class Container, class ProcPatch>
Foam::ProcessorTopology<Container, ProcPatch>::ProcessorTopology
(
const PtrList<Patch>& patches,
const Container& patches,
const label comm
)
:
......@@ -117,7 +117,8 @@ Foam::ProcessorTopology<Patch, ProcPatch>::ProcessorTopology
if (Pstream::parRun())
{
// Fill my 'slot' with my neighbours
operator[](Pstream::myProcNo()) = procNeighbours(this->size(), patches);
operator[](Pstream::myProcNo(comm)) =
procNeighbours(this->size(), patches);
// Distribute to all processors
Pstream::gatherList(*this, Pstream::msgType(), comm);
......@@ -176,7 +177,7 @@ Foam::ProcessorTopology<Patch, ProcPatch>::ProcessorTopology
(
Pstream::nProcs(comm),
comms
).procSchedule()[Pstream::myProcNo()]
).procSchedule()[Pstream::myProcNo(comm)]
);
forAll(mySchedule, iter)
......@@ -185,13 +186,13 @@ Foam::ProcessorTopology<Patch, ProcPatch>::ProcessorTopology
// Get the other processor
label nb = comms[commI][0];
if (nb == Pstream::myProcNo())
if (nb == Pstream::myProcNo(comm))
{
nb = comms[commI][1];
}
label patchi = procPatchMap_[nb];
if (Pstream::myProcNo() > nb)
if (Pstream::myProcNo(comm) > nb)
{
patchSchedule_[patchEvali].patch = patchi;
patchSchedule_[patchEvali++].init = true;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -53,7 +53,7 @@ namespace Foam
Class ProcessorTopology Declaration
\*---------------------------------------------------------------------------*/
template<class Patch, class ProcPatch>
template<class Container, class ProcPatch>
class ProcessorTopology
:
public labelListList
......@@ -76,14 +76,14 @@ private:
//- Return all neighbouring processors of this processor. Set
// procPatchMap_.
labelList procNeighbours(const label nProcs, const PtrList<Patch>&);
labelList procNeighbours(const label nProcs, const Container&);
public:
// Constructors
//- Construct from boundaryMesh
ProcessorTopology(const PtrList<Patch>& patches, const label comm);
ProcessorTopology(const Container& patches, const label comm);
// Member Functions
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "lduPrimitiveMesh.H"
#include "processorLduInterface.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::lduPrimitiveMesh::lduPrimitiveMesh
(
const label nCells,
const labelUList& l,
const labelUList& u,
const labelListList& pa,
const lduInterfacePtrsList& interfaces,
const lduSchedule& ps,
const label comm
)
:
lduAddressing(nCells),
lowerAddr_(l),
upperAddr_(u),
patchAddr_(pa),
interfaces_(interfaces),
patchSchedule_(ps),
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
(
const label nCells,
labelList& l,
labelList& u,
labelListList& pa,
lduInterfacePtrsList& interfaces,
const lduSchedule& ps,
const label comm,
bool reUse
)
:
lduAddressing(nCells),
lowerAddr_(l, reUse),
upperAddr_(u, reUse),
patchAddr_(pa, reUse),
interfaces_(interfaces, reUse),
patchSchedule_(ps),
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(Istream& is)
//:
// lduAddressing(readLabel(is)),
// lowerAddr_(is),
// upperAddr_(is),
// patchAddr_(is),
// interfaces_(is),
// patchSchedule_(is),
// comm_(readLabel(is))
//{}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//Foam::Ostream& Foam::operator<<
//(
// Ostream& os,
// const Foam::lduPrimitiveMesh& mesh
//)
//{
// os << mesh.size()
// << mesh.lowerAddr_
// << mesh.upperAddr_