CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Dictionary writes as class volScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Tobermory

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 24, 2024, 15:42
Default Dictionary writes as class volScalarField
  #1
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 711
Rep Power: 14
Tobermory will become famous soon enough
I have a really odd bug in a simple application for OF v8 that I have written to calculate some initial fields. The code updates some values in constant/thermophysicalProperties using:
Code:
IOdictionary thermoDict(
    IOobject(
        "thermophysicalProperties", 
        "constant", 
        mesh, 
        IOobject::MUST_READ, 
        IOobject::AUTO_WRITE
    )
);
thermoDict.subDict("mixture").subDict("equationOfState").set("rho0",abl.rho0);
thermoDict.regIOobject::write();
This generally works fine ... except that it changes the class entry in the header of the thermophysicalProperties file from dictionary to volScalarField! This then causes all sorts of warnings and odd behaviour in the solver.

Can anyone give me a hint as to why the class is changed on rewriting the dictionary?
Tobermory is offline   Reply With Quote

Old   July 26, 2024, 06:11
Default
  #2
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 770
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Apologies for being in the thick mist by your question.

Q1: who/what changes the class entry ?

Q2: what is the correct type, i.e., why is volScalarField not the desired type?
dlahaye is offline   Reply With Quote

Old   July 26, 2024, 09:14
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 711
Rep Power: 14
Tobermory will become famous soon enough
I should have been clearer in my first post Domenico. At the top of every foam file is a header with something like the following text:

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      thermophysicalProperties;
}
with what I have since found is a IOobject::headerClassName_, which should be "dictionary" for thermophysicalProperties, since the file is a dictionary file. It would be volScalarField for the p file, volVectorField for U etc.

Now what is bizarre is that I open thermophysicalProperties, adjust some of the contents and then write it out, and suddenly the headerClassName changes from dictionary to volScalarField.

I tried moving just the lines above into a new app, and the bug doesn't happen (!), so there must be something subtle going on. I'll keep testing.
Tobermory is offline   Reply With Quote

Old   July 26, 2024, 09:23
Default
  #4
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 770
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Very sorry to say that I am still in the mist.

Are you running an application that creates constant/thermophysicalProperties
for you?

I am happy to keep read attentively whatever you send across.
dlahaye is offline   Reply With Quote

Old   July 26, 2024, 09:31
Default
  #5
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 711
Rep Power: 14
Tobermory will become famous soon enough
Ok - weirder and weirder ... I am now printing out the contents of headerClassName:

Code:
Info << thermoDict.regIOobject::headerClassName()  << endl;
and it is still dictionary, i.e. correct, even though it writes volScalarField. Grrr.
Tobermory is offline   Reply With Quote

Old   July 26, 2024, 09:54
Default
  #6
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 711
Rep Power: 14
Tobermory will become famous soon enough
Quote:
Originally Posted by dlahaye View Post
Are you running an application that creates constant/thermophysicalProperties
for you?
Yes - or rather it updates some of the values as well as setting up the initial fields. I am slowly narrowing down what the cause is - the good old fashioned way of comment everything out, and slowly uncomment until the problem occurs, and voila - you have found your culprit.
Tobermory is offline   Reply With Quote

Old   July 26, 2024, 10:25
Default
  #7
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 711
Rep Power: 14
Tobermory will become famous soon enough
Well, I have found the culprit. I needed to pull out the value of kappa from the wall boundary, to use in the initial fields calculation, but rather crudely I had opened the nut file as a IOdictionary rather than a volScalarField. For some reason this then caused thermoDict, opened later as a IOdictionary, to write as a volScalarField! Very odd, but a problem of my making I guess.

I'll need to find another way of stripping out kappa from the nut file.
dlahaye likes this.
Tobermory is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
temperature negative occurred in rhoCentralFoam at high M longming OpenFOAM Running, Solving & CFD 10 February 25, 2024 23:46
Read from dictionary inside new smoother class TommyGun OpenFOAM Programming & Development 3 May 22, 2020 18:08
given a volScalarField object, how to read inputs from its dictionary anon_q OpenFOAM Programming & Development 6 August 9, 2019 02:07
driftFluxFoam viscosity model modification problem dleduc OpenFOAM Programming & Development 15 October 1, 2018 09:37
Compressible 2D airfoil rhoSimpleFoam fatal error volScalarField none jfournier OpenFOAM Running, Solving & CFD 4 September 28, 2017 06:28


All times are GMT -4. The time now is 20:20.