|
[Sponsors] |
![]() |
![]() |
#1 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 ![]() |
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"); 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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 ![]() |
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()); Code:
internalField()[cellNeighbours[faceIndex]] Code:
gradient()[faceIndex]
__________________
~~~ Follow me on twitter @DavidGaden |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 ![]() |
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 |
|
![]() |
![]() |
![]() |
Tags |
access volscalarfield, from patch |
|
|
![]() |
||||
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 |