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

Change values in patchField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 1, 2016, 03:02
Question Change values in patchField
  #1
New Member
 
Justin Wiegmann
Join Date: Aug 2015
Posts: 20
Rep Power: 10
SirIsaac90 is on a distinguished road
Hi Foamers!

I want to change a C-code a little bit. Therefore, I want to change only the values of
Code:
const scalarField rhow =
            patch().lookupPatchField<volScalarField, scalar>("rho");
,
which are greater or less than a specific value. As an example, one could describe it like this:

\rho =
\begin{matrix} 1.18 & 1.18 & 9 \\ 1.18 & 1.18 & 11  \\ 1.18 & 1.18 & 1.18  \end{matrix}.

This should the be set to

\rho =
\begin{matrix} 1.18 & 1.18 &  1.18 \\ 1.18 & 1.18 &  1.18 \\ 1.18 & 1.18 & 1.18  \end{matrix},

because i want to set all values > 2 to 1.18.
This should be done with an if-statement.

Anyone, who could help me with this? This would help me a lot.

Regards
JW
SirIsaac90 is offline   Reply With Quote

Old   July 6, 2016, 08:30
Default
  #2
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12
Jerryfan is on a distinguished road
Quote:
scalarField& rhow =
patch().lookupPatchField<volScalarField, scalar>("rho");

const scalar& value=2;
const scalar& valuenew=1.18;

forAll(rhow, index)
{
if (rhow[index] > value)
rhow[index] = valuenew;
}
instead of using a const scalarField, you have to change it to a reference or just normal variable. This should work fine.
Jerryfan 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
Getting internalField values from a patchField aabbasi59 OpenFOAM Programming & Development 11 October 30, 2019 07:29
Periodic (rotational)flow: a bit of confusion concerning reference values Mr.Goodcat FLUENT 0 March 22, 2016 07:31
strange u+ values with LES-Smagorinsky matejmuller OpenFOAM Running, Solving & CFD 2 January 8, 2016 06:08
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 12:04
Change system of units? Joern FLUENT 1 February 9, 2004 11:13


All times are GMT -4. The time now is 00:38.