|
[Sponsors] |
Creating a solver for the nondimensionalized Navier-Stokes equation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 15, 2012, 11:52 |
Creating a solver for the nondimensionalized Navier-Stokes equation
|
#1 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Hi everyone,
I have recently started using OpenFoam. I want to resolve the nondimensionalized Navier-Stakes equation (in which appears the Reynolds number). My equation is ( you can also find it attached ) : Re . (U . div) U + grad(meanP) - laplacian(U) = - grad(fluctP) meanP is a unit vector which is constant and P=meanP+fluctP Re is the reynolds number I want to resolve my equation for U and fluctP For this, I have modified the IcoFoam solver as follows, but it seems that there is an error ( may be with the '' meanP '' ) fvVectorMatrix UEqn ( fvm::ddt(U) + Re*(fvm::div(phi, U)) - fvm::laplacian(U) + magSqr(meanP) ); solve(UEqn == -fvc::grad(fluctP)); I will be thankfull If someone can help me to create this solver or share a web site which treated the implementation of the nondimensionalized NS equation. Best regards Mehrez Last edited by Mehrez; November 16, 2012 at 06:04. |
|
November 16, 2012, 05:01 |
|
#2 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Hi
Can someone help me please. Thank you |
|
November 16, 2012, 05:49 |
|
#3 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
please find attached the OpenFoam files of the solver (I have proceeded by modifying the IcoFoam solver to myIcoFoamB solver).
|
|
November 16, 2012, 06:39 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi,
there are many errors: Code:
fvVectorMatrix UEqn ( fvm::ddt(U) + Re*(fvm::div(phi, U)) - fvm::laplacian(U) + magSqr(meanP) ); Code:
laplacian(nu, U) OF do not know what meanP is. So you have to define Re meanP and the other variables you implemented! The following example is working: Code:
fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) - fvc::grad(p) ); solve(UEqn == -fvc::grad(p)); |
|
November 16, 2012, 06:50 |
|
#5 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 |
Hi Mehrez,
First it would be better if you modify the Make/files as in the user guide chapter 3 to be: Code:
myIcoFoamB.C EXE = $(FOAM_USER_APPBIN)/myIcoFoamB Code:
createFields.H: In function ‘int main(int, char**)’: createFields.H:23:5: error: no matching function for call to ‘Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField\ , Foam::volMesh>::GeometricField(Foam::ITstream&)’ createFields.H:23:5: note: candidates are: Code:
volVectorField gradP ( transportProperties.lookup("gradP") ); Code:
volVectorField gradP ( IOobject ( "gradP", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), fvc::grad(p) ); Code:
myIcoFoamB.C:61:18: error: no match for ‘operator+’ in ‘Foam::operator-(const Foam::tmp<Foam::fvMatrix<Type> >&, const Foam\ ::tmp<Foam::fvMatrix<Type> >&) [with Type = Foam::Vector<double>]((*(const Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > \ >*)(& Foam::fvm::laplacian(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&) [with Type = Foam::Vector<\ double>]()))) + Foam::magSqr(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Vector<double>, Pat\ chField = Foam::fvPatchField, GeoMesh = Foam::volMesh]()’ myIcoFoamB.C:61:18: note: candidates are: Code:
fvVectorMatrix UEqn ( fvm::ddt(U) + Re*(fvm::div(phi, U)) - fvm::laplacian(U) + magSqr(gradP) ); Best regards, Hisham |
|
November 16, 2012, 07:34 |
|
#6 | |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Quote:
I just had a very short look into the code and dont see the declaration of the other variables Well nice replay! Code:
( fvm::ddt(U) + Re*(fvm::div(phi, U)) - fvm::laplacian(nu, U) + magSqr(gradP) ); |
||
November 16, 2012, 07:43 |
|
#7 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Hi guys
Thank you for your help. I think that it is better if you take a look to my equation (which I have attached in my first message). You can see that I don't have : nu . laplacian (U) but I just have : laplacian (U) Concerning the declaration of the variables : I have declared " Re " and " gradP " in the file createFields.H dimensionedScalar Re ( transportProperties.lookup("Re") ); volVectorField gradP ( transportProperties.lookup("gradP") ); |
|
November 16, 2012, 07:58 |
|
#9 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Hi Hisham
Thank you for your answer. I think that I don't have to declare " gradP " like this : volVectorField gradP ( IOobject ( "gradP", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), fvc::grad(p) ); As I said before, the '' gradP '' is a unit vector which is constant and which I put it like an input (so this is why OF don't have to compute it). I have just to declare it like a vector which I will specify the value in constantProperties file. |
|
November 16, 2012, 08:01 |
|
#10 | |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Quote:
But how whould you get the information of the "vector" couse the pressure is just a scalar without a direction. |
||
November 16, 2012, 08:06 |
|
#11 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Hi Tobi
As you can see in my equation gradP is the gradient of the nondimensionalized mean pressure. I have it like an input (I will study my flow in function of given values of Re and gradP) I think that the problem is how to define this vector (gradP) in the equation |
|
November 16, 2012, 08:15 |
|
#12 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
I think that it is more clear like this
Equation : Re . (U . div) U + gradP - laplacian(U) = - grad(fluctP) OF syntax : fvVectorMatrix UEqn ( fvm::ddt(U) + Re*(fvm::div(phi, U)) - fvm::laplacian(U) + magSqr(gradP) ); solve(UEqn == -fvc::grad(fluctP)); Input : Re : scalar gradP : vector output (after computation) U : vector field fluctP : vector field |
|
November 16, 2012, 11:22 |
|
#13 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
If gradP is a constant vector, you should not store it in a volVectorField, but in a dimensionedVector from the transportproperties.
Two more things: - Are you sure Reynolds should appear like you wrote it. As far as I know, in the dimensionless NS equations, you have 1/Re in the diffusive terms. - You're now adding magSqr(gradP), which is a scalar, to a vector equation. This can not be correct. |
|
November 16, 2012, 11:52 |
|
#14 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Dear Bernhard,
I'm sure that I have a right equation (attached here) Thank you very much for your help. Actually I can compile my solver with your corrections. fvVectorMatrix UEqn ( fvm::ddt(U) Re*(fvm::div(phi, U)) - fvm::laplacian(U) + gradP ); and : dimensionedVector gradP ( transportProperties.lookup("gradP") ); To test this solver, I've taken the attached example "cavity" after putting U, p, Re, and gradP in a dimensionless form. I've done the same with the domain (I've commented the line " conversion to meters " ). Executing "cavity" with "myIcoFoamB" solver, OpenFoam returns an error message on the dimensions: -> FOAM FATAL ERROR: incompatible dimensions for operation [U [0 -1 0 0 0 0 0]] - [U [0 -2 0 0 0 0 0]] I think it comes from the operators (grad gives : L ^ -1 and Laplacian gives : L ^ -2). Is there a way to put the components (x, y, z) of the domain in a dimensionless form in order to get dimensionless values by applying one of the operators? Thank you very much for your help. Best regards. Mehrez |
|
November 16, 2012, 12:24 |
|
#15 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
Complicated one, you can choose to ignore the dimension-checking. I think you can do this in the controlDict you find in ..../OpenFOAM-2.1.x/etc/ .
Maybe you can put it in your own controlDict as well. I never tested this, but you can look here. |
|
November 16, 2012, 12:43 |
|
#17 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Hi guys,
Again thanks for your precious help. @ Bernhard : I have found the file " controlDict " , can you please precise me how to proceed. @ Tobi : I've tried what you said but it doesn't work. it returns each time a different dimensions error ! I can't understand Mehrez |
|
November 16, 2012, 12:56 |
|
#19 |
Member
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 14 |
Re Re [ 0 0 0 0 0 0 0 ] 0.01;
gradP gradP [ 0 0 0 0 0 0 0 ] (0.9 0.2 0); U : dimensions [0 0 0 0 0 0 0]; p : dimensions [0 0 0 0 0 0 0]; In the blockMeshDict, I have commented the following line : //convertToMeters 0.1; and this is what I get : Create time Create mesh for time = 0 Reading transportProperties Reading field p Reading field U Reading/calculating face flux field phi Starting time loop Time = 0.005 Courant Number mean: 0 max: 0 --> FOAM FATAL ERROR: incompatible dimensions for operation [U[0 -1 0 0 0 0 0] ] - [U[0 -2 0 0 0 0 0] ] From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&) in file /opt/openfoam211/src/finiteVolume/lnInclude/fvMatrix.C at line 1316. FOAM aborting #0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam211/platforms/linuxGccDPOpt/lib/libOpenFOAM.so" #1 Foam::error::abort() in "/opt/openfoam211/platforms/linuxGccDPOpt/lib/libOpenFOAM.so" #2 in "/opt/openfoam211/platforms/linuxGccDPOpt/bin/myIcoFoamB" #3 in "/opt/openfoam211/platforms/linuxGccDPOpt/bin/myIcoFoamB" #4 in "/opt/openfoam211/platforms/linuxGccDPOpt/bin/myIcoFoamB" #5 __libc_start_main in "/lib/i386-linux-gnu/libc.so.6" #6 in "/opt/openfoam211/platforms/linuxGccDPOpt/bin/myIcoFoamB" Aborted (core dumped) ubuntu@ubuntu-VirtualBox:~/OpenFOAM/mehrez-2.1.1/test/cavity$ |
|
Tags |
navier-stokes solver, openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
suGWFoam: Richards equation solver for porous media flows | liu | OpenFOAM Announcements from Other Sources | 4 | February 10, 2021 16:14 |
Navier Stokes solver | Siddharth | Main CFD Forum | 2 | September 13, 2007 02:06 |
test prob for 2D unsteady navier stokes equation | Shah | Main CFD Forum | 5 | April 20, 2007 08:25 |
Navier Stokes Solver | Khan | Main CFD Forum | 2 | December 12, 2006 10:41 |
help: I am trying to solve Navier Stokes compressible and viscid flow | Jose Choy | Main CFD Forum | 2 | May 18, 2000 06:45 |