|
[Sponsors] |
Is there a similar function to numpy.where in OpenFOAM? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 3, 2021, 09:13 |
Is there a similar function to numpy.where in OpenFOAM?
|
#1 |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Hello,
OpenFOAM makes it very easy to assign values to fields thanks to operator overloading which makes it more natural and avoids explicit looping over all mesh cells, e.g: Code:
// assuming p is volScalarField, we can use p = 5.0 // Now every mesh cell has a value p=5 Code:
# Assuming t and p are two 1D arrays and have the same size p = numpy.where(t<2.0, 7.0, 0.0) # That means if t <2.0 assign the value 7.0 to p, otherwise 0.0 Thank you |
|
Tags |
openfoam, python |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Map of the OpenFOAM Forum - Understanding where to post your questions! | wyldckat | OpenFOAM | 10 | September 2, 2021 06:29 |
OpenFOAM Training, London, Chicago, Munich, Houston 2016-2017 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | September 14, 2016 04:19 |
is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
Compilation errors in ThirdPartymallochoard | feng_w | OpenFOAM Installation | 1 | January 25, 2009 07:59 |
Droplet Evaporation | Christian | Main CFD Forum | 2 | February 27, 2007 07:27 |