CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   scalar points to vectorField (

deji January 25, 2012 21:12

scalar points to vectorField
Hello to all the Foamers all around the world. I have a set of points, x, y, and z coordinates, and I would like to put them into a vectorField. The code that I have written thus far gives me an error message when I try to execute it:

scalar xVSL = 0.8;
vectorField WallCell = mesh.C().boundaryField()[patchK];
scalarField XNearWall = WallCell.component(vector::X)+ xVSL;
scalarField YNearWall = WallCell.component(vector::Y);
scalarField ZNearWall = WallCell.component(vector::Z);
label vectorLength = XNearWall.size();
vectorField positions;
positions.component(vector::X)= XNearWall;
positions.component(vector::Y)= YNearWall;
positions.component(vector::Z)= ZNearWall;

OpenFOAM doesn't like the way I am assigning the positions vectorFIeld, the error states the error is "attempted to assign to a const reference to constant object...

Any thoughts on this?? I have checked the forum, but nothing really near what I need...

niklas January 26, 2012 12:52

why not write it like this

vector VSL(0.8, 0, 0);
vectorField positions = mesh.C().boundaryField()[patchK] + VSL;

seems shorter

deji January 26, 2012 13:28

Hey Niklas. Thanks for the feedback, it works this time...:D


All times are GMT -4. The time now is 05:53.