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

Copy boundaryField into adjacent cell

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2018, 23:23
Default Copy boundaryField into adjacent cell
  #1
New Member
 
Join Date: May 2017
Posts: 8
Rep Power: 9
ec91 is on a distinguished road
Hello everyone,

I have a volScalarField E, and I need to copy the boundary field (i.e., the value defined as bc in the 0 folder) into the cells adjacent to the boundary.

In other words, for every patch and for every face of the patch:

internalField of E = boundary field of E, for that patch and that face.

I tried different solutions, but I deleted them since none of them worked.

Someone can help me?

Thank you and best regards.
ec91 is offline   Reply With Quote

Old   April 8, 2018, 01:22
Default
  #2
Senior Member
 
piu58's Avatar
 
Uwe Pilz
Join Date: Feb 2017
Location: Leipzig, Germany
Posts: 744
Rep Power: 15
piu58 is on a distinguished road
One easy solution may be:

Let the simulation run for a sohrt time. In the result folder you find a result for your fields. This replaces the original "internal field uniform .." line.

Analyze this field to find out which values belongs to which part of the geometry. If you use blockMesh und your geometry is not very complicated, this is not an hard task.

Write a little program in any programming language which sets the initial field the way you need it.
__________________
Uwe Pilz
--
Die der Hauptbewegung überlagerte Schwankungsbewegung ist in ihren Einzelheiten so hoffnungslos kompliziert, daß ihre theoretische Berechnung aussichtslos erscheint. (Hermann Schlichting, 1950)
piu58 is offline   Reply With Quote

Old   April 8, 2018, 05:34
Default
  #3
New Member
 
Join Date: May 2017
Posts: 8
Rep Power: 9
ec91 is on a distinguished road
Thanks Uwe,

but the mesh is complex and I need some loop who does it automatically. I was trying this one, but it doesn't work:

Code:
forAll (mesh.boundaryMesh(), patchI)
{    
    forAll (mesh.boundaryMesh()[patchI], faceI)
    {
        label ownerI = mesh.faceOwner()[faceI];
        E[ownerI] = E.boundaryField()[patchI][faceI];    //E is the volScalarField I want to modify

    }
}
but it doesn't work at all. It loop over the patches, in every patch he misses a lot of faces and at some point I have a segmentation error.

The boundaryFields containes eiher zeros or positive numbers (they are ficedValue BC's).

Any idea?

Thanks.
ec91 is offline   Reply With Quote

Old   April 8, 2018, 08:35
Default
  #4
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
You are probably looking for the method patchInternalField(). Here is an example (actually doing the opposite of what you want to do: Set the boundary values based on the internal values): https://github.com/OpenFOAM/OpenFOAM...FvPatchField.C
jherb is offline   Reply With Quote

Old   April 13, 2018, 05:50
Default
  #5
Member
 
Jibran
Join Date: Oct 2012
Location: UK
Posts: 61
Blog Entries: 1
Rep Power: 14
Jibran is on a distinguished road
Quote:
Originally Posted by ec91 View Post
Thanks Uwe,

but the mesh is complex and I need some loop who does it automatically. I was trying this one, but it doesn't work:

Code:
forAll (mesh.boundaryMesh(), patchI)
{    
    forAll (mesh.boundaryMesh()[patchI], faceI)
    {
        label ownerI = mesh.faceOwner()[faceI];
        E[ownerI] = E.boundaryField()[patchI][faceI];    //E is the volScalarField I want to modify

    }
}
but it doesn't work at all. It loop over the patches, in every patch he misses a lot of faces and at some point I have a segmentation error.

The boundaryFields containes eiher zeros or positive numbers (they are ficedValue BC's).

Any idea?

Thanks.
Hi,

I think this should do the job for you

Code:
forAll(mesh.boundary(), patchI)
{    
    forAll(mesh.boundaryMesh()[patchI],faceI)
    {
        const label& bCellID = mesh.boundaryMesh()[patchI].faceCells()[faceI];              
        E[bCellID] = E.boundaryField()[patchI][faceI];                            
    }    
}
__________________
Jibran Haider
https://jibranhaider.com/
Jibran 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
error in fireFoam, when running the case wallFireSpread2D zhoubiao1088 OpenFOAM Running, Solving & CFD 9 February 1, 2018 18:45
Energy source for cell that are adjacent to wall BIANBOSHEN Fluent UDF and Scheme Programming 0 December 28, 2016 00:15
Checking if a cell thread is adjacent to a face thread twcp0104 Fluent UDF and Scheme Programming 17 December 20, 2016 05:58
adjacent cell thread RKH ANSYS Meshing & Geometry 0 January 4, 2010 16:17
how to connect faces(only one adjacent cell thread BC FLUENT 8 July 13, 2005 16:07


All times are GMT -4. The time now is 03:46.