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

Road emission source term

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools 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: 5
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: 3,914
Rep Power: 40
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

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
swak4foam building problem GGerber OpenFOAM Installation 54 April 24, 2015 16:02
swak4Foam-groovyBC build problem zxj160 OpenFOAM 18 July 30, 2013 13: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 01:24
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 07:49.