|
[Sponsors] |
August 11, 2010, 10:35 |
Neumann boundary conditions
|
#1 |
Member
Join Date: Aug 2010
Posts: 31
Rep Power: 16 |
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. |
|
August 16, 2010, 08:47 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
Hi Martin,
you have to do a refCast. Example: Code:
fixedGradientFvPatchVectorField& gradUPatch=refCast<fixedGradientFvPatchVectorField>(U.boundaryField()[patchI]); scalarField& gradUField = gradUPatch.gradient(); Of course you have to include "fixedGradientFvPatchFields.H" in your header. Regards, Stefan |
|
August 16, 2010, 09:33 |
|
#3 |
New Member
Join Date: Mar 2010
Posts: 27
Rep Power: 16 |
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. |
|
August 16, 2010, 14:53 |
|
#4 |
Member
Join Date: Aug 2010
Posts: 31
Rep Power: 16 |
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. |
|
August 16, 2010, 14:59 |
|
#5 |
New Member
Nadeem
Join Date: Mar 2009
Location: München, Bavarian, Deutschland
Posts: 24
Rep Power: 17 |
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; } } |
|
August 17, 2010, 04:03 |
|
#6 |
New Member
Join Date: Mar 2010
Posts: 27
Rep Power: 16 |
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. |
|
August 17, 2010, 08:31 |
|
#7 | |
New Member
Nadeem
Join Date: Mar 2009
Location: München, Bavarian, Deutschland
Posts: 24
Rep Power: 17 |
Quote:
Thanks, surely it works, I read this thread little bit late thoroughly and atlast i did it. |
||
September 6, 2010, 06:37 |
Help Neumann boundary condition in fluent
|
#8 |
New Member
Join Date: Sep 2010
Posts: 1
Rep Power: 0 |
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! |
|
October 14, 2010, 10:28 |
|
#9 | |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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 Making dependency list for source file twoDarcyF.C SOURCE=twoDarcyF.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/gemp/csoulain/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/gemp/csoulain/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude -I/gemp/csoulain/OpenFOAM/OpenFOAM-1.7.0/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/twoDarcyF.o twoDarcyF.C: In function ‘int main(int, char**)’: twoDarcyF.C:74: error: invalid initialization of reference of type ‘Foam::scalarField&’ from expression of type ‘Foam::Field<Foam::Vector<double> >’ make: *** [Make/linux64GccDPOpt/twoDarcyF.o] Erreur 1 Do you have any idea where I am wrong ? Regards, Cyp |
||
October 14, 2010, 10:44 |
|
#10 |
Member
Join Date: Aug 2010
Posts: 31
Rep Power: 16 |
It should be:
vectorField& gradUField = gradUPatch.gradient(); (in case U is a volVectorField) M. |
|
October 14, 2010, 11:26 |
|
#11 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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 ? |
|
October 14, 2010, 11:51 |
|
#12 |
Member
Join Date: Aug 2010
Posts: 31
Rep Power: 16 |
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. |
|
October 14, 2010, 13:33 |
|
#13 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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"); fixedGradientFvPatchVectorField& gradUPatch=refCast<fixedGradientFvPatchVectorField>(p.boundaryField()[patchID]); scalarField& gradUField = gradUPatch.gradient(); gradUField = -(inv(M)&U)+rho*g; In fact, it compiles but fails while running: Code:
Time = 0.1 --> FOAM FATAL ERROR: Attempt to cast type fixedValue to type fixedGradient From function refCast<To>(From&) in file /opt/openfoam171/src/OpenFOAM/lnInclude/typeInfo.H at line 114. FOAM aborting |
|
October 14, 2010, 13:49 |
|
#14 |
Member
Join Date: Aug 2010
Posts: 31
Rep Power: 16 |
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. |
|
October 14, 2010, 14:14 |
|
#15 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Thank you very much Martin. It helps me much in the understanding !
So I changed the code as : Code:
label patchID = mesh.boundaryMesh().findPatchID("inlet"); fixedGradientFvPatchScalarField& gradUPatch=refCast<fixedGradientFvPatchScalarField>(p.boundaryField()[patchID]); scalarField& gradUField = gradUPatch.gradient(); |
|
October 14, 2010, 14:41 |
|
#16 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
I think it could work with :
Code:
gradUField = linearInterpolate(-(inv(M)&U)+rho*g) & mesh.Sf(); |
|
October 14, 2010, 15:14 |
|
#17 |
Member
Join Date: Aug 2010
Posts: 31
Rep Power: 16 |
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. |
|
October 18, 2010, 12:53 |
|
#18 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
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"); fixedGradientFvPatchScalarField& gradUPatch=refCast<fixedGradientFvPatchScalarField>(p.boundaryField()[patchID]); scalarField& gradUField = gradUPatch.gradient(); vectorField n = mesh.Sf().boundaryField()[patchID]; 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 Last edited by Cyp; October 18, 2010 at 13:46. |
|
October 25, 2010, 11:28 |
|
#19 |
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18 |
Hi!
I succed in the compilation using this piece of code : Code:
label patchID = mesh.boundaryMesh().findPatchID("inlet"); fixedGradientFvPatchScalarField& gradUPatch=refCast<fixedGradientFvPatchScalarField>(p.boundaryField()[patchID]); scalarField& gradUField = gradUPatch.gradient(); vectorField n = mesh.Sf().boundaryField()[patchID]; vectorField UU_beta = U_beta.boundaryField()[patchID]; tensorField MM_beta = M_beta.boundaryField()[patchID]; tensorField invMM_beta=inv(MM_beta); gradUField = -((invMM_beta&UU_beta)&n)+(rho_beta.boundaryField()[patchID]*(g.value())&n); 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 |
|
October 26, 2010, 06:00 |
|
#20 | |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
Please realize that you are editing the BC for p with your code
Quote:
Code:
fixedGradientFvPatchScalarField& gradUPatch=refCast<fixedGradientFvPatchScalarField>(U.boundaryField()[patchID]); Stefan |
||
Tags |
boundary conditions, fixedgradient, neumann |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mesh file for flow over a circular cylinder | Ardalan | Main CFD Forum | 7 | December 15, 2020 14:06 |
Impinging Jet Boundary Conditions | Anindya | Main CFD Forum | 25 | February 27, 2016 13:58 |
Concentric tube heat exchanger (Air-Water) | Young | CFX | 5 | October 7, 2008 00:17 |
Pressure boundary conditions | Lionel S. | Main CFD Forum | 1 | August 24, 2007 19:03 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |