|
[Sponsors] |
Why is my new variable constant in all time steps? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 5, 2022, 09:13 |
Why is my new variable constant in all time steps?
|
#1 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 5 |
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; 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 ); |
|
July 5, 2022, 10:05 |
|
#2 |
Member
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4 |
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. |
|
July 5, 2022, 10:13 |
|
#3 |
New Member
Join Date: Sep 2020
Location: Germany
Posts: 17
Rep Power: 5 |
Test and Tc are created in createFields.H
Code:
const volScalarField& T = mesh.lookupObject<volScalarField>("T"); Why is the volScalarField "Test" constant in all time steps? |
|
July 5, 2022, 11:02 |
|
#4 | |
Member
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4 |
Quote:
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 |
||
|
|
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 |