|
[Sponsors] |
July 15, 2013, 19:12 |
Check boundary type in solver
|
#1 |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 13 |
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; } Code:
forAll(DT.boundaryField(),patchi) { check if patchi is a wall if(patchi is a wall) { DT.boundaryField()[patchi] == 0; } } *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. |
|
July 16, 2013, 05:54 |
|
#2 |
Member
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 13 |
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(); Cheers, Felipe |
|
July 16, 2013, 10:46 |
|
#3 |
New Member
Klas J
Join Date: Oct 2011
Location: Göteborg, Sweden
Posts: 10
Rep Power: 14 |
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])) { ... Code:
foam; grep "isA<wall" `find -iname *.C` Best regards, Klas |
|
July 16, 2013, 18:36 |
|
#4 |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 13 |
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 ) 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! |
|
July 17, 2013, 11:42 |
|
#5 |
New Member
Klas J
Join Date: Oct 2011
Location: Göteborg, Sweden
Posts: 10
Rep Power: 14 |
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 |
|
July 17, 2013, 18:57 |
|
#6 |
Member
Chris
Join Date: Aug 2012
Location: Calgary, Alberta, Canada
Posts: 77
Rep Power: 13 |
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(); } } |
|
July 22, 2013, 04:42 |
|
#7 |
Member
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 16 |
Or, alternatively, you can use
Code:
if(mesh.boundary()[patchi].type() == "wall") |
|
September 16, 2022, 04:21 |
|
#8 | |
New Member
Mostafa
Join Date: Oct 2021
Posts: 22
Rep Power: 4 |
Quote:
i used this line in my code for some purpose const volScalarField::GeometricBoundaryField& pbf=p.boundaryField() but i got the following error createFields.H:19:23: error: ‘GeometricBoundaryField’ in ‘Foam::volScalarField {aka class Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ does not name a type i wonder what header should i include to make the code run without error |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
second order schemes | marine | OpenFOAM | 67 | April 11, 2022 18:19 |
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 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 04:15 |