Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenFOAM-plus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
339
Issues
339
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Development
OpenFOAM-plus
Commits
eff78243
Commit
eff78243
authored
Jan 30, 2019
by
mattijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: nutUWallFunction: user defined tolerance on N-R. See
#1172
parent
3e4205a0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
45 deletions
+146
-45
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C
...ughWallFunction/nutURoughWallFunctionFvPatchScalarField.C
+38
-12
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H
...ughWallFunction/nutURoughWallFunctionFvPatchScalarField.H
+16
-1
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C
...WallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C
+66
-28
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H
...WallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H
+26
-4
No files found.
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C
View file @
eff78243
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -161,8 +161,8 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcYPlus
}
}
while
(
mag
(
ryPlusLam
*
(
yp
-
yPlusLast
))
>
0
.
0001
&&
++
iter
<
10
mag
(
ryPlusLam
*
(
yp
-
yPlusLast
))
>
tolerance_
&&
++
iter
<
maxIter_
&&
yp
>
VSMALL
);
...
...
@@ -190,7 +190,12 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcYPlus
yPlusLast
=
yp
;
yp
=
(
kappaRe
+
yp
)
/
(
1
.
0
+
log
(
E_
*
yp
));
}
while
(
mag
(
ryPlusLam
*
(
yp
-
yPlusLast
))
>
0
.
0001
&&
++
iter
<
10
);
}
while
(
mag
(
ryPlusLam
*
(
yp
-
yPlusLast
))
>
tolerance_
&&
++
iter
<
maxIter_
);
yPlus
[
facei
]
=
max
(
0
.
0
,
yp
);
}
...
...
@@ -200,6 +205,20 @@ tmp<scalarField> nutURoughWallFunctionFvPatchScalarField::calcYPlus
}
void
nutURoughWallFunctionFvPatchScalarField
::
writeLocalEntries
(
Ostream
&
os
)
const
{
nutWallFunctionFvPatchScalarField
::
writeLocalEntries
(
os
);
os
.
writeEntry
(
"roughnessHeight"
,
roughnessHeight_
);
os
.
writeEntry
(
"roughnessConstant"
,
roughnessConstant_
);
os
.
writeEntry
(
"roughnessFactor"
,
roughnessFactor_
);
os
.
writeEntryIfDifferent
<
label
>
(
"maxIter"
,
10
,
maxIter_
);
os
.
writeEntryIfDifferent
<
scalar
>
(
"tolerance"
,
0
.
0001
,
tolerance_
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutURoughWallFunctionFvPatchScalarField
::
nutURoughWallFunctionFvPatchScalarField
...
...
@@ -211,7 +230,9 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField
nutWallFunctionFvPatchScalarField
(
p
,
iF
),
roughnessHeight_
(
Zero
),
roughnessConstant_
(
Zero
),
roughnessFactor_
(
Zero
)
roughnessFactor_
(
Zero
),
maxIter_
(
10
),
tolerance_
(
0
.
0001
)
{}
...
...
@@ -226,7 +247,9 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField
nutWallFunctionFvPatchScalarField
(
ptf
,
p
,
iF
,
mapper
),
roughnessHeight_
(
ptf
.
roughnessHeight_
),
roughnessConstant_
(
ptf
.
roughnessConstant_
),
roughnessFactor_
(
ptf
.
roughnessFactor_
)
roughnessFactor_
(
ptf
.
roughnessFactor_
),
maxIter_
(
ptf
.
maxIter_
),
tolerance_
(
ptf
.
tolerance_
)
{}
...
...
@@ -240,7 +263,9 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField
nutWallFunctionFvPatchScalarField
(
p
,
iF
,
dict
),
roughnessHeight_
(
dict
.
get
<
scalar
>
(
"roughnessHeight"
)),
roughnessConstant_
(
dict
.
get
<
scalar
>
(
"roughnessConstant"
)),
roughnessFactor_
(
dict
.
get
<
scalar
>
(
"roughnessFactor"
))
roughnessFactor_
(
dict
.
get
<
scalar
>
(
"roughnessFactor"
)),
maxIter_
(
dict
.
lookupOrDefault
<
label
>
(
"maxIter"
,
10
)),
tolerance_
(
dict
.
lookupOrDefault
<
scalar
>
(
"tolerance"
,
0
.
0001
))
{}
...
...
@@ -252,7 +277,9 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField
nutWallFunctionFvPatchScalarField
(
rwfpsf
),
roughnessHeight_
(
rwfpsf
.
roughnessHeight_
),
roughnessConstant_
(
rwfpsf
.
roughnessConstant_
),
roughnessFactor_
(
rwfpsf
.
roughnessFactor_
)
roughnessFactor_
(
rwfpsf
.
roughnessFactor_
),
maxIter_
(
rwfpsf
.
maxIter_
),
tolerance_
(
rwfpsf
.
tolerance_
)
{}
...
...
@@ -265,7 +292,9 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField
nutWallFunctionFvPatchScalarField
(
rwfpsf
,
iF
),
roughnessHeight_
(
rwfpsf
.
roughnessHeight_
),
roughnessConstant_
(
rwfpsf
.
roughnessConstant_
),
roughnessFactor_
(
rwfpsf
.
roughnessFactor_
)
roughnessFactor_
(
rwfpsf
.
roughnessFactor_
),
maxIter_
(
rwfpsf
.
maxIter_
),
tolerance_
(
rwfpsf
.
tolerance_
)
{}
...
...
@@ -294,9 +323,6 @@ void nutURoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField
<
scalar
>::
write
(
os
);
writeLocalEntries
(
os
);
os
.
writeEntry
(
"roughnessHeight"
,
roughnessHeight_
);
os
.
writeEntry
(
"roughnessConstant"
,
roughnessConstant_
);
os
.
writeEntry
(
"roughnessFactor"
,
roughnessFactor_
);
writeEntry
(
"value"
,
os
);
}
...
...
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H
View file @
eff78243
...
...
@@ -37,6 +37,8 @@ Usage
roughnessHeight | roughness height | yes |
roughnessConstant | roughness constanr | yes |
roughnessFactor | scaling factor | yes |
maxIter | Number of N-R iterations | no | 10
tolerance | Convergence tolerance | no | 0.0001
\endtable
Example of the boundary condition specification:
...
...
@@ -53,7 +55,10 @@ Usage
Note
Suffers from non-exact restart since correctNut() (called through
turbulence->validate) returns a slightly different value every time
it is called. See nutUSpaldingWallFunctionFvPatchScalarField.C
it is called. See nutUSpaldingWallFunctionFvPatchScalarField.C.
Can be avoided by seeding the NR with e.g. the laminar viscosity
or tightening the convergence tolerance
to e.g. 1e-7 and the max number of iterations to 100.
See also
Foam::nutWallFunctionFvPatchScalarField
...
...
@@ -95,6 +100,13 @@ class nutURoughWallFunctionFvPatchScalarField
scalar
roughnessFactor_
;
//- Max iterations in calcNut
const
label
maxIter_
;
//- Convergence tolerance
const
scalar
tolerance_
;
// Protected Member Functions
//- Calculate yPlus
...
...
@@ -103,6 +115,9 @@ class nutURoughWallFunctionFvPatchScalarField
//- Calculate the turbulence viscosity
virtual
tmp
<
scalarField
>
calcNut
()
const
;
//- Write local wall function variables
virtual
void
writeLocalEntries
(
Ostream
&
)
const
;
public:
...
...
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C
View file @
eff78243
...
...
@@ -119,19 +119,21 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau
err
=
mag
((
ut
-
uTauNew
)
/
ut
);
ut
=
uTauNew
;
if
(
debug
)
{
iterations_
++
;
}
//iterations_++;
}
while
(
ut
>
ROOTVSMALL
&&
err
>
0
.
01
&&
++
iter
<
10
);
}
while
(
ut
>
ROOTVSMALL
&&
err
>
tolerance_
&&
++
iter
<
maxIter_
);
uTau
[
facei
]
=
max
(
0
.
0
,
ut
);
if
(
debug
)
{
invocations_
++
;
}
//invocations_++;
//if (iter > 1)
//{
// nontrivial_++;
//}
//if (iter >= maxIter_)
//{
// nonconvergence_++;
//}
}
}
...
...
@@ -139,6 +141,18 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau
}
void
Foam
::
nutUSpaldingWallFunctionFvPatchScalarField
::
writeLocalEntries
(
Ostream
&
os
)
const
{
nutWallFunctionFvPatchScalarField
::
writeLocalEntries
(
os
);
os
.
writeEntryIfDifferent
<
label
>
(
"maxIter"
,
10
,
maxIter_
);
os
.
writeEntryIfDifferent
<
scalar
>
(
"tolerance"
,
0
.
01
,
tolerance_
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutUSpaldingWallFunctionFvPatchScalarField
::
...
...
@@ -149,8 +163,12 @@ nutUSpaldingWallFunctionFvPatchScalarField
)
:
nutWallFunctionFvPatchScalarField
(
p
,
iF
),
invocations_
(
0
),
iterations_
(
0
)
maxIter_
(
10
),
tolerance_
(
0
.
01
)
//invocations_(0),
//nontrivial_(0),
//nonconvergence_(0),
//iterations_(0)
{}
...
...
@@ -164,8 +182,12 @@ nutUSpaldingWallFunctionFvPatchScalarField
)
:
nutWallFunctionFvPatchScalarField
(
ptf
,
p
,
iF
,
mapper
),
invocations_
(
0
),
iterations_
(
0
)
maxIter_
(
ptf
.
maxIter_
),
tolerance_
(
ptf
.
tolerance_
)
//invocations_(0),
//nontrivial_(0),
//nonconvergence_(0),
//iterations_(0)
{}
...
...
@@ -178,8 +200,12 @@ nutUSpaldingWallFunctionFvPatchScalarField
)
:
nutWallFunctionFvPatchScalarField
(
p
,
iF
,
dict
),
invocations_
(
0
),
iterations_
(
0
)
maxIter_
(
dict
.
lookupOrDefault
<
label
>
(
"maxIter"
,
10
)),
tolerance_
(
dict
.
lookupOrDefault
<
scalar
>
(
"tolerance"
,
0
.
01
))
//invocations_(0),
//nontrivial_(0),
//nonconvergence_(0),
//iterations_(0)
{}
...
...
@@ -190,8 +216,12 @@ nutUSpaldingWallFunctionFvPatchScalarField
)
:
nutWallFunctionFvPatchScalarField
(
wfpsf
),
invocations_
(
wfpsf
.
invocations_
),
iterations_
(
wfpsf
.
iterations_
)
maxIter_
(
wfpsf
.
maxIter_
),
tolerance_
(
wfpsf
.
tolerance_
)
//invocations_(wfpsf.invocations_),
//nontrivial_(wfpsf.nontrivial_),
//nonconvergence_(wfpsf.nonconvergence_),
//iterations_(wfpsf.iterations_)
{}
...
...
@@ -203,8 +233,12 @@ nutUSpaldingWallFunctionFvPatchScalarField
)
:
nutWallFunctionFvPatchScalarField
(
wfpsf
,
iF
),
invocations_
(
0
),
iterations_
(
0
)
maxIter_
(
wfpsf
.
maxIter_
),
tolerance_
(
wfpsf
.
tolerance_
)
//invocations_(0),
//nontrivial_(0),
//nonconvergence_(0),
//iterations_(0)
{}
...
...
@@ -213,15 +247,19 @@ nutUSpaldingWallFunctionFvPatchScalarField
nutUSpaldingWallFunctionFvPatchScalarField
::
~
nutUSpaldingWallFunctionFvPatchScalarField
()
{
if
(
debug
)
{
Info
<<
"nutUSpaldingWallFunctionFvPatchScalarField :"
<<
" total invocations:"
<<
returnReduce
(
invocations_
,
sumOp
<
label
>
())
<<
" total iterations:"
<<
returnReduce
(
iterations_
,
sumOp
<
label
>
())
<<
endl
;
}
//if (debug)
//{
// Info<< "nutUSpaldingWallFunctionFvPatchScalarField :"
// << " total invocations:"
// << returnReduce(invocations_, sumOp<label>())
// << " total iterations:"
// << returnReduce(iterations_, sumOp<label>())
// << " total non-convergence:"
// << returnReduce(nonconvergence_, sumOp<label>())
// << " total non-trivial:"
// << returnReduce(nontrivial_, sumOp<label>())
// << endl;
//}
}
...
...
src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.H
View file @
eff78243
...
...
@@ -51,9 +51,19 @@ Usage
<patchName>
{
type nutUSpaldingWallFunction;
// .. nutWallFunctionFvPatchScalarField entries ..
}
\endverbatim
Additional entries (see below)
\table
Property | Description | Required | Default value
maxIter | Number of N-R iterations | no | 10
tolerance | Convergence tolerance | no | 0.01
\endtable
See also
Foam::nutWallFunctionFvPatchScalarField
...
...
@@ -62,7 +72,8 @@ Note
turbulence->validate) returns a slightly different value every time
it is called. This is since the seed for the Newton-Raphson iteration
uses the current value of *this (= nut). Can be avoided by seeding the
NR with e.g. the laminar viscosity.
NR with e.g. the laminar viscosity or tightening the convergence tolerance
to e.g. 1e-7 and the max number of iterations to 100.
SourceFiles
nutUSpaldingWallFunctionFvPatchScalarField.C
...
...
@@ -73,7 +84,6 @@ SourceFiles
#define nutUSpaldingWallFunctionFvPatchScalarField_H
#include "nutWallFunctionFvPatchScalarField.H"
#include "uint64.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -92,8 +102,17 @@ protected:
// Protected data
mutable
uint64_t
invocations_
;
mutable
uint64_t
iterations_
;
//- Max iterations in calcNut
const
label
maxIter_
;
//- Convergence tolerance
const
scalar
tolerance_
;
//- Uncomment in case of intrumentation
//mutable uint64_t invocations_;
//mutable uint64_t nontrivial_;
//mutable uint64_t nonconvergence_;
//mutable uint64_t iterations_;
// Protected Member Functions
...
...
@@ -104,6 +123,9 @@ protected:
//- Calculate the friction velocity
virtual
tmp
<
scalarField
>
calcUTau
(
const
scalarField
&
magGradU
)
const
;
//- Write local wall function variables
virtual
void
writeLocalEntries
(
Ostream
&
)
const
;
public:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment