|
[Sponsors] |
How to calculate the gradient along the boundaries from a known volScalarFiled? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 18, 2011, 12:48 |
How to calculate the gradient along the boundaries from a known volScalarFiled?
|
#1 |
New Member
Join Date: Jul 2011
Posts: 2
Rep Power: 0 |
Hi,
I first obtained a volScalarField in a calculation domain, and then I want to calculate the gradient along the domain boundaries. Does anyone know how to obtain the gradient along domain boundaries from a known volScalarField? Thank you very much! |
|
October 27, 2011, 10:54 |
|
#2 |
Member
bojiezhang
Join Date: Jan 2010
Posts: 64
Rep Power: 16 |
hi shddx1:
I have the same problem with you ! I define a volScalrField first and the value is fixed for all the cells, but I want to caculate the gradient. Do you solve the problem, can you tell me? Thank you! |
|
October 28, 2011, 19:04 |
|
#3 |
Member
Ivor Clifford
Join Date: Mar 2009
Location: Switzerland
Posts: 94
Rep Power: 17 |
You can obtain the surface normal gradient at each boundary using snGrad function.
p.boundaryField()[patchI].snGrad(); This will give you the surface normal gradient without any non-orthogonality or skewness corrections. If you need these corrections, use fvc::snGrad(). surfaceScalarField snGradP = fvc::snGrad(p); Then access the value at the boundary with snGradP.boundaryField()[patchI]. If you are looking for a full gradient vector at the boundary, this is a little tricker. Here you will have to interpolate the field gradient (fvc::grad(p)) to the faces and then replace the surface normal component of this with the value coming from fvc::snGrad(p). Hope this helps Ivor |
|
October 2, 2016, 05:04 |
|
#4 | |
Senior Member
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12 |
Quote:
could you please explain about it more? Where should we get this command: p.boundaryField()[patchI].snGrad(); ?? Thanks |
||
February 27, 2017, 06:08 |
gradients along boundaries.
|
#5 |
New Member
Join Date: Feb 2016
Posts: 13
Rep Power: 10 |
p { margin-bottom: 0.1in; line-height: 120%; } Hi all,
I have a question concerning the calculation of gradients along boundaries. Let's consider the flow of an incompressible viscous fluid through a channel. At inlet, the velocity is fixed. At outlet, the pressure is fixed to the constant value 0. I using the solver simpleFoam. In my opinion, that should lead to the following results for the gradient of pressure : n&grad(p) =0 at the inlet grad(p) – n* (n&grad(p)) )=0 at the outlet. For instance, iwith a 2D horizontal channel such that the inlet and outlet are vertical segments (i.e. n_inlet = (-1 0 0) and n_outlet=(1 0 0)), we should have 1) the x-coordinate of the gradient cancels along inlet: grad(p)[x] = 0 2) the y-coordinate of the gradient cancels along outlet: grad(p)[y] =0 But I do not obtain these results. Can anyone tell me what is wrong ? I do the following things: 0. In the file p, I enter the following boundary conditions for the pressure p (volScalarField) : inlet { type zeroGradient; } outlet { type fixedValue; value uniform 0; } Now I am looking at grad(p) (volVectorField). To to that I using a own postprocessing utility. 1. Firstly, I have simply tried : Info<< "Calculate gradient " << endl; volVectorField gradp0 ( IOobject ( "gradp0", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), fvc::grad(p) ); gradp0.write(); This return a file, named “gradp0”, containing the lines type zeroGradient; at inlet and outlet !! In my opinion, that is completely wrong: the normal gradient of grad(p) does not have to cancel on inlet nor on outlet ! 2. Secondly, I added the following code lines into my postprocessing utility : Info<< "Explicitly express numerical values on borders" << endl; volVectorField gradp ( IOobject ( gradp, runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), 1.0*gradp0 ); forAll(gradp0.boundaryField(), patchI) / { gradp.boundaryField()[patchI] = gradp0.boundaryField()[patchI]; } gradp.write(); This returns a file, named “gradp”, containing numerical values over the boundaries. Using these numerical values, I can control that the normal gradient n.grad(p) cancels on inlet (i.e. that grad(p)[x]=0 in case of vertical inlet segment). Great ! But the tangential part of the gradient does not cancel on outlet (i.e. I don t have that grad(p)[y]=0 in case of vertical outlet segment). Why ? What is wrong ? Thank you for your help !!! Fanny |
|
March 15, 2017, 15:38 |
|
#6 | |
Member
Linyan X
Join Date: Dec 2015
Posts: 43
Rep Power: 10 |
Quote:
I cannot answer your question. But after reading your question, I have a quick question regarding the volVectorField that you've gotten on your 1st try, named field'gardp0'. How can you implement this volVectorField term into the equation that you want to solve? Like, for example, UEqn.H in interFoam. I want to add the force vector term into the UEqn.H, written as 'interpolate(F)'. But the system will always complain about the format of this vector term. Hence, I guess you may know this after reading your post. Really appreciate your help for any hints. Regards, Linyan |
||
March 16, 2017, 04:41 |
|
#7 |
New Member
Join Date: Feb 2016
Posts: 13
Rep Power: 10 |
Hi linyanx and all
I am not sure I am going to exactly answer your question ... I did not met any difficulty to implement gradp0 into equations. Let us, for example, consider the solver simpleFoam. We can replace solve(UEqn() == -fvc::grad(p)); with solve(UEqn() == -gradp0); (line 18 in file applications/solvers/incompressible/simpleFoam/UEqn.H) Do not forget to define grad0 with createFields.H by entering e.g. Info<< "Calculate gradient " << endl; volVectorField gradp0 ( IOobject ( "gradp0", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), fvc::grad(p) ); gradp0.write(); This definition must be placed after the p's definition. We can also implement the definition of gradp given in the 2. of my previous post (explicitly expressing numerical values on borders) Nevertheless, the results of the simulations with original simpleFoam (using fvc::grad(p)) and the modified ones (using gradp0 or gradp) ARE NOT the same... And this is my question : why ? what is wrong within the gradp0's and gradp's definitions ? Thanks !! Fanny |
|
March 16, 2017, 11:47 |
|
#8 |
Member
Linyan X
Join Date: Dec 2015
Posts: 43
Rep Power: 10 |
Thanks Fanny! Your hint inspired me! I now realise that the volVectorField term is not supposed to reconstruct. Hence, the 'F' term is written outside of 'reconstruct' structure. Please allow me to quote your answer to my post for future reader's reference.
Regards, Antelope X. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF-How to calculate gradient of a scalar | Tony Tonton | Fluent UDF and Scheme Programming | 19 | November 20, 2023 09:13 |
how to calculate the temperature gradient of wall | houbaolin | FLUENT | 0 | July 28, 2008 03:51 |
Calculate normal gradient | Sunil | FLUENT | 0 | April 30, 2008 17:44 |
calculate the temperature gradient on a profile | arther | FLUENT | 0 | April 20, 2006 00:12 |
how to calculate the gradient of volume fraction | hxhua | FLUENT | 0 | July 1, 2005 09:43 |