|
[Sponsors] |
Update all cells in volVectorField from my BC |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 18, 2018, 05:20 |
Update all cells in volVectorField from my BC
|
#1 |
Member
Ruggiero Guida
Join Date: Apr 2013
Location: World
Posts: 46
Rep Power: 13 |
Hi,
I would like to update all cell values from my boundary condition. This is what I have done so far Code:
const volVectorField& U = db().lookupObject<volVectorField>("U"); Info << "U(164): " << U.internalField()[164].x() << nl << endl; Code:
forAll(U.internalField(), cellID) { U.internalField()[cellID].x() = 1.2 * U.internalField()[cellID].x(); U.internalField()[cellID].y() = 1.2 * U.internalField()[cellID].y(); U.internalField()[cellID].z() = 1.2 * U.internalField()[cellID].z(); } Code:
error: assignment of read-only location Any advice? |
|
February 20, 2018, 13:00 |
|
#2 |
Member
Ruggiero Guida
Join Date: Apr 2013
Location: World
Posts: 46
Rep Power: 13 |
I have also tried
Code:
U.internalField()[cellID].x().value() = ... Any hint? |
|
February 21, 2018, 04:50 |
|
#3 |
New Member
Join Date: Dec 2015
Posts: 24
Rep Power: 10 |
You are trying to modify a const reference to the U field. Remove the const keyword.
|
|
March 6, 2018, 11:08 |
|
#4 |
New Member
A.KvJ
Join Date: Feb 2012
Posts: 3
Rep Power: 14 |
Hello Ruggiero,
could you solve the issue? In my case with version 17.12 I have to const cast the field (I know it is not the best solution, but at least it works) and modify the fields with using the primitiveFieldRef const volVectorField& U = db().lookupObject<volVectorField>("U"); velVectorField& Umod = const_cast<volVectorField&>(U); Umod.primitiveFieldRef()[cellID] = ... Regards Alex |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Accessing a vector in a volVectorField by cell label | andrewryan | OpenFOAM Programming & Development | 7 | June 8, 2018 04:48 |
Simulating fire in a tunnel | luca1992 | OpenFOAM | 14 | August 16, 2017 13:50 |
Update Dynamic mesh failed- Negative cell volume detected | kywong5 | Fluent UDF and Scheme Programming | 0 | April 24, 2017 08:57 |
monitoring cell | Jane | Siemens | 2 | March 4, 2004 21:01 |
cell to cell relation | CMB | Siemens | 1 | December 4, 2003 04:05 |