CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to write a solver beginner (http://www.cfd-online.com/Forums/openfoam-solving/59184-how-write-solver-beginner.html)

ivan_cozza January 8, 2008 14:00

Hi to evryone! I'm a complete
 
Hi to evryone!
I'm a complete beginner in openFOAM (I began readin the manuals since yesterday!!), and I'm intrested to build a model that, given a value of a passive scalar, transports it downstream with a convection speed that I have to read from a CFD simulation done before. The particularity is that I need to modify the transported scalar at each timestep and use this new value to calculate the new transported value.
It is possible in openFOAM??

schmidt_d January 22, 2008 23:01

Ivan, start by studying some o
 
Ivan, start by studying some of the utilities that loop over all existing output and calculation something from them (such as magU). You can use this as a starting point in your new code.

If memory serves, there is a wiki fragment floating about that gives some help about adding a transport equation.
-David

alberto January 23, 2008 13:54

Dear Ivan, what you need to
 
Dear Ivan,

what you need to do is easily doable in OpenFOAM, supposing you can convert the velocity field you have into the openFOAM format.

About the solver, give a look to scalarTransportFoam, in OpenFOAM/OpenFOAM-1.4.1/applications/solvers/basic

With a little change, you can adapt it to your case.

With kind regards,
Alberto

mlarenas January 24, 2008 16:10

Hi, I'm a complete beginner t
 
Hi,
I'm a complete beginner too. Today, I started modeling dust particles in presence of a velocity field, I think they are similar problems!

Alberto, when you say "give a look" to that solver... what do you mean? I understand the basics of the code... but I dont know exactly how to use it (I just completed the UserGuide cases, but you don't have too much work here... :P)

I have already calculated (using simpleFoam) the velocity field, so... now comes the dust part.

Please, we need help! http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Best regards,
Manuel

santos January 25, 2008 06:34

Hello Make a copy of the si
 
Hello

Make a copy of the simpleFoam solver (e.g. simpleFoam2), then edit simpleFoam2.C and add the scalar transport equation from scalarTransportFoam.C.

Search the forum for this particular problem, I think it has been addressed a few times.

Regards,
Josť Santos

alberto January 27, 2008 13:05

Hello Manuel, what I meant
 
Hello Manuel,

what I meant is that scalarTransportFoam calculates the evolution in time of a passive scalar in a frozen velocity field.

If you already calculated the velocity field with simpleFoam and you simply want to trace a passive scalar using that velocity field, you can do as follows:

- Clone the scalarTransportFoam tutorial.
- Copy the mesh of your case in it (blockMeshDict if you use blockMesh) and generate the grid.
- Copy the velocity field (U) you calculated in the case directory.
- Adapt the boundary conditions for T to your case.
- Run the case.

Of course, if you want to couple the calculation of the velocity field with the solution of the scalar transport equation you should do what Josť suggested above.

Regards,
Alberto

mlarenas January 28, 2008 09:59

Hi Alberto, thank you very mu
 
Hi Alberto,
thank you very much for your reply. I did what you said, I gave a look to the tutorial case (pitzDaily) in scalarTransportFoam and copied the velocity field I calculated before to a cloned case. Unfortunately, it seems that T does not diffuse from the boundary... I tried everything... but with no results. Can you give a look to my case please? I could send it to your email (~10 mb), it shouldn't take more than 5 minutes to you http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Best regards,
Manuel

alberto January 29, 2008 12:05

Read your e-mail :-) Regard
 
Read your e-mail :-)

Regards,
A.

asteria January 30, 2008 07:25

Hi all. I have similar prob
 
Hi all.

I have similar problem you guys. I'm trying to solve some scalar transport equations,

But there is some difference in my problem with what is mentioned above. It is that the flux is influenced by the transported scalar. so I added this line after solving U eqn.


------------------------------------------------
surfaceScalarField coeffiC4 = rhoa/rhob/18./nub*fvc::interpolate(m6);
surfaceScalarField coeffi4 = (coeffiA - coeffiB)*coeffiC4;

fvScalarMatrix m4Eqn
(
fvm::ddt(m4)
+ fvm::div(phib + coeffi4/(fvc::interpolate(m4)), m4, "div(phib,m0)")
);

m4Eqn.relax();
m4Eqn.solve();
--------------------------------------------

So I want the flux(phib + coeffi4/(fvc::interpolate(m4))) be changed as m4 is changed during iteration.

Do you think I am going right way?
I'm not sure that it reads flux each iteration inside of solver.

Any advices will be appreciated http://www.cfd-online.com/OpenFOAM_D...part/happy.gif
Thanks.

Hyunchang.

asteria January 30, 2008 07:31

And anybody knows what 'm4Eqn.
 
And anybody knows what 'm4Eqn.relax()' means?

I know this question could be foolish, but I did.

antopnieta January 30, 2008 17:25

Hi all: I need modelling a
 
Hi all:

I need modelling a heat transfer in a steel ball with his surface a constant temperature, the temperature of the surface is more less than of the interior. All this in transient.

My mesh is a semicircle....

I begin do this with buoyantFoam.... but... i have a question... where put h, cp, rho???... and... the thermophysical properties i suppose that are of the ball... or not??

I hope you can help me....

Antonieta...

dmoroian January 31, 2008 04:07

Hi Antonieta, If the surface
 
Hi Antonieta,
If the surface temperature of the ball is constant, and you are interested only in the temperature inside the ball, why don't you use directly the laplacianFoam? Why do you need the buoyanFoam solver?

Dragos

mlarenas January 31, 2008 08:42

Hola compatriota! same thing.
 
Hola compatriota!
same thing... buoyantFoam is a transient solver for turbulent fluids, so I don't understand why you're using it for the steel ball. Maybe you could explain your model better http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Saludos,
Manuel

antopnieta January 31, 2008 08:58

Dear Dragos My problem is
 
Dear Dragos


My problem is a hot steel ball that cold with water... but for simplicity (and because first I have to do in this form) I suposse that the surface temperature is less than of the interior....

And I use BuoyantFoam because i think that is the best solver fot heat transfer in transient... and because the temperature in the sphere change with the properties that have (k, rho, Cp,...).... or not??

Now I use laplacianFoam to probe... but I don't know if I can add the properties of the sphere... :S

What is the best solver to this??? laplacian??? buoyant??? other???

Antonieta

dmoroian January 31, 2008 09:20

Ok, a little more light came h
 
Ok, a little more light came http://www.cfd-online.com/OpenFOAM_D...part/happy.gif.
If you want to compute the whole domain (including water and steel) then you have a so called conjugate heat transfer problem. In this case you have two different sets of equations to solve on two different domains:
1. Navier-Stokes or other simpler model for the fluid region.
2. Heat equation for the solid region.
As I understood, Hrv developed a new coupled block mesh library which is able to solve such a problem: Integrated conjugate heat transfer solver in OpenFOAM
Some time ago, Daniele wrote also a conjugate heat transfer solver: conjugate heat transfer.
So you may try those examples above.
But if you have constant temperature at the surface of the ball, I don't see the need to compute the fluid flow. Consequently, you should solve only the heat equation inside the solid domain. That you can do by using the laplacianFoam solver. The properties you mention (k, rho, Cp), are included in the heat diffusivity coefficient (DT = k/rho/Cp) in constant/transportProperties dictionary.

I hope this will help you!
Dragos

antopnieta January 31, 2008 09:20

Hi Manuel... I am really n
 
Hi Manuel...

I am really new in this... and anybody of my partners know something about OF... can you give me your mail for explain better my problem... because it's more easy to me explain all in spanish....

I wait your answer...

Thank!

asteria January 31, 2008 09:24

Hi, all. Are there anybody wh
 
Hi, all.
Are there anybody who can help? :-)
maybe I need to clarify my question to make myself understood. Here I go.
I'm solving a scalar transport equation like
ddt(psi) + div(phi, psi) = 0

but here phi is a function of psi. So it should be changed in the iteration. So I write a code like this.

fvScalarMatrix m4Eqn
(
fvm::ddt(m4)
+ fvm::div(phib + coeffi4/(fvc::interpolate(m4)), m4, "div(phib,m0)")
);

m4Eqn.relax();
m4Eqn.solve();

Here, m4 is scalar what I want to solve and we already know phib and coeffi4 which don't change in this iteration.

I have solved my cases by this code but it seems once it read flux then it doesn't read flux again, so the flux doesn't change and it is not what I want. T.T

I'm not sure that myself is understood.
any question or comments are welcomed!!

Hyunchang

antopnieta January 31, 2008 09:28

Thank Dragos! I had not rea
 
Thank Dragos!

I had not realized of the diffusivity.... really... I was looking for DT in user's guide... because I know diffusivity like alpha... http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

Thank again... I run now with laplacian...

Antonieta

mlarenas January 31, 2008 11:14

No problem Antonieta! You can
 
No problem Antonieta!
You can see my email address in my profile, just clicking on my name http://www.cfd-online.com/OpenFOAM_D...part/happy.gif
I'm a beginner too, but we can help each other using email.

Saludos,
Manuel

mlarenas January 31, 2008 11:24

Hi Hyunchang, if I'm not wron
 
Hi Hyunchang,
if I'm not wrong, you need to solve the coupled equations... in that case I recommend you to email Alberto Passalacqua (he posted above). He sent me a very useful solver coded by himself, he is a very nice guy ;)
I'm just a beginner, so... it's all the help I can give you by now.

Kind regards,
Manuel


All times are GMT -4. The time now is 12:56.