CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Bugs

Wrong behaviour when appending vector to vectorField?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   June 3, 2015, 03:20
Default Wrong behaviour when appending vector to vectorField?
  #1
Member
 
Johan Roenby
Join Date: May 2011
Location: Denmark
Posts: 92
Rep Power: 21
roenby will become famous soon enough
This code:

vectorField test;
vector t1(1.0,2.0,3.0);
test.append(t1);
vector& t2 = test[0];
test.append(t2);
Info << "test = " << test << endl;

results in the following output:

test = 2((1 2 3) (0 2 3))

The first component of the appended vector is not appended correctly.

The error does not occur if t2 is a copy of test[0] rather than a reference to it.

Here is the situation where I discovered the bug:

//Calculate a pointField and if it only contains a single point
//append this, so it occurs twice in the pointField
pointField pf;
someFunctionPopulatingPointField(pf);
if (pf.size()==1)
{
pf.append(pf[0]);
}

The bug was reported here:
http://www.openfoam.org/mantisbt/view.php?id=1729#c4882
It was marked as "resolved" by noting that one should work with a copy of instead of a reference to test[0]. As far as I can see this is not a fix but a work-around.

Could some C++ expert comment on whether this is a genuine bug that should be properly fixed or if am I just doing dodgy stuff in my coding?
roenby is offline   Reply With Quote

 


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 04:18
udf error srihari FLUENT 1 October 31, 2016 14:18
meshing of a compound volume in GMSH shawn3531 OpenFOAM 4 March 12, 2015 10:45
alpha1 wrong behaviour with LTSInterFoam Quentin OpenFOAM Running, Solving & CFD 16 January 10, 2015 09:56
Unstable behaviour after long period of stablility plunge11 FLUENT 1 April 6, 2011 09:15


All times are GMT -4. The time now is 13:04.