CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   multiphaseEulerFoam v8: PhaseSystems - help understanding typedefs (https://www.cfd-online.com/Forums/openfoam-programming-development/236369-multiphaseeulerfoam-v8-phasesystems-help-understanding-typedefs.html)

perao May 27, 2021 00:11

multiphaseEulerFoam v8: PhaseSystems - help understanding typedefs
 
Hi,

to make it short I am going straight to the point. My apologies for the lack of accuracy with the language and/or technicalities with regards to either the programming language or the OpenFOAM's code terminologies.

For the solver in the subject we find under the multiphaseSystem.C all the aliases for the multiphase system types (the ones we must specify in constant/phaseProperties when setting up a case). For example:

Code:

    typedef
        ThermalPhaseChangePhaseSystem
        <
            PhaseTransferPhaseSystem
            <
                TwoResistanceHeatTransferPhaseSystem
                <
                    MomentumTransferPhaseSystem<phaseSystem>
                >
            >
        >
        thermalPhaseChangeMultiphaseSystem;

    addNamedToRunTimeSelectionTable
    (
        phaseSystem,
        thermalPhaseChangeMultiphaseSystem,
        dictionary,
        thermalPhaseChangeMultiphaseSystem
    );

Questions:

1.The parameter that is past to these PhaseSystems is the phaseSystem class. Is it correct to say that all these typedefs are also a phaseSystem?

2.Most of member functions used by these PhaseSystems come from the phaseSystem class. For example, the pure virtual member function:
Code:

virtual autoPtr<momentumTransferTable> momentumTransfer() = 0
. Now, looking at the innermost class within the above typedef, i.e., the MomentumTransferPhaseSystem, we find this such member function declaration and definition.

In .H:

Code:

virtual autoPtr<phaseSystem::momentumTransferTable> momentumTransfer();
In .C:

Code:

template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::momentumTransferTable>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransfer()
{ <body's function> }

Moving outwards in the typedef, we pass through the TwoResistanceHeatTransferPhaseSystem class, then this is past to PhaseTransferPhaseSystem class. However, in the latter, we find once more the declaration and the definition of
Code:

momentumTransfer()
.

In .H:

Code:

virtual autoPtr<phaseSystem::momentumTransferTable> momentumTransfer();
In .C:

Code:

template<class BasePhaseSystem>
Foam::autoPtr<Foam::phaseSystem::momentumTransferTable>
Foam::PhaseTransferPhaseSystem<BasePhaseSystem>::momentumTransferf()
{
    autoPtr<phaseSystem::momentumTransferTable> eqnsPtr =
        BasePhaseSystem::momentumTransferf();

    phaseSystem::momentumTransferTable& eqns = eqnsPtr();

    this->addDmdtUfs(totalDmdtfs(), eqns);

    return eqnsPtr;
}

a.Since the PhaseTransferPhaseSystem is a class that deals with mass transfer, is it correct to assume that the momentum appears here again in order to be taken into account as a consequence of the mass transfer process?


b.If so, this is why the MomentumTransferPhaseSystem is an inner class in this typedef, so that by using
Code:

BasePhaseSystem::momentumTransferf()
the PhaseTransferPhaseSystem class is actually using the momentum modeling available under the BasePhaseSystem instead of providing a new one?



There are other member functions that could be used in place of the
Code:

momentumTransfer()
, but I guess that the same rationale applies to the others as well.



Extra question: If someone would be able to explain better these templated classes under PhaseSystem which are of type BasePhaseSystem, but at the same time inherits from BasePhaseSystem itself, it would be a great help.

Thank you very much for your time.

perao May 27, 2021 16:44

Well, after talking to someone that knows the code much better than I do, the answers for the question 2 are:


a.Yes, the momentumTransfer() is a necessary member function to account for the mass transfer process, which is not modeled in the MomentumTransferPhaseSystem class, hence it does not exist in the inherited code.


b.Basically, the momentumTransfer() declared/defined in PhaseTransferPhaseSystem is just adding new momentum sources on top of the already existent in MomentumTransferPhaseSystem.

perao June 1, 2021 07:36

As for the extra question, a quick explanation is given here ( http://www.researchgate.net/publicat...le_user_manual on page 203), which uses KinematicParcel rather than BasePhaseSystem as an example.


First the code snippet:


Code:

template < class ParcelType >
class KinematicParcel
:
    public ParcelType
{
public :
    /* the rest of the code ... */

And now the explanation:


Quote:

The class KinematicParcel is an example for the hardships one faces when trying to understand C++. KinematicParcel is a templated class, with ParcelType as template parameter. In addition KinematicParcel also is derived from its template parameter ParcelType.
Thus, KinematicParcel is a templated class built around ParcelType, however, it is a ParcelType too (by inheritance).


All times are GMT -4. The time now is 03:29.