CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   adjust volscalarfield (http://www.cfd-online.com/Forums/openfoam/113138-adjust-volscalarfield.html)

vahidzanganeh February 13, 2013 06:04

adjust volscalarfield
 
hi foamers
i will want to constant volscalarfield (Tsol ) in particular time and place. But using the following code does not work properly. and Tsol is not adjust!!
------------------------------------------
for (int i=0;i<U.size();i++)
{
if( runTime.value() > 0.1 && runTime.value() < 0.3 )
if (mesh.C().internalField()[i][0] > 0.031 && mesh.C().internalField()[i][0] < 0.08 && mesh.C().internalField()[i][1] > 0.001 && mesh.C().internalField()[i][1] < 0.009 )
{
Tsol.internalField()[i]=1200.0;
}
}
---------------------
who can help me?
best regards

anishtain4 February 13, 2013 09:06

Where are you adding this code?
Does it change something but that is not what you want? Or there it does not affect your field at all?
there two points in solution, first change the order of for loop and if, so for every grid cell and every iteration it don't check the time. Second I never recommend to use for to loop over OF objects, instead of that try using forAll.

conceptone February 13, 2013 17:31

Hi, you can just define a volscalarfield like:
const volscalarfield T
then T would be a constant field,but you need to give the initialised value.

vahidzanganeh February 14, 2013 01:44

thanks your reply
i added my reactingFoam.C (in pimple loop)after solved hs and Tsol eqn(Tsol equation is new equation). Tsol is porous medium temperature and Tsol was increased in order to simulation ignition.
--------------------
#include "hsEqn.H"
#include "TsolEqn.H"
if( runTime.value() > 0.1 && runTime.value() < 0.3 )
if (mesh.C().internalField()[i][0] > 0.031 && mesh.C().internalField()[i][0] < 0.08 && mesh.C().internalField()[i][1] > 0.001 && mesh.C().internalField()[i][1] < 0.009 )
{
Tsol.internalField()[i]=1200.0;

}
---------------------------------------------

anishtain4 February 15, 2013 03:34

It seems right but I can understand why you are not getting what you want? Did you see any change after adding this section? Trying increasing it to a dramatic value and see what happens?
also check the limiters you may have been set somewhere else, there is a possibility you've been clipped temperature to a value way below 1200


All times are GMT -4. The time now is 00:35.