-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull request: Add functions into "ITHACAstream" to read the converged fields in parallel. #559
Conversation
…CAstream. The two functions allow to parallel read the converged fields in the subfolders. 2-The solver, 18simpleTurbNS, is also modified.
Foam::Time runTime2(Foam::Time::controlDictName, rootpath, casename); | ||
int last_s (runTime2.times().size()); | ||
|
||
GeometricField<Type, PatchField, GeoMesh> tmp_field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really wasteful. There is no reason to read the field from disk and then make a full (deep) copy if it, which is what the clone()
will do. At least wrap it as a pointer to allow the append to steal the contents. Eg,
auto tfld =
autoPtr<GeometricField<Type, PatchField, GeoMesh>>::New
(
IOobject
(
field.name(),
casename + runTime2.times()[last_s-1].name(),
field.mesh(),
IOobject::MUST_READ
),
field.mesh()
);
Lfield.append(std::move(tfld));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting with OpenFOAM-v2212, you can also use the emplace_back()
method. For example,
#if (OPENFOAM >= 2212)
Lfield.emplace_back
(
IOobject
(
field.name(),
casename + runTime2.times()[last_s-1].name(),
field.mesh(),
IOobject::MUST_READ
),
field.mesh()
);
#else
...
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good morning, Dr. Olesen. Thanks for your contributive suggestions. I will modify the code and submit it later today. As a new guy in OpenFOAM, I still need to learn lots of such programming skills.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, you just need to be "paranoid" about clean code and memory use and most things will work out fine...
void readLastFields(PtrList<GeometricField<Type, PatchField, GeoMesh>>& | ||
Lfield, | ||
GeometricField<Type, PatchField, GeoMesh>& field, | ||
fileName casename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider passing as const fileName& casename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will modify it as const fileName& casename
.
…fields_ function; 2-Use pointer to improve the efficiency of the code; 3-Add to activate _emplace_back_ function for new OF version; 4-Use instead of in the function to reduce repeating print.
1-Add two functions, read_last_fields and readLastFields, to the ITHACAstream. The two functions allow parallel reading of the converged fields in the subfolders.
2-The solver, 18simpleTurbNS, is also modified.
3-Declear as const for those immutable variables in the read_last_fields function.
4-Use pointers to improve the code's efficiency, following Dr. Mark Olesen's suggestions.
5-Add
#if defined(OFVER) && (OFVER >= 2212)_
to activate emplace_back function for the new OF version.6-Use
Info
instead ofstd::cout
in thegetTurbRBF
function to reduce repeating print.