diff --git a/applications/solvers/additiveFoam/movingHeatSource/Make/files b/applications/solvers/additiveFoam/movingHeatSource/Make/files index 044edf5..4fa0112 100644 --- a/applications/solvers/additiveFoam/movingHeatSource/Make/files +++ b/applications/solvers/additiveFoam/movingHeatSource/Make/files @@ -11,6 +11,7 @@ heatSourceModels/heatSourceModel/heatSourceModel.C heatSourceModels/heatSourceModel/heatSourceModelNew.C heatSourceModels/superGaussian/superGaussian.C heatSourceModels/modifiedSuperGaussian/modifiedSuperGaussian.C +heatSourceModels/projectedGaussian/projectedGaussian.C movingHeatSourceModel/movingHeatSourceModel.C diff --git a/applications/solvers/additiveFoam/movingHeatSource/heatSourceModels/projectedGaussian/projectedGaussian.C b/applications/solvers/additiveFoam/movingHeatSource/heatSourceModels/projectedGaussian/projectedGaussian.C new file mode 100644 index 0000000..64ac1b4 --- /dev/null +++ b/applications/solvers/additiveFoam/movingHeatSource/heatSourceModels/projectedGaussian/projectedGaussian.C @@ -0,0 +1,139 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 Oak Ridge National Laboratory +------------------------------------------------------------------------------- +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 . + +\*---------------------------------------------------------------------------*/ + +#include "projectedGaussian.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace heatSourceModels +{ + defineTypeNameAndDebug(projectedGaussian, 0); + addToRunTimeSelectionTable(heatSourceModel, projectedGaussian, dictionary); +} +} + +using Foam::constant::mathematical::pi; + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::heatSourceModels::projectedGaussian::projectedGaussian +( + const word& sourceName, + const dictionary& dict, + const fvMesh& mesh +) +: + heatSourceModel(typeName, sourceName, dict, mesh), + mesh_(mesh) +{ + A_ = heatSourceModelCoeffs_.lookup("A"); + B_ = heatSourceModelCoeffs_.lookup("B"); + + // set initial shape function + const scalar x_ = + max + ( + dimensions_.z() + / min(staticDimensions_.x(), staticDimensions_.y()), + 1.0 + ); + const scalar n_ = min(max(A_*std::log2(x_) + B_, 0.0), 9.0); + k_ = std::pow(2.0, n_); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +inline Foam::scalar +Foam::heatSourceModels::projectedGaussian::weight(const vector& d) +{ + const scalar f_ = + std::exp + ( + -2.0 + * ( + Foam::sqr(d.x() / dimensions_.x()) + + Foam::sqr(d.y() / dimensions_.y()) + ) + ); + + const scalar s_ = + std::exp(-3.0 * std::pow(mag(mag(d.z()) / dimensions_.z()), k_)); + + return f_ * s_; +} + +inline Foam::dimensionedScalar +Foam::heatSourceModels::projectedGaussian::V0() +{ + const scalar x_ = + max + ( + dimensions_.z() + / min(staticDimensions_.x(), staticDimensions_.y()), + 1.0 + ); + + const scalar n_ = min(max(A_*std::log2(x_) + B_, 0.0), 9.0); + + k_ = std::pow(2.0, n_); + + const dimensionedScalar V0 + ( + "V0", + dimVolume, + 0.5 * pi * dimensions_.x() * dimensions_.y() * dimensions_.z() + * Foam::tgamma(1.0 / k_) + / ( k_ * std::pow(3.0, 1.0 / k_) ) + ); + + return V0; +} + +bool Foam::heatSourceModels::projectedGaussian::read() +{ + if (heatSourceModel::read()) + { + heatSourceModelCoeffs_ = optionalSubDict(type() + "Coeffs"); + + //- Mandatory entries + heatSourceModelCoeffs_.lookup("A") >> A_; + heatSourceModelCoeffs_.lookup("B") >> B_; + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/additiveFoam/movingHeatSource/heatSourceModels/projectedGaussian/projectedGaussian.H b/applications/solvers/additiveFoam/movingHeatSource/heatSourceModels/projectedGaussian/projectedGaussian.H new file mode 100644 index 0000000..9e100e8 --- /dev/null +++ b/applications/solvers/additiveFoam/movingHeatSource/heatSourceModels/projectedGaussian/projectedGaussian.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2023 Oak Ridge National Laboratory +------------------------------------------------------------------------------- +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 . + +Class + Foam::heatSourceModels::projectedGaussian + +Description + projectedGaussian heat source model for additive manufacting + +SourceFiles + projectedGaussian.C + +\*---------------------------------------------------------------------------*/ + +#ifndef projectedGaussian_H +#define projectedGaussian_H + +#include "heatSourceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace heatSourceModels +{ + +/*---------------------------------------------------------------------------*\ + Class projectedGaussian +\*---------------------------------------------------------------------------*/ + +class projectedGaussian +: + public heatSourceModel +{ + // Private Data + + //- Pointer to mesh information + const fvMesh& mesh_; + + //- weights for axial decay of 2D gaussian distribution in the form: + //- n = Alog2(x) + B + scalar A_; + scalar B_; + + scalar k_; + +public: + + //- Runtime type information + TypeName("projectedGaussian"); + + + // Constructors + + //- Construct from components + projectedGaussian + ( + const word& sourceName, + const dictionary& dict, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~projectedGaussian() + {} + + + // Member Functions + + inline virtual scalar weight(const vector& d); + + inline virtual dimensionedScalar V0(); + + //- Read the heatSourceProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace heatSourceModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //