|
[Sponsors] |
Assigning values from 2d double array to Field<Type> |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Yousef
Join Date: Dec 2015
Posts: 14
Rep Power: 11 ![]() |
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]; |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |