CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   LaplacianFoam with non-constant Diffusion Coefficient (http://www.cfd-online.com/Forums/openfoam-programming-development/108845-laplacianfoam-non-constant-diffusion-coefficient.html)

aabbasi59 November 2, 2012 11:58

LaplacianFoam with non-constant Diffusion Coefficient
 
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.

treima November 5, 2012 03:19

Hi,

have you tried to convert the volScalarField to a surfaceScalarField with interpolate(...)?


regards

treima

aabbasi59 November 5, 2012 14:55

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

Sab November 6, 2012 14:29

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.

aabbasi59 November 6, 2012 17:41

Converting volScalarField to dimensionedScalar
 
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

Moslem November 6, 2012 18:01

Have you checked the Diff before using it in the solve (...) ?
for example using :
Info << Diff;
before solve?

aabbasi59 November 7, 2012 04:40

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!
:confused:
Regards,
Ali

Moslem November 7, 2012 06:32

2 Attachment(s)
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

aabbasi59 November 8, 2012 05:35

The problem was solved
 
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.
:D
Tanx a lot!!

Regards,
Ali

maalan July 14, 2013 14:32

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!

Moslem July 15, 2013 13:10

2 Attachment(s)
Quote:

Originally Posted by maalan (Post 439661)
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.
Attachment 23515

Attachment 23516

maalan July 16, 2013 07:47

It works! Thanks a lot, Moslem!

hrushi.397 July 31, 2013 02:17

Problem compiling laplacianFoam
 
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?


All times are GMT -4. The time now is 01:53.