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

applying a source term to internal face

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2024, 04:19
Default applying a source term to internal face
  #1
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
Hi everyone,
I'm struggling with a problem; I'm trying to add a class to a solver which can identify the faces belonging to the interface between two phases (of a field alpha) and apply there a source term I already programmed for other applications. I've been able to identify and count the interface cells but I can't figure out how to select the contact faces.
Thank you in advance for you help,
best,
Eric
EricS is offline   Reply With Quote

Old   June 18, 2024, 15:42
Default
  #2
New Member
 
sebastiaan bors
Join Date: Mar 2018
Posts: 7
Rep Power: 8
Sebastiaan is on a distinguished road
Hey Eric,

Could you elaborate a little more on what you need to achieve? If I understood correctly you would like to introduce a source term for some field based on some property of the alpha interface? As far as I know there is not an explicit way to do this if you require the surface of the interface to be exact and sharp without using an interpolation method similar to those from the postprocessing utilities (you might be able to adapt one of these). For example: the adIsoVector method does utilise an explicit isosurface advection method for propagating the alpha interface but these isosurfaces are chosen for an alpha value based on the local alpha gradient and values, so not necessarily for alpha = 0.5. Assuming that any source term in the cell will add to the cell average it is unclear to me how this would need to work in combination with an exact interface formulation. This may just be ignorance on my part, as it is not my expertise.
Sebastiaan is offline   Reply With Quote

Old   June 19, 2024, 04:48
Default
  #3
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
Hi Sebastiaan,


I don't care too much of following exaclty the interface, it's good enough to apply the source term on the faces of the cells involved! I want to add a source term which imposes a temperature on those faces (using an analytical rule to evaluate the right temperature). My interface is defined from cell's boundaries and values are 0 or 1 without intermediate values in between.
I attach a figure to try to make my purpose clearer!
Thank you!
Attached Images
File Type: png cfd_online_attachment.png (9.9 KB, 5 views)
EricS is offline   Reply With Quote

Old   June 19, 2024, 05:08
Default
  #4
New Member
 
sebastiaan bors
Join Date: Mar 2018
Posts: 7
Rep Power: 8
Sebastiaan is on a distinguished road
There ways to introduce some additional interface compression however (as far as I am aware) you would still expect some values between 1 and 0 for the alpha field depending on your resolution. It is of course possible to manipulate the field in an runtime function or in your own solver to achieve a strict binary, although I am not sure whether this would be advisable from a stability standpoint. If you write something to achieve this binary interface it would not be too hard to loop over face neighbours in order to identify your interface faces. Having said that, I am still a bit confused on what exactly you are trying to achieve. If you impose an interface flux I would expect the fluid interface to be more accurate than effectively “snapping” the fluid interface to the cell faces and thereby changing the surface area and local gradient. If you intend to impose a scalar field value then wouldn’t you this at the cell centres, or interpolate the interface value to the cell centres?

Last edited by Sebastiaan; June 19, 2024 at 05:09. Reason: spelling
Sebastiaan is offline   Reply With Quote

Old   June 19, 2024, 05:17
Default
  #5
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
You're right, I didn't specify that this is an iterative process. Each run has a fixed value of the interface.
Alpha is a term to switch between solid and fluid region and each run has a fixedd value before updating it with the outcome of the previous iteration. I need the to identify the interface face because I need to evaluate the distance from face center to cell center and to apply a scalar value at the face (as if it was a boundary condition)!
EricS is offline   Reply With Quote

Old   June 19, 2024, 05:25
Default
  #6
New Member
 
sebastiaan bors
Join Date: Mar 2018
Posts: 7
Rep Power: 8
Sebastiaan is on a distinguished road
Ah, that makes a lot more sense. Have you programmed a in openfoam before? You can loop over the faces and obtain the field values on both sides or the interpolated face values which would also indicate whether they are on a boundary. If not I might be able to help there but i'll need to find some time after work. I must admit being curious what kind of problem you are trying to solve that requires this approuch.
Sebastiaan is offline   Reply With Quote

Old   June 19, 2024, 05:41
Default
  #7
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
That would be great! I programmed a little in OpenFOAM but I still have a lot to learn ahah. I can share what I have done so far to have a sort of template to work on!
The purpose is to apply a temperature bc (with a particular expression to estimate the right value) on the interface between fluid and solid in a topological optimization process using the adjoint!

Anyway, I would really appreciate any kind of help! Thank you
EricS is offline   Reply With Quote

Old   June 19, 2024, 05:44
Default
  #8
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by EricS View Post
You're right, I didn't specify that this is an iterative process. Each run has a fixed value of the interface.
Alpha is a term to switch between solid and fluid region and each run has a fixedd value before updating it with the outcome of the previous iteration. I need the to identify the interface face because I need to evaluate the distance from face center to cell center and to apply a scalar value at the face (as if it was a boundary condition)!

What do you do when the interface coincides with a processor boundary?
olesen is offline   Reply With Quote

Old   June 19, 2024, 05:47
Default
  #9
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
Actually I didn't think on how to handle such a situation. I don't know what should I do in that case. Can you give me any suggestion?
EricS is offline   Reply With Quote

Old   June 19, 2024, 07:04
Default
  #10
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by EricS View Post
Actually I didn't think on how to handle such a situation. I don't know what should I do in that case. Can you give me any suggestion?
I was thinking earlier that you'd actually need to add your sources on the cell basis (eg, like fvOptions) not on a face basis anyhow.

In any case, you will need to detect the interface faces across processor boundaries. The code in planeToFaceZone :: combine() will give you some ideas.

https://develop.openfoam.com/Develop...neToFaceZone.C

Obviously you need your own detection mechanism (not a plane), but the face sync handling is what you'd need to transmit the information across and ensure the everything is parallel consistent. The thresholdCellFaces class might also give some ideas.
olesen is offline   Reply With Quote

Old   June 19, 2024, 09:12
Default
  #11
Member
 
Eric Segalerba
Join Date: Dec 2021
Location: Italy
Posts: 31
Rep Power: 4
EricS is on a distinguished road
Ok I get it, you're right, probably assigning the value to the cells could make that easier but I need to figure out how to modify face value to be correct once assigned in the cell!
Thank you for the advice!
EricS is offline   Reply With Quote

Reply

Tags
classes, face selection, programming


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
[swak4Foam] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 80 May 17, 2022 09:06
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 19:13
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 04:04
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55


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