CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Operations on volScalarField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 2, 2022, 07:46
Default Operations on volScalarField
  #1
Member
 
Join Date: Jun 2020
Posts: 49
Rep Power: 5
Swirl is on a distinguished road
Hello,

I am looking for a way to perform elementwise operations on a volScalarField. Specifically I want to add/ subtract a constant scalar from every point in the Field. Do I have to define another volScalarField that contains the scalar at every point, or is it possible to directly perform the operation between the volScalarField and the scalar?

Thanks for your help!
Swirl is offline   Reply With Quote

Old   February 2, 2022, 12:11
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Swirl View Post
Hello,

I am looking for a way to perform elementwise operations on a volScalarField. Specifically I want to add/ subtract a constant scalar from every point in the Field. Do I have to define another volScalarField that contains the scalar at every point, or is it possible to directly perform the operation between the volScalarField and the scalar?

Thanks for your help!

I assume that you have seen the https://www.openfoam.com/documentati...api/index.html docs?


Not sure why you cannot simply change the primitive field. Eg (may contain errors)...


Code:
volScalarField field( ....);


field.primitiveFieldRef() += 100.0;
field.correctBoundaryConditions();
olesen is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
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
execFlowFunctionObjects - unknown field problem Toorop OpenFOAM Post-Processing 16 March 14, 2016 03:25
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16


All times are GMT -4. The time now is 04:02.