CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Implementing a B.C. from a csv (https://www.cfd-online.com/Forums/openfoam/227802-implementing-b-c-csv.html)

sibo11890 June 10, 2020 11:06

Implementing a B.C. from a csv
 
1 Attachment(s)
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.

crubio.abujas June 10, 2020 11:58

Try timeVaryingMappedFixedValue
 
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.

sibo11890 June 10, 2020 15:34

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!!!!

crubio.abujas June 10, 2020 17:23

Quote:

Originally Posted by sibo11890 (Post 774030)
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! :D

mmohaqeqf March 20, 2021 08:52

1 Attachment(s)
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.

crubio.abujas March 20, 2021 11:55

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 ;)

https://i.imgur.com/qfxmMre.png

mmohaqeqf March 20, 2021 12:15

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?

crubio.abujas March 20, 2021 12:34

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 March 20, 2021 12:39

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

crubio.abujas March 20, 2021 12:55

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 March 20, 2021 14:02

I am using OpenFOAM.com version,
so I guess parafoam won't be an option for me.


All times are GMT -4. The time now is 16:05.