|
[Sponsors] |
Correct way to write intermediate values of field calculations |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 4, 2020, 14:22 |
Correct way to write intermediate values of field calculations
|
#1 |
New Member
Joseph E Weaver
Join Date: Sep 2019
Posts: 2
Rep Power: 0 |
I am extending a solver whose final fields are calculated using a collection of intermediate values. Generically, it writes field F, which is the sum A+B+C+D.
I would like to visualize the individual components (per cell) over time to get a feel for their relative contributions under different conditions and in different locations. While I'm able to just spit a bunch of output to the terminal and parse it, I'm also aware that the better way to do this would be to be output them using the built-in OpenFOAM registry functionality (IOobject) etc. I'm not particularly familiar with how that part of the code works, particularly in the context of local variables (the A,B,C,D components) within a function. Following the wiki, I've successfully set up an IOobject for component A Code:
volScalarField A_comp ( IOobject ( "A_comp", fc_->mesh_.time().timeName(), fc_->mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), fc_->mesh_ ); A_comp = fc_->calculate_A(); Code:
fc_ Code:
--> FOAM FATAL ERROR: cannot find file "~/case/0.002/A_comp" Note that we have no idea of what the initial values of A,B,C,D are, nor would guesses at those ICs be used in calculating them. I don't think I need to set up blank files in the 0 directory, but could be wrong. Any guidance would be appreciated. |
|
February 5, 2020, 11:10 |
|
#2 |
New Member
Morteza Mousavi
Join Date: Jul 2019
Location: Lund, Sweden
Posts: 15
Rep Power: 7 |
That might be because of the type of the constructor that you use for your volScalarField. According to following lines from GeometricField.H file, this constructor is used when you want to read an object:
Code:
//- Construct and read given IOobject GeometricField ( const IOobject&, const Mesh& ); Code:
volVectorField A_comp ( IOobject ( "A_comp", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fc_->calculate_A() // the value of the volScalarField ); |
|
February 5, 2020, 13:30 |
|
#3 |
New Member
Joseph E Weaver
Join Date: Sep 2019
Posts: 2
Rep Power: 0 |
Thanks, this makes sense but revealed a further issue.
It turns out Code:
fc_->calculate_A() I'll be looking for a better place to run this, unless there's some variant of IOobject where you can insert individual scalars and have it recreate the field. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mesh file for flow over a circular cylinder | Ardalan | Main CFD Forum | 7 | December 15, 2020 14:06 |
How can write a field in openFOAM | sven82 | OpenFOAM Programming & Development | 27 | December 11, 2019 12:57 |
Field values at the boundary cells | vcvedant | OpenFOAM Running, Solving & CFD | 4 | August 2, 2017 18:50 |
howto write a patch field during the run | m2montazari | OpenFOAM | 15 | September 6, 2016 09:57 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 15:37 |