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

How to modify field variables using fvOptions

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 24, 2024, 03:21
Default How to modify field variables using fvOptions
  #1
Member
 
Divyaprakash
Join Date: Jun 2014
Posts: 76
Rep Power: 12
Divyaprakash is on a distinguished road
I have a few question regarding fvOptions. My question has two parts.

PART 1:

In the following code
Code:
 

codedSource
{
...
codeAddSup // source term
    #{
 const labelList& cells = this->cells();
vectorField& USource = eqn.source(); 
for(auto cell : cells)         { 
USource[cell].x() = 1.0; 
USource[cell].y() = 0.0; 
USource[cell].z() = 0.0; 
} 
Info << USource << endl; 
 Info << eqn.source() << endl;
#};
...
}
The above two outputs are different and I am unable to understand why.


PART 2:

I also have a query below. Let's say I have modified my equation as below in mySolver.C by adding mySource, which I have also added in createFields.H

Code:
fvVectorMatrix UEqn
(
    fvm::ddt(U) + fvm::div(phi, U)
  + MRF.DDt(U)
  + turbulence->divDevReff(U) 

  + mySource

 ==
    fvOptions(U)
);
Then is it possible to modify the value of mySource using fvOptions?

I tried the following but it didn't work.
Code:
codedSource
{
    type            vectorCodedSource;
    selectionMode   cellSet;
    cellSet         box1;

    fields          (mySource);
    name            sourceTime;

    codeConstrain //constrain
    #{
        return;
    #};

    codeCorrect //correct
    #{
        const labelList& cells = this->cells();
        for(auto cell : cells)
        {
            fld[cell].x() = 1.0;
        }
    #};
I thought that "fields (mySource)" would give me access to the field for modification, but I don't think that happens. In fact nothing happens and no values are written to mySource, instead I get a warning
" Source codedSource defined for field mySource but never use".

Thank you!
Divyaprakash is offline   Reply With Quote

Reply

Tags
add source, fvoption, source

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 92 May 21, 2024 08:56
Odd problem linking variables with field functions JRosser_Purdue STAR-CCM+ 1 December 12, 2022 13:31
[Other] dynamicTopoFVMesh and pointDisplacement RandomUser OpenFOAM Meshing & Mesh Conversion 6 April 26, 2018 08:30
potential flows, helmholtz decomposition and other stuffs pigna Main CFD Forum 1 October 26, 2017 09:34
Creating new variables and modify existing eqn in porousSimpleFoam AJAY BHANDARI OpenFOAM Programming & Development 3 December 2, 2015 03:17


All times are GMT -4. The time now is 09:35.