CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to represent laplacian of a product of multiple terms? (https://www.cfd-online.com/Forums/openfoam-programming-development/214831-how-represent-laplacian-product-multiple-terms.html)

deepbandivadekar February 14, 2019 11:44

How to represent laplacian of a product of multiple terms?
 
\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)

massive_turbulence February 14, 2019 11:54

Quote:

Originally Posted by deepbandivadekar (Post 724779)
\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.

deepbandivadekar February 14, 2019 12:07

Quote:

Originally Posted by massive_turbulence (Post 724781)
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)")

massive_turbulence February 14, 2019 12:24

Quote:

Originally Posted by deepbandivadekar (Post 724784)
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 https://www.cfd-online.com/Forums/op...treatment.html

deepbandivadekar February 14, 2019 12:32

Quote:

Originally Posted by massive_turbulence (Post 724789)
I'm just curious if fvm::laplacian compiles?

There's also SuSp https://www.cfd-online.com/Forums/op...treatment.html

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)".

massive_turbulence February 14, 2019 12:38

Quote:

Originally Posted by deepbandivadekar (Post 724791)
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?

deepbandivadekar February 14, 2019 12:41

Quote:

Originally Posted by massive_turbulence (Post 724792)
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 (:confused:).

massive_turbulence February 14, 2019 12:48

Quote:

Originally Posted by deepbandivadekar (Post 724793)
Well I was thinking the same. But I just tried and no. Compilation fails with same errors again. Needs one more argument (:confused:).

With fvm::Sp or just fvm::laplacian, lets keep it simple. Maybe the fvSchemes file isn't correct?

deepbandivadekar February 14, 2019 12:56

Quote:

Originally Posted by massive_turbulence (Post 724796)
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)

massive_turbulence February 14, 2019 13:06

Quote:

Originally Posted by deepbandivadekar (Post 724798)
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?

deepbandivadekar February 14, 2019 13:27

Quote:

Originally Posted by massive_turbulence (Post 724801)
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. :confused:
What does that even mean!?

massive_turbulence February 14, 2019 14:47

Quote:

Originally Posted by deepbandivadekar (Post 724803)
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. :confused:
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" :confused:.

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!

deepbandivadekar February 15, 2019 08:58

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.

massive_turbulence February 15, 2019 10:54

Quote:

Originally Posted by deepbandivadekar (Post 724885)
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.

deepbandivadekar February 18, 2019 11:04

Quote:

Originally Posted by massive_turbulence (Post 724892)
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.

rarnaunot March 17, 2020 10:09

Quote:

Originally Posted by deepbandivadekar (Post 724779)
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,


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