Neumann boundary conditions
Hi,
I want to change my boundary conditions during runtime. For the Dirichlet conditions I have found a way to set up the conditions in the code: I have choosen fixedValue for the boundary type and I updated it in the code using: U.boundaryField()[patchI]== mynewScalarField; I have tried the same with fixedGradient type for a Neumann Condition but it doesn't update the gradient value. (I have reviewed it with .snGrad()). Maybe someone can give me a useful hint, thanks, m. |
Hi Martin,
you have to do a refCast. Example: Code:
fixedGradientFvPatchVectorField& gradUPatch=refCast<fixedGradientFvPatchVectorField>(U.boundaryField()[patchI]); Of course you have to include "fixedGradientFvPatchFields.H" in your header. Regards, Stefan |
Hi!
snGrad() has nothing to do with the gradient which you want to impose with your boundary condition, it is some geoemetrical quantity. The fvPatchField is a field of quantities, which are applied as fixed gradients. Therefore, you have to write the wanted values to the field the same way you do it for the fixedValue stuff. I hope you get the point... Cheers, Andreas. |
Hi Stefan,
I have already got the same answer from somebody else but thank you very much - this is exactly what I was seeking for. [.gradient() is not a member function of "volVectorField" but of "fixedGradientFvPatchVectorField"]. Hi Andreas, I don't think u r right, U.boundaryField()[patchI].snGrad() in that case should show me the current boundary condition of the fixedGradient bc object. B.r., Martin. |
HAve u guys got the solution how to update the value of gradient, I think my problem is also similar to yours.
that is expressed below: volScalarfield field ( IOobject(fieldName,runtTime.timeName(),mesh,IOobje ct::NO_READ,IOobject::AUTO_WRITE), mesh, dimensionedScalar(fieldName,dimTemperature, 200), "fixedGradient" ); forAll(field.BoundaryField(),patchID) { field.boundaryField()[patchID]==30; } As an output of this code am getting something different. that is. boundaryField { Inlet { type fixedGradient; gradient uniform 0; } and so on; } but I am interested to get output as below: boundaryField { inlet { type fixedGradient; gradient uniform 30; } } |
Martin,
at the end, its the same. What herbert is proposing is to copy (with the refCast) the reference of the fvPatchField to a new vectorField and editing THAT. Because of the reference, that still modifies the original field. But you could write to your fixedGradientFvPatchVectorField directly, without giving it a new name. Just try it :-) And - snGrad is definitely returning some geometrical stuff from the mesh, take a look at doxygen. As long as it works there is no need to worry... ;) Have fun, Andreas. |
Quote:
Thanks, surely it works, I read this thread little bit late thoroughly and atlast i did it. |
Help Neumann boundary condition in fluent
Hi!!
I need to define an output Neumann boundary condition using fluent. the condition is dc/dn=0, where c is the concentration of a certain species and n is the normal versor to the output face. How can I do this? Thanks! |
Quote:
Hi Stefan and everybody, I trying to implement neumann BC with your method but I had a fail during the compilation. I have merely copy your piece of code in my main.C file and I included "fixedGradientFvPatchFields.H" in my header. I get the following error : Code:
applications/twoDarcyF> wmake Do you have any idea where I am wrong ? Regards, Cyp |
It should be:
vectorField& gradUField = gradUPatch.gradient(); (in case U is a volVectorField) M. |
Ok. Thank you very much. It compiles now.
But in case U is a volScalarField (a pressure field for example)? The code of Hebert should works, shouldn't it ? |
No, i think in that case (for a volScalarField) you have to modify the first expression of Stefan's code in an appropriate way.
M. |
I have a problem of understanding: the gradient of a scalar should be a vector. So the following snippet should work:
Code:
label patchID = mesh.boundaryMesh().findPatchID("inlet"); In fact, it compiles but fails while running: Code:
Time = 0.1 |
You define the outer normal gradient (grad p * n) [n is the surface outer normal direction]
let p be a scalarF and V a vectorF then: grad(p) is a vectorF -> (grad(p)) *n is a scalarF grad(V) is a tensorF -> (grad(V)) *n is a vectorF I hope it helps, M. |
Thank you very much Martin. It helps me much in the understanding !
So I changed the code as : Code:
|
I think it could work with :
Code:
gradUField = linearInterpolate(-(inv(M)&U)+rho*g) & mesh.Sf(); |
The normal surface vector field on the boundarypart patchID is:
vectorField n = mesh.Sf().boundaryField()[patchID] Take care that the left part of your calculation is finally also a vectorField on the appropriate domain (boundaryField()[patchID]). M. |
Hi Martin!
Thank you very much for your answer. I am not sure to understand very well... I tried: Code:
label patchID = mesh.boundaryMesh().findPatchID("inlet"); Code:
gradUField = (-(inv(M)&U)+rho*g)&n Code:
gradUField = (-(inv(M)&U)+rho*g)*n Code:
gradUField = linearInterpolate(-(inv(M)&U)+rho*g)&n |
Hi!
I succed in the compilation using this piece of code : Code:
label patchID = mesh.boundaryMesh().findPatchID("inlet"); I set up a fixedValue at the inlet for my U_beta field but when I plot the results, the U_beta value is different that the one I chose... Did I miss something ?? Regards, Cyp |
Please realize that you are editing the BC for p with your code
Quote:
Code:
fixedGradientFvPatchScalarField& gradUPatch=refCast<fixedGradientFvPatchScalarField>(U.boundaryField()[patchID]); Stefan |
All times are GMT -4. The time now is 15:46. |