The problem is like this: a em
The problem is like this: a empty room with one inlet and one outlet. I am using simpleFoam solver and I've added a scalar transport equation in the solver to calculate the concentration at the outlet. The transport scalar is released at the inlet. And it is working well.
Now I have a question: Since this model might be extended to solve more than 30 species (transport scalar), it might be a burden to solve all these transport equations every iteration. Can I solve the flow field first and then "freeze" it while solving the transport equation? How could I do it? The other question is: how could I get the surface average concentration at the outlet? I tried to follow the "scalarTransport" example "pPrime2" and I could get all the cell face value at the outlet and then average them (since the grid is uniform). But I know it is quite a detour and there should be a much easy way to do it. Please give me some hint. A example will be even better for a C++ beginner like me. Thank you very much! 
Hi guys,
The last question
Hi guys,
The last question is already solved. I digged through all the threads and tried different things out. Finally I got what I want. But for the first question, I still cannot get any hint through old threads. Can anyone help me with it? Again the question is: How can I solve the flow field first and then, solve scalar transport equations using the known velocity field. My scalar(Y) transport equation looks like: solve ( fvm::div(phi,Y)fvm::laplacian(DI,Y) ) Any hint is appreciated!! 
Hello Simon,
Perhaps I miss
Hello Simon,
Perhaps I miss something in your first question, but I would answer to just inplement the scalar transport equation you want to resolve after the velocity be computed. For getting the surface average concentration at the oulet just inspire yu from the threat "Calculation of integral boundary values" in the forum (you can find it easily by search "sum(") using sum and identification of BC patch. Anne 
Hi Anne,
Thank you very mu
Hi Anne,
Thank you very much for your reply. Now I can calculate the surface average concentration. But I am still not very clear about the first question. Do you suggest that I run "simpleFoam mycase" and then run "scalarTransportFoam mycase"? If so, how should I adjust the createFields.H file so that the scalarTransportFoam solver could read in the solved flow field (U or Phi)? Or do I just simplely add the scalar transportequation in a new solver based on simpleFoam with adding the line " solve (fvm::div(phi,Y)fvm::laplacian(DI,Y)); ? If so, should I put it in a new loop (not in the runTime loop) so that it can be solved after the flow field is solved? It will save a lot of time if the flow field is solved. For example, if solve the flow field and the scalar transport together need 1000 iterations to converge. But solve the scalarTransport with flow field solved first (use 1000 iterations) might only need 100 iterations. It is obvious that it saves time if decouple the two solving process) I know my questions might be stupid and I wish I had made myself clear. Please help me understand this! Thank you so much! Simon 
Well, take the simpleFoam solu
Well, take the simpleFoam solution you like (any timestep or iteration will do) and use the U and phi fields from that solution in the starting directory for your scalarTransportFoam application. I'm sure you've got the drift. :)
Enjoy, Hrv 
Sorry for late response. Thank
Sorry for late response. Thanks Hrv, it works with your idea. I also found another way to do it that is adding the line "solve (fvm::div(phi,Y)fvm::laplacian(DI,Y));" at the end of the runTime loop and run it only once. Since all the variable in the equation is known by then except Y, it can be solved in only one iteration, right? (steady state problem) I've tried it and it seems right. Could anyone comment on this?
Thanks again for your help! 
Ohh, I forgot to mention that
Ohh, I forgot to mention that there still is a little trouble when I tried to add this line (solve...) to buoyantSimpleFoam. It seems that the "phi" is not what I expected as "U*rho". I added this line in the main after "#include pEqn.H". Any suggestions? Thanks a bunch!!

Hello,
I want to simulate t
Hello,
I want to simulate the transport of a passive scalar in a periodic internal velocity field which is obtained by an icoFoam simulation. I created a new solver based on icoFoam and scalarTransportFoam (I notably added the lines related to the scalar transport equation at the end of the runTime loop of icoFoam). This works but it is too slow for complicated geometry and when I want to compute the transport of the scalar during many periods. It would be much quicker if I could use the results obtained with an unsteady icoFoam simulation for a single period (I would not have to calculate the same periodic internal velocity and pressure fields for each period). Is it possible to change the scalarTransportFoam solver to read different internal velocity fields for each time step? Could you please give me some advice to do that? Thank you very much Jerome 
1) Does your scalar diffuse? I
1) Does your scalar diffuse? If it is purely transport, there are some postprocessors that have transport builtin. ('streak lines'?)
2) Move the construction of e.g. phi or U (now in createFields.H ?) into the time loop for (runTime++; !runTime.end(); runTime++) { Info<< "Time = " << runTime.timeName() << nl << endl; surfaceScalarField phi ( IOobject ( "phi", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ) ); The 'MUST_READ' argument makes sure it reads the field from file. 
Also, if you want to reread pe
Also, if you want to reread periodic flow data from earlier times, you might want to modify the
runTime.timeName() entry in the constructor so that it reads from the correct old times and not the current time. e.g scalar readTime = runTime.value()  offset; surfaceScalarField phi ( IOobject ( "phi", runTime.timeName(readTime), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ) ); 
Thank you very much for your h
Thank you very much for your help.
Yes, my scalar diffuses. I will try what you proposed. Jerome 
Hello,
The scalar that is t
Hello,
The scalar that is transported is a mass. However, I noticed that sometimes, I obtain small negative values at some cell centres. Is there any way to avoid that? Would it be possible to inform the solver that only positive values are expected? I tried to use other numerical schemes for that but it did not change anything. Is there any interpolation, laplacian or divergence schemes that I can use to obtain a positive and conservative scalar? Thank you very much Jerome 
Yup, upwing differencing on co
Yup, upwing differencing on convaction, Euler implicit in time and uncorrected laplacian guarantees the solution to be bounded and conservative on all meshes. Howeler, this is usually an overkill (you are throwing away quite a lot of accuracy), and a less aggressive discretisation is sufficient. For example:
 Gamma differencing scheme on convection (or Gamma01, if you are transporting a scalar bounded between 0 and 1, e.g. concentration).  Euler implicit in time  Gauss linear limited 1.0 on the laplacian. Once this is in place, you just need to make sure that your sink terms are implicit for the lower limit and switch properly if the scalar is bounded above as well. Enjoy, Hrv 
Thank you very much for your a
Thank you very much for your answer.
I tried what you said and I can obtain only positive values now. I still have some questions: 1. For the convection, I used a Gamma01 differencing scheme and I tried different values for the parameter. For "Gamma01 1" and "Gamma01 0.5", it is ok but for "Gamma01 0", I have some negative values. Do you advise me to use only "Gamma01 1"? 2. I would like to have a confirmation about the meaning of the scalar transport calculation. As far as I understood, as I take the "phi" field from an icoFoam simulation, this is only the flux without taking the fluid density into account, so doing solve ( fvm::ddt(C) + fvm::div(phi, C)  fvm::laplacian(DT, C) ); is equivalent to solving the following passive scalar equation: ¶C/¶t + U Â• ÑC = DT Ñ2(C) with for instance C the concentration in kg / m3, U the velocity field, and DT the diffusivity constant. Thank you very much if you can confirm that, Jerome 
hi,
i want to add a scalar tr
hi,
i want to add a scalar transport equation to the icoFoam solver.my eqn is : fvm::ddt(C) == fvc::grad (C,U) is my equation correct and where do i implement it in my solver? thanks in advance davey 
hi Dragos
i have tried what u
hi Dragos
i have tried what u said(exactly as u wrote it).it seems to run fine but when i view it with paraview i cannot see the two different concentrations?do i need to modify the equation again? kindly advise. thanks davey 
Hi Davey,
I don't exactly und
Hi Davey,
I don't exactly understand your statement. If you wrote it as I posted above, than how do you expect to see two concentrations if you compute only one scalar? Please, put a picture with the result that makes you unhappy. Dragos 
Hi dragos,
here are my source
Hi dragos,
here are my source code and createfield files: source code: http://www.cfdonline.com/OpenFOAM_D...hment_icon.gif junctionFoam.C and http://www.cfdonline.com/OpenFOAM_D...hment_icon.gif createFields.H kindly have alook and see if my parameters and synthax are correct?and why should i neglect the U? thanks davey 
Hi Davey,
Your sources look o
Hi Davey,
Your sources look ok to me. What is the problem? Do you have any results to show? Dragos 
Hi Dragos,
as u saw,i modifie
Hi Dragos,
as u saw,i modified the conc into a vector knowing that i can imput two different values for my intlets.unfortunately,when i view it in paraFoam,it shows only one conc all through which should not be so.these are my results for the various parameters at time 0.3s http://www.cfdonline.com/OpenFOAM_D...hment_icon.gif c.pvd http://www.cfdonline.com/OpenFOAM_D...hment_icon.gif p.pvd http://www.cfdonline.com/OpenFOAM_D...hment_icon.gif u.pvd any ideas? thanks 
All times are GMT 4. The time now is 12:08. 