Consider a block describing a channel with two opposite walls.
Currently in order to grade the mesh towards the walls and have a
uniform region in the centre the channel would need to be spit into 3
blocks. With the new multi/sectional grading this can be achieved in a
single block e.g.
blocks
(
hex (0 1 2 3 4 5 6 7) (20 60 20)
simpleGrading
(
1
((0.2 0.3 4) (0.6 0.4 1) (0.2 0.3 0.25))
1
)
);
In this example the block is divided uniformly in the x and z -directions
and split into three grading sections in the y-direction described by
three triples: ((0.2 0.3 4) (0.6 0.4 1) (0.2 0.3 0.25)). Each of the
grading sections is described by a triple consisting of the fraction of
the block, the fraction of the divisions and the grading ratio (size of
first division/size of last division). Both the fraction of the block
and the fraction of the divisions are normalized automatically so they
can be specified scaled in anyway, e.g. as percentages:
blocks
(
hex (0 1 2 3 4 5 6 7) (20 60 20)
simpleGrading
(
1
((2 3 4) (6 4 1) (2 3 0.25))
1
)
);
and they need not sum to 1 or 100.
This is very new functionality and not well tested but backward
compatibility has been well tested so all existing blockMeshDicts should
parse correctly.
101 lines
2.8 KiB
C
101 lines
2.8 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "gradingDescriptors.H"
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::gradingDescriptors::gradingDescriptors()
|
|
:
|
|
List<gradingDescriptor>(1, gradingDescriptor())
|
|
{}
|
|
|
|
|
|
Foam::gradingDescriptors::gradingDescriptors(const gradingDescriptor& gd)
|
|
:
|
|
List<gradingDescriptor>(1, gd)
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
Foam::gradingDescriptors Foam::gradingDescriptors::inv() const
|
|
{
|
|
gradingDescriptors ret(*this);
|
|
|
|
forAll(ret, i)
|
|
{
|
|
ret[i] = operator[](i).inv();
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
|
|
|
Foam::Istream& Foam::operator>>(Istream& is, gradingDescriptors& gds)
|
|
{
|
|
// Examine next token
|
|
token t(is);
|
|
|
|
if (t.isNumber())
|
|
{
|
|
gds = gradingDescriptors(gradingDescriptor(t.number()));
|
|
}
|
|
else
|
|
{
|
|
is.putBack(t);
|
|
|
|
// Read the list for gradingDescriptors
|
|
is >> static_cast<List<gradingDescriptor>& >(gds);
|
|
|
|
// Check state of Istream
|
|
is.check("operator>>(Istream&, gradingDescriptor&)");
|
|
|
|
// Normalize the blockFractions and nDivFractions
|
|
// of the list of gradingDescriptors
|
|
|
|
scalar sumBlockFraction = 0;
|
|
scalar sumNDivFraction = 0;
|
|
|
|
forAll(gds, i)
|
|
{
|
|
sumBlockFraction += gds[i].blockFraction_;
|
|
sumNDivFraction += gds[i].nDivFraction_;
|
|
}
|
|
|
|
forAll(gds, i)
|
|
{
|
|
gds[i].blockFraction_ /= sumBlockFraction;
|
|
gds[i].nDivFraction_ /= sumNDivFraction;
|
|
}
|
|
}
|
|
|
|
return is;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|