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/)
-   -   Road emission source term (http://www.cfd-online.com/Forums/openfoam-solving/98659-road-emission-source-term.html)

rhahn March 15, 2012 13:41

Road emission source term
 
I am attempting to add a road emission source term, which I would like to specify geometrically using pos().x, pos().y, and pos().z. I use the following CSourceDict and get a run-time parsing error. Does anyone have experience doing this or an easier way?

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.0.0 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object CSourceDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

variables ("where=0;" // Quantity introduced into the domain per second
// Source of Volume
"x1=597000.0;"
"x2=597010.0;"
"x3=597110.0;"
"x4=597100.0;"
"y1=4167510.0;"
"y2=4167700.0;"
"y3=4167700.0;"
"y4=4167510.0;"
"zmin1=0;"
"zmax1=5;"
"zmin2=0;"
"zmax2=5;"
"rate1=1;"
"Volume1=10000;"
"where=((((pos().y >= y1 && pos().y < y4) || (pos().y >= y4 && pos().y < y1)) && (pos().x < (x4 - x1) * (pos().y-y1)/(y4 - y1) + x1)) || (((pos().y >= y2 && pos().y < y1) || (pos().y >= y1 && pos().y < y2)) && (pos().x < (x1 - x2) * (pos().y - y2)/(y1 - y2) + x2)) || (((pos().y >= y3 && pos().y < y2) || (pos().y >= y2 && pos().y < y3)) && (pos().x < (x2 - x3) * (pos().y - y3)/(y2 - y3) + x3)) || (((pos().y >= y4 && pos().y < y3) || (pos().y >= y3 && pos().y < y4)) && (pos().x < (x3 - x4) * (pos().y - y4)/(y3 - y4) + x4))) ? 1 : where;"
);

expression "(rate1/Volume1)*where";

dimensions [0 0 -1 0 0 0 0];

// ************************************************** *********************** //

gschaider March 15, 2012 15:59

Quote:

Originally Posted by rhahn (Post 349682)
I am attempting to add a road emission source term, which I would like to specify geometrically using pos().x, pos().y, and pos().z. I use the following CSourceDict and get a run-time parsing error. Does anyone have experience doing this or an easier way?

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.0.0 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object CSourceDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

variables ("where=0;" // Quantity introduced into the domain per second
// Source of Volume
"x1=597000.0;"
"x2=597010.0;"
"x3=597110.0;"
"x4=597100.0;"
"y1=4167510.0;"
"y2=4167700.0;"
"y3=4167700.0;"
"y4=4167510.0;"
"zmin1=0;"
"zmax1=5;"
"zmin2=0;"
"zmax2=5;"
"rate1=1;"
"Volume1=10000;"
"where=((((pos().y >= y1 && pos().y < y4) || (pos().y >= y4 && pos().y < y1)) && (pos().x < (x4 - x1) * (pos().y-y1)/(y4 - y1) + x1)) || (((pos().y >= y2 && pos().y < y1) || (pos().y >= y1 && pos().y < y2)) && (pos().x < (x1 - x2) * (pos().y - y2)/(y1 - y2) + x2)) || (((pos().y >= y3 && pos().y < y2) || (pos().y >= y2 && pos().y < y3)) && (pos().x < (x2 - x3) * (pos().y - y3)/(y2 - y3) + x3)) || (((pos().y >= y4 && pos().y < y3) || (pos().y >= y3 && pos().y < y4)) && (pos().x < (x3 - x4) * (pos().y - y4)/(y3 - y4) + x4))) ? 1 : where;"
);

expression "(rate1/Volume1)*where";

dimensions [0 0 -1 0 0 0 0];

// ************************************************** *********************** //

You're using an expressionSource for this? (the syntax looks swakIsh)

Well. The expression for where looks impressive. First question: why don't you use 0 instead of where on the right hand side?

I wouldn't want to debug the whole expression. If I understand it correctly the parts are the road sections. One thing to make it easier would be to break up the expression into something like

"section1=(pos().x> ......;"
"section2=( ......"

and then put it together
"where=(section1 || section2 || ...) ? 1 : 0;"
Not 100% sure which fields what logical expressions accept as inputs so you might have to write it as
"where=(section1>0 || section2>0 || ...) ? 1 : 0;"

Anyway. The most elegant solution to your problem would be if you grid generation process allows you to specify cellZones or cellSets (in this example named "road") and have an expression

"where=zone(road) ? 1 : 0;"
or
"where=set(road) ? 1 : 0;"


All times are GMT -4. The time now is 04:24.