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

how to modify the momentum eqn in a way that all dU/dx=0?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By marupio
  • 1 Post By marupio
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2014, 08:59
Default how to modify the momentum eqn in a way that all dU/dx=0?
  #1
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
Hi everybody,

I'm trying to modify the PisoFoam in a way that all dU/dz=0.
actually it's a method to reach a fully developed flow by exerting dU/dz=0 and setting the pressure gradient as a negative constant.

so in momentum equation I should get rid of any dU/dz, can I do something like:
Code:
            fvVectorMatrix UEqn
            (
                fvm::ddt(U)
//              + fvm::div(phi, U)
	      - fvm::div(phi, myU)
              + turbulence->divDevReff(U)
            );

            UEqn.relax();

            if (momentumPredictor)
            {
                solve(UEqn== -theGradP);
            }
which myU is the velocity vector that its z-component is zero???

the solver complied successfully by when I run it the following error appears
Code:
--> FOAM FATAL ERROR: 
incompatible fields for operation 
    [U] - [myU]

    From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)
    in file /home/mostafa/OpenFOAM/OpenFOAM-2.1.0/src/finiteVolume/lnInclude/fvMatrix.C at line 1300.

FOAM aborting
I think that's because I have both U and myU in one equation, but I don't know how to fixed this problem!!!!

any hints or tips would be appreciated.

Regards,
Mostafa
adambarfi is offline   Reply With Quote

Old   August 11, 2014, 12:57
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
You could try by creating an fvVectorMatrix with fvm::div(phi, U) first, then setting the z-component to zero, then bringing it into the full equation.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   August 11, 2014, 13:50
Default
  #3
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
thanks for the reply.

I tried it before but I couldn't find anything that I can define a new divergence scheme. I found the below address but I got nothing from that!
OpenFOAM/OpenFOAM-2.2.2/src/finiteVolume/finiteVolume/divSchemes

can you please explain more about it?

Regards,
Mostafa

p.s:
should I use something like:
Code:
84 tmp<fvVectorMatrix> Smagorinsky2::divDevReff
   85 (
   86     volVectorField& U
   87 ) const
   88 {
   89     volTensorField gradU(fvc::grad(U));
   90 
   91     volSymmTensorField aniNuEff
   92     (
   93         "aniNuEff",
   94         I*nuEff() + cD2_*delta()*symm(gradU)
   95     );
   96 
   97     return
   98     (
   99       - fvm::laplacian(aniNuEff, U) - fvc::div(nuEff()*dev(T(fvc::grad(U))))
  100     );
  101 }
but where and how?
adambarfi is offline   Reply With Quote

Old   August 12, 2014, 04:43
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
I don't think it's necessary to create a custom divergence scheme. What I meant was to do this all at the top-level, in your solver. Kind of like this (pseudo code):
Code:
// Create a regular matrix
fvVectorMatrix divUWithoutZ(fvm::div(phi, U));

// Set the z-component to zero
// Not sure exactly how off the top of my head, but it can be done

// Put it in your full equation
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ divUWithoutZ
+ turbulence->divDevReff(U)
);
And so on. Would take some tweaking - just an idea.
adambarfi likes this.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   August 12, 2014, 05:29
Default
  #5
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
Dear David,

That's a great idea. meanwhile, I need to exert this condition for all the dU/dz in the momentum eqn including the LES turbulent model, so I'm trying to combine the fvm::div(phi, U) and turbulence->divDevReff(U) into only turbulence->mydivDevReff() which will be defined in turbulenceModel and the LESModel. I hope using this method give me the correct solution, I doesn't I'll be here again

again thanks for your consideration,

Regards,
Mostafa
adambarfi is offline   Reply With Quote

Old   August 12, 2014, 09:16
Default
  #6
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
hmmm..., I did it but again the same error:

Code:
#0  Foam::error::printStack(Foam::Ostream&) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2   in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::OSstream::write(Foam::word const&) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#4  Foam::operator<<(Foam::Ostream&, Foam::word const&) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#5  void Foam::checkMethod<Foam::Vector<double> >(Foam::fvMatrix<Foam::Vector<double> > const&, Foam::fvMatrix<Foam::Vector<double> > const&, char const*) in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/bin/pisoFoamCS2"
#6  
 in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/bin/pisoFoamCS2"
#7  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#8  
 in "/home/mostafa/OpenFOAM/OpenFOAM-2.1.0/platforms/linux64GccDPOpt/bin/pisoFoamCS2"
Segmentation fault (core dumped)
the part of error which is bolded says me that again the problem is "incompatible fields for operation". for eliminating the dU/dz in the eqns I defined a myU vector which its z-component is zero throughout the grids using below code:
Code:
    volVectorField myU("myU", U);
    forAll(myU,cellI) 
    {
         scalar Ux=U[cellI].component(vector::X);
         scalar Uy=U[cellI].component(vector::Y);
         myU[cellI]=vector(Ux,Uy,0); 
    }
so in all my equation I have two separate fields: U and myU, so this error appears!

now I'm wondering how can I get rid of this component without using a new field? is there any way to turn this problem around?

Regards,
Mostafa


P.S:
the bigger problem is that I have grad(U) in my LES model, so I should exert this condition on it, too. therefore I probably should call something except U for my turbulence model and it's the biggest crisis!!!! because my model is unsteady and I have ddt(U) in my momentum eqn and again It would lead to having two different fields in one equation.
adambarfi is offline   Reply With Quote

Old   August 12, 2014, 09:30
Default
  #7
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
You posted the stack, not the error.

Don't define myU. Use the solution I suggested.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   August 12, 2014, 09:56
Default
  #8
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
dear David,

It was the only thing I got!! No error message
What do you mean "Use the solution"? Can you illuminate it more?
adambarfi is offline   Reply With Quote

Old   August 12, 2014, 10:32
Default
  #9
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
Sorry I'm not clear. It's just an idea.

The first bit of code you posted, the top bit with "fvVectorMatrix UEqn"... replace that constructor with the bit of code I posted above (after tweaking). Don't define a myU.

As for the LES, you may have to define a custom model because you don't have access to it at the solver level. But again, do the same thing there.
adambarfi likes this.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   August 12, 2014, 11:23
Default
  #10
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
thanks David,

I know what you mean and I understand where you're going, my problem is how to set the z-component to zero?
I need more time to think about it and brainstorming!

Regards,
Mostafa
adambarfi is offline   Reply With Quote

Old   August 17, 2014, 11:26
Default
  #11
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

At Mostafa's request, yesterday I finally took a look into this and after about 1h I didn't manage to figure it out. And unfortunately I currently do not have more time to look into this.

Nonetheless, Mostafa still asked me this after that:
Quote:
is there any way to modify the div, grad, and laplacian schemes in openFoam?
I searched the src but I got nothing!
This part of OpenFOAM's source code feels almost like having to go straight to a bee's nest with no protection. It's a part of the source code that is very heavily dependant on C++ templates, which can make it quite hard to comprehend how things work. Honestly, this makes me want to ask: Mostafa, are you reaaaaally certain that you want to force "dU/dz = 0"? Why not simply run the case in pseudo-2D?

Anyway... using the User Guide as a reference, the names provided on this chapter should help us find the right keywords in the source code: http://www.openfoam.org/docs/user/fvSchemes.php
The thing is that, for example, the "div" schemes are essentially just "Gauss" using an interpolation scheme, therefore one should not look for a "div" scheme to hack/modify, but rather it's the interpolation method that you should look for.
Therefore, for example, you can look for a reference file that defined "linearUpwind", like this:
Code:
find $FOAM_SRC -name "*.H" -type f | xargs grep linearUpwind
And what should you do when you find it? Simple: you have to study all of the interpolation schemes that are present in the parent folder(s) and search for ideas on how a new interpolation scheme can be implemented. Essentially, study the complete folder of "$FOAM_SRC/finiteVolume/interpolation/surfaceInterpolation/schemes".

Beyond this, there is already a lot of studying material here: http://openfoamwiki.net/index.php/OpenFOAM_guide

Good luck! Best regards,
Bruno
adambarfi likes this.
__________________
wyldckat is offline   Reply With Quote

Old   August 17, 2014, 11:58
Default
  #12
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
Hi Bruno,

Wooooow! that's a lot of work to do, I thought that's easy to do! everything is tied together
You know, I want to solve a fully-developed turbulence flow in a channel using by a LES model. So I thought that if I can exert the dU/dx in all the equations and setting a fixed pressure gradient I can just solve a section instead of whole channel. In this way, I shouldn't wait 2 days to solve just a geometry. But it seems that solving the whole geometry would be more quicker than exerting this condition.
anyway, due to the lack of time, I'll try to modify the schemes later and I certainly going to do that. Because I need the same condition for my next project.

Thanks Bruno for the time you spent to find a solution for my problem and I appreciate it. It gives me a better prospective which how can I do that. Hope I can modify the schemes finally.

Best Regards,
Mostafa


P.S:
How can I run a pseudo-2D case?
adambarfi is offline   Reply With Quote

Old   August 17, 2014, 12:23
Default
  #13
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by adambarfi View Post
How can I run a pseudo-2D case?
An example is the very first tutorial case on the user guide: http://www.openfoam.org/docs/user/cavity.php#x5-40002.1

Last edited by wyldckat; August 17, 2014 at 12:36. Reason: fixed typo
wyldckat 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
Modify granular temperature transport eqn HELP tim FLUENT 1 June 27, 2010 06:08
Derivation of Momentum Equation in Integral Form Demonwolf Main CFD Forum 2 October 29, 2009 19:53
How to momentum eqn with bouyancy forces?? seenu FLUENT 3 March 12, 2006 16:31
Define new Reynolds stress term in momentum eqn. satoshi FLUENT 0 November 6, 2005 22:12
How to solve another continuum and momentum eqn? west_wing FLUENT 0 August 25, 2003 10:00


All times are GMT -4. The time now is 19:04.