Skip to content

Commit 3894f79

Browse files
authored
Projected gaussian source (#78)
* projectedGaussian heat source for improved dynamic heat source modeling
1 parent cb209d5 commit 3894f79

File tree

3 files changed

+251
-0
lines changed

3 files changed

+251
-0
lines changed

applications/solvers/additiveFoam/movingHeatSource/Make/files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ heatSourceModels/heatSourceModel/heatSourceModel.C
1111
heatSourceModels/heatSourceModel/heatSourceModelNew.C
1212
heatSourceModels/superGaussian/superGaussian.C
1313
heatSourceModels/modifiedSuperGaussian/modifiedSuperGaussian.C
14+
heatSourceModels/projectedGaussian/projectedGaussian.C
1415

1516
movingHeatSourceModel/movingHeatSourceModel.C
1617

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
// ************************************************************************* //
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
Class
27+
Foam::heatSourceModels::projectedGaussian
28+
29+
Description
30+
projectedGaussian heat source model for additive manufacting
31+
32+
SourceFiles
33+
projectedGaussian.C
34+
35+
\*---------------------------------------------------------------------------*/
36+
37+
#ifndef projectedGaussian_H
38+
#define projectedGaussian_H
39+
40+
#include "heatSourceModel.H"
41+
42+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43+
44+
namespace Foam
45+
{
46+
namespace heatSourceModels
47+
{
48+
49+
/*---------------------------------------------------------------------------*\
50+
Class projectedGaussian
51+
\*---------------------------------------------------------------------------*/
52+
53+
class projectedGaussian
54+
:
55+
public heatSourceModel
56+
{
57+
// Private Data
58+
59+
//- Pointer to mesh information
60+
const fvMesh& mesh_;
61+
62+
//- weights for axial decay of 2D gaussian distribution in the form:
63+
//- n = Alog2(x) + B
64+
scalar A_;
65+
scalar B_;
66+
67+
scalar k_;
68+
69+
public:
70+
71+
//- Runtime type information
72+
TypeName("projectedGaussian");
73+
74+
75+
// Constructors
76+
77+
//- Construct from components
78+
projectedGaussian
79+
(
80+
const word& sourceName,
81+
const dictionary& dict,
82+
const fvMesh& mesh
83+
);
84+
85+
86+
//- Destructor
87+
virtual ~projectedGaussian()
88+
{}
89+
90+
91+
// Member Functions
92+
93+
inline virtual scalar weight(const vector& d);
94+
95+
inline virtual dimensionedScalar V0();
96+
97+
//- Read the heatSourceProperties dictionary
98+
virtual bool read();
99+
};
100+
101+
102+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103+
104+
} // End namespace heatSourceModels
105+
} // End namespace Foam
106+
107+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108+
109+
#endif
110+
111+
// ************************************************************************* //

0 commit comments

Comments
 (0)