Construct and return a clone - trying to understand this
Hi,
I am trying to understand openfoam coding and I have come across this piece of code to often. What does this do? It located in /src/lagrangian/parcel/submodels/Momentum/ParticleForces/Gravity/GravityForce.H PHP Code:
In /src/lagrangian/parcel/submodels/ForceTypes/ParticleForceList/ParticleForceList.C I do see a piece of code PHP Code:
|
Too many questions all at once. Which is your first one?
|
Thanks Mark, lets go top top bottom as I understand the flow goes from:
1) ParticleForceList 2) ParticleForce 3) Individual particle forces for eg: gravity As I understand in ParticleForceList.C it reads user defined input for particles forces and based on user input it invokes PHP Code:
Ques2) In object particleForce object and also individual particle forces (eg gravity) there is base constructor and a clone of it. Also below it there is PHP Code:
Really appreciate your help! |
Quote:
To understand the benefit of the clone() method, consider not having it - what would that look like for the following task? Make a copy of an item. If we know the type is "ABaseClass", we can write that, but what about "BDerivedClass" and "CDerivedClass" ? How would you create a copy of each list item, which derived from "A"? Enter the clone() method. Since it is virtual, it "knows" it's own type. Call it, and you get the copy you were looking for without knowing the type. |
Thank you the explanation, as wannabe openFoam programmer, can you recommend any examples/keywords/lookups videos that can help one understand this, with out the additional baggage of dealling with 100's of differnet files? Anything that you used to self learn and climb the ladder up?
Thanks once again |
Quote:
Like any natural language, it takes time and practice to become reasonably fluent. |
All times are GMT -4. The time now is 23:56. |