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-plus
Commits
bc25f9ab
Commit
bc25f9ab
authored
Apr 06, 2017
by
mattijs
Browse files
BUG: timeActivatedFileUpdate: was potentially rereading itself!
Fixed by setting flag which then gets queried by Time. Fixes
#420
.
parent
09ba9d39
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/Time/Time.C
View file @
bc25f9ab
...
...
@@ -943,6 +943,17 @@ bool Foam::Time::run() const
addProfiling
(
functionObjects
,
"functionObjects.execute()"
);
functionObjects_
.
execute
();
}
// Check if the execution of functionObjects require re-reading
// any files. This moves effect of e.g. 'timeActivatedFileUpdate'
// one time step forward. Note that we cannot call
// readModifiedObjects from within timeActivatedFileUpdate since
// it might re-read the functionObjects themselves (and delete
// the timeActivatedFileUpdate one)
if
(
functionObjects_
.
filesModified
())
{
const_cast
<
Time
&>
(
*
this
).
readModifiedObjects
();
}
}
// Update the "running" status following the
...
...
src/OpenFOAM/db/functionObjects/functionObject/functionObject.C
View file @
bc25f9ab
...
...
@@ -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) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -146,6 +146,12 @@ bool Foam::functionObject::adjustTimeStep()
}
bool
Foam
::
functionObject
::
filesModified
()
const
{
return
false
;
}
void
Foam
::
functionObject
::
updateMesh
(
const
mapPolyMesh
&
)
{}
...
...
src/OpenFOAM/db/functionObjects/functionObject/functionObject.H
View file @
bc25f9ab
...
...
@@ -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) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -233,6 +233,9 @@ public:
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
virtual
bool
adjustTimeStep
();
//- Did any file get changed during execution?
virtual
bool
filesModified
()
const
;
//- Update for changes of mesh
virtual
void
updateMesh
(
const
mapPolyMesh
&
mpm
);
...
...
src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C
View file @
bc25f9ab
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-201
6
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-201
7
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -819,6 +819,21 @@ bool Foam::functionObjectList::read()
}
bool
Foam
::
functionObjectList
::
filesModified
()
const
{
bool
ok
=
false
;
if
(
execution_
)
{
forAll
(
*
this
,
objectI
)
{
bool
changed
=
operator
[](
objectI
).
filesModified
();
ok
=
ok
||
changed
;
}
}
return
ok
;
}
void
Foam
::
functionObjectList
::
updateMesh
(
const
mapPolyMesh
&
mpm
)
{
if
(
execution_
)
...
...
src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H
View file @
bc25f9ab
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-201
6
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-201
7
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -264,6 +264,9 @@ public:
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
bool
adjustTimeStep
();
//- Did any file get changed during execution?
bool
filesModified
()
const
;
//- Update for changes of mesh
void
updateMesh
(
const
mapPolyMesh
&
mpm
);
...
...
src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C
View file @
bc25f9ab
...
...
@@ -220,6 +220,17 @@ bool Foam::functionObjects::timeControl::read
}
bool
Foam
::
functionObjects
::
timeControl
::
filesModified
()
const
{
bool
mod
=
false
;
if
(
active
())
{
mod
=
foPtr_
->
filesModified
();
}
return
mod
;
}
void
Foam
::
functionObjects
::
timeControl
::
updateMesh
(
const
mapPolyMesh
&
mpm
...
...
src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H
View file @
bc25f9ab
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -177,6 +177,9 @@ public:
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
virtual
bool
adjustTimeStep
();
//- Did any file get changed during execution?
virtual
bool
filesModified
()
const
;
//- Read and set the function object if its data have changed
virtual
bool
read
(
const
dictionary
&
);
...
...
src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C
View file @
bc25f9ab
...
...
@@ -48,11 +48,10 @@ namespace functionObjects
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void
Foam
::
functionObjects
::
timeActivatedFileUpdate
::
updateFile
(
const
bool
checkFiles
)
void
Foam
::
functionObjects
::
timeActivatedFileUpdate
::
updateFile
()
{
modified_
=
false
;
label
i
=
lastIndex_
;
while
(
...
...
@@ -73,14 +72,7 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile
mv
(
destFile
,
fileToUpdate_
);
lastIndex_
=
i
;
if
(
checkFiles
)
{
// Do an early check to avoid an additional iteration before
// any changes are picked up (see Time::run : does readModified
// before executing FOs). Note we have to protect the read
// constructor of *this from triggering this behaviour.
const_cast
<
Time
&>
(
time_
).
Time
::
readModifiedObjects
();
}
modified_
=
true
;
}
}
...
...
@@ -98,7 +90,8 @@ Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate
time_
(
runTime
),
fileToUpdate_
(
"unknown-fileToUpdate"
),
timeVsFile_
(),
lastIndex_
(
-
1
)
lastIndex_
(
-
1
),
modified_
(
false
)
{
read
(
dict
);
}
...
...
@@ -142,8 +135,8 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
<<
timeVsFile_
[
i
].
second
()
<<
endl
;
}
// Copy starting files
. Avoid recursion by not checking for modified files.
updateFile
(
false
);
// Copy starting files
updateFile
();
return
true
;
}
...
...
@@ -151,7 +144,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
bool
Foam
::
functionObjects
::
timeActivatedFileUpdate
::
execute
()
{
updateFile
(
true
);
updateFile
();
return
true
;
}
...
...
@@ -163,4 +156,10 @@ bool Foam::functionObjects::timeActivatedFileUpdate::write()
}
bool
Foam
::
functionObjects
::
timeActivatedFileUpdate
::
filesModified
()
const
{
return
modified_
;
}
// ************************************************************************* //
src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H
View file @
bc25f9ab
...
...
@@ -106,11 +106,14 @@ class timeActivatedFileUpdate
//- Index of last file copied
label
lastIndex_
;
//- Has anything been copied?
bool
modified_
;
// Private Member Functions
//- Update file
void
updateFile
(
const
bool
checkFiles
);
void
updateFile
();
//- Disallow default bitwise copy construct
timeActivatedFileUpdate
(
const
timeActivatedFileUpdate
&
);
...
...
@@ -150,6 +153,9 @@ public:
//- Do nothing
virtual
bool
write
();
//- Did any file get changed during execution?
virtual
bool
filesModified
()
const
;
};
...
...
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