Skip to content
GitLab
Menu
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
159ee1d9
Commit
159ee1d9
authored
Apr 17, 2019
by
Andrew Heather
Browse files
ENH: solverInfo - separated execute and write functionality
parent
a6acce45
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/functionObjects/utilities/solverInfo/solverInfo.C
View file @
159ee1d9
...
...
@@ -110,41 +110,8 @@ void Foam::functionObjects::solverInfo::createResidualField
);
fieldPtr
->
store
();
}
}
void
Foam
::
functionObjects
::
solverInfo
::
writeResidualField
(
const
word
&
fieldName
)
const
{
const
word
residualName
(
"initialResidual:"
+
fieldName
);
const
auto
*
residualPtr
=
mesh_
.
findObject
<
IOField
<
scalar
>>
(
residualName
);
if
(
residualPtr
)
{
volScalarField
residual
(
IOobject
(
residualName
,
mesh_
.
time
().
timeName
(),
mesh_
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
,
false
),
mesh_
,
dimensionedScalar
(
dimless
,
Zero
),
zeroGradientFvPatchField
<
scalar
>::
typeName
);
residual
.
primitiveFieldRef
()
=
*
residualPtr
;
residual
.
correctBoundaryConditions
();
residual
.
write
();
residualFieldNames_
.
insert
(
residualName
);
}
}
...
...
@@ -162,6 +129,7 @@ Foam::functionObjects::solverInfo::solverInfo
writeFile
(
obr_
,
name
,
typeName
,
dict
),
fieldSet_
(
mesh_
),
writeResidualFields_
(
false
),
residualFieldNames_
(),
initialised_
(
false
)
{
read
(
dict
);
...
...
@@ -174,11 +142,15 @@ bool Foam::functionObjects::solverInfo::read(const dictionary& dict)
{
if
(
fvMeshFunctionObject
::
read
(
dict
))
{
initialised_
=
false
;
fieldSet_
.
read
(
dict
);
writeResidualFields_
=
dict
.
lookupOrDefault
(
"writeResidualFields"
,
false
);
residualFieldNames_
.
clear
();
return
true
;
}
...
...
@@ -209,24 +181,54 @@ bool Foam::functionObjects::solverInfo::execute()
initialised_
=
true
;
}
writeTime
(
file
());
for
(
const
word
&
fieldName
:
fieldSet_
.
selectionNames
())
{
updateSolverInfo
<
scalar
>
(
fieldName
);
updateSolverInfo
<
vector
>
(
fieldName
);
updateSolverInfo
<
sphericalTensor
>
(
fieldName
);
updateSolverInfo
<
symmTensor
>
(
fieldName
);
updateSolverInfo
<
tensor
>
(
fieldName
);
}
file
()
<<
endl
;
return
true
;
}
bool
Foam
::
functionObjects
::
solverInfo
::
write
()
{
writeTime
(
file
());
for
(
const
word
&
fieldName
:
fieldSet_
.
selectionNames
())
for
(
const
word
&
residualName
:
residualFieldNames_
)
{
writeSolverInfo
<
scalar
>
(
fieldName
);
writeSolverInfo
<
vector
>
(
fieldName
);
writeSolverInfo
<
sphericalTensor
>
(
fieldName
);
writeSolverInfo
<
symmTensor
>
(
fieldName
);
writeSolverInfo
<
tensor
>
(
fieldName
);
}
const
auto
*
residualPtr
=
mesh_
.
findObject
<
IOField
<
scalar
>>
(
residualName
);
file
()
<<
endl
;
if
(
residualPtr
)
{
volScalarField
residual
(
IOobject
(
residualName
,
mesh_
.
time
().
timeName
(),
mesh_
,
IOobject
::
NO_READ
,
IOobject
::
NO_WRITE
,
false
),
mesh_
,
dimensionedScalar
(
dimless
,
Zero
),
zeroGradientFvPatchField
<
scalar
>::
typeName
);
residual
.
primitiveFieldRef
()
=
*
residualPtr
;
residual
.
correctBoundaryConditions
();
residual
.
write
();
}
}
return
true
;
}
...
...
src/functionObjects/utilities/solverInfo/solverInfo.H
View file @
159ee1d9
...
...
@@ -107,6 +107,9 @@ protected:
//- Flag to write the residual as a vol field
bool
writeResidualFields_
;
//- Names of (result) residual fields
wordHashSet
residualFieldNames_
;
//- Initialisation flag
bool
initialised_
;
...
...
@@ -119,9 +122,6 @@ protected:
//- Create and store a residual field on the mesh database
void
createResidualField
(
const
word
&
fieldName
);
//- Write a residual field
void
writeResidualField
(
const
word
&
fieldName
)
const
;
//- Output file header information per primitive type value
template
<
class
Type
>
void
writeFileHeader
(
Ostream
&
os
,
const
word
&
fileName
)
const
;
...
...
@@ -132,7 +132,7 @@ protected:
//- Calculate the solver information
template
<
class
Type
>
void
wri
teSolverInfo
(
const
word
&
fieldName
);
void
upda
teSolverInfo
(
const
word
&
fieldName
);
private:
...
...
src/functionObjects/utilities/solverInfo/solverInfoTemplates.C
View file @
159ee1d9
...
...
@@ -105,7 +105,7 @@ void Foam::functionObjects::solverInfo::initialiseResidualField
template
<
class
Type
>
void
Foam
::
functionObjects
::
solverInfo
::
wri
teSolverInfo
(
const
word
&
fieldName
)
void
Foam
::
functionObjects
::
solverInfo
::
upda
teSolverInfo
(
const
word
&
fieldName
)
{
typedef
GeometricField
<
Type
,
fvPatchField
,
volMesh
>
volFieldType
;
typedef
typename
pTraits
<
Type
>::
labelType
labelType
;
...
...
@@ -150,8 +150,6 @@ void Foam::functionObjects::solverInfo::writeSolverInfo(const word& fieldName)
setResult
(
resultName
+
"_initial"
,
ri
);
setResult
(
resultName
+
"_final"
,
rf
);
setResult
(
resultName
+
"_iters"
,
n
);
writeResidualField
(
resultName
);
}
}
...
...
Write
Preview
Supports
Markdown
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