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

How to assign a value for a boundary patch inside createFields.H

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By Zeppo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 27, 2016, 18:08
Default How to assign a value for a boundary patch inside createFields.H
  #1
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Dear Fellows

I have defined an internal variable in createFields.H file that has non-zero value only on one boundary patch.
I want to assign that value to my variable (rhoE) inside createFields.H file.
I have written the following snippet for this end:
Code:
 label patchID= mesh.boundaryMesh().findPatchID ("middown");

    forAll(rhoE.boundaryField(), i)
    {
        if (mesh.boundaryMesh().name() == patchID)
    {
        rhoE.boundaryField()[i]= 21.79;
    }
    else 
    {
        rhoE.boundaryField()[i]= 0;
    }
    }
The code compiles correctly, however during simulation, OF still assigns zero value for that boundary patch.

Would some body hint me how can I do this or where did I make a mistake?



Regards
babakflame is offline   Reply With Quote

Old   August 27, 2016, 19:48
Default
  #2
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Code:
const word& boundName = "middown";
forAll(rhoE.boundaryField(), i)
{
    fvPatchScalarField& rhoEpatchField = rhoE.boundaryField()[i];
    if (rhoEpatchField.patch().name() == boundName)
    {
        rhoEpatchField = 21.79;
    }
    else 
    {
        rhoEpatchField = 0;
    }
}
babakflame and Zhiheng Wang like this.
Zeppo is offline   Reply With Quote

Old   August 27, 2016, 20:06
Default
  #3
Senior Member
 
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16
babakflame is on a distinguished road
Thanks sergei

I will try your snippet and give feedback soon.

It works sergei.
babakflame 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
Wind turbine simulation Saturn CFX 60 July 17, 2024 06:45
Radiation in semi-transparent media with surface-to-surface model? mpeppels CFX 11 August 22, 2019 08:30
Radiation interface hinca CFX 15 January 26, 2014 18:11
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 18:44
RPM in Wind Turbine Pankaj CFX 9 November 23, 2009 05:05


All times are GMT -4. The time now is 08:53.