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

Adding a new variable as constructor in the LISA atomization Model

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2018, 09:45
Default Adding a new variable as constructor in the LISA atomization Model
  #1
Member
 
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13
vishal_s is on a distinguished road
Hi,

I am trying to add a new variable ("AVV") in the LISA atomization model but after several attempt I am still unsuccessful in adding it. This new variable is going to be read from a .txt file (this variable changes with pressure).
I have made changes in the actual LISA atomisation.C and LISA atomisation.H file but it is giving a prototype error.

I will be grateful, if anyone can tell how to add a new variable as a constructor in the LISA atomization. I have added the new model in the langrangian/spray/parcels/include/makeSprayParcelAtomizationModels.H.

I have the added here the following section, where the changes has been done.

My changes in the NewLISAAtomization.C

Code:
#include "NewLISAAtomization.H"

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class CloudType>
Foam::NewLISAAtomization<CloudType>::NewLISAAtomization
(
    const dictionary& dict,
        const fvMesh& mesh, //Added
    const  volVectorField& U, //Added
    CloudType& owner
)
:
    AtomizationModel<CloudType>(dict, owner, typeName), //Modified
                 mesh_(U.mesh()),  //Added
    Cl_(readScalar(this->coeffDict().lookup("Cl"))),
    cTau_(readScalar(this->coeffDict().lookup("cTau"))),
    Q_(readScalar(this->coeffDict().lookup("Q"))),
    lisaExp_(readScalar(this->coeffDict().lookup("lisaExp"))),
    injectorDirection_(this->coeffDict().lookup("injectorDirection")),
                     runTime_(U.time()), //Added
 

    AVV_    // New variable added
    (
        IOobject
        (
            "AVV",
            runTime_.timeName(),
            mesh_,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh_,
        dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0, 0, 0) ,0.0)
    ),
    SMDCalcMethod_(this->coeffDict().lookup("SMDCalculationMethod"))
{
    // Note: Would be good if this could be picked up from the injector
    injectorDirection_ /= mag(injectorDirection_);

    if (SMDCalcMethod_ == "method1")
    {
        SMDMethod_ = method1;
    }
    else if (SMDCalcMethod_ == "method2")
    {
        SMDMethod_ = method2;
    }
    else
    {
        SMDMethod_ = method2;
        Info<< "Warning: SMDCalculationMethod " << SMDCalcMethod_
            << " unknown. Options are (method1 | method2). Using method2"
            << endl;
    }
}
My changes in the NewLISAAtomization.H

Code:
#ifndef NewLISAAtomization_H
#define NewLISAAtomization_H

#include "AtomizationModel.H"

#include "volFields.H" //Added
#include "IOdictionary.H" //Added
#include "autoPtr.H" //Added
#include "runTimeSelectionTables.H" //Added

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
/*---------------------------------------------------------------------------*\
                       Class NewLISAAtomization Declaration
\*---------------------------------------------------------------------------*/

template<class CloudType>
class NewLISAAtomization
:
    public AtomizationModel<CloudType>
{

public:

    //- Enumeration for SMD calculations
    enum SMDMethods
    {
        method1,
        method2
    };


private:

    // Private data
                  const  fvMesh& mesh_; //Added
        scalar Cl_;
        scalar cTau_;
        scalar Q_;
        scalar lisaExp_;
        vector injectorDirection_;
                 const Time& runTime_; //Added
             volScalarField  AVV_; //Added
        word SMDCalcMethod_;

        SMDMethods SMDMethod_;

     public:

    //- Runtime type information
    TypeName("NewLISA");


    // Constructors

        //- Construct from dictionary
        NewLISAAtomization(const dictionary&, CloudType&);

        //- Construct copy
        NewLISAAtomization(const NewLISAAtomization<CloudType>& am);

        //- Construct and return a clone
        virtual autoPtr<AtomizationModel<CloudType> > clone() const
        {
            return autoPtr<AtomizationModel<CloudType> >
            (
                new NewLISAAtomization<CloudType>(*this)
            );
        }


    //- Destructor
    virtual ~NewLISAAtomization();


    // Member Functions
 const volScalarField& AVV() const
       {
            return AVV_; //Added
       }

        //- initial value of liquidCore
        virtual scalar initLiquidCore() const;
The error I am getting is:

Quote:
In file included from lnInclude/NewLISAAtomization.H:165:0,
from lnInclude/makeSprayParcelAtomizationModels.H:34,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/NewLISAAtomization.C:31:1: error: prototype for ‘Foam::NewLISAAtomization<CloudType>::NewLISAAtomi zation(const Foam::dictionary&, const Foam::fvMesh&, const volVectorField&, CloudType&)’ does not match any in class ‘Foam::NewLISAAtomization<CloudType>’
Foam::NewLISAAtomization<CloudType>::NewLISAAtomiz ation
^
In file included from lnInclude/makeSprayParcelAtomizationModels.H:34:0,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/NewLISAAtomization.H:109:9: error: candidates are: Foam::NewLISAAtomization<CloudType>::NewLISAAtomiz ation(const Foam::NewLISAAtomization<CloudType>&)
NewLISAAtomization(const NewLISAAtomization<CloudType>& am);
^
lnInclude/NewLISAAtomization.H:106:9: error: Foam::NewLISAAtomization<CloudType>::NewLISAAtomiz ation(const Foam::dictionary&, CloudType&)
NewLISAAtomization(const dictionary&, CloudType&);
^
make: *** [Make/linux64GccDPOpt/makeBasicSprayParcelSubmodels.o] Error 1
I am still a novice in OpenFOAM, so a little help in this matter will be really helpful.

Thanks in advance.
vishal_s is offline   Reply With Quote

Old   August 9, 2018, 15:19
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Following your request in private message.

You cannot change arbitrarily constructor interface. In general you have access to the mesh (and subsequently Time) through CloudType.

In fact your error has nothing to do with OpenFOAM per se. You need basic knowledge of C++ to read the error.

So:
1. Remove your additions to constructor signature.
2. Access mesh through owner variable.
Tobi likes this.
alexeym is offline   Reply With Quote

Old   August 9, 2018, 16:10
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Dear Vishal,


I see you were writing to several people. However, there is nothing left to say. Alex already gave the correct answer.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 9, 2018, 10:24
Default
  #4
Member
 
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13
vishal_s is on a distinguished road
Hi Alexey,

Thanks for your input. I have now accessed the variables using owner, like this:
Code:
rhog_(IOobject("rhog",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimensionSet(1,-3, 0, 0, 0, 0, 0) ,1.0))
.

But now I would like to define a function calcRhoBar as follows.

Code:
template<class CloudType>
Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomization
(
    const dictionary& dict,

        CloudType& owner
)
:
    AtomizationModel<CloudType>(dict, owner, typeName),

          h_(IOobject("h",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",  dimless, 0.0)),
         x_(IOobject("x",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",  dimless, 0.0)),
         U_(IOobject("U",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",  dimless, 0.0)),    
         rhonew_(IOobject("rhonew",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",  dimless, 0.0)),
         rhog_(IOobject("rhog",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",  dimensionSet(1,-3, 0, 0, 0, 0, 0) ,1.0)),
       rhoBar_(IOobject("rhoBar",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",dimDensity  ,0.0))
    
{
     calcRhoBar(x,h);

  
   if (U.time().timeName() == "0" && rhoOverwrite == 1)
       if (this->owner_.mesh().time().timeName() == "0" && rhoOverwrite == 1)
   {       
      Info<< 
    "WARNING: Over-riding initial condition and changing the density to the equilibrium value. \n";
      rhonew = rhoBar_;
      rhonew.correctBoundaryConditions();
   }


}

template<class CloudType>
Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomization
(
    const HRMLISAAtomization<CloudType>& am
)
:
    AtomizationModel<CloudType>(am),
      h_(am.h_),
        x_(am.x_),
        rhonew_(am.rhonew_), 
        rhog_(am.rhog_),
       rhoBar_(am.rhoBar_)
       
{}
However, when I compile the code, I am getting an error variables x, U, h are not defined. Is there a way to access these field variables.

Thanks a lot
vishal_s is offline   Reply With Quote

Old   September 9, 2018, 10:31
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
How is your header file of the class?
There you have do define the quantities.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 9, 2018, 10:56
Default
  #6
Member
 
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13
vishal_s is on a distinguished road
Thanks Tobi for the prompt reply.

I am attaching my .C and .H files, Kindly share some insight regarding the error I have mentioned above.

Thanks.
Attached Files
File Type: zip HRMLISAAtomization_.zip (4.9 KB, 5 views)
vishal_s is offline   Reply With Quote

Old   September 9, 2018, 11:09
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
I have no time to compile your stuff (compile it myself) but can you please add the error message. Thanks.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 9, 2018, 11:28
Default
  #8
Member
 
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13
vishal_s is on a distinguished road
Hi Tobi,

The error message is as follows:

Quote:
In file included from lnInclude/HRMLISAAtomization.H:164:0,
from lnInclude/makeSprayParcelAtomizationModels.H:34,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/HRMLISAAtomization.C: In constructor ‘Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomi zation(const Foam::dictionary&, CloudType&)’:
lnInclude/HRMLISAAtomization.C:52:35: error: ‘U’ was not declared in this scope
thermPoint1(thermoBase::New(U,IOobject("tPoint",th is->owner_U.mesh().time().constant(),this->owner_U.db(),IOobject::NO_READ,IOobject::NO_WRITE ,true))),
^
lnInclude/HRMLISAAtomization.C:78:5: error: ‘pcritical’ was not declared in this scope
if(pcritical)
^
lnInclude/HRMLISAAtomization.C:81:24: error: declaration of ‘const Foam::IOdictionary& dict’ shadows a parameter
const IOdictionary& dict = db().lookupObject<IOdictionary>("thermophysicalPro perties");
^
lnInclude/HRMLISAAtomization.C:81:35: error: there are no arguments to ‘db’ that depend on a template parameter, so a declaration of ‘db’ must be available [-fpermissive]
const IOdictionary& dict = db().lookupObject<IOdictionary>("thermophysicalPro perties");
^
lnInclude/HRMLISAAtomization.C:81:35: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
lnInclude/HRMLISAAtomization.C:81:62: error: expected primary-expression before ‘>’ token
const IOdictionary& dict = db().lookupObject<IOdictionary>("thermophysicalPro perties");
^
lnInclude/HRMLISAAtomization.C:86:15: error: ‘x’ was not declared in this scope
calcRhoBar(x,h);
^
lnInclude/HRMLISAAtomization.C:86:17: error: ‘h’ was not declared in this scope
calcRhoBar(x,h);
^
lnInclude/HRMLISAAtomization.C:86:17: note: suggested alternative:
In file included from /home/avick/OpenFOAM/OpenFOAM-2.4.0/src/OpenFOAM/lnInclude/constants.H:46:0,
from /home/avick/OpenFOAM/OpenFOAM-2.4.0/src/lagrangian/turbulence/lnInclude/StochasticDispersionRAS.C:27,
from /home/avick/OpenFOAM/OpenFOAM-2.4.0/src/lagrangian/turbulence/lnInclude/StochasticDispersionRAS.H:103,
from /home/avick/OpenFOAM/OpenFOAM-2.4.0/src/lagrangian/turbulence/lnInclude/makeParcelTurbulenceDispersionModels.H:32,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:34:
/home/avick/OpenFOAM/OpenFOAM-2.4.0/src/OpenFOAM/lnInclude/fundamentalConstants.H:52:36: note: ‘Foam::constant::universal::h’
extern const dimensionedScalar h;
^
In file included from lnInclude/HRMLISAAtomization.H:164:0,
from lnInclude/makeSprayParcelAtomizationModels.H:34,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/HRMLISAAtomization.C:98:7: error: ‘rhonew’ was not declared in this scope
rhonew = rhoBar_;
^
lnInclude/HRMLISAAtomization.C: In copy constructor ‘Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomi zation(const Foam::HRMLISAAtomization<CloudType>&)’:
lnInclude/HRMLISAAtomization.C:118:23: error: expected ‘(’ before ‘thermPoint1’
autoPtr<thermoBase> thermPoint1(am.thermPoint1), //Added
^
lnInclude/HRMLISAAtomization.C:118:23: error: expected ‘{’ before ‘thermPoint1’
lnInclude/HRMLISAAtomization.C: At global scope:
lnInclude/HRMLISAAtomization.C:118:34: error: expected constructor, destructor, or type conversion before ‘(’ token
autoPtr<thermoBase> thermPoint1(am.thermPoint1), //Added
^
In file included from lnInclude/makeSprayParcelAtomizationModels.H:34:0,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/HRMLISAAtomization.C: In instantiation of ‘Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomi zation(const Foam::dictionary&, CloudType&) [with CloudType = Foam::SprayCloud<Foam::ReactingCloud<Foam::ThermoC loud<Foam::KinematicCloud<Foam::Cloud<Foam::SprayP arcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam ::KinematicParcel<Foam:article> > > > > > > > >]’:
lnInclude/AtomizationModel.H:64:5: required from ‘static Foam::autoPtr<Foam::AtomizationModel<CloudType> > Foam::AtomizationModel<CloudType>::adddictionaryCo nstructorToTable<AtomizationModelType>::New(const Foam::dictionary&, CloudType&) [with AtomizationModelType = Foam::HRMLISAAtomization<Foam::SprayCloud<Foam::Re actingCloud<Foam::ThermoCloud<Foam::KinematicCloud <Foam::Cloud<Foam::SprayParcel<Foam::ReactingParce l<Foam::ThermoParcel<Foam::KinematicParcel<Foam: article> > > > > > > > > >; CloudType = Foam::SprayCloud<Foam::ReactingCloud<Foam::ThermoC loud<Foam::KinematicCloud<Foam::Cloud<Foam::SprayP arcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam ::KinematicParcel<Foam:article> > > > > > > > >]’
lnInclude/AtomizationModel.H:64:5: required from ‘Foam::AtomizationModel<CloudType>::adddictionaryC onstructorToTable<AtomizationModelType>::adddictio naryConstructorToTable(const Foam::word&) [with AtomizationModelType = Foam::HRMLISAAtomization<Foam::SprayCloud<Foam::Re actingCloud<Foam::ThermoCloud<Foam::KinematicCloud <Foam::Cloud<Foam::SprayParcel<Foam::ReactingParce l<Foam::ThermoParcel<Foam::KinematicParcel<Foam: article> > > > > > > > > >; CloudType = Foam::SprayCloud<Foam::ReactingCloud<Foam::ThermoC loud<Foam::KinematicCloud<Foam::Cloud<Foam::SprayP arcel<Foam::ReactingParcel<Foam::ThermoParcel<Foam ::KinematicParcel<Foam:article> > > > > > > > >]’
parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:75:5: required from here
lnInclude/HRMLISAAtomization.H:102:21: warning: ‘Foam::HRMLISAAtomization<Foam::SprayCloud<Foam::R eactingCloud<Foam::ThermoCloud<Foam::KinematicClou d<Foam::Cloud<Foam::SprayParcel<Foam::ReactingParc el<Foam::ThermoParcel<Foam::KinematicParcel<Foam:: particle> > > > > > > > > >::rhoMin_’ will be initialized after [-Wreorder]
dimensionedScalar rhoMin_; //Added
^
lnInclude/HRMLISAAtomization.H:84:16: warning: ‘Foam::vector Foam::HRMLISAAtomization<Foam::SprayCloud<Foam::Re actingCloud<Foam::ThermoCloud<Foam::KinematicCloud <Foam::Cloud<Foam::SprayParcel<Foam::ReactingParce l<Foam::ThermoParcel<Foam::KinematicParcel<Foam: article> > > > > > > > > >::injectorDirection_’ [-Wreorder]
vector injectorDirection_;
^
In file included from lnInclude/HRMLISAAtomization.H:164:0,
from lnInclude/makeSprayParcelAtomizationModels.H:34,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/HRMLISAAtomization.C:32:1: warning: when initialized here [-Wreorder]
Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomiz ation
^
In file included from lnInclude/HRMLISAAtomization.H:164:0,
from lnInclude/makeSprayParcelAtomizationModels.H:34,
from parcels/derived/basicSprayParcel/makeBasicSprayParcelSubmodels.C:48:
lnInclude/HRMLISAAtomization.C:81:90: error: declaration of ‘const Foam::IOdictionary& dict’ shadows a parameter
const IOdictionary& dict = db().lookupObject<IOdictionary>("thermophysicalPro perties");
^
lnInclude/HRMLISAAtomization.C:81:35: error: ‘db’ was not declared in this scope
const IOdictionary& dict = db().lookupObject<IOdictionary>("thermophysicalPro perties");

I have defined h,x, U, rhoNew in the header file and still getting the above mentioned error.

Thanks.
Attached Files
File Type: c HRMLISAAtomization.C (8.7 KB, 3 views)
File Type: h HRMLISAAtomization.H (4.6 KB, 2 views)
vishal_s is offline   Reply With Quote

Old   September 9, 2018, 14:55
Default
  #9
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi, the error
Code:
thermPoint1(thermoBase::New(U,IOobject("tPoint",this->owner_U.mesh().time().constant(),this->owner_U.db(),IOobject::NO_READ,IOobject::NO_WRITE   ,true))),
tells me that there is something wrong:


Code:
owner_U ???
I cannot see anything related to owner_U, maybe you ment something different? Additionally the first quantity U is not defined anywhere.
__________________
Keep foaming,
Tobias Holzmann
Tobi 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
Adding New Drag Model to MPPICFoam surajkvs OpenFOAM Running, Solving & CFD 0 May 4, 2018 05:03
howto model species transport with additional variable? suiger CFX 2 December 25, 2017 05:55
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 08:00
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas COMSOL 1 May 30, 2008 05:35
Fortran variable ED for K-OMEGA model Viatcheslav Anissimov CFX 0 August 31, 2000 07:41


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