tutorials/fluid/aerofoilNACA0012Steady/0/U: Use $<scalar>angle instead of scoping cos and sin

to improve the handling of 0 angle of attack.
This commit is contained in:
Henry Weller
2023-06-23 17:12:05 +01:00
parent 0657826ab9
commit 755eae4aa9
2 changed files with 16 additions and 15 deletions

View File

@ -18,8 +18,8 @@ angleOfAttack 0; // degs
angle #calc "degToRad($angleOfAttack)";
liftDir #calc "vector(-::sin($angle), 0, ::cos($angle))";
dragDir #calc "vector(::cos($angle), 0, ::sin($angle))";
liftDir #calc "vector(-sin($<scalar>angle), 0, cos($<scalar>angle))";
dragDir #calc "vector(cos($<scalar>angle), 0, sin($<scalar>angle))";
Uinlet #calc "$speed*$<vector>dragDir";

View File

@ -49,6 +49,7 @@ Description
#include "OFstream.H"
using namespace Foam;
using namespace constant::mathematical;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -65,7 +66,7 @@ int main(int argc, char *argv[])
const scalar h = mesh.bounds().span().y();
Info<< "Height from centreline to wall = " << h << endl;
label centrelineID = mesh.boundary().findPatchID("centreline");
const label centrelineID = mesh.boundary().findPatchID("centreline");
const vector patchToCell =
mesh.boundary()[centrelineID].Cf()[0]
- mesh.C()[mesh.findNearestCell(location)];
@ -94,34 +95,34 @@ int main(int argc, char *argv[])
forAll(ak, i)
{
scalar k = i + 1;
ak[i] = (2.0*k - 1)/2.0*constant::mathematical::pi*::sqrt(E);
ak[i] = (2.0*k - 1)/2.0*pi*Foam::sqrt(E);
bk[i] = (1.0 + beta*sqr(ak[i]))/2.0;
ck[i] = ::sqrt(mag(sqr(bk[i]) - sqr(ak[i])));
B[i] = 48*::pow(-1, k)/::pow((2*k - 1)*constant::mathematical::pi, 3)*
::cos((2*k - 1)*constant::mathematical::pi*y/2);
ck[i] = Foam::sqrt(mag(sqr(bk[i]) - sqr(ak[i])));
B[i] = 48*pow(-1, k)/pow((2*k - 1)*pi, 3)*
Foam::cos((2*k - 1)*pi*y/2);
}
scalarField A(order, 0);
OFstream file(runTime.path()/"WatersKing.dat");
const scalar LOGvGreat = ::log(vGreat);
const scalar LOGvGreat = Foam::log(vGreat);
while (!runTime.end())
{
scalar t = runTime.userTimeValue()/lambda;
const scalar t = runTime.userTimeValue()/lambda;
forAll(A, i)
{
if (bk[i]*t < LOGvGreat)
{
if (bk[i] >= ak[i])
{
A[i] = (bk[i] - sqr(ak[i]))/ck[i]*::sinh(ck[i]*t)
+ ::cosh(ck[i]*t);
A[i] = (bk[i] - sqr(ak[i]))/ck[i]*Foam::sinh(ck[i]*t)
+ Foam::cosh(ck[i]*t);
}
else
{
A[i] = (bk[i] - sqr(ak[i]))/ck[i]*::sin(ck[i]*t)
+ ::cos(ck[i]*t);
A[i] = (bk[i] - sqr(ak[i]))/ck[i]*Foam::sin(ck[i]*t)
+ Foam::cos(ck[i]*t);
}
A[i] *= ::exp(-bk[i]*t);
A[i] *= Foam::exp(-bk[i]*t);
}
else
{
@ -132,7 +133,7 @@ int main(int argc, char *argv[])
B.resize(order);
}
}
scalar U = UInf*(1.5*(1 - sqr(y)) + sum(A*B));
const scalar U = UInf*(1.5*(1 - sqr(y)) + sum(A*B));
file<< runTime.name() << token::TAB << U << endl;
runTime++;
}