ENH: decompsition: check for mesh dimensions. Fixes #937.

This commit is contained in:
mattijs
2018-07-18 09:29:28 +01:00
parent 64855e8c12
commit 3bb5cef5bf
4 changed files with 33 additions and 3 deletions

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) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 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.
@ -58,6 +58,25 @@ void Foam::geomDecomp::readCoeffs()
} }
void Foam::geomDecomp::checkDecompositionDirections
(
const Vector<label>& meshDirs
) const
{
for (direction dir = 0; dir < Vector<label>::nComponents; dir++)
{
if (n_[dir] > 1 && meshDirs[dir] == -1)
{
FatalErrorInFunction << "Trying to decompose a 1/2D mesh"
<< " into " << n_[dir]
<< " parts in direction "
<< Vector<label>::componentNames[dir]
<< exit(FatalError);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::geomDecomp::geomDecomp Foam::geomDecomp::geomDecomp

View File

@ -76,6 +76,13 @@ protected:
tensor rotDelta_; tensor rotDelta_;
// Protected Member Functions
//- Check that mesh directions are compatible with decomposition
void checkDecompositionDirections(const Vector<label>&) const;
public: public:
// Constructors // Constructors

View File

@ -224,6 +224,7 @@ public:
const scalarField& cWeights const scalarField& cWeights
) const ) const
{ {
checkDecompositionDirections(mesh.geometricD());
return decompose(cc, cWeights); return decompose(cc, cWeights);
} }
@ -236,6 +237,7 @@ public:
const pointField& cc const pointField& cc
) const ) const
{ {
checkDecompositionDirections(mesh.geometricD());
return decompose(cc); return decompose(cc);
} }

View File

@ -128,21 +128,23 @@ public:
//- Decompose with uniform weights. //- Decompose with uniform weights.
virtual labelList decompose virtual labelList decompose
( (
const polyMesh&, const polyMesh& mesh,
const pointField& points const pointField& points
) const ) const
{ {
checkDecompositionDirections(mesh.geometricD());
return decompose(points); return decompose(points);
} }
//- Return for every coordinate the wanted processor number. //- Return for every coordinate the wanted processor number.
virtual labelList decompose virtual labelList decompose
( (
const polyMesh&, const polyMesh& mesh,
const pointField& points, const pointField& points,
const scalarField& weights const scalarField& weights
) const ) const
{ {
checkDecompositionDirections(mesh.geometricD());
return decompose(points, weights); return decompose(points, weights);
} }