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

create time independent volScalarField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2020, 03:50
Default create time independent volScalarField
  #1
Member
 
ssa
Join Date: Sep 2018
Posts: 93
Rep Power: 7
ssa_cfd is on a distinguished road
Hi all,


I am trying to create a volScalarField for storing reaction rates kf and kr in my calculation. In my simulation case, the kf and kr variables are constant throughout the simulation.



I created a volScalarFields for the reaction rates as follows.
Code:
PtrList<volScalarField> kf(N);
Info << "Creating fields for kf" << endl;
for(int i = 0; i < N; i++)
{
    word kfi ("kf-un-named-reaction-" + name(i));
    kf.set
    (
        i,
        new volScalarField 
    (
            IOobject
            (
                kfi,
                runTime.timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh
,
           dimensionedScalar(kfi, dimless, 0.0)
        )
    );
}

PtrList<volScalarField> kr(N);
Info << "Creating fields for kr" << endl;
for(int i = 0; i < N; i++)
{
    word kri ("kr-un-named-reaction-" + name(i));
    kr.set
    (
        i,
        new volScalarField 
    (
            IOobject
            (
                kri,
                runTime.timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh
,
           dimensionedScalar(kri, dimless, 0.0)
        )
    );
    
}


But when I check, it creates volScalarField also for the Previous Iteration. It creates 4 volScalarFields for each reaction. (kf, kfPrevIter, kr, krPrevIter). Since the number of reactions is large, the simulation takes too much memory and slows down the simulation.



I want to make it constant such that it creates only two volScalarField (kf and kr).



Does anyone know how to do it.?


Thanks in advance,
ssa.
ssa_cfd is offline   Reply With Quote

Old   January 20, 2020, 13:50
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 15
adhiraj is on a distinguished road
Would it help if you do not register the variables?

Code:
kf.set
(
    i,
    new volScalarField 
    (
        IOobject
        (
            kfi,
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE,
            false
         ),
         mesh,
         dimensionedScalar(kfi, dimless, 0.0)
    )
);
adhiraj is offline   Reply With Quote

Old   January 21, 2020, 03:25
Default
  #3
Member
 
ssa
Join Date: Sep 2018
Posts: 93
Rep Power: 7
ssa_cfd is on a distinguished road
If I do not register the fields, it deletes all the four (kf, kfPrevIter, kr, krPrevIter) volScalarFields.



I couldn't access kf and kr in the calculations.
ssa_cfd is offline   Reply With Quote

Old   January 24, 2020, 10:27
Default
  #4
Member
 
ssa
Join Date: Sep 2018
Posts: 93
Rep Power: 7
ssa_cfd is on a distinguished road
I found a function called checkout() in the regIOobject.c ,


but it also deletes all the four fields.



Does someone know how to delete only the prevIter fields??
ssa_cfd 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
Time Step Continuity Errors simpleFoam Dorian1504 OpenFOAM Running, Solving & CFD 1 October 9, 2022 09:23
Setting up Lid driven Cavity Benchmark with 1M cells for multiple cores puneet336 OpenFOAM Running, Solving & CFD 11 April 7, 2019 00:58
same geometry,structured and unstructured mesh,different behaviour. sharonyue OpenFOAM Running, Solving & CFD 13 January 2, 2013 22:40
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 01:07
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


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