extrudeModel.C 2.62 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2017 OpenFOAM Foundation
9
    Copyright (C) 2020 OpenCFD Ltd.
10 11 12 13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14 15 16 17
    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.
18 19 20 21 22 23 24

    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
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26 27 28

\*---------------------------------------------------------------------------*/

29
#include "extrudeModel.H"
30

31
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 33 34

namespace Foam
{
35 36 37
    defineTypeNameAndDebug(extrudeModel, 0);
    defineRunTimeSelectionTable(extrudeModel, dictionary);
}
38

39
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40

41 42 43 44 45 46
Foam::extrudeModel::extrudeModel
(
    const word& modelType,
    const dictionary& dict
)
:
47 48
    nLayers_(dict.getOrDefault<label>("nLayers", 1)),
    expansionRatio_(dict.getOrDefault<scalar>("expansionRatio", 1)),
49
    coeffDict_(dict.optionalSubDict(modelType + "Coeffs"))
50 51 52
{
    DebugInfo
        << "Selected extrudeModel for " << modelType
mattijs's avatar
mattijs committed
53
        << " using coeffs " << coeffDict_ << nl;
54
}
55 56


57
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
58

59 60 61 62
Foam::label Foam::extrudeModel::nLayers() const
{
    return nLayers_;
}
63 64


65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
Foam::scalar Foam::extrudeModel::expansionRatio() const
{
    return expansionRatio_;
}


Foam::scalar Foam::extrudeModel::sumThickness(const label layer) const
{
    // 1+r+r^2+ .. +r^(n-1) = (1-r^n)/(1-r)

    if (mag(1.0-expansionRatio_) < SMALL)
    {
        return scalar(layer)/nLayers_;
    }
    else
    {
        return
            (1.0-pow(expansionRatio_, layer))
          / (1.0-pow(expansionRatio_, nLayers_));
    }
}


88
// ************************************************************************* //