|
[Sponsors] |
August 20, 2008, 13:23 |
(1) The following code produce
|
#1 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
(1) The following code produce wrong value of yFieldTmp. Only two patch faces are wrong and the rest is correct. No warning messages or error.
(2) The code works well if we replace the marked line with: const scalarField yFieldTmp = ... (3) The code prints an error message as expected if we replace the marked line with: scalarField yFieldTmp = ... The difference between case 1 and 2 is just added & which can easily be done even if you remember that you are working with tmp field. --------------------------------------- const Foam::fvPatchList& plTmp(mesh.boundary()); label topPatch = mesh.boundaryMesh().findPatchID("topWall"); label patchII=topPatch; const scalarField& yFieldTmp = plTmp[patchII].Cf().component(1); // marked line. Info <<plTmp[patchII].name() << " " << gSum(yFieldTmp)/yFieldTmp.size() << endl; Info <<plTmp[patchII].name() << " " << min(yFieldTmp) << endl; Info <<plTmp[patchII].name() << " " << max(yFieldTmp) << endl; |
|
August 20, 2008, 13:26 |
V 1.3; could be tested on chan
|
#2 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
V 1.3; could be tested on channelOodles case.
|
|
August 20, 2008, 15:53 |
const scalarField& yFieldTmp =
|
#3 |
Senior Member
Join Date: Mar 2009
Posts: 854
Rep Power: 22 |
const scalarField& yFieldTmp = plTmp[patchII].Cf().component(1); // marked line.
is incorrect in a way the compiler and the code cannot warn you about but valgrind will probably pick it up. Correct alternatives are scalarField yFieldTmp = ... or tmp<scalarfield> yFieldTmp = ... with the latter being very slightly more efficient than the first but not so much to be something to compromise the code clarity over. H |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to add a new class locally | ville | OpenFOAM | 4 | December 11, 2006 14:20 |
Class Project | Tiger | Main CFD Forum | 5 | March 13, 2006 16:58 |
Expanding a class | fabianpk | OpenFOAM | 0 | October 3, 2005 05:26 |
CFD class notes | Lee | Main CFD Forum | 0 | January 30, 2004 13:39 |
Fluent Class - OC, CA | Chetan Kadakia | FLUENT | 0 | September 7, 2001 20:17 |