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

Add new particle force with input parameters

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ycui

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 17, 2016, 12:33
Default Add new particle force with input parameters
  #1
New Member
 
Join Date: Nov 2016
Posts: 16
Rep Power: 10
ycui is on a distinguished road
Dear All,

I'm implementing a new particle force with two input parameters. And I want these two parameters can be read from input file (/constant), then I do not need to compile for every runs. The way I did as following:

Quote:
IOdictionary environmentalProperties
(
IOobject
(
"environmentalProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

scalar a(readScalar(environmentalProperties.lookup("a"))) ;
scalar b(readScalar(environmentalProperties.lookup("b"))) ;
However, during compiling, errors occurs:
Quote:
error: ‘runTime’ was not declared in this scope
error: ‘mesh’ was not declared in this scope
I need your help!

Greetings,

ycui
ycui is offline   Reply With Quote

Old   November 17, 2016, 12:41
Default
  #2
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 21
floquation will become famous soon enough
(Please use code-tags, not quote-tags for code.)

The error is quite clear: the variables 'runTime' and 'mesh' do not exist at the position where you inserted your code.

So where exactly did you insert this piece of code?
floquation is offline   Reply With Quote

Old   November 17, 2016, 12:44
Default
  #3
New Member
 
Join Date: Nov 2016
Posts: 16
Rep Power: 10
ycui is on a distinguished road
Quote:
Originally Posted by floquation View Post
(Please use code-tags, not quote-tags for code.)

The error is quite clear: the variables 'runTime' and 'mesh' do not exist at the position where you inserted your code.

So where exactly did you insert this piece of code?
In: /home/ycui/OpenFOAM/ycui-2.3.1/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/

I try to use this->mesh().time() and this->mesh(), but doesn't works.
ycui is offline   Reply With Quote

Old   November 17, 2016, 13:21
Default
  #4
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 21
floquation will become famous soon enough
The mesh and runTime variables are part of the solver. The thing you are changing is a library used by the solver - but it has no knowledge of what is going on inside your solver. It is just doing its own thing.

To find out how to do this, use search commands:
Code:
cd ${FOAM_SRC}/lagrangian/intermediate/submodels/Kinematic/ParticleForces/
grep -rn "IOobject" .
This will teach you that OpenFoam has no example for you specifically related to ParticleForces. Going up one directory:
Code:
cd ${FOAM_SRC}/lagrangian/intermediate/submodels/Kinematic/
grep -rn "IOobject" .
Will give you (amongst other examples) the file:
Code:
vi ./PatchInteractionModel/LocalInteraction/LocalInteraction.C +122
where the following may be seen:
Code:
template<class CloudType>
Foam::volScalarField& Foam::LocalInteraction<CloudType>::massEscape()
{
    if (!massEscapePtr_.valid())
    {
        const fvMesh& mesh = this->owner().mesh();

        massEscapePtr_.reset
        (
            new volScalarField
            (
                IOobject
                (
                    this->owner().name() + ":massEscape",
                    mesh.time().timeName(),
                    mesh,
                    IOobject::READ_IF_PRESENT,
                    IOobject::AUTO_WRITE
                ),
                mesh,
                dimensionedScalar("zero", dimMass, 0.0)
            )
        );
    }

    return massEscapePtr_();
}
Can you try and see if that compiles for a ParticleForce?
floquation is offline   Reply With Quote

Old   November 24, 2016, 05:18
Default
  #5
New Member
 
Join Date: Nov 2016
Posts: 16
Rep Power: 10
ycui is on a distinguished road
Dear floquation,

Thank you very much for the answer.

I found a simple way to do this, just add

Quote:
myParameter_(readScalar(this->coeffs().lookup("myParameter")))
in the constructor. Then the code can read from the input file.

However, your method would be very helpful when one reads a time dependent parameter.

Thank you again,

Best regards,

ycui
floquation likes this.
ycui is offline   Reply With Quote

Old   March 22, 2017, 12:46
Default
  #6
New Member
 
Shuai Yuan
Join Date: Nov 2016
Posts: 29
Rep Power: 10
sy2516 is on a distinguished road
Hey,

Can you help me to implement a new force to OpenFOAM? I really appreciate it. Thank you in advance.
sy2516 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
[PyFoam] and paraview eelcovv OpenFOAM Community Contributions 28 May 30, 2016 10:23
particles leave domain Steffen595 CFX 9 March 7, 2016 17:19
About the dimension of Saffman-Mei particle lift force model haakon OpenFOAM Programming & Development 1 April 22, 2013 13:27
model particle movement under magnetic force phsieh2005 Main CFD Forum 8 March 28, 2007 08:12
Setting particle parameters Mark FLUENT 0 April 22, 2004 13:13


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