CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Road emission source term

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 15, 2012, 13:41
Default Road emission source term
  #1
New Member
 
Robert S Hahn
Join Date: Feb 2012
Posts: 7
Rep Power: 14
rhahn is on a distinguished road
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];

// ************************************************** *********************** //
rhahn is offline   Reply With Quote

Old   March 15, 2012, 15:59
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by rhahn View Post
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;"
gschaider is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
[swak4Foam] swak4Foam-groovyBC build problem zxj160 OpenFOAM Community Contributions 18 July 30, 2013 14:14
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 12:44
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51


All times are GMT -4. The time now is 23:59.