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

manipulating boundaryField of a volScalarField in OpenFOAM

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

Like Tree4Likes
  • 1 Post By thanasis
  • 3 Post By kmooney

Reply
 
LinkBack Thread Tools Display Modes
Old   December 30, 2013, 11:28
Default manipulating boundaryField of a volScalarField in OpenFOAM
  #1
New Member
 
Join Date: May 2013
Posts: 6
Rep Power: 4
thanasis is on a distinguished road
Dear all,

I need to manipulate a volScalarField using some complex expressions that include other volScalarFields and scalars. I have already a library (C++ class library) that operates on scalars and in order to take advantage of this I (note that I need to perform element by element multiplications), I employed a for loop for the internal field:

Code:
for (label i=0; i<D.internalField()[i]; ++i)
    {
         D.internalField()[i]*= libraryObject.libraryFunction
                                     (
                                         T.internalField()[i],
                                         P.internalField()[i],
                                         someScalar
                                     );
    }
I can not however perform the same type of calculations for the boundary field:

Code:
scalar scalarT;
scalar scalarP;
for (label i=0; i<D.boundaryField()[i]; ++i)
    {
         scalarT=T.boundaryField()[i];
         scalarP=P.boundaryField()[i];
         D.boundaryField()[i]*= libraryObject.libraryFunction
                                     (
                                         scalarT,
                                         scalarP,
                                         someScalar
                                     );
    }
The above code does not compile since T.boundaryField()[i] and P.boundaryField()[i] are of fvPatchField type and it seems that I can not assign them to scalars in order to call the library function.

Is there a way to "cast" boundaryField()[i] to a scalar? Is there any other way to manipulate the boundary field using the libraryFunction? I know that boundary condition models employ the == operator to reset them, but I can not figure out how this could work in the boundaryField of a volScalarField variable.

I would be grateful for any recommendations/suggestions.
mm.abdollahzadeh likes this.
thanasis is offline   Reply With Quote

Old   January 15, 2014, 16:47
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 268
Rep Power: 8
kmooney is on a distinguished road
Howdy!

When referencing the index of an D.internalField[i] <-like that, the i is refering to a cell index. A boundaryField() is different in that it returns not a patch but a list of patches. For example, to access face j on patch i you would have to write D.boundaryField()[i][j]

You're most likey meaning to do something like this:
Code:
forAll(D.boundaryField(), patchI)
{
         scalarField& tPatch=T.boundaryField()[patchI];
         scalarField& pPatch=P.boundaryField()[patchI];
         scalarField& DPatch=D.boundaryField()[patchI];

         forAll(DPatch,faceI)
         {
       DPatch[faceI]*= libraryObject.libraryFunction
                                     (
                                         tPatch[faceI],
                                         pPatch[faceI],
                                         someScalar
                                     );
         }
}
Note that there is a pretty good chance I messed something up here but I think it will help explain things!
Good luck!

Kyle
kmooney is offline   Reply With Quote

Old   January 19, 2014, 03:23
Default
  #3
New Member
 
Join Date: May 2013
Posts: 6
Rep Power: 4
thanasis is on a distinguished road
Thank you Kyle! that was the problem.
thanasis is offline   Reply With Quote

Reply

Tags
boundaryfield, fvpatchfield

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
ESI-OpenCFD Releases OpenFOAM v2.2.0 opencfd OpenFOAM Announcements from ESI-OpenCFD 13 March 30, 2013 17:52
gmsh 2.6.0 conversion to OpenFoam 160 rosswin Open Source Meshers: Gmsh, Netgen, CGNS, ... 0 March 5, 2013 08:34
Summer School on Numerical Modelling and OpenFOAM hjasak OpenFOAM 5 October 12, 2008 13:14
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07
OpenFOAM Training and Workshop Hrvoje Jasak Main CFD Forum 0 October 7, 2005 07:14


All times are GMT -4. The time now is 19:36.