|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
-Anon-
Join Date: Oct 2021
Posts: 2
Rep Power: 0 ![]() |
Hi,
I am developing an AI based solver for Openfoam and I am currrently trying to do the following thing: 1 - I have a rectangular mesh of dimension 256 * 128 * 1 cells ( adapted for a channel flow case) and some VolScalarFields. 2 - I have a neural network which gives a matrix of dimension 256 * 128. 3 - I want to assign the matrix values to the corresponding cell in OpenFoam 4 - I already have found a way to loop through the cells centers in a particular order to assign the matrix values and it works. Code:
void CNN::updateFoamFieldChannelFlow(torch::Tensor &ai_output, Foam::volScalarField &field){ int it = 0; forAll(field.mesh().C(), celli){ int i = it / 256; int j = it % 256; field[celli] = ai_output[i][j]; it++; } } Thanks, mmany |
|
![]() |
![]() |
![]() |
![]() |
#2 | |
New Member
serg
Join Date: Dec 2015
Posts: 29
Rep Power: 10 ![]() |
Hi,
I was looking for a similar answer, did you find a more efficient way to assign values back, instead of looping over? Kind regards Quote:
|
||
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error message | Bruno_Jorge | Main CFD Forum | 1 | February 5, 2019 11:12 |
namespace Foam | Argen | OpenFOAM | 4 | February 5, 2019 08:55 |
CFD by anderson, chp 10.... supersonic flow over flat plate | varunjain89 | Main CFD Forum | 18 | May 11, 2018 07:31 |
Making a PtrList<PtrList<volScalarField> > or making a square matrix volScalarField | ChasingNeutrons | OpenFOAM Programming & Development | 4 | July 6, 2016 19:45 |
writing execFlowFunctionObjects | immortality | OpenFOAM Post-Processing | 30 | September 15, 2013 06:16 |