|
[Sponsors] |
Is it possible to add comments to fields files from the code? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 31, 2021, 14:13 |
Is it possible to add comments to fields files from the code?
|
#1 |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Hello
In OpenFOAM, is there any way how can I add comments to vol{Vector,Scalar,...}Field from the code? Say I have created a variable: Code:
volVectorField X ( IOobject ( "X", runTime().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ) ) Here is an example of the output I expect: Code:
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.com \\ / A nd | Version: 2006 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2; format binary; class volVectorField; location "0.1"; object X; } dimensions [ 0 1 -1 0 0 0 0 ]; // >>> I want to add a comment here <<< internalField uniform (15 3.0 -5.0 ); boundaryField { ... ... } Thank you |
|
November 1, 2021, 09:08 |
|
#2 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14 |
To be honest, this is not trivial (due to the way that OF handles IOobjects, the write action is a pretty low level functionality, buried deep in the class hierarchy; you'd need to generate your own flavour of IOobject, with an additional constructor to take the comment, and then update a whole buch of other buried, connected stuff as well ...).
I would strongly recommend trying to do it another way, e.g. use a functionObject to run a sed command on the file when it is written, to insert the comment ... or even simpler just run a script at the end of the run to add the comment to all the save files. If you want it done on the fly, you could write the script to keep checking for new, unchanged save files, and when it finds one pause (to allow tge write to complete) and then update ... you can then run this script alongside your real run. Probably not what you wanted to hear, but good luck anyway. |
|
November 1, 2021, 12:10 |
|
#3 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Can second what Tobermory says. You can easily drop in some regular comments in the input, or even drop them in as input entries. For example
Code:
comment1 "This is an internalField"; internalFIeld .... These will survive things like foamDictionary expansion, much like how you see files being assembled with various "#include" statements. However, when the volume field is written out, it only knows about its dimensions, internalField, boundaryField and each of the boundary condition types know how to write out their content. Since this content has been generated from OpenFOAM itself, there is no direct connection with your original input file whatsoever. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fortran->Assembly : How to remove redundant non-vectorized code? | aerosayan | Main CFD Forum | 6 | November 20, 2020 05:37 |
defining fields extended code guide | chkammer1989 | OpenFOAM Programming & Development | 1 | July 28, 2020 20:10 |
Visual Studio Code (VSCode) extension for OpenFOAM dictionary files and case setup | cosscholar | OpenFOAM | 0 | June 15, 2020 14:47 |
Results saving in CFD | hawk | Main CFD Forum | 16 | July 21, 2005 20:51 |
public CFD Code development | Heinz Wilkening | Main CFD Forum | 38 | March 5, 1999 11:44 |