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

Why is my new variable constant in all time steps?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2022, 09:13
Question Why is my new variable constant in all time steps?
  #1
New Member
 
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 5
CharIie is on a distinguished road
I am working in OpenFoamV8 with buoyantPimpleFoam. I have created a new variable "Test" in the solver code. Test should be the sum of the current temperature and a user defined constant value "Tc". My solver compiles and I get results, but the variable Test does not change over time!

Only the first time step "Test" is calculated and stays constant for all time steps. Although T changes over time! How can that be?

The error must be in the following code:
I have added these lines to Ueqn.H:
Code:
const volScalarField& T = mesh.lookupObject<volScalarField>("T");
dimensionedScalar    Tc(magneticProperties.lookup("Tc"));
volScalarField Test = T + Tc;
Test and Tc are created in createFields.H like this:
Code:
Info<< "Reading magnetic properties\n" << endl;
IOdictionary magneticProperties
(
    IOobject
    (
        "magneticProperties",
        runTime.constant(),
        mesh,
        IOobject::MUST_READ_IF_MODIFIED,
        IOobject::NO_WRITE
    )
);
dimensionedScalar Tc(magneticProperties.lookup("Tc"));



Info<< "Reading field Test\n" <<endl;
volScalarField Test
(
    IOobject
    (
         "Test",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE
     ),
     mesh
);
CharIie is offline   Reply With Quote

Old   July 5, 2022, 10:05
Default
  #2
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
One thing I see here, is that those variables in UEqn.H are going to be newly declared and defined everytime the solver steps into UEqn.H. You can easily put them into createFields and just add Test = T + Tc; inside UEqn.H.


The second thing what i find curious is the constant reference that you have named T. You are looking up a volScalarField from the objectRegistry named T and then overwriting it with a reference variable T?? Is that correct? I would suggest you to rename it for clear distinciton and to avoid name conflicts ( if you already defined a field called T, which I assume)


Please check if above recommandations already solve your problem.
überschwupper is offline   Reply With Quote

Old   July 5, 2022, 10:13
Default
  #3
New Member
 
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 5
CharIie is on a distinguished road
Test and Tc are created in createFields.H
Code:
const volScalarField& T = mesh.lookupObject<volScalarField>("T");
just gets the current value of T, since buoyantPimpleFoam does not directly solve with T but the energy variable he.



Why is the volScalarField "Test" constant in all time steps?
CharIie is offline   Reply With Quote

Old   July 5, 2022, 11:02
Default
  #4
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
Quote:
Originally Posted by CharIie View Post
Test and Tc are created in createFields.H
Code:
const volScalarField& T = mesh.lookupObject<volScalarField>("T");
just gets the current value of T, since buoyantPimpleFoam does not directly solve with T but the energy variable he.



Why is the volScalarField "Test" constant in all time steps?



Yes I have seen that, but you redefine these variables everytime the solver is going into UEqn.H.


I would assum, that your T gets falsely read in.

T is calculated by the thermo package then - at least I assume that. T gets registred with "T" + phaseName
überschwupper 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
[General] Extracting ParaView Data into Python Arrays Jeffzda ParaView 30 November 6, 2023 21:00
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 05:28
Stuck in a Rut- interDyMFoam! xoitx OpenFOAM Running, Solving & CFD 14 March 25, 2016 07:09
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 02:50


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