- **OpenFOAM**
(*https://www.cfd-online.com/Forums/openfoam/*)

- - **div(phi,U) in an incompressible solver**
(*https://www.cfd-online.com/Forums/openfoam/89269-div-phi-u-incompressible-solver.html*)

div(phi,U) in an incompressible solverHi Foamers,
does anybody know if div(phi,U) in an incompressible solver (like simpleFoam) is calculating the "full" divergence term of phi*U or is it directely introducing the incompressibility conditions that the calculation would be reduced to the half. For a better understanding what i mean i will write it analytical for 2D motion (i will leave out the density): Option a) div(U,U) = u*( du/dx+dv/dy) + u*du/dx + v*du/dy Option b) div(U,U) = u*du/dx + v*du/dy (because the term in the brackets satisfies div(U)=0) Which option is openFoam using? Thanks a lot, rupert |

Rupert, FOAM solves the "weak" form if this term. When you use FVM, integrals are volumetric at the beginning but using the Gauss Theorem you don't have to use any derivatives but only values at faces, because you have a surface integral:
int_{Omega} div(U*U) dOmega=int_{Gamma} U*U&d_Gamma=sum_f U_f*U_f&S_f=sum_f U_f*phi_f where & is the dot product, Omega is the control volume and Gamma is its border and f indicates quantities at faces. phi is the flux U_f&S_f. Regards. |

Hi Rupert,
Just complementing Santiago's answer, this means that, for the x momentum equation, you have alternative a) integrated over the cell volume. Paulo |

Hi Paulo and Santiago,
thanks for the reply. Both answers are helping me. So if i want to add to an equation one more term i have to integrate it over the cell volume or just multiply the cell center value with the Volume of the cell, right? For example if i want to add a value S (like a source term) i have to integrate this value over the cell volume, too, right? Thanks rupert |

Rupert, the integration is part of the method and is implied using FOAM. Adding S to the equation starts a chain of events that finally integrate the source over each cell. The other option is to use the fvm::Sp().
Regards. |

Hello Santiago,
does that mean that the integration is implied in the discretization schemes (like in e.g. div(phi,U)) or is it automatically implied while solving an equation??? The difference would be that i don't have to integrate my source term my own if it is done by the solve() procedure... Can you understand what i mean?? As far as i get it out of the source code the Sp() function is anyhow multiplying with the cell Volumes; but i had no success to use it right :-/ ... Further: what is wrong if i type: volScalarField meshVols = U.mesh().V(); There is a compiler error: error: conversion from ‘const Foam::DimensionedField<double, Foam::volMesh>’ to non-scalar type ‘Foam::volScalarField’ requested Maybe you have some answers. thanks a lot, rupert |

Quote:
I can help you on this one :cool: : tmp<volScalarField> cellVolume ( new volScalarField); cellVolume().internalField() = mesh.V(); This part should store the volumes of your cells. I don't really understand why you call your volume like U.mesh().V ? Regards, sabin |

Quote:
do i have to use some integration over the cell volume inside an equation for the additional source term S or is it done automatically so that i have to add only the term with " + S" or do i need something else?? Thanks for your help. rupert |

Good evening,
I have the same question. I have added an explicit source term rhs in the momentum equation HTML Code:
`tmp<fvVectorMatrix> UEqn` In my case I would like to add a face-based source term which includes the face magnitudes. Therefore I suppose that I need to divide my source term by the control volume, as I do not want it to be multiplied as the multiplication with the face magnitude symbols an integration over the face already. Can someone please verify that the source term is automatically integrated if I insert it in the UEqn like stated above? I am looking forward to your answers. Kind Regards Anne |

Hi,
You can use the cell center value not the cell integrated value when you specify the explicit source term in the UEqn. Hope that helps, Fumiya |

Dear Fumiya,
thank you very much for your answer. How can I switch between cell-centered and cell-integrated value? Thank you, Anne Lincke |

Dear foamers,
I have written a face-based source which I would like to include in the UEqn. I assume that this term will automatically multiplied with the cell-volume as it is explicit? As the term corresponds to the integration over the faces it is already scaled with the face-magnitude and does not need to be scaled by the cell volume any more. Therefore I divided the term by the cell volume, but the code does not converge :( In the following a sketch of the code. HTML Code:
`for( label faceI=0; faceI < mesh.nInternalFaces(); faceI++)` Thank you very much for an answer. Anne |

Quote:
Yes it is automatically multiplied with the cell volume. I think you might be looking for the reconstruct operator to get the value in the cell center: Code:
`surfaceScalarField phi` |

Thank you, I think I found another reason for the non-convergence of my code.
Nevertheless this implementation helped me a lot to understand how OpenFOAM treats the source terms. Kind Regards Anne |

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