Work-package-09 geometric constraint

This commit is contained in:
Mark Olesen
2018-11-08 20:50:47 +00:00
parent 69c3a6fb3b
commit 3cf177e759
42 changed files with 1467 additions and 443 deletions

View File

@ -43,7 +43,6 @@ Description
#include "refinementFeatures.H" #include "refinementFeatures.H"
#include "shellSurfaces.H" #include "shellSurfaces.H"
#include "decompositionMethod.H" #include "decompositionMethod.H"
#include "noDecomp.H"
#include "fvMeshDistribute.H" #include "fvMeshDistribute.H"
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "refinementParameters.H" #include "refinementParameters.H"

View File

@ -183,50 +183,56 @@ structuredCoeffs
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Decomposition constraints // Decomposition constraints
//constraints /*
//{ constraints
// preserveBaffles {
// { baffles
// //- Keep owner and neighbour of baffles on same processor (i.e. {
// // keep it detectable as a baffle). Baffles are two boundary face //- Keep owner and neighbour of baffles on same processor (i.e.
// // sharing the same points // keep it detectable as a baffle). Baffles are two boundary face
// type preserveBaffles; // sharing the same points
// } type preserveBaffles;
// preserveFaceZones enabled false;
// { }
// //- Keep owner and neighbour on same processor for faces in zones faces
// type preserveFaceZones; {
// zones (".*"); //- Keep owner and neighbour on same processor for faces in zones
// } type preserveFaceZones;
// preservePatches zones (".*");
// { enabled false;
// //- Keep owner and neighbour on same processor for faces in patches }
// // (only makes sense for cyclic patches. Not suitable for e.g. patches
// // cyclicAMI since these are not coupled on the patch level. Use {
// // singleProcessorFaceSets for those) //- Keep owner and neighbour on same processor for faces in patches
// type preservePatches; // (only makes sense for cyclic patches. Not suitable for e.g.
// patches (".*"); // cyclicAMI since these are not coupled on the patch level. Use
// } // singleProcessorFaceSets for those)
// singleProcessorFaceSets type preservePatches;
// { patches (".*");
// //- Keep all of faceSet on a single processor. This puts all cells enabled false;
// // connected with a point, edge or face on the same processor. }
// // (just having face connected cells might not guarantee a balanced processors
// // decomposition) {
// // The processor can be -1 (the decompositionMethod chooses the //- Keep all of faceSet on a single processor. This puts all cells
// // processor for a good load balance) or explicitly provided (upsets // connected with a point, edge or face on the same processor.
// // balance) // (just having face connected cells might not guarantee a balanced
// type singleProcessorFaceSets; // decomposition)
// singleProcessorFaceSets ((f1 -1)); // The processor can be -1 (the decompositionMethod chooses the
// } // processor for a good load balance) or explicitly provided (upsets
// refinementHistory // balance)
// { type singleProcessorFaceSets;
// //- Decompose cells such that all cell originating from single cell sets ((f1 -1));
// // end up on same processor enabled false;
// type refinementHistory; }
// } refinement
//} {
//- Decompose cells such that all cell originating from single cell
// end up on same processor
type refinementHistory;
enabled false;
}
}
*/
// Deprecated form of specifying decomposition constraints: // Deprecated form of specifying decomposition constraints:
//- Keep owner and neighbour on same processor for faces in zones: //- Keep owner and neighbour on same processor for faces in zones:
@ -251,5 +257,4 @@ structuredCoeffs
// same points. // same points.
//preserveBaffles true; //preserveBaffles true;
// ************************************************************************* // // ************************************************************************* //

View File

@ -33,8 +33,8 @@ Description
processor has all triangles that overlap its mesh. processor has all triangles that overlap its mesh.
Note Note
- best decomposition option is hierarchGeomDecomp since - best decomposition option is hierarchical since it guarantees
guarantees square decompositions. square decompositions.
- triangles might be present on multiple processors. - triangles might be present on multiple processors.
- merging uses geometric tolerance so take care with writing precision. - merging uses geometric tolerance so take care with writing precision.

View File

@ -49,7 +49,6 @@ License
#include "globalIndex.H" #include "globalIndex.H"
#include "meshTools.H" #include "meshTools.H"
#include "OFstream.H" #include "OFstream.H"
#include "geomDecomp.H"
#include "Random.H" #include "Random.H"
#include "searchableSurfaces.H" #include "searchableSurfaces.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"

View File

@ -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) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -177,7 +177,7 @@ decomposition is termed a level. For example,
method hierarchical; method hierarchical;
coeffs coeffs
{ {
n (16 4 2); n (16 4 2);
} }
} }
cpus cpus
@ -228,53 +228,80 @@ For example,
\verbatim \verbatim
constraints constraints
{ {
preserveBaffles // Keep owner and neighbour of baffles on same processor
// (ie, keep it detectable as a baffle).
// Baffles are two boundary face sharing the same points
baffles
{ {
// Keep owner and neighbour of baffles on same processor
// (ie, keep it detectable as a baffle).
// Baffles are two boundary face sharing the same points
type preserveBaffles; type preserveBaffles;
enabled true;
} }
preserveFaceZones // Keep owner and neighbour on same processor for faces in zones
faces
{ {
// Keep owner and neighbour on same processor for faces in zones
type preserveFaceZones; type preserveFaceZones;
zones (".*"); zones (".*");
enabled true;
} }
preservePatches // Keep owner and neighbour on same processor for faces in patches
// (only makes sense for cyclic patches. Not suitable for e.g.
// cyclicAMI since these are not coupled on the patch level.
// Use singleProcessorFaceSets for those.
patches
{ {
// Keep owner and neighbour on same processor for faces in patches
// (only makes sense for cyclic patches. Not suitable for e.g.
// cyclicAMI since these are not coupled on the patch level.
// Use singleProcessorFaceSets for those.
type preservePatches; type preservePatches;
patches (".*"); patches (".*");
enabled true;
} }
singleProcessorFaceSets // Keep all of faceSet on a single processor. This puts all cells
// connected with a point, edge or face on the same processor.
// (just having face connected cells might not guarantee a balanced
// decomposition)
// The processor can be -1 (the decompositionMethod chooses the
// processor for a good load balance) or explicitly provided (upsets
// balance)
processors
{ {
// Keep all of faceSet on a single processor. This puts all cells
// connected with a point, edge or face on the same processor.
// (just having face connected cells might not guarantee a balanced
// decomposition)
// The processor can be -1 (the decompositionMethod chooses the
// processor for a good load balance) or explicitly provided (upsets
// balance)
type singleProcessorFaceSets; type singleProcessorFaceSets;
singleProcessorFaceSets ((f1 -1)); sets ((f1 -1));
enabled true;
} }
refinementHistory // Decompose cells such that all cell originating from single cell
// end up on same processor
refinement
{ {
// Decompose cells such that all cell originating from single cell
// end up on same processor
type refinementHistory; type refinementHistory;
enabled true;
}
// Prevent decomposition splitting of the geometric regions
// Uses any topoSetFaceSource for selecting the constrained faces
geometric
{
type geometric;
grow false;
selection
{
box1
{
source box;
min (-10 -10 -10);
max (1 1 1);
}
ball1
{
source sphere;
origin (-2 -2 1);
radius 1;
}
}
} }
} }
\endverbatim \endverbatim

View File

@ -9,14 +9,15 @@ structuredDecomp/structuredDecomp.C
noDecomp/noDecomp.C noDecomp/noDecomp.C
decompositionConstraints = decompositionConstraints constraints = decompositionConstraints
$(decompositionConstraints)/decompositionConstraint/decompositionConstraint.C $(constraints)/decompositionConstraint/decompositionConstraint.C
$(decompositionConstraints)/preserveBaffles/preserveBafflesConstraint.C $(constraints)/preserveBaffles/preserveBafflesConstraint.C
$(decompositionConstraints)/preserveFaceZones/preserveFaceZonesConstraint.C $(constraints)/preserveFaceZones/preserveFaceZonesConstraint.C
$(decompositionConstraints)/preservePatches/preservePatchesConstraint.C $(constraints)/preservePatches/preservePatchesConstraint.C
$(decompositionConstraints)/singleProcessorFaceSets/singleProcessorFaceSetsConstraint.C $(constraints)/geometric/geometricConstraint.C
$(decompositionConstraints)/refinementHistory/refinementHistoryConstraint.C $(constraints)/singleProcessorFaceSets/singleProcessorFaceSetsConstraint.C
$(constraints)/refinementHistory/refinementHistoryConstraint.C
LIB = $(FOAM_LIBBIN)/libdecompositionMethods LIB = $(FOAM_LIBBIN)/libdecompositionMethods

View File

@ -1,9 +1,11 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \ LIB_LIBS = \
-lfileFormats \
-lmeshTools \ -lmeshTools \
-ldynamicMesh \ -ldynamicMesh \
-lfiniteVolume -lfiniteVolume

View File

@ -37,16 +37,39 @@ namespace Foam
Foam::decompositionConstraint::decompositionConstraint Foam::decompositionConstraint::decompositionConstraint
( (
const dictionary& constraintsDict, const dictionary& constraintDict
const word& type
) )
: :
coeffDict_(constraintsDict) coeffDict_(constraintDict)
{}
Foam::decompositionConstraint::decompositionConstraint
(
const dictionary& constraintDict,
const word&
)
:
coeffDict_(constraintDict)
{} {}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::decompositionConstraint>
Foam::decompositionConstraint::New
(
const dictionary& dict
)
{
return decompositionConstraint::New
(
dict,
dict.get<word>("type")
);
}
Foam::autoPtr<Foam::decompositionConstraint> Foam::autoPtr<Foam::decompositionConstraint>
Foam::decompositionConstraint::New Foam::decompositionConstraint::New
( (
@ -61,14 +84,14 @@ Foam::decompositionConstraint::New
if (!cstrIter.found()) if (!cstrIter.found())
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Unknown decompositionConstraint type " << "Unknown decompositionConstraint: "
<< modelType << nl << nl << modelType << nl << nl
<< "Valid decompositionConstraint types :" << endl << "Valid types:" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError); << exit(FatalIOError);
} }
return autoPtr<decompositionConstraint>(cstrIter()(dict, modelType)); return autoPtr<decompositionConstraint>(cstrIter()(dict));
} }

View File

@ -25,6 +25,7 @@ Class
Foam::decompositionConstraint Foam::decompositionConstraint
Description Description
Abstract class for handling decomposition constraints.
SourceFiles SourceFiles
decompositionConstraint.C decompositionConstraint.C
@ -35,10 +36,10 @@ SourceFiles
#define decompositionConstraint_H #define decompositionConstraint_H
#include "dictionary.H" #include "dictionary.H"
#include "runTimeSelectionTables.H"
#include "boolList.H" #include "boolList.H"
#include "labelList.H" #include "labelList.H"
#include "labelPair.H" #include "labelPair.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,12 +59,11 @@ protected:
// Protected data // Protected data
//- Model coefficients dictionary //- Constraint coefficients dictionary
dictionary coeffDict_; dictionary coeffDict_;
private:
// Private Member Functions // Protected Member Functions
//- No copy construct //- No copy construct
decompositionConstraint(const decompositionConstraint&) = delete; decompositionConstraint(const decompositionConstraint&) = delete;
@ -71,7 +71,6 @@ private:
//- No copy assignment //- No copy assignment
void operator=(const decompositionConstraint&) = delete; void operator=(const decompositionConstraint&) = delete;
public: public:
//- Runtime type information //- Runtime type information
@ -86,20 +85,24 @@ public:
decompositionConstraint, decompositionConstraint,
dictionary, dictionary,
( (
const dictionary& constraintsDict, const dictionary& dict
const word& type
), ),
(constraintsDict, type) (dict)
); );
// Constructors // Constructors
//- Construct with generic dictionary with optional entry for type //- Construct with constraint dictionary
explicit decompositionConstraint(const dictionary& constraintDict);
//- Construct with constraint dictionary and model type.
// The model type could be used for defining a coefficients
// sub-dictionary.
decompositionConstraint decompositionConstraint
( (
const dictionary& constraintsDict, const dictionary& constraintDict,
const word& type const word& modelType
); );
@ -108,8 +111,14 @@ public:
//- Return a reference to the selected decompositionConstraint //- Return a reference to the selected decompositionConstraint
static autoPtr<decompositionConstraint> New static autoPtr<decompositionConstraint> New
( (
const dictionary& constraintsDict, const dictionary& constraintDict
const word& type );
//- Return a reference to the selected decompositionConstraint
static autoPtr<decompositionConstraint> New
(
const dictionary& constraintDict,
const word& modelType
); );
@ -119,7 +128,7 @@ public:
// Member Functions // Member Functions
//- Add my constraints to list of constraints //- Add this constraint to list of constraints
virtual void add virtual void add
( (
const polyMesh& mesh, const polyMesh& mesh,

View File

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 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 "geometricConstraint.H"
#include "addToRunTimeSelectionTable.H"
#include "syncTools.H"
#include "polyMesh.H"
#include "Time.H"
#include "BitOps.H"
#include "faceBoolSet.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace decompositionConstraints
{
defineTypeName(geometric);
addToRunTimeSelectionTable
(
decompositionConstraint,
geometric,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::decompositionConstraints::geometric::geometric
(
const dictionary& dict
)
:
decompositionConstraint(dict, typeName),
sources_(),
selection_(coeffDict_.subDict("selection")),
grow_(dict.lookupOrDefault<bool>("grow", false))
{
// Stored as dictionary, since we do not have the mesh at this stage
if (decompositionConstraint::debug)
{
Info<< type()
<< " : adding " << selection_.size()
<< " geometric constraints for faces" << endl;
}
}
Foam::decompositionConstraints::geometric::geometric
(
PtrList<topoSetFaceSource>&& selections
)
:
decompositionConstraint(dictionary(), typeName),
sources_(std::move(selections)),
selection_(),
grow_(false)
{
if (decompositionConstraint::debug)
{
Info<< type()
<< " : adding " << sources_.size()
<< " geometric constraints for faces" << endl;
}
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::decompositionConstraints::geometric::add
(
const polyMesh& mesh,
boolList& blockedFace,
PtrList<labelList>& specifiedProcessorFaces,
labelList& specifiedProcessor,
List<labelPair>& explicitConnections
) const
{
const label nFaces = mesh.nFaces();
blockedFace.resize(nFaces, true);
label nchanged = 0;
if (decompositionConstraint::debug)
{
nchanged = BitOps::count(blockedFace, false);
}
// Modify via topoSetFaceSource
faceBoolSet facesToBlock(mesh, std::move(blockedFace));
for (const topoSetFaceSource& source : sources_)
{
// source.verbose(false);
source.applyToSet(topoSetSource::SUBTRACT, facesToBlock);
}
for (const entry& dEntry : selection_)
{
if (!dEntry.isDict())
{
WarningInFunction
<< "Ignoring non-dictionary entry "
<< dEntry << endl;
continue;
}
const dictionary& spec = dEntry.dict();
auto source = topoSetFaceSource::New
(
spec.get<word>("source"),
mesh,
spec.optionalSubDict("sourceInfo")
);
// source->verbose(false);
source->applyToSet(topoSetSource::SUBTRACT, facesToBlock);
}
// Finished with topo changes
blockedFace.transfer(facesToBlock.addressing());
if (decompositionConstraint::debug)
{
nchanged = BitOps::count(blockedFace, false) - nchanged;
}
else
{
nchanged = 0;
}
// Grow mode.
// Include the faces of cells for which there are already two
// or more faces in a constraint.
if (grow_)
{
bitSet moreUnblocking(nFaces, false);
label nUnblocked = 0;
for (label celli=0; celli < mesh.nCells(); ++celli)
{
const cell& cFaces = mesh.cells()[celli];
nUnblocked = 0;
for (const label facei : cFaces)
{
if (!blockedFace[facei])
{
++nUnblocked;
if (nUnblocked > 2)
{
break;
}
}
}
if (nUnblocked > 2)
{
moreUnblocking.set(cFaces);
}
}
nUnblocked = 0;
for (label facei : moreUnblocking)
{
if (blockedFace[facei])
{
blockedFace[facei] = false;
++nUnblocked;
}
}
if (decompositionConstraint::debug)
{
Info<< type()
<< " : geometric constraint grow added "
<< returnReduce(nUnblocked, sumOp<label>())
<<" faces" << endl;
}
// Include in the total
nchanged += nUnblocked;
}
if (decompositionConstraint::debug)
{
Info<< type()
<< " : geometric constraint added for "
<< returnReduce(nchanged, sumOp<label>())
<<" faces" << endl;
}
syncTools::syncFaceList(mesh, blockedFace, andEqOp<bool>());
}
// ************************************************************************* //

View File

@ -0,0 +1,169 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 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::decompositionConstraints::geometric
Description
Keep faces together based on geometric considerations from a
searchableSurfaces list.
The faces inside of each searchableSurface are to be kept together
during the decomposition.
\verbatim
constraints
{
geom1
{
type geometric;
grow false;
selection
{
box1
{
source box;
min (-0.1 -0.01 -0.1);
max (0.1 0.30 0.1);
}
ball
{
source sphere;
origin (-0.1 -0.01 -0.1);
radius 0.25;
}
blob
{
source surface;
surfaceType triSurfaceMesh;
surfaceName blob.obj;
}
}
}
}
\endverbatim
\heading Dictionary parameters
\table
Property | Description | Required | Default
type | geometric | yes |
grow | Grow cells with partial connectivity | no | false
geometry | Dictionary of enclosing volumes | yes |
\endtable
Note
The searchableSurface must describe a closed volume.
Ie, its hasVolumeType() method must be true.
The selection of enclosing volumes is treated as an OR operation.
The "grow" mode includes an additional check to include cell faces
for any cell that already has two or more of its faces "unblocked".
This could indicate a connection over a corner, but does not distinguish
between connectivity introduced by the constraint and the connectivity
defined by other constraints.
SourceFiles
geometricConstraint.C
\*---------------------------------------------------------------------------*/
#ifndef geometricConstraint_H
#define geometricConstraint_H
#include "decompositionConstraint.H"
#include "PtrList.H"
#include "topoSetFaceSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace decompositionConstraints
{
/*---------------------------------------------------------------------------*\
Class geometric Declaration
\*---------------------------------------------------------------------------*/
class geometric
:
public decompositionConstraint
{
// Private data
//- Face selections as topoSetFaceSource
PtrList<topoSetFaceSource> sources_;
//- Dictionary of face selections for topoSetFaceSource
dictionary selection_;
//- Additional check of cell connection (via corners?)
bool grow_;
public:
//- Runtime type information
TypeName("geometric");
// Constructors
//- Construct with constraint dictionary
explicit geometric(const dictionary& dict);
//- Move construct from components.
// (topoSetFaceSource cannot be cloned)
explicit geometric(PtrList<topoSetFaceSource>&& selections);
//- Destructor
virtual ~geometric() = default;
// Member Functions
//- Add this constraint to list of constraints
virtual void add
(
const polyMesh& mesh,
boolList& blockedFace,
PtrList<labelList>& specifiedProcessorFaces,
labelList& specifiedProcessor,
List<labelPair>& explicitConnections
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace decompositionConstraints
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -34,12 +34,12 @@ namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
defineTypeName(preserveBafflesConstraint); defineTypeName(preserveBaffles);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionConstraint, decompositionConstraint,
preserveBafflesConstraint, preserveBaffles,
dictionary dictionary
); );
} }
@ -48,32 +48,31 @@ namespace decompositionConstraints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::decompositionConstraints::preserveBafflesConstraint:: Foam::decompositionConstraints::preserveBaffles::preserveBaffles
preserveBafflesConstraint
( (
const dictionary& constraintsDict, const dictionary& dict
const word& modelType
) )
: :
decompositionConstraint(constraintsDict, typeName) decompositionConstraint(dict, typeName)
{ {
if (decompositionConstraint::debug) if (decompositionConstraint::debug)
{ {
Info<< type() << " : setting constraints to preserve baffles" Info<< type()
<< " : setting constraints to preserve baffles"
//<< returnReduce(bafflePairs.size(), sumOp<label>()) //<< returnReduce(bafflePairs.size(), sumOp<label>())
<< endl; << endl;
} }
} }
Foam::decompositionConstraints::preserveBafflesConstraint:: Foam::decompositionConstraints::preserveBaffles::preserveBaffles()
preserveBafflesConstraint()
: :
decompositionConstraint(dictionary(), typeName) decompositionConstraint(dictionary(), typeName)
{ {
if (decompositionConstraint::debug) if (decompositionConstraint::debug)
{ {
Info<< type() << " : setting constraints to preserve baffles" Info<< type()
<< " : setting constraints to preserve baffles"
//<< returnReduce(bafflePairs.size(), sumOp<label>()) //<< returnReduce(bafflePairs.size(), sumOp<label>())
<< endl; << endl;
} }
@ -82,7 +81,7 @@ preserveBafflesConstraint()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::decompositionConstraints::preserveBafflesConstraint::add void Foam::decompositionConstraints::preserveBaffles::add
( (
const polyMesh& mesh, const polyMesh& mesh,
boolList& blockedFace, boolList& blockedFace,
@ -177,7 +176,7 @@ void Foam::decompositionConstraints::preserveBafflesConstraint::add
} }
void Foam::decompositionConstraints::preserveBafflesConstraint::apply void Foam::decompositionConstraints::preserveBaffles::apply
( (
const polyMesh& mesh, const polyMesh& mesh,
const boolList& blockedFace, const boolList& blockedFace,

View File

@ -22,11 +22,17 @@ 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::preserveBafflesConstraint Foam::decompositionConstraints::preserveBaffles
Description Description
Detects baffles and keeps owner and neighbour on same processor. Detects baffles and keeps owner and neighbour on same processor.
\heading Dictionary parameters
\table
Property | Description | Required | Default
type | preserveBaffles | yes |
\endtable
SourceFiles SourceFiles
preserveBafflesConstraint.C preserveBafflesConstraint.C
@ -41,15 +47,14 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class preserveBafflesConstraint Declaration Class preserveBaffles Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class preserveBafflesConstraint class preserveBaffles
: :
public decompositionConstraint public decompositionConstraint
{ {
@ -61,19 +66,15 @@ public:
// Constructors // Constructors
//- Construct with generic dictionary with optional entry for type //- Construct with constraint dictionary
preserveBafflesConstraint explicit preserveBaffles(const dictionary& dict);
(
const dictionary& constraintsDict,
const word& type
);
//- Construct from components //- Construct from components
preserveBafflesConstraint(); preserveBaffles();
//- Destructor //- Destructor
virtual ~preserveBafflesConstraint() = default; virtual ~preserveBaffles() = default;
// Member Functions // Member Functions

View File

@ -33,12 +33,12 @@ namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
defineTypeName(preserveFaceZonesConstraint); defineTypeName(preserveFaceZones);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionConstraint, decompositionConstraint,
preserveFaceZonesConstraint, preserveFaceZones,
dictionary dictionary
); );
} }
@ -47,15 +47,13 @@ namespace decompositionConstraints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::decompositionConstraints::preserveFaceZonesConstraint:: Foam::decompositionConstraints::preserveFaceZones::preserveFaceZones
preserveFaceZonesConstraint
( (
const dictionary& constraintsDict, const dictionary& dict
const word& modelType
) )
: :
decompositionConstraint(constraintsDict, typeName), decompositionConstraint(dict, typeName),
zones_(coeffDict_.lookup("zones")) zones_(coeffDict_.get<wordRes>("zones"))
{ {
if (decompositionConstraint::debug) if (decompositionConstraint::debug)
{ {
@ -66,8 +64,7 @@ preserveFaceZonesConstraint
} }
Foam::decompositionConstraints::preserveFaceZonesConstraint:: Foam::decompositionConstraints::preserveFaceZones::preserveFaceZones
preserveFaceZonesConstraint
( (
const UList<wordRe>& zones const UList<wordRe>& zones
) )
@ -86,7 +83,7 @@ preserveFaceZonesConstraint
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::decompositionConstraints::preserveFaceZonesConstraint::add void Foam::decompositionConstraints::preserveFaceZones::add
( (
const polyMesh& mesh, const polyMesh& mesh,
boolList& blockedFace, boolList& blockedFace,
@ -127,7 +124,7 @@ void Foam::decompositionConstraints::preserveFaceZonesConstraint::add
} }
void Foam::decompositionConstraints::preserveFaceZonesConstraint::apply void Foam::decompositionConstraints::preserveFaceZones::apply
( (
const polyMesh& mesh, const polyMesh& mesh,
const boolList& blockedFace, const boolList& blockedFace,

View File

@ -22,12 +22,19 @@ 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::preserveFaceZonesConstraint Foam::decompositionConstraints::preserveFaceZones
Description Description
Constraint to keep/move owner and neighbour of faceZone onto same Constraint to keep/move owner and neighbour of faceZone onto same
processor. processor.
\heading Dictionary parameters
\table
Property | Description | Required | Default
type | preserveFaceZones | yes |
zones | List of face zone names or regexs | yes |
\endtable
SourceFiles SourceFiles
preserveFaceZonesConstraint.C preserveFaceZonesConstraint.C
@ -43,15 +50,14 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class preserveFaceZonesConstraint Declaration Class preserveFaceZones Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class preserveFaceZonesConstraint class preserveFaceZones
: :
public decompositionConstraint public decompositionConstraint
{ {
@ -69,19 +75,15 @@ public:
// Constructors // Constructors
//- Construct with generic dictionary with optional entry for type //- Construct with constraint dictionary
preserveFaceZonesConstraint explicit preserveFaceZones(const dictionary& dict);
(
const dictionary& constraintsDict,
const word& type
);
//- Construct from components //- Construct from components
preserveFaceZonesConstraint(const UList<wordRe>& zones); explicit preserveFaceZones(const UList<wordRe>& zones);
//- Destructor //- Destructor
virtual ~preserveFaceZonesConstraint() = default; virtual ~preserveFaceZones() = default;
// Member Functions // Member Functions

View File

@ -33,12 +33,12 @@ namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
defineTypeName(preservePatchesConstraint); defineTypeName(preservePatches);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionConstraint, decompositionConstraint,
preservePatchesConstraint, preservePatches,
dictionary dictionary
); );
} }
@ -47,15 +47,13 @@ namespace decompositionConstraints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::decompositionConstraints::preservePatchesConstraint:: Foam::decompositionConstraints::preservePatches::preservePatches
preservePatchesConstraint
( (
const dictionary& constraintsDict, const dictionary& dict
const word& modelType
) )
: :
decompositionConstraint(constraintsDict, typeName), decompositionConstraint(dict, typeName),
patches_(coeffDict_.lookup("patches")) patches_(coeffDict_.get<wordRes>("patches"))
{ {
if (decompositionConstraint::debug) if (decompositionConstraint::debug)
{ {
@ -66,8 +64,7 @@ preservePatchesConstraint
} }
Foam::decompositionConstraints::preservePatchesConstraint:: Foam::decompositionConstraints::preservePatches::preservePatches
preservePatchesConstraint
( (
const UList<wordRe>& patches const UList<wordRe>& patches
) )
@ -86,7 +83,7 @@ preservePatchesConstraint
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::decompositionConstraints::preservePatchesConstraint::add void Foam::decompositionConstraints::preservePatches::add
( (
const polyMesh& mesh, const polyMesh& mesh,
boolList& blockedFace, boolList& blockedFace,
@ -97,7 +94,7 @@ void Foam::decompositionConstraints::preservePatchesConstraint::add
{ {
const polyBoundaryMesh& pbm = mesh.boundaryMesh(); const polyBoundaryMesh& pbm = mesh.boundaryMesh();
blockedFace.setSize(mesh.nFaces(), true); blockedFace.resize(mesh.nFaces(), true);
const labelList patchIDs(pbm.patchSet(patches_).sortedToc()); const labelList patchIDs(pbm.patchSet(patches_).sortedToc());
@ -129,7 +126,7 @@ void Foam::decompositionConstraints::preservePatchesConstraint::add
} }
void Foam::decompositionConstraints::preservePatchesConstraint::apply void Foam::decompositionConstraints::preservePatches::apply
( (
const polyMesh& mesh, const polyMesh& mesh,
const boolList& blockedFace, const boolList& blockedFace,
@ -177,7 +174,7 @@ void Foam::decompositionConstraints::preservePatchesConstraint::apply
forAll(faceCells, i) forAll(faceCells, i)
{ {
label bFaceI = pp.start()+i-mesh.nInternalFaces(); const label bFaceI = pp.start()+i-mesh.nInternalFaces();
if (decomposition[faceCells[i]] != destProc[bFaceI]) if (decomposition[faceCells[i]] != destProc[bFaceI])
{ {

View File

@ -22,12 +22,19 @@ 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::preservePatchesConstraint Foam::decompositionConstraints::preservePatches
Description Description
Constraint to keep owner and neighbour of (cyclic) patch on same Constraint to keep owner and neighbour of (cyclic) patch on same
processor. processor.
\heading Dictionary parameters
\table
Property | Description | Required | Default
type | preservePatches | yes |
patches | List of patch names or regexs | yes |
\endtable
SourceFiles SourceFiles
preservePatchesConstraint.C preservePatchesConstraint.C
@ -48,10 +55,10 @@ namespace decompositionConstraints
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class preservePatchesConstraint Declaration Class preservePatches Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class preservePatchesConstraint class preservePatches
: :
public decompositionConstraint public decompositionConstraint
{ {
@ -69,19 +76,15 @@ public:
// Constructors // Constructors
//- Construct with generic dictionary with optional entry for type //- Construct with constraint dictionary
preservePatchesConstraint explicit preservePatches(const dictionary& dict);
(
const dictionary& constraintsDict,
const word& type
);
//- Construct from components //- Construct from components
preservePatchesConstraint(const UList<wordRe>& patches); explicit preservePatches(const UList<wordRe>& patches);
//- Destructor //- Destructor
virtual ~preservePatchesConstraint() = default; virtual ~preservePatches() = default;
// Member Functions // Member Functions

View File

@ -32,50 +32,52 @@ License
namespace Foam namespace Foam
{ {
defineTypeName(refinementHistoryConstraint); namespace decompositionConstraints
{
defineTypeName(refinementHistory);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionConstraint, decompositionConstraint,
refinementHistoryConstraint, refinementHistory,
dictionary dictionary
); );
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::refinementHistoryConstraint::refinementHistoryConstraint Foam::decompositionConstraints::refinementHistory::refinementHistory
( (
const dictionary& constraintsDict, const dictionary& dict
const word& modelType
) )
: :
decompositionConstraint(constraintsDict, typeName) decompositionConstraint(dict, typeName)
{ {
if (decompositionConstraint::debug) if (decompositionConstraint::debug)
{ {
Info<< type() << " : setting constraints to refinement history" Info<< type()
<< endl; << " : setting constraints to refinement history" << endl;
} }
} }
Foam::refinementHistoryConstraint::refinementHistoryConstraint() Foam::decompositionConstraints::refinementHistory::refinementHistory()
: :
decompositionConstraint(dictionary(), typeName) decompositionConstraint(dictionary(), typeName)
{ {
if (decompositionConstraint::debug) if (decompositionConstraint::debug)
{ {
Info<< type() << " : setting constraints to refinement history" Info<< type()
<< endl; << " : setting constraints to refinement history" << endl;
} }
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::refinementHistoryConstraint::add void Foam::decompositionConstraints::refinementHistory::add
( (
const polyMesh& mesh, const polyMesh& mesh,
boolList& blockedFace, boolList& blockedFace,
@ -84,16 +86,33 @@ void Foam::refinementHistoryConstraint::add
List<labelPair>& explicitConnections List<labelPair>& explicitConnections
) const ) const
{ {
const refinementHistory* refPtr = // The refinement history type
mesh.findObject<refinementHistory>("refinementHistory"); typedef ::Foam::refinementHistory HistoryType;
autoPtr<const refinementHistory> storagePtr; // Local storage if read from file
autoPtr<const HistoryType> readFromFile;
if (!refPtr) const HistoryType* historyPtr =
mesh.findObject<HistoryType>("refinementHistory");
if (historyPtr)
{ {
storagePtr.reset if (decompositionConstraint::debug)
{
Info<< type() << " : found refinementHistory" << endl;
}
}
else
{
if (decompositionConstraint::debug)
{
Info<< type() << " : reading refinementHistory from time "
<< mesh.facesInstance() << endl;
}
readFromFile.reset
( (
new refinementHistory new HistoryType
( (
IOobject IOobject
( (
@ -107,27 +126,11 @@ void Foam::refinementHistoryConstraint::add
mesh.nCells() mesh.nCells()
) )
); );
historyPtr = readFromFile.get(); // get(), not release()
} }
if (decompositionConstraint::debug) const auto& history = *historyPtr;
{
if (refPtr)
{
Info<< type() << " : found refinementHistory" << nl;
}
else
{
Info<< type() << " : reading refinementHistory from time "
<< mesh.facesInstance() << nl;
}
}
const refinementHistory& history =
(
storagePtr.valid()
? *storagePtr
: *refPtr
);
if (history.active()) if (history.active())
{ {
@ -143,7 +146,7 @@ void Foam::refinementHistoryConstraint::add
} }
void Foam::refinementHistoryConstraint::apply void Foam::decompositionConstraints::refinementHistory::apply
( (
const polyMesh& mesh, const polyMesh& mesh,
const boolList& blockedFace, const boolList& blockedFace,
@ -153,16 +156,20 @@ void Foam::refinementHistoryConstraint::apply
labelList& decomposition labelList& decomposition
) const ) const
{ {
const refinementHistory* refPtr = // The refinement history type
mesh.findObject<refinementHistory>("refinementHistory"); typedef ::Foam::refinementHistory HistoryType;
autoPtr<const refinementHistory> storagePtr; // Local storage if read from file
autoPtr<const HistoryType> readFromFile;
if (!refPtr) const HistoryType* historyPtr =
mesh.findObject<HistoryType>("refinementHistory");
if (!historyPtr)
{ {
storagePtr.reset readFromFile.reset
( (
new refinementHistory new HistoryType
( (
IOobject IOobject
( (
@ -176,14 +183,11 @@ void Foam::refinementHistoryConstraint::apply
mesh.nCells() mesh.nCells()
) )
); );
historyPtr = readFromFile.get(); // get(), not release()
} }
const refinementHistory& history = const auto& history = *historyPtr;
(
storagePtr.valid()
? *storagePtr
: *refPtr
);
if (history.active()) if (history.active())
{ {

View File

@ -22,12 +22,18 @@ 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::refinementHistoryConstraint Foam::decompositionConstraints::refinementHistory
Description Description
Constraint to keep all cells originating from refining the same cell Constraint to keep all cells originating from refining the same cell
onto the same processor. Reads polyMesh/refinementHistory. onto the same processor. Reads polyMesh/refinementHistory.
\heading Dictionary parameters
\table
Property | Description | Required | Default
type | refinementHistory | yes |
\endtable
SourceFiles SourceFiles
refinementHistoryConstraint.C refinementHistoryConstraint.C
@ -42,12 +48,14 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace decompositionConstraints
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class refinementHistoryConstraint Declaration Class refinementHistory Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class refinementHistoryConstraint class refinementHistory
: :
public decompositionConstraint public decompositionConstraint
{ {
@ -59,24 +67,20 @@ public:
// Constructors // Constructors
//- Construct with generic dictionary with optional entry for type //- Construct with constraint dictionary
refinementHistoryConstraint explicit refinementHistory(const dictionary& dict);
(
const dictionary& constraintsDict,
const word& type
);
//- Construct from components //- Construct from components
refinementHistoryConstraint(); refinementHistory();
//- Destructor //- Destructor
virtual ~refinementHistoryConstraint() = default; virtual ~refinementHistory() = default;
// Member Functions // Member Functions
//- Add my constraints to list of constraints //- Add this constraint to list of constraints
virtual void add virtual void add
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -86,7 +90,7 @@ public:
List<labelPair>& explicitConnections List<labelPair>& explicitConnections
) const; ) const;
//- Apply any additional post-decomposition constraints //- Apply this constraint post-decomposition
virtual void apply virtual void apply
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -101,6 +105,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace decompositionConstraints
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -3,7 +3,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) 2015-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,34 +28,45 @@ License
#include "syncTools.H" #include "syncTools.H"
#include "faceSet.H" #include "faceSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
defineTypeName(singleProcessorFaceSetsConstraint); defineTypeName(singleProcessorFaceSets);
addToRunTimeSelectionTable addToRunTimeSelectionTable
( (
decompositionConstraint, decompositionConstraint,
singleProcessorFaceSetsConstraint, singleProcessorFaceSets,
dictionary dictionary
); );
} }
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::decompositionConstraints::singleProcessorFaceSets::printInfo() const
{
for (const auto& nameAndProc : setNameAndProcs_)
{
Info<< " all cells connected to faceSet "
<< nameAndProc.first()
<< " on processor " << nameAndProc.second() << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::decompositionConstraints::singleProcessorFaceSetsConstraint:: Foam::decompositionConstraints::singleProcessorFaceSets::
singleProcessorFaceSetsConstraint singleProcessorFaceSets
( (
const dictionary& constraintsDict, const dictionary& dict
const word& modelType
) )
: :
decompositionConstraint(constraintsDict, typeName), decompositionConstraint(dict, typeName),
setNameAndProcs_ setNameAndProcs_
( (
coeffDict_.lookupCompat("sets", {{"singleProcessorFaceSets", 1806}}) coeffDict_.lookupCompat("sets", {{"singleProcessorFaceSets", 1806}})
@ -66,18 +77,13 @@ singleProcessorFaceSetsConstraint
Info<< type() Info<< type()
<< " : adding constraints to keep" << endl; << " : adding constraints to keep" << endl;
forAll(setNameAndProcs_, setI) printInfo();
{
Info<< " all cells connected to faceSet "
<< setNameAndProcs_[setI].first()
<< " on processor " << setNameAndProcs_[setI].second() << endl;
}
} }
} }
Foam::decompositionConstraints::singleProcessorFaceSetsConstraint:: Foam::decompositionConstraints::singleProcessorFaceSets::
singleProcessorFaceSetsConstraint singleProcessorFaceSets
( (
const List<Tuple2<word, label>>& setNameAndProcs const List<Tuple2<word, label>>& setNameAndProcs
) )
@ -90,19 +96,33 @@ singleProcessorFaceSetsConstraint
Info<< type() Info<< type()
<< " : adding constraints to keep" << endl; << " : adding constraints to keep" << endl;
forAll(setNameAndProcs_, setI) printInfo();
{ }
Info<< " all cells connected to faceSet " }
<< setNameAndProcs_[setI].first()
<< " on processor " << setNameAndProcs_[setI].second() << endl;
} Foam::decompositionConstraints::singleProcessorFaceSets::
singleProcessorFaceSets
(
Istream& is
)
:
decompositionConstraint(dictionary(), typeName),
setNameAndProcs_(is)
{
if (decompositionConstraint::debug)
{
Info<< type()
<< " : adding constraints to keep" << endl;
printInfo();
} }
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add void Foam::decompositionConstraints::singleProcessorFaceSets::add
( (
const polyMesh& mesh, const polyMesh& mesh,
boolList& blockedFace, boolList& blockedFace,
@ -111,20 +131,19 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add
List<labelPair>& explicitConnections List<labelPair>& explicitConnections
) const ) const
{ {
blockedFace.setSize(mesh.nFaces(), true); blockedFace.resize(mesh.nFaces(), true);
// Mark faces already in set // Mark faces already in set
labelList faceToSet(mesh.nFaces(), -1); labelList faceToSet(mesh.nFaces(), -1);
forAll(specifiedProcessorFaces, setI) forAll(specifiedProcessorFaces, setI)
{ {
const labelList& faceLabels = specifiedProcessorFaces[setI]; const labelList& faceLabels = specifiedProcessorFaces[setI];
forAll(faceLabels, i) for (const label facei : faceLabels)
{ {
faceToSet[faceLabels[i]] = setI; faceToSet[facei] = setI;
} }
} }
forAll(setNameAndProcs_, setI) forAll(setNameAndProcs_, setI)
{ {
//Info<< "Keeping all cells connected to faceSet " //Info<< "Keeping all cells connected to faceSet "
@ -140,10 +159,10 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add
labelList nMatch(specifiedProcessorFaces.size(), 0); labelList nMatch(specifiedProcessorFaces.size(), 0);
forAllConstIter(faceSet, fz, iter) forAllConstIter(faceSet, fz, iter)
{ {
label setI = faceToSet[iter.key()]; label seti = faceToSet[iter.key()];
if (setI != -1) if (seti != -1)
{ {
nMatch[setI]++; ++nMatch[seti];
} }
} }
@ -156,13 +175,13 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add
{ {
if (nMatch[setI] == fz.size()) if (nMatch[setI] == fz.size())
{ {
// full match // Full match
store = false; store = false;
break; break;
} }
else if (nMatch[setI] > 0) else if (nMatch[setI] > 0)
{ {
// partial match // Partial match
store = false; store = false;
break; break;
} }
@ -184,13 +203,14 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add
boolList procFacePoint(mesh.nPoints(), false); boolList procFacePoint(mesh.nPoints(), false);
forAll(specifiedProcessorFaces, setI) forAll(specifiedProcessorFaces, setI)
{ {
const labelList& set = specifiedProcessorFaces[setI]; const labelList& faceLabels = specifiedProcessorFaces[setI];
forAll(set, fI) for (const label facei : faceLabels)
{ {
const face& f = mesh.faces()[set[fI]]; const face& f = mesh.faces()[facei];
forAll(f, fp)
for (const label pointi : f)
{ {
procFacePoint[f[fp]] = true; procFacePoint[pointi] = true;
} }
} }
} }
@ -210,7 +230,7 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add
if (blockedFace[pFaces[i]]) if (blockedFace[pFaces[i]])
{ {
blockedFace[pFaces[i]] = false; blockedFace[pFaces[i]] = false;
nUnblocked++; ++nUnblocked;
} }
} }
} }
@ -226,7 +246,7 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::add
} }
void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::apply void Foam::decompositionConstraints::singleProcessorFaceSets::apply
( (
const polyMesh& mesh, const polyMesh& mesh,
const boolList& blockedFace, const boolList& blockedFace,
@ -286,23 +306,23 @@ void Foam::decompositionConstraints::singleProcessorFaceSetsConstraint::apply
if (procFacePoint[pointi]) if (procFacePoint[pointi])
{ {
const labelList& pFaces = mesh.pointFaces()[pointi]; const labelList& pFaces = mesh.pointFaces()[pointi];
forAll(pFaces, i) for (const label faceI : pFaces)
{ {
label faceI = pFaces[i]; const label own = mesh.faceOwner()[faceI];
label own = mesh.faceOwner()[faceI];
if (decomposition[own] != procI) if (decomposition[own] != procI)
{ {
decomposition[own] = procI; decomposition[own] = procI;
nChanged++; ++nChanged;
} }
if (mesh.isInternalFace(faceI)) if (mesh.isInternalFace(faceI))
{ {
label nei = mesh.faceNeighbour()[faceI]; const label nei = mesh.faceNeighbour()[faceI];
if (decomposition[nei] != procI) if (decomposition[nei] != procI)
{ {
decomposition[nei] = procI; decomposition[nei] = procI;
nChanged++; ++nChanged;
} }
} }
} }

View File

@ -22,12 +22,36 @@ 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::singleProcessorFaceSetsConstraint Foam::decompositionConstraints::singleProcessorFaceSets
Description Description
Constraint to keep all cells connected to face or point of faceSet on Constraint to keep all cells connected to face or point of faceSet on
a single processor. a single processor.
\heading Dictionary parameters
\table
Property | Description | Required | Default
type | singleProcessorFaceSets | yes |
sets | List of sets and processers | yes |
\endtable
Example,
\verbatim
constraints
{
procs
{
type singleProcessorFaceSets;
sets
(
(faceSet1 0)
(faceSet5 12)
(faceSet25 510)
);
}
}
\endverbatim
SourceFiles SourceFiles
singleProcessorFaceSetsConstraint.C singleProcessorFaceSetsConstraint.C
@ -43,15 +67,14 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace decompositionConstraints namespace decompositionConstraints
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class singleProcessorFaceSetsConstraint Declaration Class singleProcessorFaceSets Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class singleProcessorFaceSetsConstraint class singleProcessorFaceSets
: :
public decompositionConstraint public decompositionConstraint
{ {
@ -60,6 +83,10 @@ class singleProcessorFaceSetsConstraint
//- List of faceSet+processor //- List of faceSet+processor
List<Tuple2<word, label>> setNameAndProcs_; List<Tuple2<word, label>> setNameAndProcs_;
//- Report names of sets and processor numnbers
void printInfo() const;
public: public:
//- Runtime type information //- Runtime type information
@ -68,27 +95,26 @@ public:
// Constructors // Constructors
//- Construct with generic dictionary with optional entry for type //- Construct with constraint dictionary
singleProcessorFaceSetsConstraint explicit singleProcessorFaceSets(const dictionary& dict);
(
const dictionary& constraintsDict,
const word& type
);
//- Construct from components //- Copy construct from components
singleProcessorFaceSetsConstraint explicit singleProcessorFaceSets
( (
const List<Tuple2<word, label>>& setNameAndProcs const List<Tuple2<word, label>>& setNameAndProcs
); );
//- Read construct a List of (setName processor)
explicit singleProcessorFaceSets(Istream& is);
//- Destructor //- Destructor
virtual ~singleProcessorFaceSetsConstraint() = default; virtual ~singleProcessorFaceSets() = default;
// Member Functions // Member Functions
//- Add my constraints to list of constraints //- Add this constraint to list of constraints
virtual void add virtual void add
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -98,7 +124,7 @@ public:
List<labelPair>& explicitConnections List<labelPair>& explicitConnections
) const; ) const;
//- Apply any additional post-decomposition constraints //- Add this constraint post-decomposition
virtual void apply virtual void apply
( (
const polyMesh& mesh, const polyMesh& mesh,

View File

@ -34,6 +34,7 @@ License
#include "BitOps.H" #include "BitOps.H"
#include "FaceCellWave.H" #include "FaceCellWave.H"
// Compatibility (MAY-2014)
#include "preserveBafflesConstraint.H" #include "preserveBafflesConstraint.H"
#include "preservePatchesConstraint.H" #include "preservePatchesConstraint.H"
#include "preserveFaceZonesConstraint.H" #include "preserveFaceZonesConstraint.H"
@ -114,103 +115,106 @@ const Foam::dictionary& Foam::decompositionMethod::optionalRegionDict
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::decompositionMethod::constraintCompat(const word& modelType) const
{
bool usable = decompDict_.found(modelType);
if (!usable)
{
return false;
}
for (const auto& item : constraints_)
{
if (modelType == item.type())
{
usable = false;
break;
}
}
if (usable)
{
Warning
<< nl << " Using '" << modelType
<< "' constraint specification." << nl;
}
else
{
Warning
<< nl << " Ignoring '" << modelType
<< "' constraint specification - was already specified." << nl;
}
// The syntax changed MAY-2014
error::warnAboutAge("constraint keyword", 1406);
return usable;
}
void Foam::decompositionMethod::readConstraints() void Foam::decompositionMethod::readConstraints()
{ {
constraints_.clear(); constraints_.clear();
// Read any constraints const dictionary* dictptr = decompDict_.findDict("constraints");
wordList constraintTypes;
const dictionary* dictptr = decompositionDict_.findDict("constraints");
if (dictptr) if (dictptr)
{ {
for (const entry& dEntry : *dictptr) for (const entry& dEntry : *dictptr)
{ {
if (!dEntry.isDict()) // safety
{
// Ignore or warn
continue;
}
const dictionary& dict = dEntry.dict(); const dictionary& dict = dEntry.dict();
constraintTypes.append(dict.get<word>("type")); if (dict.lookupOrDefault("enabled", true))
{
constraints_.append constraints_.append(decompositionConstraint::New(dict));
( }
decompositionConstraint::New
(
dict,
constraintTypes.last()
)
);
} }
} }
// Backwards compatibility // Backwards compatibility (MAY-2014)
if if (constraintCompat("preserveBaffles"))
(
decompositionDict_.found("preserveBaffles")
&& !constraintTypes.found
(
decompositionConstraints::preserveBafflesConstraint::typeName
)
)
{ {
constraints_.append constraints_.append
( (
new decompositionConstraints::preserveBafflesConstraint() new decompositionConstraints::preserveBaffles()
); );
} }
if if (constraintCompat("preservePatches"))
(
decompositionDict_.found("preservePatches")
&& !constraintTypes.found
(
decompositionConstraints::preservePatchesConstraint::typeName
)
)
{ {
const wordReList pNames(decompositionDict_.lookup("preservePatches"));
constraints_.append constraints_.append
( (
new decompositionConstraints::preservePatchesConstraint(pNames) new decompositionConstraints::preservePatches
);
}
if
(
decompositionDict_.found("preserveFaceZones")
&& !constraintTypes.found
(
decompositionConstraints::preserveFaceZonesConstraint::typeName
)
)
{
const wordReList zNames(decompositionDict_.lookup("preserveFaceZones"));
constraints_.append
(
new decompositionConstraints::preserveFaceZonesConstraint(zNames)
);
}
if
(
decompositionDict_.found("singleProcessorFaceSets")
&& !constraintTypes.found
(
decompositionConstraints::preserveFaceZonesConstraint::typeName
)
)
{
const List<Tuple2<word, label>> zNameAndProcs
(
decompositionDict_.lookup("singleProcessorFaceSets")
);
constraints_.append
(
new decompositionConstraints::singleProcessorFaceSetsConstraint
( (
zNameAndProcs decompDict_.get<wordRes>("preservePatches")
)
);
}
if (constraintCompat("preserveFaceZones"))
{
constraints_.append
(
new decompositionConstraints::preserveFaceZones
(
decompDict_.get<wordRes>("preserveFaceZones")
)
);
}
if (constraintCompat("singleProcessorFaceSets"))
{
constraints_.append
(
new decompositionConstraints::singleProcessorFaceSets
(
decompDict_.lookup("singleProcessorFaceSets")
) )
); );
} }
@ -268,14 +272,14 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
if if
( (
!decompositionRegionDict_.empty() !decompRegionDict_.empty()
&& &&
( (
(fnd = decompositionRegionDict_.csearch(coeffsName)).isDict() (fnd = decompRegionDict_.csearch(coeffsName)).isDict()
|| ||
( (
!(select & selectionType::EXACT) !(select & selectionType::EXACT)
&& (fnd = decompositionRegionDict_.csearch(defaultName)).isDict() && (fnd = decompRegionDict_.csearch(defaultName)).isDict()
) )
) )
) )
@ -285,11 +289,11 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
if if
( (
(fnd = decompositionDict_.csearch(coeffsName)).isDict() (fnd = decompDict_.csearch(coeffsName)).isDict()
|| ||
( (
!(select & selectionType::EXACT) !(select & selectionType::EXACT)
&& (fnd = decompositionDict_.csearch(defaultName)).isDict() && (fnd = decompDict_.csearch(defaultName)).isDict()
) )
) )
{ {
@ -301,7 +305,7 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
{ {
FatalIOError FatalIOError
<< "'" << coeffsName << "' dictionary not found in dictionary " << "'" << coeffsName << "' dictionary not found in dictionary "
<< decompositionDict_.name() << endl << decompDict_.name() << endl
<< abort(FatalIOError); << abort(FatalIOError);
} }
@ -310,7 +314,7 @@ const Foam::dictionary& Foam::decompositionMethod::findCoeffsDict
return dictionary::null; return dictionary::null;
} }
return decompositionDict_; return decompDict_;
} }
@ -321,8 +325,8 @@ Foam::decompositionMethod::decompositionMethod
const dictionary& decompDict const dictionary& decompDict
) )
: :
decompositionDict_(decompDict), decompDict_(decompDict),
decompositionRegionDict_(dictionary::null), decompRegionDict_(dictionary::null),
nDomains_(nDomains(decompDict)) nDomains_(nDomains(decompDict))
{ {
readConstraints(); readConstraints();
@ -335,10 +339,10 @@ Foam::decompositionMethod::decompositionMethod
const word& regionName const word& regionName
) )
: :
decompositionDict_(decompDict), decompDict_(decompDict),
decompositionRegionDict_ decompRegionDict_
( (
optionalRegionDict(decompositionDict_, regionName) optionalRegionDict(decompDict_, regionName)
), ),
nDomains_(nDomains(decompDict, regionName)) nDomains_(nDomains(decompDict, regionName))
{ {
@ -381,7 +385,6 @@ Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New
( (
const dictionary& decompDict, const dictionary& decompDict,
const word& regionName const word& regionName
) )
{ {
const dictionary& regionDict(optionalRegionDict(decompDict, regionName)); const dictionary& regionDict(optionalRegionDict(decompDict, regionName));
@ -428,7 +431,7 @@ Foam::labelList Foam::decompositionMethod::decompose
const pointField& points const pointField& points
) const ) const
{ {
scalarField weights(points.size(), 1.0); scalarField weights(points.size(), scalar(1));
return decompose(mesh, points, weights); return decompose(mesh, points, weights);
} }
@ -482,7 +485,7 @@ Foam::labelList Foam::decompositionMethod::decompose
const pointField& coarsePoints const pointField& coarsePoints
) const ) const
{ {
scalarField weights(coarsePoints.size(), 1.0); scalarField weights(coarsePoints.size(), scalar(1));
return decompose return decompose
( (
@ -500,7 +503,7 @@ Foam::labelList Foam::decompositionMethod::decompose
const pointField& cc const pointField& cc
) const ) const
{ {
scalarField weights(cc.size(), 1.0); scalarField weights(cc.size(), scalar(1));
return decompose(globalCellCells, cc, weights); return decompose(globalCellCells, cc, weights);
} }
@ -565,7 +568,7 @@ void Foam::decompositionMethod::calcCellCells
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Number of faces per coarse cell // Number of faces per coarse cell
labelList nFacesPerCell(nLocalCoarse, 0); labelList nFacesPerCell(nLocalCoarse, Zero);
for (label facei = 0; facei < mesh.nInternalFaces(); ++facei) for (label facei = 0; facei < mesh.nInternalFaces(); ++facei)
{ {
@ -764,7 +767,7 @@ void Foam::decompositionMethod::calcCellCells
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Number of faces per coarse cell // Number of faces per coarse cell
labelList nFacesPerCell(nLocalCoarse, 0); labelList nFacesPerCell(nLocalCoarse, Zero);
for (label facei = 0; facei < mesh.nInternalFaces(); ++facei) for (label facei = 0; facei < mesh.nInternalFaces(); ++facei)
{ {
@ -1016,7 +1019,7 @@ Foam::labelList Foam::decompositionMethod::decompose
// If we average the region centre instead, cyclics could cause // If we average the region centre instead, cyclics could cause
// the average domain centre to be outside of domain. // the average domain centre to be outside of domain.
scalarField regionWeights(localRegion.nLocalRegions(), 0.0); scalarField regionWeights(localRegion.nLocalRegions(), Zero);
pointField regionCentres(localRegion.nLocalRegions(), point::max); pointField regionCentres(localRegion.nLocalRegions(), point::max);

View File

@ -50,7 +50,14 @@ class decompositionMethod
{ {
// Private Member Functions // Private Member Functions
//- Set PtrList of constraints by reading decompositionDict_. //- Check (and warn) about existence of old constraint syntax.
// The syntax changed MAY-2014.
//
// \return true if this model name was found in the decompDict_
// but not previously added with the newer syntax.
bool constraintCompat(const word& modelType) const;
//- Set PtrList of constraints by reading decompDict_.
void readConstraints(); void readConstraints();
//- No copy construct //- No copy construct
@ -77,10 +84,10 @@ protected:
// Protected data // Protected data
//- Top-level decomposition dictionary (eg, decomposeParDict) //- Top-level decomposition dictionary (eg, decomposeParDict)
const dictionary& decompositionDict_; const dictionary& decompDict_;
//- Region-specific decomposition dictionary information //- Region-specific decomposition dictionary information
const dictionary& decompositionRegionDict_; const dictionary& decompRegionDict_;
//- Number of domains for the decomposition //- Number of domains for the decomposition
label nDomains_; label nDomains_;
@ -238,14 +245,14 @@ public:
) const ) const
{ {
NotImplemented; NotImplemented;
return labelList(0); return labelList();
} }
//- Decompose with uniform weights on the points //- Decompose with uniform weights on the points
virtual labelList decompose(const pointField& points) const virtual labelList decompose(const pointField& points) const
{ {
NotImplemented; NotImplemented;
return labelList(0); return labelList();
} }

View File

@ -30,7 +30,6 @@ License
void Foam::geomDecomp::readCoeffs() void Foam::geomDecomp::readCoeffs()
{ {
coeffsDict_.readIfPresent("delta", delta_); coeffsDict_.readIfPresent("delta", delta_);
coeffsDict_.readEntry("n", n_); coeffsDict_.readEntry("n", n_);
// Verify that the input makes sense // Verify that the input makes sense
@ -63,7 +62,7 @@ void Foam::geomDecomp::checkDecompositionDirections
const Vector<label>& meshDirs const Vector<label>& meshDirs
) const ) const
{ {
for (direction dir = 0; dir < Vector<label>::nComponents; dir++) for (direction dir = 0; dir < Vector<label>::nComponents; ++dir)
{ {
if (n_[dir] > 1 && meshDirs[dir] == -1) if (n_[dir] > 1 && meshDirs[dir] == -1)
{ {

View File

@ -59,7 +59,7 @@ void Foam::hierarchGeomDecomp::setDecompOrder()
{ {
if (order.size() != 3) if (order.size() != 3)
{ {
FatalIOErrorInFunction(decompositionDict_) FatalIOErrorInFunction(decompDict_)
<< "number of characters in order (" << order << ") != 3" << "number of characters in order (" << order << ") != 3"
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -75,7 +75,7 @@ void Foam::hierarchGeomDecomp::setDecompOrder()
case 'z': decompOrder_[i] = 2; break; case 'z': decompOrder_[i] = 2; break;
default: default:
FatalIOErrorInFunction(decompositionDict_) FatalIOErrorInFunction(decompDict_)
<< "Illegal decomposition order " << order << nl << "Illegal decomposition order " << order << nl
<< "It should only contain x, y or z" << "It should only contain x, y or z"
<< exit(FatalError); << exit(FatalError);
@ -536,7 +536,7 @@ void Foam::hierarchGeomDecomp::sortComponent
// Now evaluate local cumulative weights, based on the sorting. // Now evaluate local cumulative weights, based on the sorting.
// Make one bigger than the nodes. // Make one bigger than the nodes.
scalarField sortedWeightedSizes(current.size()+1, 0); scalarField sortedWeightedSizes(current.size()+1, Zero);
calculateSortedWeightedSizes calculateSortedWeightedSizes
( (
current, current,
@ -719,7 +719,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
) const ) const
{ {
// construct a list for the final result // construct a list for the final result
labelList finalDecomp(points.size(), 0); labelList finalDecomp(points.size(), Zero);
// Start off with every point sorted onto itself. // Start off with every point sorted onto itself.
labelList slice(points.size()); labelList slice(points.size());
@ -759,8 +759,8 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose
const scalarField& weights const scalarField& weights
) const ) const
{ {
// construct a list for the final result // Construct a list for the final result
labelList finalDecomp(points.size(), 0); labelList finalDecomp(points.size(), Zero);
// Start off with every point sorted onto itself. // Start off with every point sorted onto itself.
labelList slice(points.size()); labelList slice(points.size());

View File

@ -24,9 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "manualDecomp.H" #include "manualDecomp.H"
#include "addToRunTimeSelectionTable.H"
#include "IFstream.H"
#include "labelIOList.H" #include "labelIOList.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +54,10 @@ namespace Foam
Foam::manualDecomp::manualDecomp(const dictionary& decompDict) Foam::manualDecomp::manualDecomp(const dictionary& decompDict)
: :
decompositionMethod(decompDict), decompositionMethod(decompDict),
dataFile_(findCoeffsDict(typeName + "Coeffs").lookup("dataFile")) dataFile_
(
findCoeffsDict(typeName + "Coeffs").get<fileName>("dataFile")
)
{} {}
@ -66,7 +68,10 @@ Foam::manualDecomp::manualDecomp
) )
: :
decompositionMethod(decompDict, regionName), decompositionMethod(decompDict, regionName),
dataFile_(findCoeffsDict(typeName + "Coeffs").lookup("dataFile")) dataFile_
(
findCoeffsDict(typeName + "Coeffs").get<fileName>("dataFile")
)
{} {}

View File

@ -111,11 +111,6 @@ public:
//- Return for every coordinate the wanted processor number. //- Return for every coordinate the wanted processor number.
// Explicitly provided connectivity - does not use mesh_. // Explicitly provided connectivity - does not use mesh_.
// The connectivity is equal to mesh.cellCells() except for
// - in parallel the cell numbers are global cell numbers (starting
// from 0 at processor0 and then incrementing all through the
// processors)
// - the connections are across coupled patches
virtual labelList decompose virtual labelList decompose
( (
const labelListList& globalCellCells, const labelListList& globalCellCells,
@ -124,7 +119,7 @@ public:
) const ) const
{ {
NotImplemented; NotImplemented;
return labelList(0); return labelList();
} }
}; };

View File

@ -397,7 +397,7 @@ void Foam::multiLevelDecomp::decompose
Pout<< "Decomposition at level " << currLevel << " :" << endl; Pout<< "Decomposition at level " << currLevel << " :" << endl;
} }
for (label domainI = 0; domainI < nCurrDomains; domainI++) for (label domainI = 0; domainI < nCurrDomains; ++domainI)
{ {
// Extract elements for current domain // Extract elements for current domain
const labelList domainPoints(findIndices(dist, domainI)); const labelList domainPoints(findIndices(dist, domainI));
@ -505,12 +505,12 @@ void Foam::multiLevelDecomp::decompose
) )
); );
for (label blockI = 0; blockI < nCurrDomains; blockI++) for (label blockI = 0; blockI < nCurrDomains; ++blockI)
{ {
// Count the number inbetween blocks of nNext size // Count the number inbetween blocks of nNext size
label nPoints = 0; label nPoints = 0;
labelList nOutsideConnections(nCurrDomains, 0); labelList nOutsideConnections(nCurrDomains, Zero);
forAll(pointPoints, pointi) forAll(pointPoints, pointi)
{ {
if ((dist[pointi] / nNext) == blockI) if ((dist[pointi] / nNext) == blockI)
@ -633,7 +633,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
CompactListList<label> cellCells; CompactListList<label> cellCells;
calcCellCells(mesh, identity(cc.size()), cc.size(), true, cellCells); calcCellCells(mesh, identity(cc.size()), cc.size(), true, cellCells);
labelList finalDecomp(cc.size(), 0); labelList finalDecomp(cc.size(), Zero);
labelList cellMap(identity(cc.size())); labelList cellMap(identity(cc.size()));
decompose decompose
@ -659,7 +659,7 @@ Foam::labelList Foam::multiLevelDecomp::decompose
const scalarField& pointWeights const scalarField& pointWeights
) const ) const
{ {
labelList finalDecomp(points.size(), 0); labelList finalDecomp(points.size(), Zero);
labelList pointMap(identity(points.size())); labelList pointMap(identity(points.size()));
decompose decompose

View File

@ -50,7 +50,7 @@ Foam::structuredDecomp::structuredDecomp(const dictionary& decompDict)
: :
decompositionMethod(decompDict), decompositionMethod(decompDict),
methodDict_(findCoeffsDict(typeName + "Coeffs", selectionType::MANDATORY)), methodDict_(findCoeffsDict(typeName + "Coeffs", selectionType::MANDATORY)),
patches_(methodDict_.lookup("patches")) patches_(methodDict_.get<wordRes>("patches"))
{ {
methodDict_.set("numberOfSubdomains", nDomains()); methodDict_.set("numberOfSubdomains", nDomains());
method_ = decompositionMethod::New(methodDict_); method_ = decompositionMethod::New(methodDict_);
@ -150,7 +150,7 @@ Foam::labelList Foam::structuredDecomp::decompose
{ {
WarningInFunction WarningInFunction
<< "Did not visit some cells, e.g. cell " << celli << "Did not visit some cells, e.g. cell " << celli
<< " at " << mesh.cellCentres()[celli] << endl << " at " << mesh.cellCentres()[celli] << nl
<< "Assigning these cells to domain 0." << endl; << "Assigning these cells to domain 0." << endl;
haveWarned = true; haveWarned = true;
} }
@ -166,17 +166,4 @@ Foam::labelList Foam::structuredDecomp::decompose
} }
Foam::labelList Foam::structuredDecomp::decompose
(
const labelListList& globalCellCells,
const pointField& cc,
const scalarField& cWeights
) const
{
NotImplemented;
return labelList(0);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -105,7 +105,11 @@ public:
const labelListList& globalCellCells, const labelListList& globalCellCells,
const pointField& cc, const pointField& cc,
const scalarField& cWeights const scalarField& cWeights
) const; ) const
{
NotImplemented;
return labelList();
}
}; };

View File

@ -71,8 +71,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
// k-way: multi-level k-way // k-way: multi-level k-way
word method("recursive"); word method("recursive");
const dictionary* coeffsDictPtr = const dictionary* coeffsDictPtr = decompDict_.findDict("metisCoeffs");
decompositionDict_.findDict("metisCoeffs");
label numCells = xadj.size()-1; label numCells = xadj.size()-1;
@ -133,7 +132,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Method " << method << " in metisCoeffs in dictionary : " << "Method " << method << " in metisCoeffs in dictionary : "
<< decompositionDict_.name() << decompDict_.name()
<< " should be 'recursive' or 'k-way'" << " should be 'recursive' or 'k-way'"
<< exit(FatalError); << exit(FatalError);
} }
@ -148,7 +147,7 @@ Foam::label Foam::metisDecomp::decomposeSerial
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Number of options in metisCoeffs in dictionary : " << "Number of options in metisCoeffs in dictionary : "
<< decompositionDict_.name() << decompDict_.name()
<< " should be " << METIS_NOPTIONS << " should be " << METIS_NOPTIONS
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -0,0 +1,9 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
\rm -f constant/triSurface/blob.obj
cleanCase0
#------------------------------------------------------------------------------

View File

@ -0,0 +1,20 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
mkdir -p constant/triSurface
# Use 'blob' as an arbitrary enclosing surface
runApplication surfaceTransformPoints \
-translate '(0 0 5)' \
-origin '(0 0 5)' \
-rotate-angle '((1 0 0) 45)' \
$FOAM_TUTORIALS/resources/geometry/blob.stl.gz constant/triSurface/blob.obj
runApplication blockMesh
runApplication decomposePar -dry-run -cellDist
runApplication foamToVTK -xml -excludePatches '(".*")'
#------------------------------------------------------------------------------

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu 1.5e-05;
// ************************************************************************* //

View File

@ -0,0 +1,28 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
RASModel kOmegaSST;
turbulence on;
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,86 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 1;
vertices
(
(-5 -4 0)
(15 -4 0)
(15 4 0)
(-5 4 0)
(-5 -4 8)
(15 -4 8)
(15 4 8)
(-5 4 8)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (200 80 80) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
frontAndBack
{
type patch;
faces
(
(3 7 6 2)
(1 5 4 0)
);
}
inlet
{
type patch;
faces
(
(0 4 7 3)
);
}
outlet
{
type patch;
faces
(
(2 6 5 1)
);
}
lowerWall
{
type wall;
faces
(
(0 3 2 1)
);
}
upperWall
{
type patch;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application decomposePar;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 500;
deltaT 1;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeConstraints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Optional decomposition constraints
constraints
{
geometric
{
type geometric;
grow true;
selection
{
blob
{
source surface;
surfaceType triSurfaceMesh;
surfaceName blob.obj;
}
box1
{
source box;
min (-10 -10 -10);
max (1 1 1);
}
semi
{
source sphere;
origin (-2 -2 1);
radius 1;
}
mid
{
source sphere;
origin (5 0 4);
radius 1;
}
ball
{
source sphere;
origin (15 4 8);
radius 3;
}
// This entry should generate a warning (and be ignored)
// since it does not describe an enclosed volume.
disk
{
source surface;
surface disk;
origin (0 0 0);
normal (0 0 1);
radius 3;
}
}
}
baffles
{
type preserveBaffles;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,34 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Do NOT attempt with hierarchical with these constraints!
numberOfSubdomains 128;
// method simple;
method scotch;
// method random;
coeffs
{
n (16 8 4);
}
// Optional decomposition constraints
#include "<system>/decomposeConstraints"
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1812 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Do NOT attempt with hierarchical with these constraints!
numberOfSubdomains 8;
method scotch;
coeffs
{
n (2 2 2);
}
// Optional decomposition constraints
#include "<system>/decomposeConstraints"
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
grad(U) cellLimited Gauss linear 1;
}
divSchemes
{
default none;
div(phi,U) bounded Gauss linearUpwindV grad(U);
div(phi,k) bounded Gauss upwind;
div(phi,omega) bounded Gauss upwind;
div((nuEff*dev2(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
wallDist
{
method meshWave;
}
// ************************************************************************* //

View File

@ -0,0 +1,92 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
tolerance 1e-7;
relTol 0.01;
smoother GaussSeidel;
nPreSweeps 0;
nPostSweeps 2;
cacheAgglomeration on;
agglomerator faceAreaPair;
nCellsInCoarsestLevel 10;
mergeLevels 1;
}
Phi
{
$p;
}
U
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-8;
relTol 0.1;
nSweeps 1;
}
k
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-8;
relTol 0.1;
nSweeps 1;
}
omega
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-8;
relTol 0.1;
nSweeps 1;
}
}
SIMPLE
{
nNonOrthogonalCorrectors 0;
consistent yes;
}
potentialFlow
{
nNonOrthogonalCorrectors 10;
}
relaxationFactors
{
equations
{
U 0.9;
k 0.7;
omega 0.7;
}
}
cache
{
grad(U);
}
// ************************************************************************* //