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

Access a volScalarField from BC code

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 24, 2011, 08:10
Default Access a volScalarField from BC code
  #1
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 16
Hisham is on a distinguished road
Dear Foamers,

I am trying to access a volScalarField values at cells next to a patch from the BC code. I tried the following:
Code:
const fvPatchField<scalar>& Mu =
      patch().lookupPatchField<volScalarField, scalar>("solidShearMod");
The code compiles fine but does not work properly ... The value passed is different from what the solver outputs. I have tried that with a uniform value for the volScalarField. Nevertheless, the solver should have nonuniform values in practice.

I would appreciate any hint on what may be wrong. I did not provide more data because I frankly do not know what may cause this.

Best regards,
Hisham
Hisham is offline   Reply With Quote

Old   November 24, 2011, 10:44
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
Hi Hisham,

I just did this myself. Are you trying to access its own values, or another volScalarField? If you are in... say... T's boundary condition, and you want T's values *next* to the boundary patch, then I can tell you what to do. Otherwise, you need to use the object registry to look up the other volScalarField.

This gives you a list of cell indices that correspond to the internal field cells next to the patch:

Code:
    labelList cellNeighbours(patch().faceCells());
Then it's one to one:

Code:
    internalField()[cellNeighbours[faceIndex]]
corresponds with:
Code:
    gradient()[faceIndex]
or whatever you are using.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   November 24, 2011, 11:27
Default
  #3
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 16
Hisham is on a distinguished road
Hi David,

Thanks a lot for the quick feedback. The volScalarField I am trying to access is not the one for the BC. The approach I posted is used in the tractionDisplacementFvPatchVectorField.C BC line 173 to access the sigmaD volSymmTensorField from the BC that is used for displacement volVectorField in the solidDisplacementFoam solver.

With regard to what you posted, I understand that in my case I should pass the whole volField from the registry then find cells with faces on patch and extract values individually ... Is that well understood?

Best regards,
Hisham
Hisham is offline   Reply With Quote

Old   November 24, 2011, 11:29
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
Yes, use the object registry to gain a const reference to the field in question. The cellNeighbours list should be the same for the local GeometricField as it is for the volScalarField you look up.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   November 25, 2011, 15:27
Default
  #5
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 16
Hisham is on a distinguished road
Hi David,

I found a reference to internal field in the fvPatchField class (similar to the patch() reference). I will try to use it then if still not successful I will try the objectRegistry.

Thanks a lot for you help!

Best regards,
Hisham
Hisham is offline   Reply With Quote

Old   November 25, 2011, 15:54
Default
  #6
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
The internalField() reference or dimensionedInternalField() will give you direct access to the data in the GeometricField your boundary condition applies to, not any others. To access others, I think you have to use lookupObject in the objectRegistry.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   November 25, 2011, 16:33
Default
  #7
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 16
Hisham is on a distinguished road
OK ... Thanks again!
Hisham is offline   Reply With Quote

Reply

Tags
access volscalarfield, from patch

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging Unsteady 2-D Panel Method Code: Wake Modeling RajeshAero Main CFD Forum 5 November 10, 2011 06:48
A question about the source code of realizableKE.C yuhai OpenFOAM Programming & Development 1 June 26, 2009 09:05
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 09:10
Where do we go from here? CFD in 2001 John C. Chien Main CFD Forum 36 January 24, 2001 22:10
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07


All times are GMT -4. The time now is 06:10.