# How to represent laplacian of a product of multiple terms?

 Register Blogs Members List Search Today's Posts Mark Forums Read

 February 14, 2019, 11:44 How to represent laplacian of a product of multiple terms? #1 Senior Member   Deep Join Date: Oct 2017 Posts: 180 Rep Power: 4 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. I know that following is not right: Code: fvm::laplacian((X/Y*mag(Z)), U) rarnaunot likes this.

February 14, 2019, 11:54
#2
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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. 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.

February 14, 2019, 12:07
#3
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 4
Quote:
 Originally Posted by massive_turbulence 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)")

February 14, 2019, 12:24
#4
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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 >)’ ); ^ 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

February 14, 2019, 12:32
#5
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 4
Quote:
 Originally Posted by massive_turbulence 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)".

February 14, 2019, 12:38
#6
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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?

February 14, 2019, 12:41
#7
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 4
Quote:
 Originally Posted by massive_turbulence 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 ().

February 14, 2019, 12:48
#8
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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?

February 14, 2019, 12:56
#9
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 4
Quote:
 Originally Posted by massive_turbulence 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 13:02. Reason: Not div, laplacian

February 14, 2019, 13:06
#10
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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?

February 14, 2019, 13:27
#11
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 4
Quote:
 Originally Posted by massive_turbulence 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!?

February 14, 2019, 14:47
#12
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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: /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!

 February 15, 2019, 08:58 #13 Senior Member   Deep Join Date: Oct 2017 Posts: 180 Rep Power: 4 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.

February 15, 2019, 10:54
#14
Senior Member

Andrew Somorjai
Join Date: May 2013
Posts: 172
Rep Power: 8
Quote:
 Originally Posted by deepbandivadekar 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.

February 18, 2019, 11:04
#15
Senior Member

Deep
Join Date: Oct 2017
Posts: 180
Rep Power: 4
Quote:
 Originally Posted by massive_turbulence 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.

March 17, 2020, 10:09
#16
Member

Rosario Arnau
Join Date: Feb 2017
Location: Spain
Posts: 44
Rep Power: 5
Quote:
 Originally Posted by deepbandivadekar deepbandivadekar My question is: How to represent laplacian of an expression which involves product of more terms involving various operators. e.g. I know that following is not right: Code: fvm::laplacian((X/Y*mag(Z)), U)

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,