# openFoam syntax

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 September 29, 2011, 15:27 openFoam syntax #1 Senior Member   Nima Sam Join Date: Sep 2009 Location: Tehran, Iran Posts: 1,123 Blog Entries: 1 Rep Power: 14 hi openFoamer in compressibleInterFoam and in pEqn.H there are following syntax: Code: ``` dgdt = (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) *(pEqnComp & p);``` can any body tell me whats the meaning of "pEqnComp & p" ? pEqnComp : fvScalarMatrix p : volScalarField so whats "&" here ?

 September 29, 2011, 20:30 #2 Senior Member   David Gaden Join Date: Apr 2009 Location: Winnipeg, Canada Posts: 397 Rep Power: 12 I think it's the inner product. __________________ ~~~ Follow me on twitter @DavidGaden

 September 29, 2011, 21:57 #3 Senior Member   Nima Sam Join Date: Sep 2009 Location: Tehran, Iran Posts: 1,123 Blog Entries: 1 Rep Power: 14 im confused how we can inner product fvScalarMatrix with volScalarField? what is the output and how this calculation can be done? give me a mathematical concept please

 September 29, 2011, 22:39 #4 Senior Member   David Gaden Join Date: Apr 2009 Location: Winnipeg, Canada Posts: 397 Rep Power: 12 fvMatrix.C implements operator& around line 2270. The result is a GeometricField. I'm not exactly sure what it does, but it looks like it affects the matrix. I don't have my Foaming computer in front of me at the moment. __________________ ~~~ Follow me on twitter @DavidGaden

 September 30, 2011, 05:45 #5 Senior Member   Nima Sam Join Date: Sep 2009 Location: Tehran, Iran Posts: 1,123 Blog Entries: 1 Rep Power: 14 & operator is defined in fvMatrix.C like below: Code: ```template Foam::tmp > Foam::operator& ( const fvMatrix& M, const DimensionedField& psi ) { tmp > tMphi ( new GeometricField ( IOobject ( "M&" + psi.name(), psi.instance(), psi.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), psi.mesh(), M.dimensions()/dimVol, zeroGradientFvPatchScalarField::typeName ) ); GeometricField& Mphi = tMphi(); // Loop over field components for (direction cmpt=0; cmpt::nComponents; cmpt++) { scalarField psiCmpt = psi.field().component(cmpt); scalarField boundaryDiagCmpt(M.diag()); M.addBoundaryDiag(boundaryDiagCmpt, cmpt); Mphi.internalField().replace(cmpt, -boundaryDiagCmpt*psiCmpt); } Mphi.internalField() += M.lduMatrix::H(psi.field()) + M.source(); M.addBoundarySource(Mphi.internalField()); Mphi.internalField() /= -psi.mesh().V(); Mphi.correctBoundaryConditions(); return tMphi; }``` 1) could you please tell me what does this piece of code do? it seems it loops over the field to make it diagonal predominate, but its confusing! 2)why it returns tMphi while it does all operation on Mphi? i feel it should be Mphi

 September 30, 2011, 06:02 #6 Senior Member   Niels Gjoel Jacobsen Join Date: Mar 2009 Location: Deltares, Delft, The Netherlands Posts: 1,609 Rep Power: 25 add 2) tMphi is a tmp, whereas Mphi (of type Type) is a reference to tMphi. Hence all changes to Mphi is directly a change to tMphi. tMphi is returned, as the tmp class is included in OpenFOAM to optimise the memory handling. Since volFieldsType> can potentially be very large, the return of a tmp > speeds up the run-time. Kind regards, Niels

 September 30, 2011, 09:33 #7 Senior Member   David Gaden Join Date: Apr 2009 Location: Winnipeg, Canada Posts: 397 Rep Power: 12 It's probably the inner product. When it involves a fvMatrix, it apparently does something to the Matrix's diagonal. I'm not going to try to decode it because I agree: it is confusing. __________________ ~~~ Follow me on twitter @DavidGaden

 September 30, 2011, 12:26 #8 Senior Member   David Gaden Join Date: Apr 2009 Location: Winnipeg, Canada Posts: 397 Rep Power: 12 Hi Nima, sorry for being dismissive in the last response. If you want to go into detail about what the & operator does, I've added some comments in blue that might help you out. It looks like it doesn't actually affect the matrix. It looks like it is the inner product between the field associated with the matirx, with the field p you mention. Since a matrix is involved, it has to account for boundary conditions, and I think that's where it gets confusing, especially when it comes to boundary patches that have out-of-core multiplication (cyclic, processor, etc). Also see below for links to useful pages that might help further explain things. Code: ```template Foam::tmp > Foam::operator& ( const fvMatrix& M, const DimensionedField& psi ) { // Here we create the return object tmp > tMphi ( new GeometricField ( IOobject ( "M&" + psi.name(), psi.instance(), psi.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), psi.mesh(), M.dimensions()/dimVol, zeroGradientFvPatchScalarField::typeName ) ); // This is for convenience, because it is awkward dealing directly with tmp<> // See link below. GeometricField& Mphi = tMphi(); // Loop over field components for (direction cmpt=0; cmpt::nComponents; cmpt++) { // psiCmpt is your "p" scalarField psiCmpt = psi.field().component(cmpt); // Here we're grabbing a copy of the matrix diagonal of your "pEqnComp" scalarField boundaryDiagCmpt(M.diag()); // This function brings in out-of-core multiplication effects from the boundary // (e.g. cyclic patches) and puts it into our copy of the diagonal M.addBoundaryDiag(boundaryDiagCmpt, cmpt); // Multiplying p by the modified diagonal, store result in output object Mphi.internalField().replace(cmpt, -boundaryDiagCmpt*psiCmpt); } // H operator stuff. Shorthand operation built into the matrix that I never // remember what it does... see link below Mphi.internalField() += M.lduMatrix::H(psi.field()) + M.source(); M.addBoundarySource(Mphi.internalField()); // Per unit volume - the matrix is integrated over the volume; a field is not Mphi.internalField() /= -psi.mesh().V(); Mphi.correctBoundaryConditions(); return tMphi; }``` For H operator stuff, see this page: http://openfoamwiki.net/index.php/Op...ide/H_operator For what tmp<> is all about, see here: http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp ubald and nimasam like this. __________________ ~~~ Follow me on twitter @DavidGaden

 Tags equation, operator, syntax

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25 amtri OpenFOAM 5 August 28, 2010 07:19 pete Site News & Announcements 0 June 29, 2009 05:56 oseen OpenFOAM Installation 9 August 26, 2007 13:50 CFD user CFX 3 November 25, 2002 16:16

All times are GMT -4. The time now is 17:08.

 Contact Us - CFD Online - Top