|
[Sponsors] |
[swak4Foam] is it possible to exclude some faces in calculating an expression on a patch in SWAK? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 10, 2013, 13:02 |
is it possible to exclude some faces in calculating an expression on a patch in SWAK?
|
#1 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi
in Swak postProcessing function below: Code:
totalPressure_left { type swakExpression; valueType patch; patchName left; accumulations ( average ); variables ( "gamma=1.4;" "R=287.14;" ); expression "sum(p*(pow(1+(gamma-1)/2*magSqr(U)/(gamma*R*T),(gamma/(gamma-1))))*rho*area())/sum(rho*area())"; verbose true; outputControlMode outputTime; outputInterval 1; } thanks.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
August 10, 2013, 15:34 |
|
#2 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
if I implement something like:
Code:
totalPressure_left { type swakExpression; valueType patch; patchName left; accumulations ( average ); variables ( "gamma=1.4;" "R=287.14;" ); expression "(U.x != 0) ? sum(p*(pow(1+(gamma-1)/2*magSqr(U)/(gamma*R*T),(gamma/(gamma-1))))*rho*area())/sum(rho*area()) : "; verbose true; outputControlMode outputTime; outputInterval 1; }
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
August 11, 2013, 19:41 |
|
#3 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
August 12, 2013, 01:19 |
|
#4 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi dear Bernhard
could you please explain a bit about what do you mean by indicator variable after ":" ? would you give me an example? what should I do exactly to do that? thanks.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
August 12, 2013, 12:21 |
|
#5 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
b. Based on that variable you'll have to calculate the area/nr of the patches that are used. Later divide the sum by this to get a valid average c. what I mean was that in "a ? b : c" you can't leave out the c the way you did Bottom line: if you need the average of only a part of the cells you'll have to do some work yourself. But it's not to hard.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
August 12, 2013, 15:33 |
|
#6 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thanks dear Bernhard but there is a doubt about sum.sum function gives an average of all faces on patch then if I divide it to the desired faces areas how it lead to a acceptable result? could clarify more please? thanks.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
August 13, 2013, 13:12 |
|
#7 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
sum(value*area()*indicator)/sum(area()*indicator) That is really first semester mathematics
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
August 13, 2013, 14:37 |
|
#8 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thanks dear Bernhard. I know weighted average but the value I want(total pressure) isn't zero on unwanted faces,can do something in this situation in your opinion?
-------------------------------------------------------------- I think it can be done like this: Code:
indicator=(U.x)!=0; sum(p0*rho*area()*indicator)/sum(rho*area()*indicator); does Boolean variable indicator could be recognized in postProcessing Swak functions like groovyBC? --------------------------- one thing occurred that when indicator is zero on all the faces then the expression will be 0/0,how can overcome this issue?maybe by a condition operetor "?" that sum(indicator)!=0 ? expression:0; then it becomes Code:
indicator=(U.x)!=0; sum(indicator)!=0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0;
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
August 14, 2013, 12:51 |
|
#9 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi
this error occurred.what maybe mean it?I think the conditional expression seems be true.what has caused the error? Code:
Time = 0.00933193 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 diagonal: Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0 diagonal: Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0 smoothSolver: Solving for Ux, Initial residual = 2.9533107882475e-05, Final residual = 4.2967271628453e-17, No Iterations 2 smoothSolver: Solving for Uy, Initial residual = 8.0832933323101e-05, Final residual = 4.5628728437651e-17, No Iterations 2 diagonal: Solving for rhoE, Initial residual = 0, Final residual = 0, No Iterations 0 smoothSolver: Solving for h, Initial residual = 1.522803139063e-06, Final residual = 3.2095933944988e-14, No Iterations 1 time step continuity errors : sum local = 1.1240866522131e-18, global = -5.1806902584343e-20, cumulative = 8.2541483939109e-20 smoothSolver: Solving for omega, Initial residual = 0.00011915535218725, Final residual = 7.4211337852284e-16, No Iterations 5 smoothSolver: Solving for k, Initial residual = 0.0001685515398489, Final residual = 1.868800540843e-15, No Iterations 5 smoothSolver: Solving for gas, Initial residual = 4.9588347286066e-06, Final residual = 5.869001155104e-13, No Iterations 1 ExecutionTime = 20.3 s ClockTime = 22 s faceSource massflow_left output: sum(left) for phi = -0.00016110414104695 [1] [3] [3] [3] --> FOAM FATAL ERROR: [3] Parser Error for driver PatchValueExpressionDriver at "1.14" :"syntax error, unexpected ')', expecting '?' or TOKEN_OR or TOKEN_AND" "sum(indicator)!=0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0" ^ ---------------| Context of the error: - From dictionary: IOstream.functions.totalPressure_left Evaluating expression "sum(indicator)!=0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0" [3] [3] [3] From function parsingValue [3] in file [1] [1] [2] Expression totalPressure_left : --> FOAM FATAL ERROR: [1] Parser Error for driver PatchValueExpressionDriver at "1.14" :"syntax error, unexpected ')', expecting '?' or TOKEN_OR or TOKEN_AND" "sum(indicator)!=0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0" ^ ---------------| Context of the error: - From dictionary: IOstream.functions.totalPressure_left Evaluating expression "sum(indicator)!=0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0" [1] [1] [1] From function parsingValue[0] [2] [2] --> FOAM FATAL ERROR: [2] [0] Parser Error for driver PatchValueExpressionDriver at "1.14" :"syntax error, unexpected ')', expecting '?' or TOKEN_OR or TOKEN_AND" "sum(indicator)!=0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0" ^ ---------------|
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
August 14, 2013, 13:37 |
|
#10 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
I wrote
Code:
indicator=(U.x)!=0 ? 1 : 0; but now another error has occurred about dividing by zero in expression while I had anticipated and set a condition for that but it occurred despite of the condition on the denominator. Code:
diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 diagonal: Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0 diagonal: Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0 smoothSolver: Solving for Ux, Initial residual = 2.9533107882475e-05, Final residual = 4.2967271628453e-17, No Iterations 2 smoothSolver: Solving for Uy, Initial residual = 8.0832933323101e-05, Final residual = 4.5628728437651e-17, No Iterations 2 diagonal: Solving for rhoE, Initial residual = 0, Final residual = 0, No Iterations 0 smoothSolver: Solving for h, Initial residual = 1.522803139063e-06, Final residual = 3.2095933944988e-14, No Iterations 1 time step continuity errors : sum local = 1.1240866522131e-18, global = -5.1806902584343e-20, cumulative = 8.2541483939109e-20 smoothSolver: Solving for omega, Initial residual = 0.00011915535218725, Final residual = 7.4211337852284e-16, No Iterations 5 smoothSolver: Solving for k, Initial residual = 0.0001685515398489, Final residual = 1.868800540843e-15, No Iterations 5 smoothSolver: Solving for gas, Initial residual = 4.9588347286066e-06, Final residual = 5.869001155104e-13, No Iterations 1 ExecutionTime = 20.06 s ClockTime = 22 s faceSource massflow_left output: sum(left) for phi = -0.00016110414104695 Expression totalPressure_left : average=931179.89871181 Expression totalTemperature_left : average=1251.9731758588 Expression totalEnthalpy_left : average=1038600.1239856 faceSource massflow_right output: sum(right) for phi = 0 [3] #0 Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" [3] #1 Foam::sigFpe::sigHandler(int) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" [3] #2 in "/lib/x86_64-linux-gnu/libc.so.6" [3] #3 Foam::divide(Foam::Field<double>&, Foam::UList<double> const&, Foam::UList<double> const&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" [3] #4 Foam::operator/(Foam::UList<double> const&, Foam::UList<double> const&) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" [3] #5 parserPatch::PatchValueExpressionParser::parse() in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so" [3] #6 Foam::PatchValueExpressionDriver::parseInternal(int) in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so" [3] #7 Foam::CommonValueExpressionDriver::parse(std::string const&, Foam::word const&) in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so" [3] #8 Foam::swakExpressionFunctionObject::write() in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libsimpleSwakFunctionObjects.so" [3] #9 Foam::simpleFunctionObject::execute(bool) in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libsimpleFunctionObjects.so" [3] #10 Foam::functionObjectList::execute(bool) in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" [3] #11 Foam::Time::run() const in "/opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so" [3] #12 [3] in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/bin/rhoCentralFoamGasCont" [3] #13 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" [3] #14 [3] in "/home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/bin/rhoCentralFoamGasCont" [Ehsan-com:05814] *** Process received signal *** [Ehsan-com:05814] Signal: Floating point exception (8) [Ehsan-com:05814] Signal code: (-6) [Ehsan-com:05814] Failing at address: 0x3e8000016b6 [Ehsan-com:05814] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x36460) [0x7fe65973f460] [Ehsan-com:05814] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7fe65973f3e5] [Ehsan-com:05814] [ 2] /lib/x86_64-linux-gnu/libc.so.6(+0x36460) [0x7fe65973f460] [Ehsan-com:05814] [ 3] /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam6divideERNS_5FieldIdEERKNS_5UListIdEES6_+0x9f) [0x7fe65a8e4def] [Ehsan-com:05814] [ 4] /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4FoamdvERKNS_5UListIdEES3_+0x62) [0x7fe65a8e7a82] [Ehsan-com:05814] [ 5] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so(_ZN11parserPatch26PatchValueExpressionParser5parseEv+0x19b5a) [0x7fe64af81e7a] [Ehsan-com:05814] [ 6] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so(_ZN4Foam26PatchValueExpressionDriver13parseInternalEi+0x39) [0x7fe64b037c99] [Ehsan-com:05814] [ 7] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libswak4FoamParsers.so(_ZN4Foam27CommonValueExpressionDriver5parseERKSsRKNS_4wordE+0x61) [0x7fe64afef831] [Ehsan-com:05814] [ 8] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libsimpleSwakFunctionObjects.so(_ZN4Foam28swakExpressionFunctionObject5writeEv+0x63) [0x7fe64a7cf453] [Ehsan-com:05814] [ 9] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/lib/libsimpleFunctionObjects.so(_ZN4Foam20simpleFunctionObject7executeEb+0xe0) [0x7fe64a453b90] [Ehsan-com:05814] [10] /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZN4Foam18functionObjectList7executeEb+0x59) [0x7fe65a726f49] [Ehsan-com:05814] [11] /opt/openfoam220/platforms/linux64GccDPOpt/lib/libOpenFOAM.so(_ZNK4Foam4Time3runEv+0xb0) [0x7fe65a732250] [Ehsan-com:05814] [12] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/bin/rhoCentralFoamGasCont() [0x421876] [Ehsan-com:05814] [13] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7fe65972a30d] [Ehsan-com:05814] [14] /home/ehsan/OpenFOAM/ehsan-2.2.0/platforms/linux64GccDPOpt/bin/rhoCentralFoamGasCont() [0x42bb0d] [Ehsan-com:05814] *** End of error message *** -------------------------------------------------------------------------- mpirun noticed that process rank 3 with PID 5814 on node Ehsan-com exited on signal 8 (Floating point exception). -------------------------------------------------------------------------- gnuplot> set terminal png small color gnuplot> set terminal png small color ^ ^ line 0: invalid color spec, must be xRRGGBB line 0: invalid color spec, must be xRRGGBB gnuplot> set terminal png small color ^ line 0: invalid color spec, must be xRRGGBB Killing PID 5807 PyFoam WARNING on line 232 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Execution/FoamThread.py : Process 5807 was already dead Code:
"sum(indicator)!=0.0 ? sum(p0*rho*area()*indicator)/sum(rho*area()*indicator) : 0.0";
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. Last edited by immortality; August 14, 2013 at 17:13. |
|
August 14, 2013, 18:33 |
|
#11 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Please: sit down with a piece of paper. Write down in mathematical terms what you want to do. Especially the sums. Then implement that. Or write down the formula you just implemented in mathematical terms.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
August 14, 2013, 18:41 |
|
#12 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
thanks dear Bernhard
I wrote this before I read your post: Code:
variables ( "gamma=1.34;" "R=287.14;" "p0=p*(pow(1+(gamma-1)/2*magSqr(U)/(gamma*R*T),(gamma/(gamma-1))));" "indicator=(U.x) !=0.0 ? 1.0 : 0.0;" "n_faces=sum(indicator);" ); expression "sum(p0*rho*area()*indicator)/(n_faces!=0.0 ? sum(rho*area()*indicator):1.0)"; |
|
August 14, 2013, 22:52 |
|
#13 | ||
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi dear Bernhard
it's working fine and this is a part of results for instance.thanks a lot for advice. Quote:
Quote:
Code:
0.00972493 0 0.00972593 0 0.00972693 0 0.00972793 0 0.00972893 0 0.00972993 0 0.00973093 0 0.00973193 0 0.00973293 0 0.00973393 0 0.00973493 0 0.00973593 0 0.00973693 0 0.00973793 0 0.00973893 0 0.00973993 0 0.00974093 0 0.00974193 0 0.00974293 0 0.00974393 0 0.00974493 0 0.00974593 0 0.00974693 414795.85022427 0.00974793 489127.77079362 0.00974893 472354.87446518 0.00974993 482980.41909857 0.00975093 494396.69083149 0.00975193 482668.24744863 0.00975293 498096.79130297 0.00975393 505365.79868396 0.00975493 495282.94955258 0.00975593 494496.16003915 0.00975693 501671.61352294 0.00975793 498786.77690335 0.00975893 502646.98502813 0.00975993 493838.06447913 0.00976093 478599.84236925 0.00976193 477714.51069725 0.00976293 459831.85650171 0.00976393 459876.5015917 0.00976493 458529.81644997 0.00976593 454067.8936771 0.00976693 443300.43927585 0.00976793 444404.06857093 0.00976893 442221.55475606 0.00976993 437269.13737899 0.00977093 433116.49478566 0.00977193 425775.8593933 0.00977293 426494.565387 0.00977393 420896.47405805 0.00977493 409250.91511963 0.00977593 408500.35547509 0.00977693 401335.77795219 0.00977793 403805.09654604 0.00977893 395448.226802 0.00977993 394032.47412188 0.00978093 387114.7456731 0.00978193 384717.75851883 0.00978293 382704.63340763 0.00978393 379050.09920179 0.00978493 373321.53130754 0.00978593 370391.58279858 0.00978693 365658.79864664 0.00978793 362175.43849012 0.00978893 358684.35934306 0.00978993 355910.32026514 0.00979093 352661.24884802 0.00979193 349745.23245139 0.00979293 346571.32192524 0.00979393 344226.49876395 0.00979493 340888.22069943 0.00979593 338389.87999866 0.00979693 336430.75220489 0.00979793 335699.95381484 0.00979893 333837.54800648 0.00979993 332881.48561233 0.00980093 332510.03460048 0.00980193 331245.85492146 0.00980293 330760.4603577
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Wedge patch '*' is not planar | LilumDaru | OpenFOAM Meshing & Mesh Conversion | 6 | January 12, 2021 05:55 |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 04:13 |
[snappyHexMesh] Layers not growing at all | zonda | OpenFOAM Meshing & Mesh Conversion | 12 | June 6, 2020 11:28 |
[Other] Mesh Importing Problem | cuteapathy | ANSYS Meshing & Geometry | 2 | June 24, 2017 05:29 |
Near wall treatment in k-omega SST | Arnoldinho | OpenFOAM Running, Solving & CFD | 38 | March 8, 2017 13:48 |