|
[Sponsors] |
Lagrangian library: Edit particle properties within force calculation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 12, 2016, 06:22 |
Lagrangian library: Edit particle properties within force calculation
|
#1 |
Member
Join Date: Sep 2010
Location: Leipzig, Germany
Posts: 96
Rep Power: 16 |
Dear Foamers,
I have a problem with the lagrangian intermediate library. My goal is to have access to certain particle properties (e.g. d, U, ...) from within the calculation of a force I'm trying to implement. Unfortunately, the forces are called with code similar to this (from SphereDragForce.C): Code:
template<class CloudType> Foam::forceSuSp Foam::SphereDragForce<CloudType>::calcCoupled ( const typename CloudType::parcelType& p, const scalar dt, const scalar mass, const scalar Re, const scalar muc ) const Code:
error: passing 'const parcelType {aka const Foam::KinematicParcel<Foam::particle>}' as 'this' argument of 'void Foam::KinematicParcel<ParcelType>::d() [with ParcelType = Foam::particle]' discards qualifiers [-fpermissive] p.d(); So my question is: How can I access distinct parcel properties from within the force calculation? Thanks in advance! |
|
January 12, 2016, 08:09 |
|
#2 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
If the parcel is passed as the constant reference to a function, it's object should not be changed.
Why should a function that computes a force density from particles/parcels be able to change the particle/parcel properties? Your question: Quote:
What is it you want to do? Please do not use C++ terms and use Lagrangian terms in answering the question. If you are trying to implement only force calculation, you should not modify parcel properties. If your function is computing the force and doing something else to the parcels (modifying them), you should consider refactoring the function into two of them: one for force calculatio, the other function for the property modification. Obviously, property modification will have to happen outside the force calculation function, that does not, and should not, change parcel properties.
__________________
When asking a question, prepare a SSCCE. |
||
January 12, 2016, 08:37 |
|
#3 |
Member
Join Date: Sep 2010
Location: Leipzig, Germany
Posts: 96
Rep Power: 16 |
Dear Tomislav,
thank you very much for your answer. I'm trying to implement the Basset or History Force. For this purpose I need to store for example old values of this force and certain other values for every particle, which are not available outside the force calculation and which are also needed to be written out for a restart of calculations. The diameter in the original post was just an example, I'm not trying to change "usual" particle porperties as density, diameter, ... Sometimes it's a bit strange... I tried on this for several days now, but within some minutes after my post I found out that adapting the force calls in forceSuSp.C/H and ParticleForce.C/H was the solution to my problem. But if you (Tomislav) or anyone else has an approach were I wouldn't have to change the const-definitions I would be glad to here about it! |
|
January 13, 2016, 09:03 |
|
#4 | |||
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Just a few ideas on how to attack this without breaking the function signatures/changing the intermediate library:
Quote:
Quote:
Quote:
This is just a rough sketch, but by checking the code, it is prepared for extension without tampering with the intermediate library...
__________________
When asking a question, prepare a SSCCE. |
||||
January 13, 2016, 11:06 |
|
#5 |
Member
Join Date: Sep 2010
Location: Leipzig, Germany
Posts: 96
Rep Power: 16 |
Thank you again for your answer!
I wasn't really correct or specific enough in my last post. I don't only need the force values itself, but also some values that are calculated inside the force calculation. I want to calculate the Basset force according to Hinsberg, Boonkamp, Clercx (2010): "An efficient, second order method for the approximation of the Basset history force". In principal, this force needs an integral over the whole path of the particle, which is quite time and memory consumptive. The approach of Hinsberg et al is to split this in the calculation of a "window" term (e.g. the last five time steps), where the actual values are calculated and an approximated "tail". This tail is modeled with 10 exponential functions and each is split in a direct and a recursive part. The value of each of the 10 functions is then used in the next time step for the recursive part. Do you see any chance to keep these values? It would also be okay if they are lost when the calculation stops. |
|
January 14, 2016, 13:26 |
|
#6 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
You're welcome! I've just browsed through the paper you mentioned. As far as I understand it, it would be possible to compute something like this, with the code extensions I proposed in the previous post. You need a Basset parcel/particle that stores the data needed for the force calculation within a prescribed range of time steps, and a Basset force calculator that expects the same data to be provided by the parcel / particle.
Since the force calculator is templated: Code:
template<class CloudType> Foam::forceSuSp Foam::SphereDragForce<CloudType>::calcCoupled (const typename CloudType:parcelType& p, In any case, the article defines your classes and extensions, exactly like your second post - you have a parcel with extended information and a new force calculator that expects that info.
__________________
When asking a question, prepare a SSCCE. |
|
January 20, 2016, 09:39 |
|
#7 |
Member
Join Date: Sep 2010
Location: Leipzig, Germany
Posts: 96
Rep Power: 16 |
Thank you again, Tomislav! At the moment it's working with the not-so-nice const-removal and I'm doing my simulations with it, because I'm in a hurry (deadline's coming near...). But I'll try to switch to your approach when I have the time for it.
|
|
January 20, 2016, 09:54 |
|
#8 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Your're welcome! Don't worry about breaking the interface a bit, you'll have time to refactor once the results are there. I usually open issues on bitbucket so that I don't forget what I planned for code cleanup. Deadlines are definitely more important than clean code, good luck!
__________________
When asking a question, prepare a SSCCE. |
|
April 5, 2018, 12:47 |
|
#9 |
Member
Joaquín Neira
Join Date: Oct 2017
Posts: 38
Rep Power: 9 |
I'm working with the same algorithm, and so far I've managed to do this in a new BassetForce class (using the same structure as existing forces):
Code:
// Private data // Constantes Basset const scalar N; //pasos basset // scalar C1_; //tiempo inicial (0) scalar C2_; //tiempo final (N) scalarList C3_; //tiempos intermedios (n) Code:
template<class CloudType> Foam::BassetForcePM<CloudType>::BassetForcePM ( CloudType& owner, const fvMesh& mesh, const dictionary& dict ) : ParticleForce<CloudType>(owner, mesh, dict, typeName, true), N(readScalar(this->coeffs().lookup("N"))) { C2_ = (N-4/3)/((N-1)*sqrt(N-1)+(N-3/2)*sqrt(N)); C3_.setSize(N-1); scalar k; forAll(C3_, i) { k=i+1.0; C3_[i] = (k+4.0/3.0)/((k+1.0)*sqrt(k+1.0)+(k+3.0/2.0)*sqrt(k)) + (k-4.0/3.0)/((k-1.0)*sqrt(k-1.0)+(k-3.0/2.0)*sqrt(k)); } } Should (and can I?) do this in the Basset code or I must modify the kinematicParcel code? |
|
Tags |
lagrangian, openfoam, particle |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting the height of the stream in the free channel | kevinmccartin | CFX | 12 | October 13, 2022 22:43 |
Adding material to CFX material library | marlon | CFX | 2 | October 16, 2016 10:33 |
Particle Trajectory calculation | yueroo | FLUENT | 2 | July 13, 2009 14:32 |
model particle movement under magnetic force | phsieh2005 | Main CFD Forum | 8 | March 28, 2007 08:12 |
Particle Trajectory calculation when particle hit | yueroo | FLUENT | 2 | February 28, 2001 05:26 |