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

Check boundary type in solver

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

Like Tree1Likes
  • 1 Post By KlasJ

Reply
 
LinkBack Thread Tools Display Modes
Old   July 15, 2013, 19:12
Default Check boundary type in solver
  #1
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 73
Rep Power: 5
ChrisA is on a distinguished road
I'm attempting to implement a thermal diffusion model in the species equation (mass diffusion due to temperature gradient) but I'm having issues with my boundary conditions. Because the temperature gradient isn't necessarily zero at the wall for some cases mass transports through the wall and leaves the domain. Essentially I'm losing mass through walls when I obviously shouldn't be.

My current solution* has been to set the thermal diffusion coefficient to zero at all boundaries:

Code:
forAll(DT.boundaryField(),patchi)
{
    DT.boundaryField()[patchi] == 0;
}
This proves to be true for my current case, but for other cases this wouldn't be true. Is there any way to check what type a boundary is? So I could do something like:

Code:
forAll(DT.boundaryField(),patchi)
{
check if patchi is a wall
if(patchi is a wall)
{
    DT.boundaryField()[patchi] == 0;
}
}
I've looked around the boundary functions but no luck yet, has anyone else done something similar?

*I should note that I'm assuming this is the issue with my simulations and that my fix is appropriate, the corrected code is running as I type this and I wont know if this is true for a day or so.

Last edited by ChrisA; July 16, 2013 at 00:51.
ChrisA is offline   Reply With Quote

Old   July 16, 2013, 05:54
Default
  #2
Member
 
Felipe Portela
Join Date: Dec 2012
Location: London
Posts: 58
Rep Power: 4
fportela is on a distinguished road
Hi Chris,

Not sure is this will work, but I believe you can get the type of the patch as follows:

Code:
const volScalarField::GeometricBoundaryField& pbf = p.boundaryField();
wordList pBoundaryTypes = pbf.types();
Then probably pBoundaryTypes[patchi] will give you the name type of patchi.


Cheers,
Felipe
fportela is offline   Reply With Quote

Old   July 16, 2013, 10:46
Default
  #3
New Member
 
Klas J
Join Date: Oct 2011
Location: Göteborg, Sweden
Posts: 10
Rep Power: 5
KlasJ is on a distinguished road
Hi Chris,

I would recommend having a look at for example (in OpenFOAM 2.2): $FOAM_SRC/postProcessing/functionObjects/field/streamLine/streamLine.C You will find the statement:

Code:
...
forAll(patches, patchI)
{
    if (isA<wallPolyPatch>(patches[patchI]))
    {
...
In this case we are looking at the patch itself to see if it is a wall. More examples could be found by searching in terminal using:

Code:
foam; grep "isA<wall" `find -iname *.C`
This way seems simple and fairly easy to read to me, but for sure there are other ways to do it.

Best regards,

Klas
fportela likes this.
KlasJ is offline   Reply With Quote

Old   July 16, 2013, 18:36
Default
  #4
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 73
Rep Power: 5
ChrisA is on a distinguished road
Felipe,

Thanks for your reply, it looks like your suggestion is returning the boundary condition type (which could be useful for other things) here's the output of pBoundaryTypes from your code:

Code:
7
(
fixedValue
zeroGradient
fixedValue
zeroGradient
zeroGradient
zeroGradient
empty
)
I'll dig through the boundary functions a bit more and see if theres anything similar but for the type I'm looking for.

Klas,

Thank you for that, it looks like it will do exactly what I need... when I finish updating my code to be 2.2.0 compatible (it's not in previous versions). Guess that's yet another reason to get off my butt and update my code.


Edit:

I've done a bit of digging into 2.1.1 and thought I'd share what I found. It looks like the polymesh libraries have a function physicalTypes() contained in polyBoundaryMesh.C which should return the physical definitions (wall, patch etc.) but it looks like this isn't easy to access at the solver level (although to be fair I'm absolutely horrible at figuring out how to properly access things like that, if there's an easy way to get access to these functions I'm all for it). This function appears to only be used in blockMesh, or rather was used in block mesh, it seems to be commented out now.

That said I think I'll stick with what I have and put in the wall check in my 2.2.0 code as thats the code that will be solving all my future cases. Thank you both for your assistance!
ChrisA is offline   Reply With Quote

Old   July 17, 2013, 11:42
Default
  #5
New Member
 
Klas J
Join Date: Oct 2011
Location: Göteborg, Sweden
Posts: 10
Rep Power: 5
KlasJ is on a distinguished road
Hi again,

The functions that I am referring to (isA<>) exists also in earlier versions of the code. You will find this in 2.1.x as well. (I was only referring to 2.2 to give an example.)

Good luck!

// Klas
KlasJ is offline   Reply With Quote

Old   July 17, 2013, 18:57
Default
  #6
Member
 
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 73
Rep Power: 5
ChrisA is on a distinguished road
Ah, you're right it seems I just fail at writing grep statments. Anyway, to bring some conclusion to this thread, the problem was solved (and probably can be solved in other ways) by the following:

including "wallFvPatch.H" in the solver

and the thermal diffusion coefficient (DT) was given the proper boundary conditions via:

Code:
forAll(DT.boundaryField(),patchi)
{
    if (isA<wallFvPatch>(mesh.boundary()[patchi]))
    {
        DT.boundaryField()[patchi] == 0;
    }
    else
    {
        DT.boundaryField()[patchi] == DT.boundaryField()[patchi].patchInternalField();
    }
}
ChrisA is offline   Reply With Quote

Old   July 22, 2013, 04:42
Default
  #7
Member
 
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 7
ARTem is on a distinguished road
Or, alternatively, you can use

Code:
if(mesh.boundary()[patchi].type() == "wall")
without including "wallFvPatch.H".
ARTem is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
second order schemes marine OpenFOAM 66 October 26, 2014 12:10
T Junction Stability ignacio OpenFOAM Running, Solving & CFD 5 May 2, 2013 10:44
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01
Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 2 July 15, 2005 04:15


All times are GMT -4. The time now is 14:23.