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

Acess the owner cell

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 10, 2022, 12:32
Default Acess the owner cell
  #1
Member
 
Peng Liang
Join Date: Mar 2014
Posts: 59
Rep Power: 12
tjliang is on a distinguished road
Dear Foamers,

I wan to loop over all face values of a surfaceScalar field, and for some faces of them which could fulfill certain condition, I want to apply a value to its owner cell. Is it possible to do so in OpenFOAM? I have found that mesh().faceOwner() could possibly search for this, could anyone tell me a possible way to do it? Thanks.

Regards,

Peng
tjliang is offline   Reply With Quote

Old   August 10, 2022, 13:11
Default
  #2
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,089
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by tjliang View Post
Dear Foamers,

I wan to loop over all face values of a surfaceScalar field, and for some faces of them which could fulfill certain condition, I want to apply a value to its owner cell. Is it possible to do so in OpenFOAM? I have found that mesh().faceOwner() could possibly search for this, could anyone tell me a possible way to do it? Thanks.

Regards,

Peng
Code:
// Take a reference to the owner list: this gives the owner cell index for each internal face
// As a by the way, "faceOwner" is for all faces (internal and boundary) whereas "owner" is for just internal faces
const labelUList& owner = mesh.owner();

// Assuming you have some volScalarField called myField
// Take a reference to the internal field of myField, i.e. the raw list of cell values
scalarField& myFieldI = myField.primitiveFieldRef();

// Loop over all internal faces
forAll(owner, faceI)
{
    // Owner cell index
    const label ownCellID = owner[faceI];

    // Set value of owner cell in myField
    myFieldI[ownCellID] = 123456.789; // or what ever you want
}

// What about the boundary face values for myField? You may want to set something there too?
// In any case, you should update the processor boundaries:
myField.correctBoundaryConditions()
bigphil 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
UDF in case with DPM modle POSTHU Fluent UDF and Scheme Programming 0 March 3, 2021 07:21
[Other] Is mesh.sf() points from owner cell to neighbor cell? cfdopenfoam OpenFOAM Meshing & Mesh Conversion 0 November 3, 2017 10:49
Partition: cell count = 0 metmet FLUENT 1 August 31, 2014 19:41
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 12:25
cell to cell relation CMB Siemens 1 December 4, 2003 04:05


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