Commit 0c1eea7d authored by mattijs's avatar mattijs
Browse files

ENH: lduPrimitiveMesh: added processor agglomeration routines

parent d7d0b07e
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,6 +25,7 @@ License
#include "lduMesh.H"
#include "objectRegistry.H"
#include "processorLduInterface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -44,4 +45,56 @@ const Foam::objectRegistry& Foam::lduMesh::thisDb() const
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<lduMesh>& ip)
{
const lduMesh& ldum = ip.t_;
const lduAddressing& addr = ldum.lduAddr();
const lduInterfacePtrsList interfaces = ldum.interfaces();
Pout<< "lduMesh :"
<< " size:" << addr.size()
<< " l:" << addr.lowerAddr().size()
<< " u:" << addr.upperAddr().size()
<< " interfaces:" << interfaces.size()
<< " comm:" << ldum.comm()
<< endl;
forAll(interfaces, i)
{
if (interfaces.set(i))
{
const labelUList& faceCells = addr.patchAddr(i);
if (isA<processorLduInterface>(interfaces[i]))
{
const processorLduInterface& pi = refCast
<
const processorLduInterface
>(interfaces[i]);
Pout<< " patch:" << i
<< " type:" << interfaces[i].type()
<< " size:" << faceCells.size()
<< " myProcNo:" << pi.myProcNo()
<< " neighbProcNo:" << pi.neighbProcNo()
<< " comm:" << pi.comm()
<< endl;
}
else
{
Pout<< " patch:" << i
<< " type:" << interfaces[i].type()
<< " size:" << faceCells.size()
<< endl;
}
}
}
os.check("Ostream& operator<<(Ostream&, const lduMesh&");
return os;
}
// ************************************************************************* //
......@@ -36,6 +36,7 @@ Description
#include "lduAddressing.H"
#include "lduInterfacePtrsList.H"
#include "typeInfo.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -88,6 +89,19 @@ public:
T& Value,
const BinaryOp& bop
) const;
// Info
//- Return info proxy.
// Used to print mesh information to a stream
InfoProxy<lduMesh> info() const
{
return *this;
}
// Ostream operator
friend Ostream& operator<<(Ostream&, const InfoProxy<lduMesh>&);
};
......
......@@ -71,16 +71,31 @@ class lduPrimitiveMesh
//- List of pointers for each patch
// with only those pointing to interfaces being set
const lduInterfacePtrsList interfaces_;
lduInterfacePtrsList interfaces_;
//- Patch field evaluation schedule
const lduSchedule patchSchedule_;
lduSchedule patchSchedule_;
//- Communicator to use for any parallel communication
const label comm_;
// Private Member Functions
//- Get size of all meshes
static label size(const PtrList<lduMesh>&);
//- Check if in upper-triangular ordering
static void checkUpperTriangular
(
const label size,
const labelUList& l,
const labelUList& u
);
//- Get non-scheduled send/receive schedule
template<class ProcPatch>
static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList&);
//- Disallow default bitwise copy construct
lduPrimitiveMesh(const lduPrimitiveMesh&);
......@@ -117,8 +132,36 @@ public:
bool reUse
);
//- Construct from Istream
lduPrimitiveMesh(Istream& is);
////- Construct from Istream
//lduPrimitiveMesh(Istream& is);
//- Construct by combining multiple meshes. The meshes come from
// processors procIDs but these are only used to detect the interfaces
// that are to be merged.
//
// Sets mapping information:
// cellOffsets : per mesh the starting cell
// faceMap : per mesh, per internal face, the combined face
// boundaryMap : per mesh, per boundary, the combined boundary
// or -1 for merged boundaries
// boundaryFaceMap : per mesh, per boundary face:
// kept boundaries: the new boundary face
// merged boundaries: the new internal face (on the owner) or
// -faceI-1 (on the neighbour)
//
// TBD: hardcoded for processorGAMGInterface. Should use some 'clone' or
// New functionality instead.
lduPrimitiveMesh
(
const label comm,
const labelList& procIDs,
const PtrList<lduMesh>& procMeshes,
labelList& cellOffsets,
labelListList& faceMap,
labelListList& boundaryMap,
labelListListList& boundaryFaceMap
);
//- Destructor
......@@ -172,6 +215,19 @@ public:
{
return patchSchedule_;
}
// Helper
//- Gather meshes from processors. Hardcoded for
// processorGAMGInterface
static void gather
(
const lduMesh& mesh,
const labelList& procIDs,
PtrList<lduMesh>& procMeshes
);
//
// // Ostream operator
//
......@@ -185,6 +241,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "lduPrimitiveMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ProcPatch>
Foam::lduSchedule Foam::lduPrimitiveMesh::nonBlockingSchedule
(
const lduInterfacePtrsList& interfaces
)
{
lduSchedule schedule(2*interfaces.size());
label slotI = 0;
forAll(interfaces, i)
{
if (interfaces.set(i) && !isA<ProcPatch>(interfaces[i]))
{
schedule[slotI].patch = i;
schedule[slotI].init = true;
slotI++;
schedule[slotI].patch = i;
schedule[slotI].init = false;
slotI++;
}
}
forAll(interfaces, i)
{
if (interfaces.set(i) && isA<ProcPatch>(interfaces[i]))
{
schedule[slotI].patch = i;
schedule[slotI].init = true;
slotI++;
}
}
forAll(interfaces, i)
{
if (interfaces.set(i) && isA<ProcPatch>(interfaces[i]))
{
schedule[slotI].patch = i;
schedule[slotI].init = false;
slotI++;
}
}
return schedule;
}
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment