CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

chtMultiRegion same boundary conditions for different regions

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By kera
  • 1 Post By simrego
  • 1 Post By simrego
  • 1 Post By simrego
  • 1 Post By simrego
  • 1 Post By simrego

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 5, 2018, 04:57
Default chtMultiRegion same boundary conditions for different regions
  #1
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 11
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
Hello everyone,


I am using chtMultiregion solver to study the heat transfer between fluid and solid.
Suppose i am having a closed surface with an inlet and outlet for fluid. This closed surface having 10 solid cylinders enclosed in it.
By using SHM for multiregion I have generated 11 regions for this geometry (1 for fluid and 10 for each cylinder inside the closed surface).
Now, I want to apply boundary condition for each cylinder like this


CYLINDER 1


boundaryField
{
top
{type fixed value; Vaue xxx;}
bottom
{type fixed value; Vaue xxx;}
wall
{type fixed value; Vaue xxx;}


CYLINDER 2.....


It is very time consuming to define each BC for each cylinder separately.


Is there a way to define BC only for once and it could be used for all other cylinders.
I am sorry, I cannot post my geometry here.

Thank you


I am using OF5x.



Regards
mwaqas is offline   Reply With Quote

Old   June 5, 2018, 06:14
Default
  #2
Member
 
Ricky
Join Date: Jul 2014
Location: Germany
Posts: 78
Rep Power: 11
kera is on a distinguished road
I haven't used it myself but you can define a global boundray condtion using regular expressions per field file and include them using "#include" in your respective regions!
mwaqas likes this.
__________________
If it is easy, then something is fishy!
kera is offline   Reply With Quote

Old   June 5, 2018, 06:42
Default
  #3
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!

Or you can use the changeDictionary utility. You need a changeDictionaryDict for each region in the system folder (system/regionName/changeDictionaryDict). Then you can run:
changeDictionary -region regionName
for every regions. It can be done with a simple for loop quickly.
In your case you need only one Dict, and juts copy them into your region folders if you have the same boundary names.
You can use what kera said, but for me the splitMeshRegions always ruins every BC, but in this way you can be sure that you have the boundary conditions you want.
And with this you also have some freedom if any of your cylinders should have different boundary conditions.
mwaqas likes this.
simrego is offline   Reply With Quote

Old   June 5, 2018, 06:45
Default
  #4
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 11
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
Hi Kera,


Thank you for your reply. I am not expert in OpenFOAM. I am sorry, If I am asking to obvious or too basic question. What I understand from your comment.


I could define a boundary conditions for all field for one region (say cylinder1).
For all other regions I can use '#include'. But I don't know how to use '#include' for all other regions.
Regards
mwaqas is offline   Reply With Quote

Old   June 5, 2018, 06:51
Default
  #5
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 11
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
Quote:
Originally Posted by simrego View Post
Hi!

Or you can use the changeDictionary utility. You need a changeDictionaryDict for each region in the system folder (system/regionName/changeDictionaryDict). Then you can run:
changeDictionary -region regionName
for every regions. It can be done with a simple for loop quickly.
In your case you need only one Dict, and juts copy them into your region folders if you have the same boundary names.
You can use what kera said, but for me the splitMeshRegions always ruins every BC, but in this way you can be sure that you have the boundary conditions you want.
And with this you also have some freedom if any of your cylinders should have different boundary conditions.

Hi Simrego,


Thank you for your suggestion. I was thinking to use changeDictionary for all fields for one region and copy paste that changeDictionary in every region folder.
Suppose, I change a BC in one region, then I have to change in every region.
You have mentioned I can use a loop or something. Could you please elaborate little bit, How could I use loop to automate the process.


Regards
mwaqas is offline   Reply With Quote

Old   June 5, 2018, 07:07
Default
  #6
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!

I correct my reply a bit. Just checked, you can use one changeDictionaryDict using:
changeDictionary -dict pathToYourDict -region regionName

You can use for loops in the shell under linux (i hope you are using linux) like:
for i in listOfRegionnames // example: for i in solid fluid cyl1 cyl2 etc.
do
changeDictionary -dict pathToYourDict -region $i
done

It will loop through your regions

What kera said, you can find an example in the tutorials/incompressible/simpleFoam/turbineSiting/
Here some files located in the 0.orig/include folder which are included for example into the U file with $include "include/initialConditions"
So you can write field file into every region with only an $include "pathToAFileToInclude" line, and into that file what you include, you can write the field file what you usually do.

But also an another example if you just write the field files somewhere, and you can link the files into the folders with a loop. It won't copy the file so you won't waste your space, just tell to the operation system that, "there is a U file which is located somewhere else".
So there are a lot of ways to do what you want.
kera likes this.
simrego is offline   Reply With Quote

Old   June 5, 2018, 07:27
Default
  #7
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 11
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
Thank you Simrego. You saved me a lot of time.



Yes i am using Ubuntu 17.1 and OF5x. I will try both approaches and I will check which one suit me better.


Regards
mwaqas is offline   Reply With Quote

Old   June 5, 2018, 07:33
Default
  #8
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
You are welcome! But you should also try links. It's really powerful.
Let's assume you have directory 0 and 1. in 0 directory you have file U, while 1 is empty.
so:
0/U
1/

Then if you run ln -s 0/U 1/U
Then you will have a link in the 1 directory which points to the U file in the 0 directory. So if you change 0/U, everything will be changed since 1/U is linked to 0/U

Good luck!
mwaqas likes this.
simrego is offline   Reply With Quote

Old   June 5, 2018, 08:09
Default
  #9
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 11
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
Quote:
Originally Posted by simrego View Post

You are welcome! But you should also try links. It's really powerful.
Let's assume you have directory 0 and 1. in 0 directory you have file U, while 1 is empty.
so:
0/U
1/

Then if you run ln -s 0/U 1/U
Then you will have a link in the 1 directory which points to the U file in the 0 directory. So if you change 0/U, everything will be changed since 1/U is linked to 0/U


Sure, I will keep in mind while linking the files







Quote:
Originally Posted by simrego View Post
Hi!

for i in listOfRegionnames // example: for i in solid fluid cyl1 cyl2 etc.
do
changeDictionary -dict pathToYourDict -region $i
done

I am not expert with Linux Shell environment. I have one more question regarding loop please.
Is there a way to implement loop for all regions like this


for j in {1, 100}
do

for i in cyl$j
do
my command
done
done



What i want to do. instead of writing all the region names in for loop (like for i in cyl1 cyl2...), just want to tell loop, go in every folder and implement "my command"
mwaqas is offline   Reply With Quote

Old   June 5, 2018, 08:15
Default
  #10
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
You can do like:

for i in cyl*
do
command
done

In this case the shell will replace the cyl* with all the files/folders which is start with cyl.

just for try you can write:

echo cyl*

So you will see what are the folders (or files if you have a file which start with cyl) it'll go through
mwaqas likes this.
simrego is offline   Reply With Quote

Old   June 5, 2018, 08:26
Default
  #11
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Sorry!
Since you have to run the changeDict from the root folder, you can't use cyl* because they are located in the system directory.
Honestly i don't know how can you solve this elegantly, but a rude version can be like:

cd system
for i in cyl*
do
cd ..
commands
cd system
done
cd ..

in this case cyl* will works, because you have these folders in your system folder, and before every changeDict you just step back one, after changeDict step back into the system folder.
it's not a nice solution but it'll work.
Maybe some expert can tell you a nicer solution.
mwaqas likes this.
simrego is offline   Reply With Quote

Old   June 5, 2018, 08:32
Default
  #12
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 11
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
No problem...I will experiment with these things. I am sure, i will figure out something.
Or may be I will run for loop from system folder instead of root folder. In the end I have to place only changeDictionary in all region folders.

I am really thankful for your help
mwaqas is offline   Reply With Quote

Old   August 25, 2018, 10:38
Default
  #13
Senior Member
 
Peter Baskovich
Join Date: Jul 2014
Posts: 127
Rep Power: 11
pete20r2 is on a distinguished road
Quote:
Originally Posted by mwaqas View Post
No problem...I will experiment with these things. I am sure, i will figure out something.
Or may be I will run for loop from system folder instead of root folder. In the end I have to place only changeDictionary in all region folders.

I am really thankful for your help
How accurate are you wanting this simulation, you are aware the conductivity in the "solid regions" is anisotropic?
pete20r2 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
Basic Nozzle-Expander Design karmavatar CFX 20 March 20, 2016 08:44
Problem in setting Boundary Condition Madhatter92 CFX 12 January 12, 2016 04:39
Low torque values on Screw Turbine Shaun Waters CFX 34 July 23, 2015 08:16
Waterwheel shaped turbine inside a pipe simulation problem mshahed91 CFX 3 January 10, 2015 11:19
Low Mixing time Problem Mavier CFX 5 April 29, 2013 00:00


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