|
[Sponsors] |
December 13, 2021, 07:00 |
Conversion matrix to VolScalarField
|
#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 |
|
May 25, 2024, 10:49 |
|
#2 | |
New Member
serg
Join Date: Dec 2015
Posts: 29
Rep Power: 11 |
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:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error message | Bruno_Jorge | Main CFD Forum | 1 | February 5, 2019 12:12 |
namespace Foam | Argen | OpenFOAM | 4 | February 5, 2019 09:55 |
CFD by anderson, chp 10.... supersonic flow over flat plate | varunjain89 | Main CFD Forum | 18 | May 11, 2018 08:31 |
Making a PtrList<PtrList<volScalarField> > or making a square matrix volScalarField | ChasingNeutrons | OpenFOAM Programming & Development | 4 | July 6, 2016 20:45 |
writing execFlowFunctionObjects | immortality | OpenFOAM Post-Processing | 30 | September 15, 2013 07:16 |