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

Circulare inlet from matlab

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 6, 2017, 03:08
Default Circulare inlet from matlab
  #1
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 8
Fridrik is on a distinguished road
Hallo everyone

This post will take you through a method of creating a circular inlet condition. Where the inlet condition is made from an array generated in Matlab

This Matlab function can take an array and put into the right syntax for OpenFOAM.
Code:
%input syntax
% filename = 'data/test.txt';
% 
% x = 0:.1:1;
% tal = [t.^2;t.^3;t.^4];
% output_file(x,tal,filename);

function output_file(t,val,filename)
%%% note this function only works on velocity bundary conditins.
A = [t;val];

% this defines the precision, if higher needed look up fprintf in matlab
% doc
formatSpec = '(   %4.2f    (%4.2f %4.2f %4.2f)   )\r\n';

fileID = fopen(filename,'w');

fprintf(fileID,'%1s\r\n','(')

fprintf(fileID,formatSpec,A);
fprintf(fileID,'%1s',');');

fclose(fileID);

end
The output from matlab are then saved in the general case directory (here named "myDataFile"), and has this syntax (for velocity):

Code:
(
    (  0   (0 0 1))
    (100  (0 0 2))
);
The boundary condition are then changed into:

Code:
 
    inlet
      {
          type            cylindricalInletVelocity;
          axis             (0 0 1);          // <-These two defines where the center axis is.  
          centre          (0 0 0);         // <-
          axialVelocity   constant 0;
          radialVelocity                     //<- Here the radial velocity is defined.
          {
            type             tableFile;
            file             "$FOAM_CASE/myDataFile";    //<- The path to the file which descripes the inlet speed
          }
          rpm             constant 0;       //<- This sets the swirl of inlet.
          value           uniform (0 0 0); //<- This will initialize the postproces and calculation, will be overwritten when the 
                                                  //     boundary is accessed the first time
      }
(Credit to TomF for helping with the syntax of the import and debugging my code)

This should do it. Any improvements are welcome, so others easily can remake these inlet condition.

- Fridrik Magnusson

Last edited by Fridrik; October 12, 2017 at 05:51. Reason: additional information
Fridrik is offline   Reply With Quote

Old   October 9, 2017, 04:14
Default
  #2
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Quote:
Originally Posted by Fridrik View Post
Code:
--> FOAM FATAL IO ERROR:
keyword file is undefined in dictionary "/--/--/--/--/OpenFOAM/Compressor_simpel/Circulare_inlet/0/U.boundaryField.inlet"

file: "/--/--/--/--/OpenFOAM/Compressor_simpel/Circulare_inlet/0/U.boundaryField.inlet from line 26 to line 46.

    From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const
    in file db/dictionary/dictionary.C at line 551.

FOAM exiting
- Fridrik Magnusson
Hi,

This indicates that OpenFOAM expects the keyword file, while you have the keyword fileName.

So I think changing that would solve this error.

Regards,
Tom
tomf is offline   Reply With Quote

Old   October 9, 2017, 04:56
Default
  #3
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 8
Fridrik is on a distinguished road
Quote:
Originally Posted by tomf View Post
Hi,

This indicates that OpenFOAM expects the keyword file, while you have the keyword fileName.

Regards,
Tom
Thanks for the answer, will i sure did help me get the right syntax i will update the thread to incorporate the solution
Fridrik is offline   Reply With Quote

Old   October 12, 2017, 04:04
Question cylindricalInletVelocity
  #4
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 8
Fridrik is on a distinguished road
The derived boundary conditions: "cylindricalInletVelocity" should do the trick but it dosent seem to work.

from the website:
To test the inlet condition. I set the rpm and the axial velocity to 0. This will just have a radial component then.

Code:
  inlet
    {
        type            cylindricalInletVelocity;
        axis            (0 0 1);
        origin          (0 0 0);
        axialVelocity   constant 0;
        radialVelocity  constant 1;
        rpm             constant 0;
    }
but when i try to run this i get an error message:

Code:
--> FOAM FATAL IO ERROR:
Essential entry 'value' missing

file: /-/-/-/-/OpenFOAM/Circulare_inlet/0/U.boundaryField.inlet from line 26 to line 31.

    From function Foam::fvPatchField<Type>::fvPatchField(const Foam::fvPatch&, const Foam::DimensionedField<Type, Foam::volMesh>&, const Foam::dictionary&, bool) [with Type = Foam::Vector<double>]
    in file /home/pgh/OpenFOAM/OpenFOAM-v1706/src/finiteVolume/lnInclude/fvPatchField.C at line 131.

FOAM exiting
What does this error mean ?
How do i make this boundary condition work ?
Fridrik is offline   Reply With Quote

Old   October 12, 2017, 04:35
Default
  #5
Senior Member
 
Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 634
Rep Power: 32
tomf will become famous soon enoughtomf will become famous soon enough
Send a message via MSN to tomf Send a message via Skype™ to tomf
Quote:
Originally Posted by Fridrik View Post
but when i try to run this i get an error message:

Code:
--> FOAM FATAL IO ERROR:
Essential entry 'value' missing

file: /-/-/-/-/OpenFOAM/Circulare_inlet/0/U.boundaryField.inlet from line 26 to line 31.
What does this error mean ?
How do i make this boundary condition work ?
This error means that there is an entry missing and that entry is "value". This is needed for the start-up of your simulation or for post-processing tools, it will be overwritten in the first acces to the boundary. To make it work, I guess you need something like this:

Code:
  inlet
    {
        type            cylindricalInletVelocity;
        axis            (0 0 1);
        origin          (0 0 0);
        axialVelocity   constant 0;
        radialVelocity  constant 1;
        rpm             constant 0;
        value           uniform (1 1 0);
    }
Please adapt the value to something in the right order of magnitude.

Best Regards,
Tom
tomf is offline   Reply With Quote

Old   October 12, 2017, 05:37
Default
  #6
Member
 
Fridrik Magnusson
Join Date: Aug 2017
Location: Denmark
Posts: 34
Rep Power: 8
Fridrik is on a distinguished road
Thanks again Tom

Since the value is only for postprocessing and only gives a value at t = 0, i put it to (0 0 0).

I think this pushed me over the finish line, i will update the post to be a tutorial for other users
Fridrik is offline   Reply With Quote

Reply

Tags
bash on ubuntu on windows, circulare inlet condition, swag4foam


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
setting the correct format of nonuniform List<vector> for inlet in 0 Folder cfdonline2mohsen OpenFOAM Running, Solving & CFD 8 July 18, 2019 08:03
Problem with assigned inlet velocity profile as a boundary condition Ozgur_ FLUENT 5 August 25, 2015 04:58
velocity inlet and ideal gas simultaneously-what's wrong? preetam69 FLUENT 0 September 28, 2013 04:51
Inlet Velocity in CFX aeroman CFX 12 August 6, 2009 18:42
Diffusion component at inlet Balaji FLUENT 2 August 8, 2005 07:37


All times are GMT -4. The time now is 10:31.