Since, you are about to create your own relativeVelocityModel, which is a separate compilation unit than the solver itself, you need to include the header file for the appropriate data type. Secondly, you can look-up the gravity field from the object data base of OpenFOAM.
In the code below, the necessary include statement as well as the construction by look-up is listed. You might want to put the include statement into the header of your relativeVelocityModel class, and the look-up statement into the function-body of your Udm() method, or whereever you need to access gravity. Code:
// include data type, if necessary |
Hi Gerhard, thank you for your post.
I have not yet been able to solve the problem! I am creating an alternative relative velocity model (simple and general are the default models) called general2 and I would like to define Udm within the general2.C file. If I declare Code:
uniformDimensionedVectorField g I feel there must be a way to simply read the g file located in the constant folder without having to read it from the mesh itself? Could I somehow get transportProperties to read it for me and then just take it from transportProperties with all the other parameters? |
Quote:
If you take a look at the constructor of the base class for the relative velocity models, especially, the second and third argument of the IOobject constructor, shows you how to get a reference to the mesh and the run-time objects. Code:
Foam::relativeVelocityModel::relativeVelocityModel There is no need to read gravity from the constant directory again, as it has been already read. And it has been registered with the mesh, hence you can use object lookup. Which is done e.g. in twoPhaseEulerFoam/twoPhaseSystem/diameterModels/IATE/IATEsources/IATEsource/IATEsource.C The whole purpose of OpenFOAM's object registry is to avoid every class reading fields on their own. If the solver and the drag model would read the velocity field independently, you end up with two independent copies of U. If the solver updates U, then the drag models needs to be told, that its copy of U is now outdated. This is a can of worms nobody really wants opened. Thus, you get yourself a reference to the one and only velocity field, which is by virtue of being the only one, always up to date. |
Hi Gerhard,
Thanks again for your help and explaining about the OF objectRegistry. I was eventually able to implement g in the following way: Code:
g_ |
All times are GMT -4. The time now is 00:45. |