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: method mag(...) withing method solveAlphase() (https://www.cfd-online.com/Forums/openfoam-programming-development/127810-multiphaseeulerfoam-method-mag-withing-method-solvealphase.html)

maybee December 21, 2013 10:13

multiphaseEulerFoam: method mag(...) withing method solveAlphase()
 
hi,

within method solveAlphas in file multiphaseSystem.C of the multiphaseEulerFoam solver is found:

Code:

//SNIPPET 1
(mag(phi_) + mag(phase1.phi() - phase2.phi()))/mesh_.magSf()

where phi_ is "const surfaceScalarField& phi_ in multiphasesystem.H" and therefore the first mag method is:

Code:

//SNIPPET 2
template<class Type, template<class> class PatchField, class GeoMesh>
323*tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
324*(
325* const GeometricField<Type, PatchField, GeoMesh>& gf  //const surfaceScalarField& phi_
326*)
327*{
328* tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
329* (
330* new GeometricField<scalar, PatchField, GeoMesh>
331* (
332* IOobject
333* (
334* "mag(" + gf.name() + ')',
335* gf.instance(),
336* gf.db(),
337* IOobject::NO_READ,
338* IOobject::NO_WRITE
339* ),
340* gf.mesh(),
341* gf.dimensions()
342* )
343* );
344*
345* mag(tMag(), gf);   
346*
347* return tMag;    //tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
348*}

In line 345 is found the second mag(...) method:

Code:

//SNIPPET 3
template<class Type, template<class> class PatchField, class GeoMesh>
  312 void mag
  313 (
  314    GeometricField<scalar, PatchField, GeoMesh>& gsf,
  315    const GeometricField<Type, PatchField, GeoMesh>& gf
  316 )
  317 {
  318    mag(gsf.internalField(), gf.internalField());        //QUESTION 1
  319    mag(gsf.boundaryField(), gf.boundaryField());    //QUESTION 2
  320 }

with the third and the fourth mag(...) methods

Code:

//SNIPPET 4
Foam::GeometricField<Type, PatchField, GeoMesh>::internalField()  //QUESTION 1
  674 {
  675    this->setUpToDate();
  676    storeOldTimes();
  677    return *this;
  678 }

and

Code:

//SNIPPET 5
Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField()  //QUESTION 2
  686 {
  687    this->setUpToDate();
  688    storeOldTimes();
  689    return boundaryField_; //GeometricBoundaryField boundaryField_
  690 }

My questions are about the three last codesnippets (SNIPPET 3-5):

QUESTION 1:

If "internalfield()" returns the updated object it is called on and afterwards mag(...) is called in line 318 of SNIPPET 3 wouldn't this cause an endless loop since the SAME method mag(...) like at the beginning of SNIPPET 3 would be called again and again?

QUESTION 2:

method mag(...) in line 319 of SNIPPET 3 should be
Code:

void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f) //sf: GeometricBoundaryField boundaryField_ of GeometricField of tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
189*{                                                                    //f: GeometricBoundaryField boundaryField_ of const surfaceScalarField& phi_
190* forAll(sf, i)
191* {
192* mag(sf[i], f[i]);
193* }
194*}

Where can I find the mag(...) method that in this case should take two scalars as input parameters (as I suppose)?


All times are GMT -4. The time now is 16:07.