|
[Sponsors] |
Division by zero exception - loop over scalarField |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 6, 2013, 18:04 |
Division by zero exception - loop over scalarField
|
#1 |
Member
Patrick Wollny
Join Date: Apr 2010
Posts: 58
Rep Power: 16 |
Hiho,
I´m programming a tool for the post processing in openFOAM. In this code I divide a value by the denominator ( fvc::interpolate(T) - T_ref) which is a surfaceScalarField. To prevent the code from a division by zero, I do this: Code:
surfaceScalarField dT = ( fvc::interpolate(T) - T_ref ); forAll(dT.internalField(),i) { if(dT.internalField()[i] < 1e-10) { dT.internalField()[i] = 1e-10; } }; forAll(dT.boundaryField(),patchi) { forAll(dT.boundaryField()[patchi],i) { if(dT.boundaryField()[patchi][i] < 1e-10) { dT.boundaryField()[patchi][i] = 1e-10; } }; }; Best regards, Patrick |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[openSmoke] libOpenSMOKE | Tobi | OpenFOAM Community Contributions | 562 | January 25, 2023 09:21 |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 02:09 |
[CAD formats] my stl surface is seen as just a line | rcastilla | OpenFOAM Meshing & Mesh Conversion | 2 | January 6, 2010 01:30 |
ScalarField division | maka | OpenFOAM Pre-Processing | 2 | August 27, 2007 05:10 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 15:57 |