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

How to represent laplacian of a product of multiple terms?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By deepbandivadekar

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 14, 2019, 12:44
Default How to represent laplacian of a product of multiple terms?
  #1
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
\frac{\partial \rho U}{\partial t} + \bigtriangledown \bullet \phi U - \bigtriangledown \bullet \mu\bigtriangledown U = -\bigtriangledown p

This is represented as
Code:
solve
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(mu, U)
==
- fvc::grad(p)
)
Specifically, where laplacian operator is used, it's a product of phi and U (only two terms).



My question is: How to represent laplacian of an expression which involves product of more terms involving various operators. e.g.
\bigtriangledown \bullet \frac{X}{Y} \mid Z\mid \bigtriangledown U
I know that following is not right:
Code:
fvm::laplacian((X/Y*mag(Z)), U)
rarnaunot likes this.
deepbandivadekar is offline   Reply With Quote

Old   February 14, 2019, 12:54
Default
  #2
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
\frac{\partial \rho U}{\partial t} + \bigtriangledown \bullet \phi U - \bigtriangledown \bullet \mu\bigtriangledown U = -\bigtriangledown p

This is represented as
Code:
solve
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(mu, U)
==
- fvc::grad(p)
)
Specifically, where laplacian operator is used, it's a product of phi and U (only two terms).



My question is: How to represent laplacian of an expression which involves product of more terms involving various operators. e.g.
\bigtriangledown \bullet \frac{X}{Y} \mid Z\mid \bigtriangledown U
I know that following is not right:
Code:
fvm::laplacian((X/Y*mag(Z)), U)
I'm not sure if this is right but fvm::Sp() solves this implicitly so that it adds to the diagonal matrix so basically you would do something like

fvm::Sp( fvc::laplacian((X/Y*mag(Z)), U)?

Notice I have fvc so that it solves for the laplacian explicit and then it multiplies U and that goes to the diagonal, but once again I've never tried this so that might be wrong.
massive_turbulence is offline   Reply With Quote

Old   February 14, 2019, 13:07
Default
  #3
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
I'm not sure if this is right but fvm::Sp() solves this implicitly so that it adds to the diagonal matrix so basically you would do something like

fvm::Sp( fvc::laplacian((X/Y*mag(Z)), U)?

Notice I have fvc so that it solves for the laplacian explicit and then it multiplies U and that goes to the diagonal, but once again I've never tried this so that might be wrong.

Thanks for a quick reply. But no, this doesn't work.
The error is:
Code:
error: no matching function for call to ‘Sp(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
             );
             ^
and further below:
Code:
note:   candidate expects 2 arguments, 1 provided
             );
             ^
But we've provided both arguments! (", U)")
deepbandivadekar is offline   Reply With Quote

Old   February 14, 2019, 13:24
Default
  #4
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Thanks for a quick reply. But no, this doesn't work.
The error is:
Code:
error: no matching function for call to ‘Sp(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
             );
             ^
and further below:
Code:
note:   candidate expects 2 arguments, 1 provided
             );
             ^
But we've provided both arguments! (", U)")

I'm just curious if fvm::laplacian compiles?

There's also SuSp fvMatrix, fvOptions and SuSp: automatic implicit/explicit source-term treatment
massive_turbulence is offline   Reply With Quote

Old   February 14, 2019, 13:32
Default
  #5
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
I'm just curious if fvm::laplacian compiles?

There's also SuSp fvMatrix, fvOptions and SuSp: automatic implicit/explicit source-term treatment
Well, without the Sp, it sure did compile earlier. But wasn't successful in running a case. From the crash error I was sure it was about the way it is represented. SuSp is just about distinguishing implicit/explicit, I believe.
The core issue I think is handling this term here: "X/Y * mag(Z)".
deepbandivadekar is offline   Reply With Quote

Old   February 14, 2019, 13:38
Default
  #6
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Well, without the Sp, it sure did compile earlier. But wasn't successful in running a case. From the crash error I was sure it was about the way it is represented. SuSp is just about distinguishing implicit/explicit, I believe.
The core issue I think is handling this term here: "X/Y * mag(Z)".
The magnitude must be messing up the parsing or something. It works with X/Y right?
massive_turbulence is offline   Reply With Quote

Old   February 14, 2019, 13:41
Default
  #7
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
The magnitude must be messing up the parsing or something. It works with X/Y right?

Well I was thinking the same. But I just tried and no. Compilation fails with same errors again. Needs one more argument ().
deepbandivadekar is offline   Reply With Quote

Old   February 14, 2019, 13:48
Default
  #8
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Well I was thinking the same. But I just tried and no. Compilation fails with same errors again. Needs one more argument ().
With fvm::Sp or just fvm::laplacian, lets keep it simple. Maybe the fvSchemes file isn't correct?
massive_turbulence is offline   Reply With Quote

Old   February 14, 2019, 13:56
Default
  #9
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
With fvm::Sp or just fvm::laplacian, lets keep it simple. Maybe the fvSchemes file isn't correct?

Compilation worked with simple fvm::laplacian in my first post. But case failed citing wrong dimensions. This was bound to happen because I was prompted to have a term in fvSchemes for a physically unrealistic quantity (e.g. laplacian of X/mag(Z)*mag(Z) instead of expected laplacian of X/mag(Y)*mag(Z).. as in the original expression). This led me think I'm not representing it right.


With fvm::Sp it never managed to compile. Same error everytime. I just also tried changing the sequence of Sp and laplacian. Doesn't work.
Code:
fvm::laplacian(fvc::Sp(1/Y, fvc::Sp(X,mag(Z))), U)

Last edited by deepbandivadekar; February 14, 2019 at 14:02. Reason: Not div, laplacian
deepbandivadekar is offline   Reply With Quote

Old   February 14, 2019, 14:06
Default
  #10
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Compilation worked with simple fvm::laplacian in my first post. But case failed citing wrong dimensions. This was bound to happen because I was prompted to have a term in fvSchemes for a physically unrealistic quantity (e.g. laplacian of X/mag(Z)*mag(Z) instead of expected laplacian of X/mag(Y)*mag(Z).. as in the original expression). This led me think I'm not representing it right.


With fvm::Sp it never managed to compile. Same error everytime. I just also tried changing the sequence of Sp and laplacian. Doesn't work.
Code:
fvm::laplacian(fvc::Sp(1/Y, fvc::Sp(X,mag(Z))), U)
Could it be possible to solve for this term "X/Y * mag(Z)" outside of the laplacian or sp and then put that variable into the laplacian?
massive_turbulence is offline   Reply With Quote

Old   February 14, 2019, 14:27
Default
  #11
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
Could it be possible to solve for this term "X/Y * mag(Z)" outside of the laplacian or sp and then put that variable into the laplacian?
Hmm, that's a good idea. Tried this. Compiler doesn't give any problems. Case still is stuck.


Weird error:
Code:
--> FOAM FATAL IO ERROR: 
keyword laplacian(laplacian(

 file: <path to case folder>/system/fvSchemes.laplacianSchemes from line 37 to line 41.
There is no syntax error in fvSchemes, I checked.
What does that even mean!?
deepbandivadekar is offline   Reply With Quote

Old   February 14, 2019, 15:47
Default
  #12
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Hmm, that's a good idea. Tried this. Compiler doesn't give any problems. Case still is stuck.


Weird error:
Code:
--> FOAM FATAL IO ERROR: 
keyword laplacian(laplacian(

 file: <path to case folder>/system/fvSchemes.laplacianSchemes from line 37 to line 41.
There is no syntax error in fvSchemes, I checked.
What does that even mean!?
Weird, I was thinking it was maybe a type error with X Y or Z not being differentiable but now it compiles which implies it's not a type error? I honestly don't know enough about the schemes myself so unless someone helps beyond here I'm "game over" .

If you could post your schemes file that might help someone see something that was overlooked or maybe you could just upload the parts of your project that are necessary to see the problem, not the whole thing (unless you don't mind). Best regards!
massive_turbulence is offline   Reply With Quote

Old   February 15, 2019, 09:58
Default
  #13
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Thanks for your help so far nonetheless. I also tried to change the order of terms and it doesn't change the situation much.



I'll try to share more if I can soon.
deepbandivadekar is offline   Reply With Quote

Old   February 15, 2019, 11:54
Default
  #14
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
Thanks for your help so far nonetheless. I also tried to change the order of terms and it doesn't change the situation much.



I'll try to share more if I can soon.
I'm wondering if you can represent the Laplacian in terms of the grad and div instead and try that by breaking down the equation for the X/Ymag(Z) term.

Basically you solve for that part separately and then solve the Laplacian by taking the divergence of the gradient literally.
massive_turbulence is offline   Reply With Quote

Old   February 18, 2019, 12:04
Default
  #15
Senior Member
 
Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 9
deepbandivadekar is on a distinguished road
Quote:
Originally Posted by massive_turbulence View Post
I'm wondering if you can represent the Laplacian in terms of the grad and div instead and try that by breaking down the equation for the X/Ymag(Z) term.

Basically you solve for that part separately and then solve the Laplacian by taking the divergence of the gradient literally.
I'm not quite following you. I mean I don't see the math behind this. I managed to get rid of this error, however now I have a dimension mismatch when solving a case. Which is absolutely absurd. I have checked the units hundred times now but I think it doesn't interpret the terms as I think they are interpreted.


So, I was wondering if there's any way to print the dimensions of a certain quantity (with or without the value) as the solver runs? I bumped up an old thread here if you want to see what I mean.
deepbandivadekar is offline   Reply With Quote

Old   March 17, 2020, 11:09
Default
  #16
Member
 
Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 57
Rep Power: 9
rarnaunot is on a distinguished road
Quote:
Originally Posted by deepbandivadekar View Post
deepbandivadekar
My question is: How to represent laplacian of an expression which involves product of more terms involving various operators. e.g.
\bigtriangledown \bullet \frac{X}{Y} \mid Z\mid \bigtriangledown U
I know that following is not right:
Code:
fvm::laplacian((X/Y*mag(Z)), U)
Dear deepbandivadekar,

Have you solved your problem?

I would like to ask you if fvm::laplacian can have three terms or it just can have 2 terms.

Have you tried with something like this?
Code:
      - fvm::laplacian
        (
            fvc::interpolate(alpha)
           *fvc::interpolate(this->turbulence().nut()*rho/Sc_),
            Yi
        )
This appears in https://github.com/OpenFOAM/OpenFOAM...ntPhaseModel.C

Actually, I'm not sure what fvc::interpolate does but there's a product and division at the second term nut*rho/Sc ....

Regards,
rarnaunot 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
MULES with source terms and multiple phases tgvosk OpenFOAM Running, Solving & CFD 8 March 21, 2018 07:14
Question in definition of terms in solve titio OpenFOAM Running, Solving & CFD 0 March 19, 2009 17:02
Doubts on how to represent some terms for viscoelastic Flow Simulation titio OpenFOAM Running, Solving & CFD 0 February 4, 2009 08:42
Multiple species and UDS source terms Ale FLUENT 2 September 9, 2002 04:45
K-Epsilon model? Brindaban Ghosh Main CFD Forum 2 June 24, 2000 05:22


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