CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Problem with linearized Navier-Stokes equations

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 4, 2014, 12:57
Default Problem with linearized Navier-Stokes equations
  #1
New Member
 
Andrea
Join Date: Sep 2014
Posts: 17
Rep Power: 12
And901 is on a distinguished road
Hi everybody,

i'm new to OpenFOAM and i'm trying to solve the incompressible linearized Navier-Stokes equations.
Called U_zero the equilibrium solution, i tried to modify the icoFoam.C code as follow:

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi_zero, U)
+ fvm::div(phi,U_zero)
- fvm::laplacian(nu, U)
);

solve(UEqn == -fvc::grad(p));

where phi_zero is defined as

surfaceScalarField phi_zero
(
IOobject
(
"phi_zero",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(U_zero) & mesh.Sf()
);

I also defined U_zero in createFields.H as:

Info<< "Reading field U_zero\n" << endl;
volVectorField U_zero
(
IOobject
(
"U_zero",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
Foam::vector(1,0,0)
);

I compiled the code without errors but when i try to run a case (cavity for example) the following error message appears:

--> FOAM FATAL ERROR:

valueInternalCoeffs cannot be called for a calculatedFvPatchField
on patch movingWall of field U_zero in file "/home/andrea/Desktop/tesi/openfoam/tutorials/incompressible/icoFoam/cavityLinearized/0/U_zero"
You are probably trying to solve for a field with a default boundary condition.

From function calculatedFvPatchField<Type>::valueInternalCoeffs( const tmp<scalarField>&) const
in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 144.

FOAM exiting

I know that i should first calculate U_zero as a stationary solution and then solve the linearized NS equation in a neighbourhood of it . In my case U_zero is just a constant vector, but i'm just trying to run the code without errors to see what happens.

Thanks for your help.

Regards, Andrea
And901 is offline   Reply With Quote

Old   October 4, 2014, 16:32
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

if I got your problem right, you need to set boundary conditions for U_zero. Now you create the field with:

Code:
volVectorField U_zero
(
IOobject
(
"U_zero",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
Foam::vector(1,0,0)
);
but you can add

Code:
volVectorField U_zero
(
IOobject
(
"U_zero",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
Foam::vector(1,0,0),
U.boundaryField().types()
);
so U_zero will have the same BCs as U. In fact you can change U.boundaryField().types() to any BC you'd like U_zero to have.
alexeym is offline   Reply With Quote

Old   October 5, 2014, 04:58
Default
  #3
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Good morning,

You must use fvc:: on the U_zero term, as it should not be a part of your matrix, but rather the source term.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   October 5, 2014, 06:19
Default
  #4
New Member
 
Andrea
Join Date: Sep 2014
Posts: 17
Rep Power: 12
And901 is on a distinguished road
Hi Alexey,

thanks for your reply, i added the new line for BC as you said but a new error appears:

--> FOAM FATAL ERROR:
incompatible dimensions for operation
[U[0 1 -2 0 0 0 0] ] + [U[0 0 -1 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&) at ??:?
#1 Foam::error::abort() at ??:?
#2
at ??:?
#3
at ??:?
#4
at ??:?
#5 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#6
at ??:?
Aborted (core dumped)

It seems that U dimensions are not correct but U file in /0 directory has dimensions:

dimensions [0 1 -1 0 0 0 0];
And901 is offline   Reply With Quote

Old   October 5, 2014, 06:23
Default
  #5
New Member
 
Andrea
Join Date: Sep 2014
Posts: 17
Rep Power: 12
And901 is on a distinguished road
Hi Niels,

sorry, maybe my question is stupid but why did you say that U_zero should be a source term? In linearized Navier-Stokes equations U_zero is always coupled with U so how can i write it as a source term?

Best Regards,

Andrea.
And901 is offline   Reply With Quote

Old   October 5, 2014, 10:18
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Quote:
Originally Posted by And901 View Post
--> FOAM FATAL ERROR:
incompatible dimensions for operation
[U[0 1 -2 0 0 0 0] ] + [U[0 0 -1 0 0 0 0] ]

...

It seems that U dimensions are not correct but U file in /0 directory has dimensions:

dimensions [0 1 -1 0 0 0 0];
I think it's U_zero, not U, that gives you dimension problem; it seems U_zero is dimless (so dimensions of div(phi, U_zero) is 1/s.

Maybe dimensions of U_zero that you've put in 0 folder are overwritten by Foam::vector(1,0,0), try using dimensionedVector("U_zero", dimVelocity, vector(1, 0, 0)).

About comment by Niels, in your div(phi, U_zero) there's no U, so you have to use div method from fvc namespace. And it will be treated as a source term.
ngj likes this.
alexeym is offline   Reply With Quote

Old   October 6, 2014, 06:49
Default
  #7
New Member
 
Andrea
Join Date: Sep 2014
Posts: 17
Rep Power: 12
And901 is on a distinguished road
Hi Alexey,

thanks a lot for your advices, i solved the problem.
Sorry if i ask you one more question; i would like to read U_zero from a file following these steps:

1) run cavity case with icoFoam;
2) extract U field at each time step typing "foamCalc components U";
3) Set U_zero = U (so i need to read U_zero from a file);
4)Solve linearized Navier-Stokes equations around U_zero;

I have done step 1 and 2 but i don't know how to do step 3.

I would appreciate your help.

Best regards,

Andrea
And901 is offline   Reply With Quote

Old   October 6, 2014, 09:52
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

right now the only solution that I can think of is to use another variant of IObject constructor to create U_zero vector field:

http://foam.sourceforge.net/docs/cpp...52f901319147b6

Code:
IOobject 	
( 	
    const fileName& path,
    const objectRegistry& registry,
    readOption r = NO_READ,
    writeOption w = NO_WRITE,
    bool registerObject = true 
)
with this constructor you can directly specify path of the object i.e. path to the simulation results you've obtained with icoFoam.
alexeym is offline   Reply With Quote

Old   October 7, 2014, 11:11
Default
  #9
New Member
 
Andrea
Join Date: Sep 2014
Posts: 17
Rep Power: 12
And901 is on a distinguished road
Thanks Alexey,

problem solved.

Best Regards,

Andrea
And901 is offline   Reply With Quote

Old   December 6, 2015, 07:51
Default
  #10
Senior Member
 
Join Date: Jan 2013
Posts: 135
Rep Power: 13
kkpal is on a distinguished road
Thanks to this thread, my icoLinearFoam is also compiled.
Now I am trying to construct the operation matrix M, for U_{n+1}=MU_n, and analysis the eigenvalues of M to see if the base flow is stable or not.

Last edited by kkpal; December 6, 2015 at 09:26.
kkpal is offline   Reply With Quote

Old   December 6, 2015, 09:32
Default
  #11
Member
 
ali alkebsi
Join Date: Jan 2012
Location: Strasbourg, France
Posts: 82
Rep Power: 14
kebsiali is on a distinguished road
Hello
I think you either have a missing file or a miss-spell in the name of the file or inside U_zero
kebsiali is offline   Reply With Quote

Old   December 6, 2015, 09:42
Default
  #12
Senior Member
 
Join Date: Jan 2013
Posts: 135
Rep Power: 13
kkpal is on a distinguished road
Hi, ali,
Yes, I made a mistake and I've corrected it. I have successfully compiled and run it.
Now I would like to analyse the global stability of the flow by the eigenvectors (growth rate) of the matrix M by constructing U_{n+1}=MU_{n}, in which U is the velocity velocity vector. Any idea how to achieve this?
kkpal is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-dimensionalizing Navier Stokes VincentD Main CFD Forum 16 July 10, 2017 05:55
Navier stokes Equations in Unstructured Grid Mh.R Main CFD Forum 4 October 19, 2011 16:37
Navier stokes compresible viscid flow fea, somebody can help? Jose Choy Main CFD Forum 3 October 24, 2003 03:28
Presure range of the Navier Stokes Equations Dr. Tsimento Main CFD Forum 7 May 23, 2001 11:12
need help on solution to Stokes equations Yuksel Onsoy Main CFD Forum 3 November 2, 2000 06:54


All times are GMT -4. The time now is 15:58.