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

Implementing a B.C. from a csv

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By crubio.abujas
  • 1 Post By crubio.abujas
  • 1 Post By crubio.abujas
  • 1 Post By crubio.abujas
  • 1 Post By crubio.abujas

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 10, 2020, 11:06
Smile Implementing a B.C. from a csv
  #1
New Member
 
Sibo Anthony Athikho
Join Date: Apr 2020
Posts: 2
Rep Power: 0
sibo11890 is on a distinguished road
Dear Foamers,


I am trying to simulate mixed convection over a heated flat plate. The simulation is 3D and the boundary conditions are available in a .csv format. I am trying to apply a temperature profile (in csv format) B.C. on the plate in the x and z direction using the fixedProfile boundary condition. However, I am unable to do so as I could not find the option for adding the two co-ordinate directions. So, how do i add two coordinate directions using the fixedProfile boundary condition? What are the other options through which the desired boundary condition can be implemented?

I am attaching a diagram of the problem, the csv file and T file.


Note: The first and second column in the csv file are the x and z coordinates.
Attached Files
File Type: zip attachement.zip (46.3 KB, 55 views)
sibo11890 is offline   Reply With Quote

Old   June 10, 2020, 11:58
Default Try timeVaryingMappedFixedValue
  #2
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
I don't know of any way to do this from a CSV directly. Maybe you can try timeVaryingMappedFixedValue. It reads a folder format inside constant/boundaryData/heated_wall, you have to create these folders yourself.

In this folder you need to define at least two files:
  • points - where the coordinate of the values are stored
  • 0/T - Inside a folder "0" the temperature at each of the points.
The format of these files is:
constant/boundaryData/heated_wall/points:
Code:
458 (
(0 -0.14 0)
(0 -0.07 0)
(0 0 0)
...

(0 -0.14 0.1)
(0 -0.07 0.1)
(0 0 0.1)
...
)
I used the double of the points you referenced because it is needed to have sufficient information to interpolate in all the three axis, so additional information is needed in the z axis. These points don't have to match the ones in the mesh, the code will interpolate the data provided to fit the results.

constant/boundaryData/heated_wall//0/T
Code:
458 (
327.6
334.5
340.3
...
 327.6
334.5
 340.3
)
Again the information must be duplicated, as each point must have a specific temperature.

If you think that the temperature of the plate may change across time you can create further folders, for example constant/boundaryData/heated_wall//100/T and the profile will interpolate across the time. You don't have to redefine the points for this, the same file is valid for each of the time instants.

In the boundary file T just define it as:
Code:
    heated_wall
    {
        type            timeVaryingMappedFixedValue;
        offset          (0 0 0);
        setAverage      off;
    }
I know is not reading straightforwardly a csv, but its not so hard for a small number of points to create these files. It shouldn't be so difficult to create a small script in python or any other scripting language to automate the creation of these files.

I hope that helps you.
mmohaqeqf likes this.
crubio.abujas is offline   Reply With Quote

Old   June 10, 2020, 15:34
Default
  #3
New Member
 
Sibo Anthony Athikho
Join Date: Apr 2020
Posts: 2
Rep Power: 0
sibo11890 is on a distinguished road
Thank you very much. The timeVaryingMappedFixedValue worked. A slight change in the boundary file of T was made: offset (0 0 0); was changed to offset 0; as the former led to an error:
--> FOAM FATAL IO ERROR:
wrong token type - expected Scalar, found on line 26 the punctuation token '('
.


Thank you once again for helping out!!!!
sibo11890 is offline   Reply With Quote

Old   June 10, 2020, 17:23
Default
  #4
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
Quote:
Originally Posted by sibo11890 View Post
Thank you very much. The timeVaryingMappedFixedValue worked. A slight change in the boundary file of T was made: offset (0 0 0); was changed to offset 0; as the former led to an error:
--> FOAM FATAL IO ERROR:
wrong token type - expected Scalar, found on line 26 the punctuation token '('
.


Thank you once again for helping out!!!!

Wops, my fault. I've just copy-pasted from a previous example and didn't figure out that it is from a vectorField. Glad I've could help you!
mmohaqeqf likes this.
crubio.abujas is offline   Reply With Quote

Old   March 20, 2021, 08:52
Default
  #5
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Hi Carlos;
I have a simple 2-D inclined Couette flow, and I want to apply a fixed boundary condition for U at the inlet using timeVaryingMappedFixedValue.


The vertical axis is x, and flow is in +y direction. And domain is one cell thickness in z direction (from -0.05mm to +0.05mm). My data for inlet velocity would be on x-z plane (y=0). The bottom wall will be moving at 5 mm/s in +y direction, while the inclined top wall is stationary.



However, I am not sure why paraview is not showing the correct velocity profile at the inlet.


I followed exactly what you said, but no luck.


I would be grateful if you could take a quick look at my case folder to see why it is not working.
Attached Files
File Type: zip couetteFLow.zip (165.0 KB, 26 views)
mmohaqeqf is offline   Reply With Quote

Old   March 20, 2021, 11:55
Default
  #6
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
Hi Mohammad,

Quote:
However, I am not sure why paraview is not showing the correct velocity profile at the inlet.
Maybe you're using paraview instead of paraFoam? Altough paraview can understand the information of the mesh, sometimes it fails in interpreting some sofisticated boundary conditions and just plot it at uniform value.

Try using paraFoam, which has a closest relation with openFoam and will be able to run the required code to interpret your boundary condition. You're expecting a profile like this one, right? If so that is the cause

mmohaqeqf likes this.
crubio.abujas is offline   Reply With Quote

Old   March 20, 2021, 12:15
Default
  #7
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Thanks Carlos;
Yes, I am using paraView.
And yes, I noticed that my simulation results are correct, but somehow paraView does not want to show the correct profile.
I am using OpenFOAM on WSL on windows 10.
When I type paraFoam, I get an error:


Code:
Invalid $PV_PLUGIN_PATH and -plugin-path= not defined
No supplementary ParaView/OpenFOAM reader modules
Using builtin reader: paraFoam -vtk

Created temporary 'couetteFLow.foam'
/opt/OpenFOAM/OpenFOAM-v2006/bin/paraFoam: 420: /opt/OpenFOAM/OpenFOAM-v2006/bin/paraFoam: paraview: not found

I guess it is not installed, right?
mmohaqeqf is offline   Reply With Quote

Old   March 20, 2021, 12:34
Default
  #8
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
Look like its not installed. If you're using a ubuntu distribution inside the WSL (and assuming you have administrator priviledges) you may install paraview with:

Code:
sudo apt-get install paraviewopenfoam56
Please take into account that you will need a X server to display linux apps into windows.Check this as an example on how to setup this.
mmohaqeqf likes this.
crubio.abujas is offline   Reply With Quote

Old   March 20, 2021, 12:39
Default
  #9
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Thanks;

I have already set up X server to be used with pyFoamPlotWatcher.


When I run the command, I get this error:


Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package paraviewopenfoam56
mmohaqeqf is offline   Reply With Quote

Old   March 20, 2021, 12:55
Default
  #10
Senior Member
 
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9
crubio.abujas is on a distinguished road
Oh, sorry. I think you need to add the repository

Code:
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo apt-get update
It is mantained by openfoam.org so you can check the steps in their web
mmohaqeqf likes this.
crubio.abujas is offline   Reply With Quote

Old   March 20, 2021, 14:02
Default
  #11
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
I am using OpenFOAM.com version,
so I guess parafoam won't be an option for me.
mmohaqeqf is offline   Reply With Quote

Reply

Tags
csvfile, fixedprofile, openfoam6


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
[extend-bazaar] How to apply timeVaryingSolidTraction B.C. to fsiFoam? postechkian OpenFOAM Programming & Development 1 April 8, 2019 04:25
Problem with reading CSV files MrNinainaidi OpenFOAM Running, Solving & CFD 1 July 2, 2015 05:34
question about implementing boundary conditions saygin Main CFD Forum 0 July 6, 2006 07:08
Urgent! Help on UDF to set B.C. of 3rd type Ray Hong FLUENT 0 December 28, 2005 19:35
How to set B.C. of the 2nd or 3rd type in UDS? Ray Hong FLUENT 0 December 28, 2005 06:03


All times are GMT -4. The time now is 07:00.