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

Adding new parameters and auto fill them in the constructor

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 16, 2016, 06:04
Default Adding new parameters and auto fill them in the constructor
  #1
New Member
 
Join Date: Mar 2016
Posts: 1
Rep Power: 0
Bob Dylan is on a distinguished road
Hello OpenFOAM users,

I've got a question on some coding I did recently and what I haven't been able to get to work yet.


In our team we are doing a simulation of particles moving in a solution through a tube. We reworked one of the lagrangian solvers (I'm afraid I cannot tell you which one it is atm, but that doesn't go into account too much) and implemented a dielectrophoretic force, that eventually stops the particles moving in the solution.

So far everything goes fine, the particles really stop moving at the desired point, but now I want to implement a little if query that makes the solver stop trying to move the particle, when it hasn't moved for the last 3 steps. Therefore i could reduce the amount of calculation needed for the simulation.

So I did the following:
in the src/lagrangian/basic/particle library I added in particle.H in

Code:
 public:

        // Public data

            typedef CloudType cloudType;

            //- Flag to switch processor
            bool switchProcessor;

            //- Flag to indicate whether to keep particle (false = delete)
            bool keepParticle;
the following line:

Code:
//- Flag to stop particle from moving without deleting
        bool moveParticle;
and in the protected data I added

Code:
//- List of last 3 positions
    FixedList<scalar, 3> positionHistory_;
The idea of the list is, to save the last 3 positions of the particle and when the difference of the positions becomes smaller then a certain moving tolerance, the "moveParticle" flag should be turned to false.

In the particle.C file I added in every constructor:
Code:
positionHistory_
    (
    0.0
    0.0
    0.0
    )
cause the particles should be initialised with an empty positionHistory.

When I try to compile this, i get the output:

particle/particle.C:68:2: error: expected ) before numeric constant
0.0

But even if I put brackets around the scalars nothing changes on the error message.

Thats been a lot of text so far, but I hope you will be able to help me.

Greetings BD
Bob Dylan is offline   Reply With Quote

Old   March 16, 2016, 15:12
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 436
Rep Power: 14
marupio is on a distinguished road
Does your version of code have:

FixedList.H
Code:
        //- Construct from value
        inline FixedList(const T&);
If so, you can just use one 0.0. i.e. positionHistory_(0.0). Or if there's a constructor that converts from UList<T>, then you can use a vector: positionHistory_(vector::ZERO).

I don't know of any easy way to initialise a list in one line. atomicWeights.C does something like this, though. You could also create a static function that returns a fixedList with 0.0 set for all elements, and call that in the constructor initialisation list for each constructor.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:37.