CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   where is the function "addField" defined? (https://www.cfd-online.com/Forums/openfoam/217822-where-function-addfield-defined.html)

SAIKRISHNA N May 26, 2019 04:15

where is the function "addField" defined?
 
Hello Foamers,
I am going through the source code in reactingEulerFoam in OpenFOAM 6. I have found a function addField, for example, in momentumTransferPhaseSystem.C as
Code:

this->addField
          (
              pair.phase1(),
              "phiF",
              fvc::flux(rAUs[pair.phase1().index()]*F),
              phiFs
          );

The function is declared in phaseSystem.H as

Code:

  //- Add the field to a phase-indexed list, with the given name,
          //  constructing if necessary
          template<class GeoField>
          void addField
          (
              const phaseModel& phase,
              const word& fieldName,
              tmp<GeoField> field,
              PtrList<GeoField>& fieldList
          ) const;

But, I could not find the definition anywhere.
I would like to know what exactly this function does and where is it defined.
Because, this function is used to add interfacial transfer forces to momentum conservations equations in momentumTransferPhaseSystem.C multiple times and also used many other places in this solver.
I want to understand whether this function algebraically adds "field" to the already existing field referenced by "fieldName" which is in "fieldList"?

jherb May 30, 2019 10:25

Searching for it on github (https://github.com/OpenFOAM/OpenFOAM...ped_q=addField) finds this:


https://github.com/OpenFOAM/OpenFOAM...temTemplates.C

SAIKRISHNA N May 30, 2019 11:12

Dear Joachim herb,
Thank you very much. I don't know how this file got skipped while going through the code.
After going through the definition in phaseSystemTemplates.C, I understand that "addField" is algebraically adding the "field" supplied into the existing location (or will create new location) in the "fieldList".
let us say, if field "a" as values 5 stored in it. if I use this addField on this with field = 2, then the result would be a=7.
Am I right?

jherb May 31, 2019 08:44

What do you mean with algebraically adding? The fields are referenced by the phase.index(). Otherwise, I think you are correct: If there is no entry for a certain phase.index(), a new one is created and the field argument put insert at this index. Otherwise the field is added to the existing value.

SAIKRISHNA N May 31, 2019 13:07

Yes. That is exactly what I am saying. It matches with the context of this function as well.

Now it's all clear.



Thank you :-)


All times are GMT -4. The time now is 10:55.