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

Values of a volScalarField not updated

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 9, 2015, 07:53
Default Values of a volScalarField not updated
  #1
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi all,

I will try my best to describe my problem, but it is very puzzling.

I have a runTime-selectable class that contains a volScalarField, which is constructed in the following manner:

Code:
weights_
(
    IOobject
    (
        "weights",
        mesh.time().timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedScalar("null", dimless, 0.0),
    "zeroGradient"
)
This is all very basic. I then I have an update function that takes the following form:

Code:
void simpleSpatialCorrections::update()
{
    weights_.internalField() += 1.0;

    weights_.correctBoundaryConditions();

//    if (mesh_.time().outputTime())
//    {
//        weights_.write();
//    }
}
I have checked that the update is actually called every single time step. The problem is that the values in the volScalarField as written to the disk equals the initial constructed values! If I change the field weights_ to "IOobject::NO_WRITE" and use the manual writing (commented part of the update method), then things works.

Furthermore, I have tried to make a small testProgram (you could term it a unit test) that only contains this one single class and its derivatives. Suddenly, the field is written correctly, so the observed error is not reproducible in a different context.

Anyone who has experienced the same behaviour and who knows a solution to it?

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   April 9, 2015, 10:27
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Thank you for your attention.

I have solved the problem, because I suddenly realised that I used part of the functionality of the same class elsewhere, i.e. the field was created twice, but only updated in one of the versions. Consequently I had introduced the conflict myself.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj 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
How to update a volScalarField's values ThomasV OpenFOAM Programming & Development 9 March 10, 2020 12:51
Values for nu t and nu tilda Phizz82 OpenFOAM Running, Solving & CFD 1 March 2, 2020 06:00
How can I write out a volscalarfield in openFOAM Marshak OpenFOAM Programming & Development 3 August 29, 2013 14:10
Counting non-zero values in a volScalarField javier_motta OpenFOAM 1 May 29, 2013 10:30
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 12:04


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