|
| 1 | +/*---------------------------------------------------------------------------*\ |
| 2 | + ========= | |
| 3 | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| 4 | + \\ / O peration | Website: https://openfoam.org |
| 5 | + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation |
| 6 | + \\/ M anipulation | |
| 7 | +------------------------------------------------------------------------------- |
| 8 | + Copyright (C) 2023 Oak Ridge National Laboratory |
| 9 | +------------------------------------------------------------------------------- |
| 10 | +License |
| 11 | + This file is part of OpenFOAM. |
| 12 | +
|
| 13 | + OpenFOAM is free software: you can redistribute it and/or modify it |
| 14 | + under the terms of the GNU General Public License as published by |
| 15 | + the Free Software Foundation, either version 3 of the License, or |
| 16 | + (at your option) any later version. |
| 17 | +
|
| 18 | + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT |
| 19 | + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 20 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 21 | + for more details. |
| 22 | +
|
| 23 | + You should have received a copy of the GNU General Public License |
| 24 | + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. |
| 25 | +
|
| 26 | +\*---------------------------------------------------------------------------*/ |
| 27 | + |
| 28 | +#include "projectedGaussian.H" |
| 29 | +#include "addToRunTimeSelectionTable.H" |
| 30 | + |
| 31 | +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // |
| 32 | + |
| 33 | +namespace Foam |
| 34 | +{ |
| 35 | +namespace heatSourceModels |
| 36 | +{ |
| 37 | + defineTypeNameAndDebug(projectedGaussian, 0); |
| 38 | + addToRunTimeSelectionTable(heatSourceModel, projectedGaussian, dictionary); |
| 39 | +} |
| 40 | +} |
| 41 | + |
| 42 | +using Foam::constant::mathematical::pi; |
| 43 | + |
| 44 | +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // |
| 45 | + |
| 46 | +Foam::heatSourceModels::projectedGaussian::projectedGaussian |
| 47 | +( |
| 48 | + const word& sourceName, |
| 49 | + const dictionary& dict, |
| 50 | + const fvMesh& mesh |
| 51 | +) |
| 52 | +: |
| 53 | + heatSourceModel(typeName, sourceName, dict, mesh), |
| 54 | + mesh_(mesh) |
| 55 | +{ |
| 56 | + A_ = heatSourceModelCoeffs_.lookup<scalar>("A"); |
| 57 | + B_ = heatSourceModelCoeffs_.lookup<scalar>("B"); |
| 58 | + |
| 59 | + // set initial shape function |
| 60 | + const scalar x_ = |
| 61 | + max |
| 62 | + ( |
| 63 | + dimensions_.z() |
| 64 | + / min(staticDimensions_.x(), staticDimensions_.y()), |
| 65 | + 1.0 |
| 66 | + ); |
| 67 | + const scalar n_ = min(max(A_*std::log2(x_) + B_, 0.0), 9.0); |
| 68 | + k_ = std::pow(2.0, n_); |
| 69 | +} |
| 70 | + |
| 71 | + |
| 72 | +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // |
| 73 | + |
| 74 | +inline Foam::scalar |
| 75 | +Foam::heatSourceModels::projectedGaussian::weight(const vector& d) |
| 76 | +{ |
| 77 | + const scalar f_ = |
| 78 | + std::exp |
| 79 | + ( |
| 80 | + -2.0 |
| 81 | + * ( |
| 82 | + Foam::sqr(d.x() / dimensions_.x()) |
| 83 | + + Foam::sqr(d.y() / dimensions_.y()) |
| 84 | + ) |
| 85 | + ); |
| 86 | + |
| 87 | + const scalar s_ = |
| 88 | + std::exp(-3.0 * std::pow(mag(mag(d.z()) / dimensions_.z()), k_)); |
| 89 | + |
| 90 | + return f_ * s_; |
| 91 | +} |
| 92 | + |
| 93 | +inline Foam::dimensionedScalar |
| 94 | +Foam::heatSourceModels::projectedGaussian::V0() |
| 95 | +{ |
| 96 | + const scalar x_ = |
| 97 | + max |
| 98 | + ( |
| 99 | + dimensions_.z() |
| 100 | + / min(staticDimensions_.x(), staticDimensions_.y()), |
| 101 | + 1.0 |
| 102 | + ); |
| 103 | + |
| 104 | + const scalar n_ = min(max(A_*std::log2(x_) + B_, 0.0), 9.0); |
| 105 | + |
| 106 | + k_ = std::pow(2.0, n_); |
| 107 | + |
| 108 | + const dimensionedScalar V0 |
| 109 | + ( |
| 110 | + "V0", |
| 111 | + dimVolume, |
| 112 | + 0.5 * pi * dimensions_.x() * dimensions_.y() * dimensions_.z() |
| 113 | + * Foam::tgamma(1.0 / k_) |
| 114 | + / ( k_ * std::pow(3.0, 1.0 / k_) ) |
| 115 | + ); |
| 116 | + |
| 117 | + return V0; |
| 118 | +} |
| 119 | + |
| 120 | +bool Foam::heatSourceModels::projectedGaussian::read() |
| 121 | +{ |
| 122 | + if (heatSourceModel::read()) |
| 123 | + { |
| 124 | + heatSourceModelCoeffs_ = optionalSubDict(type() + "Coeffs"); |
| 125 | + |
| 126 | + //- Mandatory entries |
| 127 | + heatSourceModelCoeffs_.lookup("A") >> A_; |
| 128 | + heatSourceModelCoeffs_.lookup("B") >> B_; |
| 129 | + |
| 130 | + return true; |
| 131 | + } |
| 132 | + else |
| 133 | + { |
| 134 | + return false; |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | + |
| 139 | +// ************************************************************************* // |
0 commit comments