View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000912 | OpenFOAM | Bug | public | 2013-07-04 12:17 | 2014-02-10 13:23 |
Reporter | Assigned To | henry | |||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Platform | Linux | OS | OpenSuse | OS Version | 11.1 |
Summary | 0000912: basicThermo.kappa(): not all field entries set | ||||
Description | The first 4 entries of the patchfields of the resulting field from basicThermo.kappa()are not set/initialized - caused some sigsegv/headache in a boundary condition where I need to divide by kappa | ||||
Steps To Reproduce | add, for example, this in createFields.H of buoyantSimpleFoam: int numPatches=(mesh.boundary()).size(); for(int ip=0;ip<numPatches;ip++) { Info << "patch no. " << ip << ", name=" << mesh.name() << endl; const scalarField& k=thermo.kappa(ip); forAll(k,ik) { Info << k[ik] << " "; } } Then run tutorial case buoyantCavity, output is: patch no. 0, name=region0 6.92022e-310 6.92022e-310 0 0 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0. ..... patch no. 1, name=region0 6.92022e-310 6.92022e-310 0 0 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 0.0260859 ..... patch no. 2, name=region0 6.92022e-310 6.92022e-310 0 0 0.0260859 0.0260859 0.0260859 0.0260 ..... | ||||
Additional Information | Tested using 2.2.x, checked out on July,3, 2013 | ||||
Tags | No tags attached. | ||||
|
I wrote basicThermo - of course its a virtual function, I have seen that until now using rhoThermo and solidThermo. |
|
When calling a function you should first check the return type which in the case of thermo.kappa(ip) is tmp<scalarField> not const scalarField&. So in your code const scalarField& k=thermo.kappa(ip); you hold k as a reference to a temporary which is deleted at the ; causing the segv when you use k. What you need to do is cache the temporary e.g. tmp<scalarField> tk(thermo.kappa(ip)); const scalarField& k = tk(); |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-07-04 12:17 |
|
New Issue | |
2013-07-04 12:21 |
|
Note Added: 0002305 | |
2013-07-04 12:35 | henry | Note Added: 0002306 | |
2013-07-04 12:35 | henry | Status | new => resolved |
2013-07-04 12:35 | henry | Resolution | open => no change required |
2013-07-04 12:35 | henry | Assigned To | => henry |