Access a volScalarField from BC code
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 = 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 |
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] |
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 |
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.
|
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 |
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.
|
OK ... Thanks again!
|
All times are GMT -4. The time now is 08:40. |