CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Laplacian(A*B)

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

Like Tree4Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   August 13, 2013, 02:28
Question Laplacian(A*B)
  #1
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
Hello, is possible solve in openFoam a function laplacian(k,A*B) where k is constant, A is known volScalarField and B is searched unknown (volScalarField)?

Thanks
Richard
immortality likes this.
Ricardo is offline   Reply With Quote

Old   August 13, 2013, 03:42
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
Did you consider fvm::laplacian(k*A,B)?
immortality likes this.
Bernhard is offline   Reply With Quote

Old   August 13, 2013, 06:22
Default
  #3
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
Yes I did, but I don't know if it is correct from mathematical point of view.
I need solve this:

dF/dt=laplacian(delta,P)
P is partial pressure and could be rewrite F = P / Psat
Psat is partial saturated pressure (function of Temperature)

I tried this, but without succes...
fvm::ddt(dw,F)=fvm::laplacian(delta*Psat,F)
fvm::ddt(dw,F)=fvc::laplacian(delta,Psat*F)

Thanks
Richard
Ricardo is offline   Reply With Quote

Old   August 13, 2013, 06:50
Default
  #4
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
when you say tried, but without success....what does that mean?

Could you not compile it?
Could you not run it?
Did it not yield the desired result?

fvm::ddt(dw,F)=fvm::laplacian(delta*Psat,F)

this should work and be your best bet...assuming Psat is just a constant.

just a note, but remember that
laplacian(k,AB) = div(k * grad(AB))
and is not, in general, equal to
laplacian(kA,B) = div(kA * grad(B))
only if A = const.
niklas is offline   Reply With Quote

Old   August 13, 2013, 06:53
Default
  #5
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
also
= is an assignement
== is checking if its equal

so in that implementation you should use ==
niklas is offline   Reply With Quote

Old   August 13, 2013, 07:00
Default
  #6
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
Quote:
Originally Posted by niklas View Post
== is checking if its equal
Not always: == operator
Bernhard is offline   Reply With Quote

Old   August 13, 2013, 07:05
Default
  #7
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 19
niklas will become famous soon enough
Quote:
Originally Posted by Bernhard View Post
Not always: == operator
true
sorry, should have clarified that I ment in this example
niklas is offline   Reply With Quote

Old   August 13, 2013, 07:11
Default
  #8
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
I have operator "==" in code, it is right, compile and solution done, but result is wrong, I think.

I write solver for Heat and Moisture transport in porous materials.
1 step - Temperature calculation (changing thermal parameters with moisture)
2 step - Humidity calculation (changing moisture parameters with temperature)
next Iterations...

Saturated Pressure is not a constant, it depends on temerature and the temperature is changing in time. Transport parameters are calculated in time and stored in volScalarFields.

Thanks
Richard
Ricardo is offline   Reply With Quote

Old   August 13, 2013, 07:32
Default
  #9
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Hi Ricardo
how you have solved this equation?! with which solver of OF?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 13, 2013, 07:36
Default
  #10
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
I started from basic Laplacian example, and still using PCG solver with DIC preconditioner, is it wrong?
Ricardo is offline   Reply With Quote

Old   August 13, 2013, 07:46
Default
  #11
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
No I just wanted to know.you are modifying the laplacianFoam,right? could you send me your case?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 13, 2013, 07:51
Default
  #12
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
Quote:
Originally Posted by immortality View Post
No I just wanted to know.you are modifying the laplacianFoam,right? could you send me your case?
It is not problem, but it doesn't work correctly now, ...
Ricardo is offline   Reply With Quote

Old   August 13, 2013, 07:56
Default
  #13
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
I just like to know the way you are doing it.no problem.maybe an idea occurred to me.
my email is: force.of.love@gmail.com if you want to send it.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 13, 2013, 08:10
Default
  #14
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
Quote:
Originally Posted by immortality View Post
I just like to know the way you are doing it.no problem.maybe an idea occurred to me.
my email is: force.of.love@gmail.com if you want to send it.
It has been send.

I am Ph.D. student, I would like use this program for simulations in my thesis. I wrote similar algorithm in 1D in Visual Basic, it works without any problem. OpenFOAM and C++ is new for me...
Richard
Ricardo is offline   Reply With Quote

Old   August 13, 2013, 16:45
Default Dont forget the chain rule
  #15
Senior Member
 
fabian_roesler's Avatar
 
Fabian Roesler
Join Date: Mar 2009
Location: Bad Friedrichshall, Germany
Posts: 161
Rep Power: 8
fabian_roesler is on a distinguished road
Hi,

when psat is a function of temperature, you are not allowed to pull it out of the gradient in the laplacian function. But you could use the chain rule to get an implicit term of F and an explicit term of psat. Here we go:

Eqn (1): This is your starting point
Code:
    fvm::ddt(dw,F)
  + fvm::laplacian(delta,psat*F)
Eqn (2): Split the gradient term
Code:
    fvm::ddt(dw,F)
  + fvc::div(delta*F*fvc::grad(psat) + delta*psat*fvc::grad(F))
Eqn (3): Split the divergence term
Code:
    fvm::ddt(dw,F)
  + fvc::div(delta*F*fvc::grad(psat))
  + fvm::div(delta*psat*fvc::grad(F))
Eqn (4): form the last two terms into laplacians again
Code:
    fvm::ddt(dw,F)
  + fvc::laplacian(delta*F,psat)
  + fvm::laplacian(delta*psat,F)
Eqn 4 should work for you. Try it out.

Regards

Fabian
immortality likes this.
fabian_roesler is offline   Reply With Quote

Old   August 13, 2013, 18:02
Default
  #16
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Code:
dF/dt=laplacian(delta,P)
P is partial pressure and could be rewrite F = P / Psat
Psat is partial saturated pressure (function of Temperature)

I tried this, but without succes... 
fvm::ddt(dw,F)=fvm::laplacian(delta*Psat,F)
fvm::ddt(dw,F)=fvc::laplacian(delta,Psat*F)
whats dw in these equations while it isn't in dF/dt?
Code:
Eqn (1): This is your starting point
Code:
    fvm::ddt(dw,F)
  + fvm::laplacian(delta,psat*F)
Eqn (2): Split the gradient term
Code:
    fvm::ddt(dw,F)
  + fvc::div(delta*F*fvc::grad(psat) + delta*psat*fvc::grad(F))
Eqn (3): Split the divergence term
Code:
    fvm::ddt(dw,F)
  + fvc::div(delta*F*fvc::grad(psat))
  + fvm::div(delta*psat*fvc::grad(F))
how and why implicit terms convert to explicit ones and vice versa?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 14, 2013, 02:43
Default
  #17
Senior Member
 
fabian_roesler's Avatar
 
Fabian Roesler
Join Date: Mar 2009
Location: Bad Friedrichshall, Germany
Posts: 161
Rep Power: 8
fabian_roesler is on a distinguished road
Hi

The first laplacian

Code:
  + fvc::laplacian(delta*F,psat)
accounts for the change in saturation pressure and would be zero for constant psat. It has to be treated explicit (fvc), as the conservation equation is for F. The second term

Code:
  + fvm::laplacian(delta*psat,F)
can be treated implicit (fvm) now due to the chain rule.

Regards

Fabian
fabian_roesler is offline   Reply With Quote

Old   August 14, 2013, 05:07
Default
  #18
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Quote:
laplacian(k,AB) = div(k * grad(AB))
Hi Niklas, laplacian(A)=d^2A/dx^2+d^2A/dy^2 in 2D but what means above laplacian(k,AB)?if they are multiply why laplacian(k,AB) is different from laplacian(kA,B)?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 14, 2013, 09:56
Smile
  #19
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
Quote:
Originally Posted by fabian_roesler View Post
Hi,
Code:
    fvm::ddt(dw,F)
  + fvc::laplacian(delta*F,psat)
  + fvm::laplacian(delta*psat,F)
Eqn 4 should work for you. Try it out.

Regards

Fabian

Thank you very much, I am going to try it.
Yesterday I used other approach (similar which I using in Visual Basic) for implicit scheme and I think that results was correct.

- generate fvscalarmatrix "mat" from laplacian(delta,F)
- multiply each cell in fvscalarmatrix mat by Psat in point of this cell (using lduAddressing)
- solve (fvm::ddt(dw,F)==mat)

But this code is more complicated and your approach seems better.

dw is aproximation function of sorption curve (relation between water content and relative humidity of air) it is nonlinear function, I forgot write in equation

Richard
Ricardo is offline   Reply With Quote

Old   August 14, 2013, 10:47
Default
  #20
New Member
 
Richard
Join Date: Aug 2013
Location: Zilina, Slovakia
Posts: 20
Rep Power: 3
Ricardo is on a distinguished road
The part "fvc::laplacian(delta*F,Psat)" causes stability problem,...

volScalarField F

internalField nonuniform List<scalar>
4000
(
0.503748
0.500001
0.5
0.5
0.5
0.5
0.49999
0.44179
-361.167
-2.31903e+06
0.500001
0.5
0.5
0.5
0.5
0.5
0.49999
0.44179
-361.165
-2.31902e+06
Ricardo is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:59.