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

update object in objectRegistry

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 17, 2016, 04:32
Default update object in objectRegistry
  #1
New Member
 
Khomenko Maxim
Join Date: Aug 2015
Posts: 18
Rep Power: 11
mbookin is on a distinguished road
Hello!

I run my solver which uses field.oldTime().oldTime().oldTime() function. When I start from initial time the field_0_0_0 updates in objectRegistry and every thing is ok. But then I continue calculation from some time the field_0_0_0 in object registry is not equal to field_0_0_0 its self. In objectRegistry it is equal to initial value read from time directory.

So the question is how to update a field_0_0_0 in its objectRegistry manually?

Code:
// create or read T
// mesh is objectRegistry for T
while (runTime.run())
    {
    //  update T
    //  use T.oldTime().oldTime().oldTime()
    Info<<T.oldTime().oldTime().oldTime()<<endl;
    //  and 
    Info<<mesh.lookupObject<volScalarField>("T_0_0_0")<<endl;
    runtime.write()
    }
The code return equal value when I start from the beginning and return different value when I continue calculation. The whole solver is complicated to show it here and I haven't done any simple one to reproduce this problem hoping that someone can answer my question without reproduction. I use OF-2.3.x on Linux based system (SL-6.0)

Last edited by mbookin; November 17, 2016 at 04:35. Reason: clarity
mbookin is offline   Reply With Quote

Old   November 19, 2016, 08:43
Default Default update object in objectRegistry
  #2
jmf
Member
 
Jean-Michel FONTAINE
Join Date: Aug 2009
Location: Orleans - France
Posts: 55
Rep Power: 17
jmf is on a distinguished road
Hi

You might want to read my answer #2 to a similar problem here:
http://www.cfd-online.com/Forums/ope...dymfoam-c.html

based on the answer #14 in :
http://www.cfd-online.com/Forums/ope...rfield-bc.html

Regards

Jean-Michel
jmf is offline   Reply With Quote

Old   November 28, 2016, 10:00
Default update geometricField in registry
  #3
New Member
 
Khomenko Maxim
Join Date: Aug 2015
Posts: 18
Rep Power: 11
mbookin is on a distinguished road
Thank you for your answer!

The post you gave, as I understood, is about how to write something that is not in registry. You use function set() to update you dictionaries. My field_0_0_0 is in the registry, but is not updated. The problem is that geometricField class has no such function like set() so I cant update it manually or may be I miss something. Did I understand you right?

Last edited by mbookin; November 28, 2016 at 10:27. Reason: clarity, typo
mbookin is offline   Reply With Quote

Old   November 28, 2016, 18:59
Default Update geometricField in registry
  #4
jmf
Member
 
Jean-Michel FONTAINE
Join Date: Aug 2009
Location: Orleans - France
Posts: 55
Rep Power: 17
jmf is on a distinguished road
Dear Maxim


You don't give much details...
Instead of "runtime.write()" would "T.write()" work ?

Jean-Michel
jmf is offline   Reply With Quote

Old   November 29, 2016, 06:58
Default
  #5
New Member
 
Khomenko Maxim
Join Date: Aug 2015
Posts: 18
Rep Power: 11
mbookin is on a distinguished road
I made simple testSolver and testCase for someone who wants to help me to handle this problem. PseudoCode as follows, and the code is attached below.
Code:
volScalarField T
(
     IOobject
     (
        "T",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE
     ),
     mesh
); 
while (runTime.run())
    {
        runTime++;

        T=runTime.timeIndex();

        Pout<<tab<<"T="<<T[0]<<endl;
        Pout<<tab<<"T.()="<<T.oldTime()[0]<<tab<<"  writeOpt=  "<<T.oldTime().writeOpt()<<endl;
        Pout<<tab<<"T.()()="<<T.oldTime().oldTime()[0]<<tab<<"  writeOpt=  "<<T.oldTime().oldTime().writeOpt()<<endl;
        Pout<<tab<<"T.()()()="<<T.oldTime().oldTime().oldTime()[0]<<tab<<"  writeOpt=  "<<T.oldTime().oldTime().oldTime().writeOpt()<<endl;
        Pout<<tab<<"T.reg_0_0_0="<<T.db().lookupObject<volScalarField>("T_0_0_0")[0]<<endl;
 
        runTime.write();
}
The output is as follows:
Code:
Reading field T
 T.().().writeopt=  1
 T.().().().writeopt=  1
 T=0
 T.()=0
 T.()()=0
 T.()()()=0
Time = 1
 T=1
 T.()=0   writeOpt=  0
 T.()()=0   writeOpt=  1
 T.()()()=0   writeOpt=  1
 T.reg_0_0_0=0
Time = 2
 T=2
 T.()=1   writeOpt=  0
 T.()()=0   writeOpt=  0
 T.()()()=0   writeOpt=  1
 T.reg_0_0_0=0
Time = 3
 T=3
 T.()=2   writeOpt=  0
 T.()()=1   writeOpt=  0
 T.()()()=0   writeOpt=  1
 T.reg_0_0_0=0
Time = 4
 T=4
 T.()=3   writeOpt=  0
 T.()()=2   writeOpt=  0
 T.()()()=1   writeOpt=  1
 T.reg_0_0_0=1
Time = 5
 T=5
 T.()=4   writeOpt=  0
 T.()()=3   writeOpt=  0
 T.()()()=2   writeOpt=  1
 T.reg_0_0_0=2
End
T.oldTime().oldTime().writeOpt() is switched to AUTO_WRITE automatically. But T.oldTime().oldTime().oldTime().writeOpt() is not. So T.oldTime().oldTime().oldTime() is not written. That's why it will be updated in a wrong way when you continue. So the problem is how to switch T.oldTime().oldTime().oldTime().writeOpt() to AUTO_WRITE??
I even can write need field by T.db().lookupObject<volScalarField>("T_0_0_0").wri te(); But when I continue it is still not updated in objectRegistry, so the second continue is impossible.

Attachment 52119
Attached Files
File Type: zip testSolverFoam.zip (114.6 KB, 6 views)

Last edited by mbookin; November 29, 2016 at 16:49. Reason: adding information
mbookin 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
error in fireFoam, when running the case wallFireSpread2D zhoubiao1088 OpenFOAM Running, Solving & CFD 9 February 1, 2018 19:45
[foam-extend.org] Error compiling OpenFOAM-1.6-ext Canesin OpenFOAM Installation 137 January 20, 2016 15:56
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 04:23
Compilation error OF1.5-dev on Suse10.3 darenyang OpenFOAM Installation 0 April 29, 2009 05:55
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36


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