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

Change values in patchField

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   July 1, 2016, 03:02
Question Change values in patchField
  #1
New Member
 
Justin Wiegmann
Join Date: Aug 2015
Posts: 19
Rep Power: 2
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: 47
Rep Power: 4
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

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Periodic (rotational)flow: a bit of confusion concerning reference values Mr.Goodcat FLUENT 0 March 22, 2016 08:31
strange u+ values with LES-Smagorinsky matejmuller OpenFOAM Running, Solving & CFD 2 January 8, 2016 07:08
Getting internalField values from a patchField aabbasi59 OpenFOAM Programming & Development 10 December 1, 2013 02:45
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 13:04
Change system of units? Joern FLUENT 1 February 9, 2004 12:13


All times are GMT -4. The time now is 01:32.