Manipulating source fvc::grad(vsf1+vsf2)
Hello,
I need to manipulate the source term (fvc::grad(vsf1+vsf2)) of the momentum equation. The physical behaviour should be, that every identified internal face should be treated as a zero gradient condition: Code:
int icounterinternalfaces = 0; I'm using the gauss gradient scheme ...==fvc::grad(vsf1+vsf2) First way I: Should I copy the gaussGrad.H/C and manipulate the code? But then I need to use something like ...==fvc::grad(vsf1,vsf2,vsf3) to be able to distinguish between normal internal faces and the ones which should have a zero gradient condition. So I need to create also a new gradScheme-class. Second way: I use the fixedInternalValueFvPatchField, create temporarily an internal patch consisting of the specified faces and treating them with a zero gradient condition. But I'm not sure, if this is a good way. I would be happy about every comment on this. I tend to use the first way, or do you think, there is a more easy way like manipulating directly the outcome of the grad-calculation :confused: like: Code:
volVectorField sourceTerm = fvc::grad(vsf1+vsf2); Andy |
Try something like this in your code.
Code:
volScalarField sumVf = vf1+vf2; |
what about the correctBoundaryConditions
hi cliffoi,
many thanks for your hint. Yes, I use the gaussgrad scheme and in the meantime I had a deeper look in that source code. As you propose, I should calculate the gradient over all faces and subtracting the values of the specific faces, where neighour and owner fullfill some condition. Of course dividing the value with the volume of that cell. With volVectorField gradVsf = fvc::grad(sumVff); I use the first template-class in gaussgrad-scheme, putting in the surfaceScalarField of the sumVf into the fvc::grad() and I get back the gradient (volVectorField gradVsf). But what about the correctBoundaryConditions(vsf, gGrad); :confused: In the original form, the gaussGrad does first the loop with the surfaceScalarField, and then the correctBoundaryConditions(vsf,gGrad) with looping over the patches (except the coupled ones). Of course, I have in the first template-class the function: gGrad.correctBoundaryConditions(); But do I need the correctBoundaryConditions(vsf, gGrad); correction too? And if so, how can I perform this calculation/correction? Many thanks in advance! Best regards Andy |
correctBoundaryConditions(vsf, gGrad) modifies the value of the gradient on all normal (non-coupled) boundaries so that the surface-normal component of gradient matches the surface-normal of the boundary condition. This correction has no influence on the internal field values of the gradient so, unless the boundary values are important to you, you can safely ignore this. Conveniently this function is static so you can call it yourself to correct the surface-normal component afterwards.
Code:
volScalarField sumVf = vf1+vf2; |
summarising your last post
Hello cliffoi,
thank you for your very fast reply. Please correct me, if I summaries something wrong: 1) First we go through the internal field, calculating the gradients with: volVectorField gradVsf = fvc::grad(sumVff); Then we manipulate the internal field with the first loop. Ok. In file gaussGrad.C, after dividing the cell gradient with the volume, then comes: Code:
gGrad.correctBoundaryConditions(); This, we have to manipulate again with your suggestion: Code:
//- Now apply correction to all coupled boundaries Which is similar to your call: Code:
fv::gaussGrad<scalar>::correctBoundaryConditions(sumVf, gradVsf); Thank you very much. You are a great help! Best regards Andy |
That's pretty much it. Let me know if it actually works...
|
I made progess
Hello Cliffoi,
the implementation of the source worked and I could manipulate the source term of the momentum equation. Here I did one correction to your suggestion: Code:
... Then I got almost the expected result in my testcase. However, I manipulated the source term of the momentum equation before the piso-loop. So, I have a flux-field, which is not divergence free, but approximately satisfies momentum (because this grad term has the same function as "fvc::grad(p)" in my incompressible flow). Now I have to do the same corrections in the piso-loop [having a correction (?) of the grad(p)/grad(vsf1+vsf2) values as I see in Ferziger & Peric] because I have fluctuations in the flux-values after the time-step ... So first, I must understand the piso-loop. I think, some new interesting questions will arise from my side soon. Sorry about that in advance... Best regards, Andy |
All times are GMT -4. The time now is 19:39. |