# LaplacianFoam with non-constant Diffusion Coefficient

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

 November 2, 2012, 11:58 LaplacianFoam with non-constant Diffusion Coefficient #1 New Member   Ali Abbasi Join Date: Apr 2012 Location: Delft, The Netherlands Posts: 12 Rep Power: 7 Sponsored Links Hi FOAMERS, I want to solve the laplacian equation for heat transfer in a solid.It's a very simple problem. But I want to use a non-constant Diffusion coefficient{fvm::ddt(T) - fvm::laplacian(Diff, T) }. It is simple too. I have add the below part to laplacianFoam.C and compile it again. There isn't any problem in compiling but when I run a case it doesn't work correctly. the problem is that the new solver doesn't consider the new Diff. I think the problem is in converting volScalarField to Diff in laplacian equation. The added part: //************************************************** ************* volScalarField Diff ( IOobject ( "Diff", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("zero",dimensionSet(0,2,-1,0,0),0.0) ); Diff=kvan*uStar*(Depth-mesh.C().component(1))*exp(-1*kStar*(Depth-mesh.C().component(1))); solve ( fvm::ddt(T) - fvm::laplacian(Diff, T) ); //************************************************** ********** Every opinion would be appreciated.

 November 5, 2012, 03:19 #2 Member   Join Date: Mar 2012 Location: Munich, Germany Posts: 67 Rep Power: 7 Hi, have you tried to convert the volScalarField to a surfaceScalarField with interpolate(...)? regards treima

 November 5, 2012, 14:55 #3 New Member   Ali Abbasi Join Date: Apr 2012 Location: Delft, The Netherlands Posts: 12 Rep Power: 7 Dear Treima, tanx for your post, but this parameter is a volScalarField and converting it to surfaceScalarField will not solve the problem. In addition if you have a look to this post; http://www.cfd-online.com/Forums/openfoam-programming-development/81698-non-constant-diffusion-coefficient.html then you will accept my opinion. I am very complicated why I run the case it seems that the Diff is equal zero!!! Regards, Ali

 November 6, 2012, 14:29 #4 New Member   M.Sabouri Join Date: Oct 2012 Posts: 2 Rep Power: 0 Hi, It is not clear what kind of error you have encountered. It seems that the code runs without any error, but you see no change in the results with respect to the original case. Is it the problem? If so, you may have forgotten to delete the first declaration for the Diff and the new Diff could be defined because of overloading capability. But the code uses the first scalar Diff.

 November 6, 2012, 17:41 Converting volScalarField to dimensionedScalar #5 New Member   Ali Abbasi Join Date: Apr 2012 Location: Delft, The Netherlands Posts: 12 Rep Power: 7 Dear Sab(Sboori); Thank you for your advice. Let me explain two situations: 1- When I use DT(dimensionedScalar: a constant value) in createFields there isn't any problem and the results are OK. 2- When I use Diff(volScalarField: a non-constant value) in createFields there isn't any problem in compiling the code but when I run a case with new solver it seems that the Diff is equal to zero.I mean the equation is solved with Diff(or DT) =0.(please see:http://www.cfd-online.com/Forums/ope...efficient.html) I don't know why but I think the problem is related to definition of Diff as a volScalarField. I am waiting for your advice. Regards, Ali

 November 6, 2012, 18:01 #6 New Member   M. Sabouri Join Date: Nov 2011 Posts: 24 Rep Power: 7 Have you checked the Diff before using it in the solve (...) ? for example using : Info << Diff; before solve?

 November 7, 2012, 04:40 #7 New Member   Ali Abbasi Join Date: Apr 2012 Location: Delft, The Netherlands Posts: 12 Rep Power: 7 Dear Moslem, Tanx for your comment. In fact, when I run the new solver there isn't any result. It gives me "T" in each time step but it seems that the solver solves laplacian equation with Diff=0. I have changed the value and even its function but the problem have not been solved. I think the problem is related to the considering a volScalarField as Diff. coefficient in laplacian equation. I have checked the value of Diff in each time step and they were correct but these values were not put in laplacian equation. I am waiting for your solutions! Regards, Ali

November 7, 2012, 06:32
#8
New Member

M. Sabouri
Join Date: Nov 2011
Posts: 24
Rep Power: 7
Hi,
There is no problem with that. I tested a simple problem (rectangle of uniform initial temperature and a higher temp on the top).
with:
kvan=1.0
kStar=1.0
uStar=1.0
Depth=1.0
Attached Images
 Initial.jpg (44.0 KB, 18 views) final_T.jpg (44.0 KB, 17 views)

Last edited by Moslem; November 7, 2012 at 11:49.

 November 8, 2012, 05:35 The problem was solved #9 New Member   Ali Abbasi Join Date: Apr 2012 Location: Delft, The Netherlands Posts: 12 Rep Power: 7 Dear Moslem, Thanks for your useful post. I checked my code few times and found the problem. The function for Diff in my code is a function of depth(z) and its value for z=0 is 0 so in the top of domain Diff=0. So there isn't any transportation of heat. so it sees that the Diff=0. I edited the the code and the problem was solved. Tanx a lot!! Regards, Ali

 July 14, 2013, 14:32 #10 Member   Join Date: Jun 2011 Posts: 79 Rep Power: 8 Hi there!! I am trying to solve the laplace's equation for a scalar phi over an arbitrary domain!! do you know how I should modify the laplacianFoam application?? I have noticed in the .C file the laplacian application has 2 inputs and I just need one of them: laplacian(phi). By the moment, the steps I have followed have been: 1) create my phi volScalarField in the same manner as T in the original laplacianFoam, and comment the rest 2) leave the original libraries in the top of the laplacianFoam.C file and modify the diffusion equation by solve ( fvm::laplacian(phi); ); It should be very easy, but I don't see the mistake! Thanks a lot!

July 15, 2013, 13:10
#11
New Member

M. Sabouri
Join Date: Nov 2011
Posts: 24
Rep Power: 7
Quote:
 Originally Posted by maalan Hi there!! I am trying to solve the laplace's equation for a scalar phi over an arbitrary domain!! do you know how I should modify the laplacianFoam application?? I have noticed in the .C file the laplacian application has 2 inputs and I just need one of them: laplacian(phi). By the moment, the steps I have followed have been: 1) create my phi volScalarField in the same manner as T in the original laplacianFoam, and comment the rest 2) leave the original libraries in the top of the laplacianFoam.C file and modify the diffusion equation by solve ( fvm::laplacian(phi); ); It should be very easy, but I don't see the mistake! Thanks a lot!
Hi,
Find the attachment.

plate.zip

 July 16, 2013, 07:47 #12 Member   Join Date: Jun 2011 Posts: 79 Rep Power: 8 It works! Thanks a lot, Moslem!

 July 31, 2013, 02:17 Problem compiling laplacianFoam #13 Member   Hrushi Join Date: Jan 2013 Posts: 58 Rep Power: 6 Hi all, I have made some changes to laplacianfoam and I want to run it, but wmake gives following error: error: simpleControl.H could not be found Any ideas why this could be happening?

 Tags diffusion coefficient, laplacianfoam

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 lzgwhy Main CFD Forum 1 January 11, 2011 19:44 manaliac Main CFD Forum 2 November 29, 2010 07:25 Miguel Baritto CFX 4 August 31, 2006 12:02 iceabc FLUENT 1 June 10, 2004 10:04