CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   bubbleFoam validation case (https://www.cfd-online.com/Forums/openfoam-solving/79302-bubblefoam-validation-case.html)

alberto August 30, 2010 01:58

Quote:

Originally Posted by balkrishna (Post 273299)
Thanks for the link .... Can i get the source code of the solver ?? The implementation of the algorithm is the tough aspect in OpenFOAM .....

Try to contact the Authors of the paper. I believe the code was not released, and it is surely not part of OpenFOAM and OpenFOAM-dev/-ext.

Best,

balkrishna August 30, 2010 02:11

Ok .... Thanks

alberto August 30, 2010 03:05

Quote:

Originally Posted by balkrishna (Post 273301)
Ok .... Thanks

I can give you some hints which are not explained anywhere in the OF documentation (top secret! :D), and are quite useful to carry around a lot of fields, as required in multiphase simulations.

Let's assume you have N phases. You will have to define:

- N momentum equations (N velocity fields and N fvVectorMatrices)

- N*(N-1)/2 interaction fields (meaning relative velocities, drag coefficients, ...)

- N-1 phase fraction equations (assuming one fraction is computed as alpha_0 = 1-sum(alpha_i), i != 0. You will need N phase fraction fields for this.

- 1 pressure equation based on the mixture

As you can easily imagine, if N is arbitrary, coding this can be messy, if not done with proper care.

You can collect your phase fields and equations (also objects if you want) for each property in a PtrList (http://foam.sourceforge.net/doc/Doxy..._1PtrList.html).

I will give you an example for the relative velocity fields:

First define:

Code:

const nUr = N*(N-1)/2;
You can define
Code:

PtrList<volScalarField> Ur(nUr);
Then, each field has to be actually initialized with
Code:

forAll (Ur, urI)
{
    Ur.set
    (
      urI,
      yourFieldInitialization
    );
}

To access the relative velocity of index i, you simply have to use

Code:

Ur[i]()
Note the (), because you are actually working with a PtrList now, so you have to invoke the corresponding method that returns the field (or a reference to it)!

The same operation can be done with equations:

Code:

PtrList<fvVectorMatrix> UEqn(N);

forAll (UEqn, uEqnI)
{
    UEqn.set
    (
        fvm::ddt(U())
      + ...
      ==
        ...
    );
}

To solve, you loop again over the PtrList, and for each equation, you have to do

Code:

solve (UEqn[uEqnI]() == ...);
More good news! If you consider twoPhaseEulerFoam, instead than bubbleFoam, which is actually a bit more ready to be extended to N phases, you will notice that all the properties of a phase are collected in the phaseModel object.
Of course you can create a ptrList of the phaseModel object, and further simplify your work. If you decide to do this, I would suggest to incorporate alpha in the phaseModel, since it is currently not there, or you have an inconsistent syntax that becomes annoying with many phases.

Last hint: since you are beginning with OpenFOAM from what I read, proceed step by step, and ask questions (poking me by email is allowed too, I do not bite :D, and I usually answer if I can).

Best,

balkrishna August 30, 2010 03:42

thats clean .... i was about to write python programs to output the necessary files .... In that way , I can take the user input and just write out the files . However the approach requires the compilation of the source code evrytime you specify different number of components ....

alberto August 30, 2010 04:37

No :)

You simply have to read the number of phases from a dictionary (label nPhases, being it integer), before allocating the PtrList objects ;-)

Something similar is done in OF for the species in reacting solvers, and in multiphaseInterFoam, but in this last solver the implementation of what they called mixture class abuses a bit of C++ functionality, making the code quite unreadable (never a good idea!).

Best,


All times are GMT -4. The time now is 13:27.