move reconstructPar 'guts' to src/parallel/reconstruct

- in preparation for adding an optional '-reconstruct' to a few utilities
  re-use as -lreconstruct library

- move related stuff there too
      src/decompositionMethods/decompositionMethods
      -> src/parallel/decompositionMethods

- added missing namespace qualifiers
This commit is contained in:
Mark Olesen
2009-11-20 14:37:56 +01:00
parent d6e4c1a9a2
commit 2c52705cf7
60 changed files with 117 additions and 143 deletions

View File

@ -1,7 +1,7 @@
decomposeMesh.C
decomposePar.C
domainDecomposition.C
distributeCells.C
domainDecompositionMesh.C
domainDecompositionDistribute.C
fvFieldDecomposer.C
pointFieldDecomposer.C
lagrangianFieldDecomposer.C

View File

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompositionMethods/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude

View File

@ -106,7 +106,6 @@ int main(int argc, char *argv[])
Info<< "Decomposing mesh " << regionName << nl << endl;
}
bool writeCellDist = args.optionFound("cellDist");
bool copyUniform = args.optionFound("copyUniform");
bool decomposeFieldsOnly = args.optionFound("fields");

View File

@ -38,7 +38,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void domainDecomposition::mark
void Foam::domainDecomposition::mark
(
const labelList& zoneElems,
const label zoneI,
@ -66,7 +66,7 @@ void domainDecomposition::mark
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// from components
domainDecomposition::domainDecomposition(const IOobject& io)
Foam::domainDecomposition::domainDecomposition(const IOobject& io)
:
fvMesh(io),
decompositionDict_
@ -105,13 +105,13 @@ domainDecomposition::domainDecomposition(const IOobject& io)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
domainDecomposition::~domainDecomposition()
Foam::domainDecomposition::~domainDecomposition()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool domainDecomposition::writeDecomposition()
bool Foam::domainDecomposition::writeDecomposition()
{
Info<< "\nConstructing processor meshes" << endl;

View File

@ -26,7 +26,7 @@ Class
Foam::domainDecomposition
Description
Automatic domain decomposition class for FOAM meshes
Automatic domain decomposition class for finite-volume meshes
SourceFiles
domainDecomposition.C
@ -42,13 +42,11 @@ SourceFiles
#include "PtrList.H"
#include "point.H"
#ifndef namespaceFoam
#define namespaceFoam
using namespace Foam;
#endif
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class domainDecomposition Declaration
Class domainDecomposition Declaration
\*---------------------------------------------------------------------------*/
class domainDecomposition
@ -79,7 +77,7 @@ class domainDecomposition
// original face. In order to do this properly, all face
// indices will be incremented by 1 and the decremented as
// necessary t avoid the problem of face number zero having no
// sign.
// sign.
labelListList procFaceAddressing_;
//- Labels of cells for each processor
@ -165,6 +163,11 @@ public:
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif

View File

@ -33,7 +33,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void domainDecomposition::distributeCells()
void Foam::domainDecomposition::distributeCells()
{
Info<< "\nCalculating distribution of cells" << endl;

View File

@ -40,7 +40,7 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
{
// Decide which cell goes to which processor
distributeCells();
@ -775,3 +775,5 @@ void domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
sort(globallySharedPoints_);
}
}
// ************************************************************************* //

View File

@ -26,14 +26,10 @@ License
#include "fvFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
Foam::fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
(
const unallocLabelList& addressingSlice,
const label addressingOffset
@ -41,15 +37,15 @@ fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
:
directAddressing_(addressingSlice)
{
forAll (directAddressing_, i)
forAll(directAddressing_, i)
{
// Subtract one to align addressing.
// Subtract one to align addressing.
directAddressing_[i] -= addressingOffset + 1;
}
}
fvFieldDecomposer::processorVolPatchFieldDecomposer::
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::
processorVolPatchFieldDecomposer
(
const fvMesh& mesh,
@ -61,9 +57,9 @@ processorVolPatchFieldDecomposer
const labelList& own = mesh.faceOwner();
const labelList& neighb = mesh.faceNeighbour();
forAll (directAddressing_, i)
forAll(directAddressing_, i)
{
// Subtract one to align addressing.
// Subtract one to align addressing.
label ai = mag(addressingSlice[i]) - 1;
if (ai < neighb.size())
@ -97,7 +93,7 @@ processorVolPatchFieldDecomposer
}
fvFieldDecomposer::processorSurfacePatchFieldDecomposer::
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::
processorSurfacePatchFieldDecomposer
(
const unallocLabelList& addressingSlice
@ -106,7 +102,7 @@ processorSurfacePatchFieldDecomposer
addressing_(addressingSlice.size()),
weights_(addressingSlice.size())
{
forAll (addressing_, i)
forAll(addressing_, i)
{
addressing_[i].setSize(1);
weights_[i].setSize(1);
@ -117,7 +113,7 @@ processorSurfacePatchFieldDecomposer
}
fvFieldDecomposer::fvFieldDecomposer
Foam::fvFieldDecomposer::fvFieldDecomposer
(
const fvMesh& completeMesh,
const fvMesh& procMesh,
@ -147,7 +143,7 @@ fvFieldDecomposer::fvFieldDecomposer
static_cast<processorSurfacePatchFieldDecomposer*>(NULL)
)
{
forAll (boundaryAddressing_, patchi)
forAll(boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
{
@ -162,14 +158,14 @@ fvFieldDecomposer::fvFieldDecomposer
}
else
{
processorVolPatchFieldDecomposerPtrs_[patchi] =
processorVolPatchFieldDecomposerPtrs_[patchi] =
new processorVolPatchFieldDecomposer
(
completeMesh_,
procMesh_.boundary()[patchi].patchSlice(faceAddressing_)
);
processorSurfacePatchFieldDecomposerPtrs_[patchi] =
processorSurfacePatchFieldDecomposerPtrs_[patchi] =
new processorSurfacePatchFieldDecomposer
(
static_cast<const unallocLabelList&>
@ -187,9 +183,9 @@ fvFieldDecomposer::fvFieldDecomposer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
fvFieldDecomposer::~fvFieldDecomposer()
Foam::fvFieldDecomposer::~fvFieldDecomposer()
{
forAll (patchFieldDecomposerPtrs_, patchi)
forAll(patchFieldDecomposerPtrs_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
@ -197,7 +193,7 @@ fvFieldDecomposer::~fvFieldDecomposer()
}
}
forAll (processorVolPatchFieldDecomposerPtrs_, patchi)
forAll(processorVolPatchFieldDecomposerPtrs_, patchi)
{
if (processorVolPatchFieldDecomposerPtrs_[patchi])
{
@ -205,7 +201,7 @@ fvFieldDecomposer::~fvFieldDecomposer()
}
}
forAll (processorSurfacePatchFieldDecomposerPtrs_, patchi)
forAll(processorSurfacePatchFieldDecomposerPtrs_, patchi)
{
if (processorSurfacePatchFieldDecomposerPtrs_[patchi])
{
@ -214,9 +210,4 @@ fvFieldDecomposer::~fvFieldDecomposer()
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -28,16 +28,11 @@ License
#include "processorFvPatchField.H"
#include "processorFvsPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
fvFieldDecomposer::decomposeField
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::fvFieldDecomposer::decomposeField
(
const GeometricField<Type, fvPatchField, volMesh>& field
) const
@ -106,8 +101,8 @@ fvFieldDecomposer::decomposeField
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
fvFieldDecomposer::decomposeField
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::fvFieldDecomposer::decomposeField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
) const
@ -217,7 +212,7 @@ fvFieldDecomposer::decomposeField
template<class GeoField>
void fvFieldDecomposer::decomposeFields
void Foam::fvFieldDecomposer::decomposeFields
(
const PtrList<GeoField>& fields
) const
@ -229,8 +224,4 @@ void fvFieldDecomposer::decomposeFields
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -29,16 +29,10 @@ Description
#include "lagrangianFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
lagrangianFieldDecomposer::lagrangianFieldDecomposer
Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
(
const polyMesh& mesh,
const polyMesh& procMesh,
@ -88,6 +82,4 @@ lagrangianFieldDecomposer::lagrangianFieldDecomposer
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -27,15 +27,10 @@ License
#include "lagrangianFieldDecomposer.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void lagrangianFieldDecomposer::readFields
void Foam::lagrangianFieldDecomposer::readFields
(
const label cloudI,
const IOobjectList& lagrangianObjects,
@ -70,7 +65,8 @@ void lagrangianFieldDecomposer::readFields
template<class Type>
tmp<IOField<Type> > lagrangianFieldDecomposer::decomposeField
Foam::tmp<Foam::IOField<Type> >
Foam::lagrangianFieldDecomposer::decomposeField
(
const word& cloudName,
const IOField<Type>& field
@ -100,7 +96,7 @@ tmp<IOField<Type> > lagrangianFieldDecomposer::decomposeField
template<class GeoField>
void lagrangianFieldDecomposer::decomposeFields
void Foam::lagrangianFieldDecomposer::decomposeFields
(
const word& cloudName,
const PtrList<GeoField>& fields
@ -116,8 +112,4 @@ void lagrangianFieldDecomposer::decomposeFields
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -26,14 +26,9 @@ License
#include "pointFieldDecomposer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
(
const pointPatch& completeMeshPatch,
const pointPatch& procMeshPatch,
@ -52,7 +47,7 @@ pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
forAll (completeMeshPatchPoints, pointi)
forAll(completeMeshPatchPoints, pointi)
{
pointMap[completeMeshPatchPoints[pointi]] = pointi;
}
@ -61,7 +56,7 @@ pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
// patch
const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
forAll (procMeshPatchPoints, pointi)
forAll(procMeshPatchPoints, pointi)
{
directAddressing_[pointi] =
pointMap[directAddr[procMeshPatchPoints[pointi]]];
@ -79,7 +74,7 @@ pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
}
pointFieldDecomposer::pointFieldDecomposer
Foam::pointFieldDecomposer::pointFieldDecomposer
(
const pointMesh& completeMesh,
const pointMesh& procMesh,
@ -97,7 +92,7 @@ pointFieldDecomposer::pointFieldDecomposer
static_cast<patchFieldDecomposer*>(NULL)
)
{
forAll (boundaryAddressing_, patchi)
forAll(boundaryAddressing_, patchi)
{
if (boundaryAddressing_[patchi] >= 0)
{
@ -114,9 +109,9 @@ pointFieldDecomposer::pointFieldDecomposer
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
pointFieldDecomposer::~pointFieldDecomposer()
Foam::pointFieldDecomposer::~pointFieldDecomposer()
{
forAll (patchFieldDecomposerPtrs_, patchi)
forAll(patchFieldDecomposerPtrs_, patchi)
{
if (patchFieldDecomposerPtrs_[patchi])
{
@ -128,6 +123,4 @@ pointFieldDecomposer::~pointFieldDecomposer()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -28,16 +28,11 @@ License
#include "processorPointPatchFields.H"
#include "globalPointPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh> >
pointFieldDecomposer::decomposeField
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> >
Foam::pointFieldDecomposer::decomposeField
(
const GeometricField<Type, pointPatchField, pointMesh>& field
) const
@ -117,7 +112,7 @@ pointFieldDecomposer::decomposeField
template<class GeoField>
void pointFieldDecomposer::decomposeFields
void Foam::pointFieldDecomposer::decomposeFields
(
const PtrList<GeoField>& fields
) const
@ -131,6 +126,4 @@ void pointFieldDecomposer::decomposeFields
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,7 +1,3 @@
processorMeshes.C
fvFieldReconstructor.C
pointFieldReconstructor.C
reconstructLagrangianPositions.C
reconstructPar.C
EXE = $(FOAM_APPBIN)/reconstructPar

View File

@ -1,9 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/parallel/reconstruct/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-llagrangian \
-lmeshTools
-lmeshTools \
-lreconstruct

View File

@ -1,48 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fvFieldReconstructor.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fvFieldReconstructor::fvFieldReconstructor
(
fvMesh& mesh,
const PtrList<fvMesh>& procMeshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing,
const PtrList<labelIOList>& boundaryProcAddressing
)
:
mesh_(mesh),
procMeshes_(procMeshes),
faceProcAddressing_(faceProcAddressing),
cellProcAddressing_(cellProcAddressing),
boundaryProcAddressing_(boundaryProcAddressing)
{}
// ************************************************************************* //

View File

@ -1,186 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fvFieldReconstructor
Description
FV volume and surface field reconstructor.
SourceFiles
fvFieldReconstructor.C
fvFieldReconstructorReconstructFields.C
\*---------------------------------------------------------------------------*/
#ifndef fvFieldReconstructor_H
#define fvFieldReconstructor_H
#include "PtrList.H"
#include "fvMesh.H"
#include "IOobjectList.H"
#include "fvPatchFieldMapper.H"
#include "labelIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fvFieldReconstructor Declaration
\*---------------------------------------------------------------------------*/
class fvFieldReconstructor
{
// Private data
//- Reconstructed mesh reference
fvMesh& mesh_;
//- List of processor meshes
const PtrList<fvMesh>& procMeshes_;
//- List of processor face addressing lists
const PtrList<labelIOList>& faceProcAddressing_;
//- List of processor cell addressing lists
const PtrList<labelIOList>& cellProcAddressing_;
//- List of processor boundary addressing lists
const PtrList<labelIOList>& boundaryProcAddressing_;
// Private Member Functions
//- Disallow default bitwise copy construct
fvFieldReconstructor(const fvFieldReconstructor&);
//- Disallow default bitwise assignment
void operator=(const fvFieldReconstructor&);
public:
class fvPatchFieldReconstructor
:
public fvPatchFieldMapper
{
label size_;
public:
// Constructors
//- Construct given size
fvPatchFieldReconstructor(const label size)
:
size_(size)
{}
// Member functions
label size() const
{
return size_;
}
bool direct() const
{
return true;
}
const unallocLabelList& directAddressing() const
{
return unallocLabelList::null();
}
};
// Constructors
//- Construct from components
fvFieldReconstructor
(
fvMesh& mesh,
const PtrList<fvMesh>& procMeshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing,
const PtrList<labelIOList>& boundaryProcAddressing
);
// Member Functions
//- Reconstruct volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
reconstructFvVolumeField
(
const IOobject& fieldIoObject
);
//- Reconstruct surface field
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
reconstructFvSurfaceField
(
const IOobject& fieldIoObject
);
//- Reconstruct and write all/selected volume fields
template<class Type>
void reconstructFvVolumeFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
);
//- Reconstruct and write all/selected volume fields
template<class Type>
void reconstructFvSurfaceFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fvFieldReconstructorReconstructFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,524 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fvFieldReconstructor.H"
#include "Time.H"
#include "PtrList.H"
#include "fvPatchFields.H"
#include "emptyFvPatch.H"
#include "emptyFvPatchField.H"
#include "emptyFvsPatchField.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::fvFieldReconstructor::reconstructFvVolumeField
(
const IOobject& fieldIoObject
)
{
// Read the field for all the processors
PtrList<GeometricField<Type, fvPatchField, volMesh> > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, procI)
{
procFields.set
(
procI,
new GeometricField<Type, fvPatchField, volMesh>
(
IOobject
(
fieldIoObject.name(),
procMeshes_[procI].time().timeName(),
procMeshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[procI]
)
);
}
// Create the internalField
Field<Type> internalField(mesh_.nCells());
// Create the patch fields
PtrList<fvPatchField<Type> > patchFields(mesh_.boundary().size());
forAll (procMeshes_, procI)
{
const GeometricField<Type, fvPatchField, volMesh>& procField =
procFields[procI];
// Set the cell values in the reconstructed field
internalField.rmap
(
procField.internalField(),
cellProcAddressing_[procI]
);
// Set the boundary patch values in the reconstructed field
forAll(boundaryProcAddressing_[procI], patchI)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[procI][patchI];
// Get addressing slice for this patch
const labelList::subList cp =
procMeshes_[procI].boundary()[patchI].patchSlice
(
faceProcAddressing_[procI]
);
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
// Regular patch. Fast looping
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
fvPatchField<Type>::New
(
procField.boundaryField()[patchI],
mesh_.boundary()[curBPatch],
DimensionedField<Type, volMesh>::null(),
fvPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size()
)
)
);
}
const label curPatchStart =
mesh_.boundaryMesh()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll(cp, faceI)
{
// Subtract one to take into account offsets for
// face direction.
reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
}
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchI],
reverseAddressing
);
}
else
{
const Field<Type>& curProcPatch =
procField.boundaryField()[patchI];
// In processor patches, there's a mix of internal faces (some
// of them turned) and possible cyclics. Slow loop
forAll(cp, faceI)
{
// Subtract one to take into account offsets for
// face direction.
label curF = cp[faceI] - 1;
// Is the face on the boundary?
if (curF >= mesh_.nInternalFaces())
{
label curBPatch = mesh_.boundaryMesh().whichPatch(curF);
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
fvPatchField<Type>::New
(
mesh_.boundary()[curBPatch].type(),
mesh_.boundary()[curBPatch],
DimensionedField<Type, volMesh>::null()
)
);
}
// add the face
label curPatchFace =
mesh_.boundaryMesh()
[curBPatch].whichFace(curF);
patchFields[curBPatch][curPatchFace] =
curProcPatch[faceI];
}
}
}
}
}
forAll(mesh_.boundary(), patchI)
{
// add empty patches
if
(
isType<emptyFvPatch>(mesh_.boundary()[patchI])
&& !patchFields(patchI)
)
{
patchFields.set
(
patchI,
fvPatchField<Type>::New
(
emptyFvPatchField<Type>::typeName,
mesh_.boundary()[patchI],
DimensionedField<Type, volMesh>::null()
)
);
}
}
// Now construct and write the field
// setting the internalField and patchFields
return tmp<GeometricField<Type, fvPatchField, volMesh> >
(
new GeometricField<Type, fvPatchField, volMesh>
(
IOobject
(
fieldIoObject.name(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::fvFieldReconstructor::reconstructFvSurfaceField
(
const IOobject& fieldIoObject
)
{
// Read the field for all the processors
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, procI)
{
procFields.set
(
procI,
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
fieldIoObject.name(),
procMeshes_[procI].time().timeName(),
procMeshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[procI]
)
);
}
// Create the internalField
Field<Type> internalField(mesh_.nInternalFaces());
// Create the patch fields
PtrList<fvsPatchField<Type> > patchFields(mesh_.boundary().size());
forAll (procMeshes_, procI)
{
const GeometricField<Type, fvsPatchField, surfaceMesh>& procField =
procFields[procI];
// Set the face values in the reconstructed field
// It is necessary to create a copy of the addressing array to
// take care of the face direction offset trick.
//
{
labelList curAddr(faceProcAddressing_[procI]);
forAll (curAddr, addrI)
{
curAddr[addrI] -= 1;
}
internalField.rmap
(
procField.internalField(),
curAddr
);
}
// Set the boundary patch values in the reconstructed field
forAll(boundaryProcAddressing_[procI], patchI)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[procI][patchI];
// Get addressing slice for this patch
const labelList::subList cp =
procMeshes_[procI].boundary()[patchI].patchSlice
(
faceProcAddressing_[procI]
);
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
// Regular patch. Fast looping
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
fvsPatchField<Type>::New
(
procField.boundaryField()[patchI],
mesh_.boundary()[curBPatch],
DimensionedField<Type, surfaceMesh>::null(),
fvPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size()
)
)
);
}
const label curPatchStart =
mesh_.boundaryMesh()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll(cp, faceI)
{
// Subtract one to take into account offsets for
// face direction.
reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
}
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchI],
reverseAddressing
);
}
else
{
const Field<Type>& curProcPatch =
procField.boundaryField()[patchI];
// In processor patches, there's a mix of internal faces (some
// of them turned) and possible cyclics. Slow loop
forAll(cp, faceI)
{
label curF = cp[faceI] - 1;
// Is the face turned the right side round
if (curF >= 0)
{
// Is the face on the boundary?
if (curF >= mesh_.nInternalFaces())
{
label curBPatch =
mesh_.boundaryMesh().whichPatch(curF);
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
fvsPatchField<Type>::New
(
mesh_.boundary()[curBPatch].type(),
mesh_.boundary()[curBPatch],
DimensionedField<Type, surfaceMesh>
::null()
)
);
}
// add the face
label curPatchFace =
mesh_.boundaryMesh()
[curBPatch].whichFace(curF);
patchFields[curBPatch][curPatchFace] =
curProcPatch[faceI];
}
else
{
// Internal face
internalField[curF] = curProcPatch[faceI];
}
}
}
}
}
}
forAll(mesh_.boundary(), patchI)
{
// add empty patches
if
(
isType<emptyFvPatch>(mesh_.boundary()[patchI])
&& !patchFields(patchI)
)
{
patchFields.set
(
patchI,
fvsPatchField<Type>::New
(
emptyFvsPatchField<Type>::typeName,
mesh_.boundary()[patchI],
DimensionedField<Type, surfaceMesh>::null()
)
);
}
}
// Now construct and write the field
// setting the internalField and patchFields
return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
IOobject
(
fieldIoObject.name(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
// Reconstruct and write all/selected volume fields
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
)
{
const word& fieldClassName =
GeometricField<Type, fvPatchField, volMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
forAllConstIter(IOobjectList, fields, fieldIter)
{
if
(
!selectedFields.size()
|| selectedFields.found(fieldIter()->name())
)
{
Info<< " " << fieldIter()->name() << endl;
reconstructFvVolumeField<Type>(*fieldIter())().write();
}
}
Info<< endl;
}
}
// Reconstruct and write all/selected surface fields
template<class Type>
void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
)
{
const word& fieldClassName =
GeometricField<Type, fvsPatchField, surfaceMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
forAllConstIter(IOobjectList, fields, fieldIter)
{
if
(
!selectedFields.size()
|| selectedFields.found(fieldIter()->name())
)
{
Info<< " " << fieldIter()->name() << endl;
reconstructFvSurfaceField<Type>(*fieldIter())().write();
}
}
Info<< endl;
}
}
// ************************************************************************* //

View File

@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "pointFieldReconstructor.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointFieldReconstructor::pointFieldReconstructor
(
const pointMesh& mesh,
const PtrList<pointMesh>& procMeshes,
const PtrList<labelIOList>& pointProcAddressing,
const PtrList<labelIOList>& boundaryProcAddressing
)
:
mesh_(mesh),
procMeshes_(procMeshes),
pointProcAddressing_(pointProcAddressing),
boundaryProcAddressing_(boundaryProcAddressing),
patchPointAddressing_(procMeshes.size())
{
// Inverse-addressing of the patch point labels.
labelList pointMap(mesh_.size(), -1);
// Create the pointPatch addressing
forAll(procMeshes_, proci)
{
const pointMesh& procMesh = procMeshes_[proci];
patchPointAddressing_[proci].setSize(procMesh.boundary().size());
forAll(procMesh.boundary(), patchi)
{
if (boundaryProcAddressing_[proci][patchi] >= 0)
{
labelList& procPatchAddr = patchPointAddressing_[proci][patchi];
procPatchAddr.setSize(procMesh.boundary()[patchi].size(), -1);
const labelList& patchPointLabels =
mesh_.boundary()[boundaryProcAddressing_[proci][patchi]]
.meshPoints();
// Create the inverse-addressing of the patch point labels.
forAll (patchPointLabels, pointi)
{
pointMap[patchPointLabels[pointi]] = pointi;
}
const labelList& procPatchPoints =
procMesh.boundary()[patchi].meshPoints();
forAll (procPatchPoints, pointi)
{
procPatchAddr[pointi] =
pointMap
[
pointProcAddressing_[proci][procPatchPoints[pointi]]
];
}
if (procPatchAddr.size() && min(procPatchAddr) < 0)
{
FatalErrorIn
(
"pointFieldReconstructor::pointFieldReconstructor"
"(\n"
" const pointMesh& mesh,\n"
" const PtrList<pointMesh>& procMeshes,\n"
" const PtrList<labelIOList>& pointProcAddressing,\n"
" const PtrList<labelIOList>& "
"boundaryProcAddressing\n"
")"
) << "Incomplete patch point addressing"
<< abort(FatalError);
}
}
}
}
}
// ************************************************************************* //

View File

@ -1,162 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::pointFieldReconstructor
Description
Point field reconstructor.
SourceFiles
pointFieldReconstructor.C
\*---------------------------------------------------------------------------*/
#ifndef pointFieldReconstructor_H
#define pointFieldReconstructor_H
#include "pointMesh.H"
#include "pointFields.H"
#include "pointPatchFieldMapperPatchRef.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointFieldReconstructor Declaration
\*---------------------------------------------------------------------------*/
class pointFieldReconstructor
{
// Private data
//- Reconstructed mesh reference
const pointMesh& mesh_;
//- List of processor meshes
const PtrList<pointMesh>& procMeshes_;
//- List of processor point addressing lists
const PtrList<labelIOList>& pointProcAddressing_;
//- List of processor boundary addressing lists
const PtrList<labelIOList>& boundaryProcAddressing_;
//- Point patch addressing
labelListListList patchPointAddressing_;
// Private Member Functions
//- Disallow default bitwise copy construct
pointFieldReconstructor
(
const pointFieldReconstructor&
);
//- Disallow default bitwise assignment
void operator=(const pointFieldReconstructor&);
public:
class pointPatchFieldReconstructor
:
public pointPatchFieldMapper
{
label size_;
public:
// Constructors
//- Construct given size
pointPatchFieldReconstructor(const label size)
:
size_(size)
{}
// Member functions
label size() const
{
return size_;
}
bool direct() const
{
return true;
}
const unallocLabelList& directAddressing() const
{
return unallocLabelList::null();
}
};
// Constructors
//- Construct from components
pointFieldReconstructor
(
const pointMesh& mesh,
const PtrList<pointMesh>& procMeshes,
const PtrList<labelIOList>& pointProcAddressing,
const PtrList<labelIOList>& boundaryProcAddressing
);
// Member Functions
//- Reconstruct field
template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh> >
reconstructField(const IOobject& fieldIoObject);
//- Reconstruct and write all fields
template<class Type>
void reconstructFields(const IOobjectList& objects);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "pointFieldReconstructorReconstructFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,177 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "pointFieldReconstructor.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> >
Foam::pointFieldReconstructor::reconstructField(const IOobject& fieldIoObject)
{
// Read the field for all the processors
PtrList<GeometricField<Type, pointPatchField, pointMesh> > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, proci)
{
procFields.set
(
proci,
new GeometricField<Type, pointPatchField, pointMesh>
(
IOobject
(
fieldIoObject.name(),
procMeshes_[proci]().time().timeName(),
procMeshes_[proci](),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[proci]
)
);
}
// Create the internalField
Field<Type> internalField(mesh_.size());
// Create the patch fields
PtrList<pointPatchField<Type> > patchFields(mesh_.boundary().size());
forAll (procMeshes_, proci)
{
const GeometricField<Type, pointPatchField, pointMesh>&
procField = procFields[proci];
// Get processor-to-global addressing for use in rmap
const labelList& procToGlobalAddr = pointProcAddressing_[proci];
// Set the cell values in the reconstructed field
internalField.rmap
(
procField.internalField(),
procToGlobalAddr
);
// Set the boundary patch values in the reconstructed field
forAll(boundaryProcAddressing_[proci], patchi)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[proci][patchi];
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
if (!patchFields(curBPatch))
{
patchFields.set(
curBPatch,
pointPatchField<Type>::New
(
procField.boundaryField()[patchi],
mesh_.boundary()[curBPatch],
DimensionedField<Type, pointMesh>::null(),
pointPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size()
)
)
);
}
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchi],
patchPointAddressing_[proci][patchi]
);
}
}
}
// Construct and write the field
// setting the internalField and patchFields
return tmp<GeometricField<Type, pointPatchField, pointMesh> >
(
new GeometricField<Type, pointPatchField, pointMesh>
(
IOobject
(
fieldIoObject.name(),
mesh_().time().timeName(),
mesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
// Reconstruct and write all point fields
template<class Type>
void Foam::pointFieldReconstructor::reconstructFields
(
const IOobjectList& objects
)
{
word fieldClassName
(
GeometricField<Type, pointPatchField, pointMesh>::typeName
);
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
for
(
IOobjectList::iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{
Info<< " " << fieldIter()->name() << endl;
reconstructField<Type>(*fieldIter())().write();
}
Info<< endl;
}
}
// ************************************************************************* //

View File

@ -1,254 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "processorMeshes.H"
#include "Time.H"
#include "primitiveMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::processorMeshes::read()
{
forAll (databases_, procI)
{
meshes_.set
(
procI,
new fvMesh
(
IOobject
(
meshName_,
databases_[procI].timeName(),
databases_[procI]
)
)
);
pointProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"pointProcAddressing",
meshes_[procI].facesInstance(),
meshes_[procI].meshSubDir,
meshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
faceProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"faceProcAddressing",
meshes_[procI].facesInstance(),
meshes_[procI].meshSubDir,
meshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
cellProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"cellProcAddressing",
meshes_[procI].facesInstance(),
meshes_[procI].meshSubDir,
meshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
boundaryProcAddressing_.set
(
procI,
new labelIOList
(
IOobject
(
"boundaryProcAddressing",
meshes_[procI].facesInstance(),
meshes_[procI].meshSubDir,
meshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::processorMeshes::processorMeshes
(
PtrList<Time>& databases,
const word& meshName
)
:
databases_(databases),
meshName_(meshName),
meshes_(databases.size()),
pointProcAddressing_(databases.size()),
faceProcAddressing_(databases.size()),
cellProcAddressing_(databases.size()),
boundaryProcAddressing_(databases.size())
{
read();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fvMesh::readUpdateState Foam::processorMeshes::readUpdate()
{
fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
forAll (databases_, procI)
{
// Check if any new meshes need to be read.
fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
/*
if (procStat != fvMesh::UNCHANGED)
{
Info<< "Processor " << procI
<< " at time " << databases_[procI].timeName()
<< " detected mesh change " << procStat
<< endl;
}
*/
// Combine into overall mesh change status
if (stat == fvMesh::UNCHANGED)
{
stat = procStat;
}
else
{
if (stat != procStat)
{
FatalErrorIn("processorMeshes::readUpdate()")
<< "Processor " << procI
<< " has a different polyMesh at time "
<< databases_[procI].timeName()
<< " compared to any previous processors." << nl
<< "Please check time " << databases_[procI].timeName()
<< " directories on all processors for consistent"
<< " mesh files."
<< exit(FatalError);
}
}
}
if
(
stat == fvMesh::TOPO_CHANGE
|| stat == fvMesh::TOPO_PATCH_CHANGE
)
{
// Reread all meshes and addresssing
read();
}
return stat;
}
void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
{
// Read the field for all the processors
PtrList<pointIOField> procsPoints(meshes_.size());
forAll (meshes_, procI)
{
procsPoints.set
(
procI,
new pointIOField
(
IOobject
(
"points",
meshes_[procI].time().timeName(),
polyMesh::meshSubDir,
meshes_[procI],
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
}
// Create the new points
vectorField newPoints(mesh.nPoints());
forAll (meshes_, procI)
{
const vectorField& procPoints = procsPoints[procI];
// Set the cell values in the reconstructed field
const labelList& pointProcAddressingI = pointProcAddressing_[procI];
if (pointProcAddressingI.size() != procPoints.size())
{
FatalErrorIn("processorMeshes")
<< "problem :"
<< " pointProcAddressingI:" << pointProcAddressingI.size()
<< " procPoints:" << procPoints.size()
<< abort(FatalError);
}
forAll(pointProcAddressingI, pointI)
{
newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
}
}
mesh.movePoints(newPoints);
mesh.write();
}
// ************************************************************************* //

View File

@ -1,141 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::processorMeshes
Description
Container for processor mesh addressing.
SourceFiles
processorMeshes.C
\*---------------------------------------------------------------------------*/
#ifndef processorMeshes_H
#define processorMeshes_H
#include "PtrList.H"
#include "fvMesh.H"
#include "IOobjectList.H"
#include "labelIOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class processorMeshes Declaration
\*---------------------------------------------------------------------------*/
class processorMeshes
{
// Private data
//- Processor databases
PtrList<Time>& databases_;
const word meshName_;
//- List of processor meshes
PtrList<fvMesh> meshes_;
//- List of processor point addressing lists
PtrList<labelIOList> pointProcAddressing_;
//- List of processor face addressing lists
PtrList<labelIOList> faceProcAddressing_;
//- List of processor cell addressing lists
PtrList<labelIOList> cellProcAddressing_;
//- List of processor boundary addressing lists
PtrList<labelIOList> boundaryProcAddressing_;
// Private Member Functions
//- Read all meshes
void read();
//- Disallow default bitwise copy construct
processorMeshes(const processorMeshes&);
//- Disallow default bitwise assignment
void operator=(const processorMeshes&);
public:
// Constructors
//- Construct from components
processorMeshes(PtrList<Time>& databases, const word& meshName);
// Member Functions
//- Update the meshes based on the mesh files saved in
// time directories
fvMesh::readUpdateState readUpdate();
//- Reconstruct point position after motion in parallel
void reconstructPoints(fvMesh& mesh);
PtrList<fvMesh>& meshes()
{
return meshes_;
}
const PtrList<labelIOList>& pointProcAddressing() const
{
return pointProcAddressing_;
}
PtrList<labelIOList>& faceProcAddressing()
{
return faceProcAddressing_;
}
const PtrList<labelIOList>& cellProcAddressing() const
{
return cellProcAddressing_;
}
const PtrList<labelIOList>& boundaryProcAddressing() const
{
return boundaryProcAddressing_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,95 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass
Foam::reconstructLagrangian
Description
SourceFiles
reconstructLagrangianPositions.C
reconstructLagrangianFields.C
\*---------------------------------------------------------------------------*/
#ifndef reconstructLagrangian_H
#define reconstructLagrangian_H
#include "cloud.H"
#include "polyMesh.H"
#include "IOobjectList.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void reconstructLagrangianPositions
(
const polyMesh& mesh,
const word& cloudName,
const PtrList<fvMesh>& meshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing
);
template<class Type>
tmp<IOField<Type> > reconstructLagrangianField
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const word& fieldName
);
template<class Type>
void reconstructLagrangianFields
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const IOobjectList& objects
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "reconstructLagrangianFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,126 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "IOField.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::IOField<Type> > Foam::reconstructLagrangianField
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const word& fieldName
)
{
// Construct empty field on mesh
tmp<IOField<Type> > tfield
(
new IOField<Type>
(
IOobject
(
fieldName,
mesh.time().timeName(),
cloud::prefix/cloudName,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
Field<Type>(0)
)
);
Field<Type>& field = tfield();
forAll(meshes, i)
{
// Check object on local mesh
IOobject localIOobject
(
fieldName,
meshes[i].time().timeName(),
cloud::prefix/cloudName,
meshes[i],
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (localIOobject.headerOk())
{
IOField<Type> fieldi(localIOobject);
label offset = field.size();
field.setSize(offset + fieldi.size());
forAll(fieldi, j)
{
field[offset + j] = fieldi[j];
}
}
}
return tfield;
}
template<class Type>
void Foam::reconstructLagrangianFields
(
const word& cloudName,
const polyMesh& mesh,
const PtrList<fvMesh>& meshes,
const IOobjectList& objects
)
{
word fieldClassName(IOField<Type>::typeName);
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing lagrangian "
<< fieldClassName << "s\n" << endl;
forAllIter(IOobjectList, fields, fieldIter)
{
Info<< " " << fieldIter()->name() << endl;
reconstructLagrangianField<Type>
(
cloudName,
mesh,
meshes,
fieldIter()->name()
)().write();
}
Info<< endl;
}
}
// ************************************************************************* //

View File

@ -1,76 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "reconstructLagrangian.H"
#include "labelIOList.H"
#include "Cloud.H"
#include "passiveParticle.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::reconstructLagrangianPositions
(
const polyMesh& mesh,
const word& cloudName,
const PtrList<fvMesh>& meshes,
const PtrList<labelIOList>& faceProcAddressing,
const PtrList<labelIOList>& cellProcAddressing
)
{
Cloud<passiveParticle> lagrangianPositions
(
mesh,
cloudName,
IDLList<passiveParticle>()
);
forAll(meshes, i)
{
const labelList& cellMap = cellProcAddressing[i];
Cloud<passiveParticle> lpi(meshes[i], cloudName, false);
forAllIter(Cloud<passiveParticle>, lpi, iter)
{
const passiveParticle& ppi = iter();
lagrangianPositions.append
(
new passiveParticle
(
lagrangianPositions,
ppi.position(),
cellMap[ppi.cell()]
)
);
}
}
IOPosition<passiveParticle>(lagrangianPositions).write();
}
// ************************************************************************* //

View File

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompositionMethods/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude

View File

@ -33,11 +33,11 @@ Description
Balances mesh and writes new mesh to new time directory.
Can also work like decomposePar:
@verbatim
mkdir processor0
cp -r constant processor0
mpirun -np ddd redistributeMeshPar -parallel
@endverbatim
\*---------------------------------------------------------------------------*/
#include "Field.H"