Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
1fc82434
Commit
1fc82434
authored
Mar 23, 2017
by
Henry Weller
Browse files
CrankNicolsonDdtScheme: Reorganized the code to simplify maintenance
parent
92b6f3dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.C
View file @
1fc82434
...
...
@@ -27,6 +27,7 @@ License
#include
"surfaceInterpolate.H"
#include
"fvcDiv.H"
#include
"fvMatrices.H"
#include
"Constant.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -277,7 +278,70 @@ const FieldField<fvPatchField, Type>& ff
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class
Type
>
CrankNicolsonDdtScheme
<
Type
>::
CrankNicolsonDdtScheme
(
const
fvMesh
&
mesh
)
:
ddtScheme
<
Type
>
(
mesh
),
ocCoeff_
(
new
Function1Types
::
Constant
<
scalar
>
(
"ocCoeff"
,
1
))
{
// Ensure the old-old-time cell volumes are available
// for moving meshes
if
(
mesh
.
moving
())
{
mesh
.
V00
();
}
}
template
<
class
Type
>
CrankNicolsonDdtScheme
<
Type
>::
CrankNicolsonDdtScheme
(
const
fvMesh
&
mesh
,
Istream
&
is
)
:
ddtScheme
<
Type
>
(
mesh
,
is
)
{
token
firstToken
(
is
);
if
(
firstToken
.
isNumber
())
{
const
scalar
ocCoeff
=
firstToken
.
scalarToken
();
if
(
ocCoeff
<
0
||
ocCoeff
>
1
)
{
FatalIOErrorInFunction
(
is
)
<<
"Off-centreing coefficient = "
<<
ocCoeff
<<
" should be >= 0 and <= 1"
<<
exit
(
FatalIOError
);
}
ocCoeff_
=
new
Function1Types
::
Constant
<
scalar
>
(
"ocCoeff"
,
ocCoeff
);
}
else
{
is
.
putBack
(
firstToken
);
dictionary
dict
(
is
);
ocCoeff_
=
Function1
<
scalar
>::
New
(
"ocCoeff"
,
dict
);
}
// Ensure the old-old-time cell volumes are available
// for moving meshes
if
(
mesh
.
moving
())
{
mesh
.
V00
();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
Type
>
tmp
<
GeometricField
<
Type
,
fvPatchField
,
volMesh
>>
...
...
src/finiteVolume/finiteVolume/ddtSchemes/CrankNicolsonDdtScheme/CrankNicolsonDdtScheme.H
View file @
1fc82434
...
...
@@ -91,7 +91,7 @@ SourceFiles
#define CrankNicolsonDdtScheme_H
#include
"ddtScheme.H"
#include
"
Constant
.H"
#include
"
Function1
.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -153,7 +153,8 @@ class CrankNicolsonDdtScheme
};
//- Off-centering coefficient, 1 -> CN, less than one blends with EI
//- Off-centering coefficient function
// 1 -> CN, less than one blends with EI
autoPtr
<
Function1
<
scalar
>>
ocCoeff_
;
...
...
@@ -210,59 +211,10 @@ public:
// Constructors
//- Construct from mesh
CrankNicolsonDdtScheme
(
const
fvMesh
&
mesh
)
:
ddtScheme
<
Type
>
(
mesh
),
ocCoeff_
(
new
Function1Types
::
Constant
<
scalar
>
(
"ocCoeff"
,
1
))
{
// Ensure the old-old-time cell volumes are available
// for moving meshes
if
(
mesh
.
moving
())
{
mesh
.
V00
();
}
}
CrankNicolsonDdtScheme
(
const
fvMesh
&
mesh
);
//- Construct from mesh and Istream
CrankNicolsonDdtScheme
(
const
fvMesh
&
mesh
,
Istream
&
is
)
:
ddtScheme
<
Type
>
(
mesh
,
is
)
{
token
firstToken
(
is
);
if
(
firstToken
.
isNumber
())
{
const
scalar
ocCoeff
=
firstToken
.
scalarToken
();
if
(
ocCoeff
<
0
||
ocCoeff
>
1
)
{
FatalIOErrorInFunction
(
is
)
<<
"Off-centreing coefficient = "
<<
ocCoeff
<<
" should be >= 0 and <= 1"
<<
exit
(
FatalIOError
);
}
ocCoeff_
=
new
Function1Types
::
Constant
<
scalar
>
(
"ocCoeff"
,
ocCoeff
);
}
else
{
is
.
putBack
(
firstToken
);
dictionary
dict
(
is
);
ocCoeff_
=
Function1
<
scalar
>::
New
(
"ocCoeff"
,
dict
);
}
// Ensure the old-old-time cell volumes are available
// for moving meshes
if
(
mesh
.
moving
())
{
mesh
.
V00
();
}
}
CrankNicolsonDdtScheme
(
const
fvMesh
&
mesh
,
Istream
&
is
);
// Member Functions
...
...
@@ -273,7 +225,7 @@ public:
return
fv
::
ddtScheme
<
Type
>::
mesh
();
}
//- Return the off-centreing coefficient
//- Return the
current
off-centreing coefficient
scalar
ocCoeff
()
const
{
return
ocCoeff_
->
value
(
mesh
().
time
().
value
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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