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

Assigning values from 2d double array to Field<Type>

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 2, 2021, 20:23
Default Assigning values from 2d double array to Field<Type>
  #1
New Member
 
Yousef
Join Date: Dec 2015
Posts: 14
Rep Power: 11
yousefaz is on a distinguished road
Hello everyone,

I am new to OF programming and am having trouble assigning values from a 2d double array to a Field.
The 2d array "velocity" and the Field<Type> "vals" are initialized as follows:

Code:
double velocity[dim1][dim2];

Field<Type> vals(dim1);

Where dim1 is the number of points, and dim2 is the number of velocity components (=3).

I have tried assigning the values from "velocity" to "vals" using the forAll loop as suggested in many threads but this returns an error:

Code:
forAll(vals, i)
     {
          vals[i].component(0) = velocity[i][0];
          vals[i].component(1) = velocity[i][1];
          vals[i].component(2) = velocity[i][2];
      }

error: request for member ‘component’ in ‘vals.Foam::Field<double>::<anonymous>.Foam::List<double>::<anonymous>.Foam::UList<double>::operator[](i)’, which is of non-class type ‘double’
                 vals[i].component(0) = velocity[i][0];
Any help is greatly appreciated!
yousefaz is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Assigning values to read-only location saumavadey OpenFOAM Running, Solving & CFD 0 February 10, 2021 08:20
Assign values in an array to each cell of volscalarfield Yongqiang66 OpenFOAM Programming & Development 7 June 7, 2020 09:19
[swak4Foam] #codeStream options & includes, swak4Foam dEntropy OpenFOAM Community Contributions 10 July 29, 2015 05:10
GAMBIT: Export values of an Array into a file Marcus FLUENT 0 January 4, 2007 08:23
REAL GAS UDF brian FLUENT 6 September 11, 2006 08:23


All times are GMT -4. The time now is 14:38.