|
[Sponsors] |
How to change/set different boundary condition for particular cell region? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 8, 2021, 07:30 |
How to change/set different boundary condition for particular cell region?
|
#1 |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear all,
I am using OpenFoam 5.0 and working on heat transfer simulation using chtMultiRegionSimpleFoam solver. 1. I have a temperature data file which equals to the face center length of a particular region. This temp file has "0" temp in some regions and rest with variable temperature. (say out of 1000 temp values, 400 are 0s and rest are varying). This is a Dirichet BC. 2. I have used this temperature data and simulated it. But now, I need this "zero" temperature value to be changed to convection BC. I know the parameters for convection BC. But, how do I change the zero temperature cells to different boundary condition? 3. I checked with SetFields (FieldToCell), but I can only give scalar value there and not BC. I hope my question is understood. Any leads will be appreciated. Regards, Sunag R A. |
|
April 8, 2021, 14:06 |
|
#2 |
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunag,
So if I understand right, you need to change Dirichlet BC to Robin BC at patch faces where 0 temperature exists. Are these faces geometrically neighbouring to each other so you can easily make a new patch from them and assign a different BC type? Kind regards, Robin |
|
April 9, 2021, 00:36 |
|
#3 |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Robin,
Thank you very much for your reply. As the first part, yes you have understood correctly and yes I need to change BC where 0 temperature exists. As for second part, the faces are geometrically neighbouring, but the geometry takes arbitrary shape. I have attached two images of the images, one from top and isolated view. The blue color shows the 0 temperature where BC need to be changed. Isolated view: https://drive.google.com/file/d/13I6...ew?usp=sharing Top view: https://drive.google.com/file/d/1Jwr...ew?usp=sharing Regards, Sunag R A. |
|
April 9, 2021, 04:16 |
codedMixed bc
|
#4 |
New Member
Simon
Join Date: Jan 2014
Location: Freiburg, Germany
Posts: 15
Rep Power: 12 |
Hi Sunag,
maybe the codedMixed bc does the job for you... e.g for the T file changing fixed value to zeroGradient at t = 10 s: Code:
boundaryField { patchName { type codedMixed; refValue uniform 0; refGradient uniform 0; valueFraction uniform 0; value uniform 0; name mixedBCname; code #{ const scalar t = this->db().time().value(); scalar Tair = 305; //scalar PI = Foam::constant::mathematical::pi; scalar w = 1; // w = 0 only gradient applies , w = 1 only fixedValue applies. if(t >= 10) { w=0; } this->refValue() = Tair; this->refGrad()=0; // zeroGradient this->valueFraction()=w; #}; } } |
|
April 9, 2021, 04:36 |
|
#5 |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Robin,
This looks good and advanced. I will definitely work with this and update you. But, I have few questions based on this code. 1. So, in this, w = 0 means it applies Robin function and w = 1, applies Dirichlet function from an external source implemented.? 2. As you have mentioned as example, after t=10s, it will be switched to w=0 meaning Robin funciton. I understand that. But, how to keep this robin funciton only for temp = 0, rest should be with Dirichet function only..!! 3. Also, how to run this code? I mean, should I include this in system/region or system folder? 4. Main Convection BC I am intended to give in place of temp = 0, is as below: type externalWallHeatFluxTemperature; mode coefficient; Ta constant 22; h uniform 10; kappaMethod solidThermo; value uniform 30; Thanks and Regards, Sunag R A. |
|
April 9, 2021, 06:04 |
|
#6 | ||||
New Member
Simon
Join Date: Jan 2014
Location: Freiburg, Germany
Posts: 15
Rep Power: 12 |
Hi Sunag, it is Simon here ;-)
Quote:
this->refValue() = Tair; this->refGrad()=0; // zeroGradient Quote:
Quote:
Quote:
So I think you have to check the source code of externalWallHeatFluxTemperature and calculate the gradient and define it manually as mentioned in 1. Good luck! Simon |
|||||
April 10, 2021, 16:13 |
|
#7 |
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunag,
Simon gave definitely a great tip. You can think about codedMixed BC. Certainly, other option would be to code your own boundary condition. I have seen that externalWallHeatFluxTemperature BC actually inherits from mixedFvPatchScalarField so you might start from that if the coded one would not be appropriate for some reason. If you want to study mixed boundary conditions a typical one is InletOultet, where - Positive flux (out of domain): apply zero-gradient condition - Negative flux (into of domain): apply the "inletValue" fixed-value That should not be difficult to understand. Kind regards, Robin |
|
April 14, 2021, 00:31 |
|
#8 |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Simon,
Sorry for late reply. Thank you so much for your reply with suggestions. I will try to work on this. But, I am using chtMultiRegionSimpleFoam, so I don't think t>0 will work. But I need when temp(fieldvalue) = 0, the BC should change. Based on "PatchName", well how to create a Patch where the FieldValue = 0.? After this only, I can implement right? I think since it is new to me, it will be difficult for me to understand and implement. Will work on this. Regards, Sunag R A. |
|
April 14, 2021, 00:33 |
|
#9 |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Hi Robin,
Sorry for late reply. I will check with mixedFvPatchScalarFieldand and try to work with this. Regards, Sunag R A. |
|
April 14, 2021, 03:24 |
|
#10 |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Robin and Simon,
I am thinking to create the patch using TopoSet or setSet using 1. Creating FaceLabel and then create faceSet from those labels and finally create faceZoneSet so that creates a patch. 2. My idea is to get the faceLabels where the surface temp BC is 0 and then implement in the topoSet. But my question is, 1. How to get the faceLabel values? I checked in postProcessing after running the simulation for 1 iteration. I get the faceCenter values and not FaceLabels. 2. Once I get the faceLabel, is it possible to use #include in topoSet so that it directly access the corresponding faceLabels? I do not know this method works on that, but I think my understanding is quite clear in this context. Regards, Sunag R A. |
|
April 14, 2021, 05:58 |
|
#11 | ||
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunag
Quote:
If you use more regions then go in constant/region/polymesh/boundary. An example is here: Code:
*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1906 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class polyBoundaryMesh; location "constant/region/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 3 ( walls { type wall; physicalType wall; nFaces 4445; startFace 80760; } maxY { type patch; physicalType patch; nFaces 1225; startFace 85205; } fluid_to_solid { type mappedWall; inGroups 1(wall); nFaces 510; startFace 86430; sampleMode nearestPatchFaceAMI; sampleRegion solid; samplePatch solid_to_fluid; } ) // ************************************************************************* // Certainly a question is how to get those where T is zero. Currently I am not sure about any utility, but I will have a look. Otherwise a python or bash scripts should be straight forward to write. These labels you can then probably use in topoSetDict and then use createPatch command. I am just not sure how will OpenFOAM treat (label) your new patch if the patch faces are going to be scattered around and will not be neighbouring. You can give a try. That is the reason why I thought about the previous way. Quote:
Maybe Simon will have another idea. Kind regards, Robin |
|||
April 14, 2021, 07:12 |
|
#12 | |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Robin,
Below is my list of patches obtained after splitRegionMesh. Quote:
1. Split this gland region into two patches using topoSet. One with variable temp and other with zero temperature (As shown in the figures attached previously). So that, I can apply BC separately for each. 2. For this, I thought of accessing the faces of this region with Temp=0 and then implement in toposet. I have faceCentres of this region, so I thought of splitting into two patches separately using faceCentres itself through python (This can be done). But can I use faceCentres only to createPatch in topoSet or faceLabels are necessary? 3. In the previous method as u mentioned, it is quite complicated for me, but I am trying to understand it. But since mine is steady flow, I think t>0 or t>10s dosent work for this case. Also, I need to say where it can be differentiated between temp and time if I can understand properly. Regards, Sunag R A. |
||
April 17, 2021, 13:21 |
|
#13 | ||
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunag,
Quote:
Code:
name pointNearest1; type pointSet; action new; source nearestToPoint; points( (0 0 0) (0 0 1) ); Code:
name pointFace1; type pointSet; action new; source pointToFace; option all; sets ( pointNearest1 ); Just make yourself sure, it did what you expect. Also, the code is based on ESI group version, but I guess it should be same or very similar. Quote:
Regards, Robin |
|||
April 19, 2021, 07:06 |
|
#14 | ||
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Robin,
Thank you very much for your suggestion. 1. With respect to the pointSet creation, I could access the points where Temp = 0 and then implemented in topoSet as follows. Quote:
After running topoSet, this assignment does work and create a file pointsPatch1 in constant/polymesh/sets as expected. But it throws an error as below. Quote:
Where do I put the keyword "name" in the assignment.? What am I missing here? Regards, Sunag R A. |
|||
April 19, 2021, 07:12 |
|
#15 | |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Simon and Robin,
I did work with codedMixed BC as suggested from your code. 1. I looked at a brief description of how does CodedMixed work in the image attached along with this thread. 2. I tried to work with the following steps in boundaryField. a. Get the faceCentres mesh details of the surface. b. Put a condition to say if the faceCentres temp value==0, then apply convection. 3. I do not whether it is correct way or not, but the implementation is as follows. I know this below implementation does not work, but any suggestion is appreciated. Quote:
How do I proceed with this? The term "actualSkinData" represents the temp file externally applied. The scalar T here is the temperature value. I have attached the image link for reference of the code which I found: Link: https://drive.google.com/file/d/1HBS...ew?usp=sharing Regards, Sunag R A. |
||
April 20, 2021, 06:17 |
|
#16 | |
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunagra,
How does look whole topoSetDict you wrote? Quote:
Code:
actions ({name pointNearest1; type pointSet; action new; source nearestToPoint; sourceInfopoints (#include "pointsPatch1";);} {name pointFace1; type pointSet; action new; source pointToFace; option all; sets (pointNearest1);}); I will return to the second post later. Kind regards, Robin |
||
April 21, 2021, 05:44 |
|
#17 | |
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Dear Robin,
I have implemented the pointToFace in topoSet and its working fine currently. Also, in the next phase, I also done with createPatch using the faceSet obtained from topoSet. This is also working fine, and now, the surface domain is splitted into two BC's (one with temp ==0 and other temp >0). 1. But I have one issue in the nFaces obtained in constant/polymesh/boundary. Below is the topoSet implementation. Code:
{ name pointNearest1; type pointSet; action new; source nearestToPoint; sourceInfo { points ( #include "pointsPatch1" ); } } { name pointFace1; type faceSet; action new; source pointToFace; sourceInfo { option all; set pointNearest1; } } 3. But, for BC applied from external temp file, the length of temp value from faceCenters for temp>0 is 14476. So, after splitting the region nFaces and this temperature should match as per our problem. Else, during simulation it shows as, size 14476 is not equal to the given value of 14635. (It might be difficult to understand what I might be saying). 4. This might have occured since the pointToFace has created faces from points obtained. So, may be there might be some mismatch. 5. Is there a possibility to create faceSet from faces and faceCentres ?? Faces example: Quote:
Sunag R A. Last edited by sunagra27; April 21, 2021 at 09:54. |
||
April 25, 2021, 07:47 |
|
#18 | |||
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunag,
Quote:
Quote:
Quote:
Kind regards, Robin |
||||
April 26, 2021, 00:59 |
|
#19 | |||
Member
Sunag R A
Join Date: Jul 2019
Location: Bangalore, India
Posts: 82
Rep Power: 7 |
Hi Robin,
Quote:
I obtained list of points in this way. 1. I applied external temperature BC to skin where T is variable and T = 0 as mentioned before. From this, I ran simulation for 1 iteration. During this process, I used "functions" in controlDict to get the value of surfaces. 2. After 1 iterated simulation, I get faceCentres, points, scalar Field T in the post-Process folder. 3. Using these points, I took points only with T = 0 (As I had temp values externally, I could coorelate these two and segregate the points). 4. From these points where T= 0, I thought of creating faces from PointToFace and from this FaceSet. (In the sense, I think these points create faces where T=0 only). 5. After this FaceSet, I used createToPatch and then used splitMesh. Quote:
I do not need new faces, I just need the faces where T=0 is applied. I think points does a pretty good job. But, I am unable to understand why it is not considering all the points where T=0. I could see this visually too. Quote:
The topoSet has several utilities, but none shows the creation of faceSet from faces and faceCentres. But, there is one such utility which uses faceLabels to create faceSet. But how do I get the faceLabels of the surface? There is one post related to this where I have put the link below, but for this where should I write the code to obtain the faceIDs? Link: How to get face IDs of a boundary Kind regards, Sunag R A. |
||||
April 30, 2021, 17:05 |
|
#20 | |||
Member
Robin Kamenicky
Join Date: Mar 2016
Posts: 74
Rep Power: 11 |
Hi Sunag,
Certainly somewhere is a mistake, but it is getting difficult to spot without the case. Quote:
Quote:
Quote:
Nevertheless, I assume that you access the patch already in your function in ControlDict and that you also iterate over the patch faces. Then you can try to do something like this Code:
forAll(mesh.boundary()[patch], facei) { const label& face = boundaryMesh[patch].start() + facei; } |
||||
Tags |
boundary condition, chtmultiregionsimpefoam, heat and mass transfer, temperature |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
Fatal overflow in linear solver. | iamnotfajar | CFX | 9 | October 28, 2020 05:47 |
accessing internal cell gradient field at boundary when applying boundary condition | vishalsacharya | OpenFOAM Programming & Development | 7 | February 25, 2019 16:36 |
Problem in setting Boundary Condition | Madhatter92 | CFX | 12 | January 12, 2016 05:39 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |