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

How to change a dimensionedScalar into volScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By jherb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 25, 2019, 12:05
Arrow How to change a dimensionedScalar into volScalarField
  #1
New Member
 
Purn Prakash
Join Date: Nov 2018
Posts: 27
Blog Entries: 1
Rep Power: 7
purnp2 is on a distinguished road
Hello,
I am using one RAS model (Hellsten-EARSM from Furst's GIT repository) to make some changes into it.
In the transport equation maker function, I want to change a few coefficients (zeta_, beta_, and alphaD_) from its type [dimensionedScalar] to another type [volScalarField] to make it compatible with the rest of the code in its original code.
Original Code:
Code:
        volScalarField gamma( this->gamma(fMix) );
        volScalarField beta( this->beta(fMix) );
        volScalarField alphaD( this->alphaD(fMix) );
Here, this->gamma(fMix) is of the type volScalarField.
Changes I made which are producing error:
Code:
        volScalarField zeta( this->zeta_ );
        volScalarField beta( this->beta_ );
        volScalarField alphaD= this->alphaD_ ;
In the changed code, zeta_ [dimensionedScalar] replaces this->gamma(fMix) [volScalarField] and like wise in two other cases.
I am attaching changed files also:
So, how can I change its type?

Thank you for your time for reading this.
Purn
Attached Files
File Type: c transEARSM.C (14.6 KB, 4 views)
File Type: h transEARSM.H (8.0 KB, 2 views)

Last edited by purnp2; May 25, 2019 at 15:45.
purnp2 is offline   Reply With Quote

Old   May 25, 2019, 15:51
Default
  #2
New Member
 
Purn Prakash
Join Date: Nov 2018
Posts: 27
Blog Entries: 1
Rep Power: 7
purnp2 is on a distinguished road
One possible solution (which, I guess, is not correct even though it compiles and run) is as follows:
I used a formula:
Code:
    tmp<volScalarField> blend
    (
        const volScalarField& fMix,
        const dimensionedScalar& psi
    ) const
    {
        return fMix*(psi)/fMix;
    }
were fMix is of type [volScalarFeild].
Is it an acceptable solution?

I am hoping for a solution where I can use any standard function of foam:: like:
Code:
typedef GeometricField<scalar, fvPatchField, volMesh> volScalarField
purnp2 is offline   Reply With Quote

Old   May 30, 2019, 09:46
Default
  #3
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
Have a look e.g. at https://github.com/OpenFOAM/OpenFOAM...ewtonian.C#L54


Code:
     nu_
     (
         IOobject
         (
             name,
             U_.time().timeName(),
             U_.db(),
             IOobject::NO_READ,
             IOobject::NO_WRITE
         ),
         U_.mesh(),
         nu0_
     )
nu_ is a volScalarField and nu0_ a dimensioned scalar. So if you use this in a function (and not in a constructor), it should look like this (not tested):

Code:
     volScalarField nu_
     (
         IOobject
         (
             "name",
             U_.time().timeName(),
             U_.db(),
             IOobject::NO_READ,
             IOobject::NO_WRITE
         ),
         U_.mesh(),
         nu0_
     )
you need the variable containing a reference to the mesh or the internal database in for the call to IOobject. (see e.g. the solver source codes or boundary conditions)
purnp2, lpz456 and wht like this.
jherb is offline   Reply With Quote

Old   May 31, 2019, 16:37
Default
  #4
New Member
 
Purn Prakash
Join Date: Nov 2018
Posts: 27
Blog Entries: 1
Rep Power: 7
purnp2 is on a distinguished road
Thank you very much, sir. I'll check this code and update this reply if it works for me or not. I appreciate your help.
purnp2 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
No matching function error: Phase change source term added to interMixingFoam wavefunction OpenFOAM Programming & Development 2 February 4, 2022 07:46
how to change boundaryType in volScalarField gaza OpenFOAM Programming & Development 6 October 20, 2017 07:35
Compressible 2D airfoil rhoSimpleFoam fatal error volScalarField none jfournier OpenFOAM Running, Solving & CFD 4 September 28, 2017 06:28
Radiation interface hinca CFX 15 January 26, 2014 17:11
converting from dimensionedScalar to volScalarField shash OpenFOAM Running, Solving & CFD 7 July 11, 2012 05:02


All times are GMT -4. The time now is 08:43.