
[Sponsors] 
June 1, 2011, 08:30 
Using Octave/MatLab functions to set border conditions?

#1 
New Member
Join Date: Jun 2011
Posts: 12
Rep Power: 6 
Hello!
I have a question and hope that you can help me. My company is searching for a software to calculate heat flux through a concrete wall of a tower due to solar radiation. (will be 2Dmodel in the first case) We were doing one such calculation before using Autodesk Multiphysics (Algor). But since there is no possibility to automate data in and output and do other scripting stuff we have to switch to another software or I will go crazy because of all that repetitive GUI clicking While searching for different software packages to compare OpenFOAM caught my eye, because it looks quite complete and is open source. In our problem the solar radiation and ambient temperature are used as border conditions and we have Octave/MatLab functions that return these values. Is it possible and easy to use these returned values as input for OpenFOAM? Pseudocode maybe would be  include "octave.h" or include "matlab.h" border_condition_wall(time) = MATLABFUNCTION.solarirradiation(time, date, weather, airmass)  Kind regards, Walter 

June 1, 2011, 09:38 

#2  
Member

Hi Walter!
Quote:
First, pythonFlu initially comes with the automation capabilities you are looking for (you can easily bind corresponding pythonFlu based code with your specific application, look). Second, Python has a lot of libraries that could easily satisfy all your "Matlab / Octave like" needs (NumPy and SciPy, for example). And, might be, the third, there is a living example who uses pythonFlu in the way you are interested in. Best regards, Alexey 

June 2, 2011, 04:02 

#3 
New Member
Join Date: Jun 2011
Posts: 12
Rep Power: 6 
Hi!
Thanks for your answer. pythonFlu looks quite interesting. I also read a presentation about pyFoam. What is the difference between the two? But since I usually write C++ code I would rather use it instead of Python to glue OpenFOAM to Octave/MatLab. Has someone of you ever done this and can show me a small piece of code how this could be done? Kind regards, Walter 

June 2, 2011, 09:42 

#4  
Member

Hi Walter,
Quote:
You said, that Octave so suitable for you, that you are going to invest your time and energy for embedding it into the target C++ solver. Now, imagine, that the OpenFOAM solver itself could be written completely in Octave. Would you still like to implement your solver in C++? And this is the pythonFlu case  "solver as any other user specific code could be written and communicated directly in Python without any loss in clarity and performance" Also, imagine, you need to add some automation features in your OpenFOAM calculation environment. Something like, parameter variation, conditional running and so on. As we know, Octave will come first in your mind (you are going to use it at any case). Ok, then you decide to implement such stuff through Octave  that is PyFoam case. I mean, that you still have two different beasts  C++, for solver implementation and Python, for its automation. Quote:
By the way, while I were trying to find out the proper answer on your last question I have bumped on the list of the existing Octave frontends, namely Perl, Tcl and Java. I started to wonder, why there is no Python among them? Actually, I have found Pytave, but it seems has been abandoned long ago (the latest modifications were done at 2008). So, I started to wonder once again, why?! The answer was actually straightforward  Existing NumPy and SciPy libraries cover all aspects of Octave functionality and made it no sense to invent any Python Octave frontend at allSo, if you would like to use something as flexible as Octave, but are going to base your solver implementation on OpenFOAM ... you know the right solution Best regards, Alexey Last edited by alexey2petrov; June 2, 2011 at 10:11. 

June 2, 2011, 18:26 

#5 
New Member
Join Date: Jun 2011
Posts: 12
Rep Power: 6 
Hi!
Thanks for the explanation, I get the difference now pythonFlu seems to be a good solution for some situations, but I am still not convinced... And since we need this in our company for important calculations I would rather stick to the wellknown and mature OpenFOAM and our working Octavefunctions. Well, until now there is no answer from people that could give some lines of C++ code showing how difficult or easy it is to glue OpenFOAM to MatLab or Octave. Maybe my question is not clear enough... I need to set transient border conditions, and in the end I do not care about how these are set, I just do not want to do it manually And I do not want to completly rewrite a solver until implementing transient border conditions is a really really easy job. Is it? My idea was just to call a MatLabfunction from a C++ program, which is quite an easy job to do. But is it easy to put the returned values into into the solver? Or is this not possible at all? I read about the possibility to use  type timeVaryingUniformFixedValue; timeDataFileName "inlet.dat";  to use transient border conditions. Well, this seems to be quite easy. So I got an idea and please tell me if this is completly nonsense: I have to set border conditions on the outside of a 2Dcircle. This simulates sunshine onto the tower. The circle has to be discretized. So I will subdivide it into 1° pieces. Each of this subdividions will receive different and transient border conditions. To achieve this I will use Octave and OpenFOAM separatly. An Octave function will write the meshfile using forloops creating the 360 Physical Surfaces and assign their names, e.g. Face001  Face360. I am not familiar with blockMesh's file format, but thinking of gmsh's syntax seems this is quite an easy job. And the Octave function calls the sunpositionfunction and writes the results to 360 different text files,e.g."Face001.dat" that are called by that are called by using  type timeVaryingUniformFixedValue; timeDataFileName "Face001.dat"; .... type timeVaryingUniformFixedValue; timeDataFileName "Face002.dat";  and so on... Well, I need a second opinion  does this sound like complete nonsense??? Or is it easier to glue OpenFOAM to MatLab/Octave directly? Kind regards, Walter 

June 4, 2011, 08:57 

#6 
Member
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 7 
Hi
Im not sure if this will help at all, but here goes. My programming skills in anything other than octave is limited at best, and thus I've opted to use octave scripts to do the following for me: 1) update gmsh geometry file 2) call gmsh to create mesh 3) call convert mesh to OpenFOAM 4) update velocity boundary conditions 5) call OpenFOAM to solve case 6) read cost function value/s into optimisation script 7) optimise geometry variables 8) loop from 1 This doesnt really "glue" octave and OpenFOAM together, but rather uses OpenFOAM as a tool inside octave. I wont even begin to claim that this is a good way to do things, but its the best I could come up with. 

June 5, 2011, 02:38 

#7 
New Member
Join Date: Jun 2011
Posts: 12
Rep Power: 6 
Hi!
This sounds quite good from my point of view since it looks like you used octave to script all the way from automated mesh creation to solving the case. And since for my case I need about 360 faces to form a circle, each of them having different BCs, scripting sounds great. So, if you do not mind, I would really like to see some scripts you wrote Kind regards, Walter 

June 5, 2011, 07:26 

#8 
Member
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 7 
Hi Walter
No problem. Send me your email address and we can discuss further. Regards Logan 

June 5, 2011, 16:47 

#9 
Senior Member

If you want to do optimisation many consulting companies (ICON, Engys, etc.) use DAKOTA http://dakota.sandia.gov/software.html
Read the post by Paolo Geremia http://www.extendproject.de/compone...=6&start=6#187 (to read you have to register) Last edited by elvis; June 7, 2011 at 02:23. 

June 5, 2011, 16:59 

#10 
Member
Logan Page
Join Date: Sep 2010
Posts: 38
Rep Power: 7 
Thanks for the info. It is useful to know.
For now I will be sticking to an optimisation algorithm developed at the university (DYNAMICQ), If I dont come right I'll look at this as an alternative. Regards 

June 20, 2011, 06:29 

#11  
Senior Member
Francois Beaubert
Join Date: Mar 2009
Location: Lille, France
Posts: 138
Rep Power: 8 
Quote:
Of course you can do that easier with pythonFlu ! Cheers Francois 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Cannot set boundary conditions in Pointwise  filipwa  Pointwise & Gridgen  5  November 29, 2010 17:11 
Cannot set boundary conditions in Poitwise  filipwa  Pointwise & Gridgen  0  November 10, 2010 06:20 
How to set the inflow conditions of turbulent BL?  CFDer  Main CFD Forum  2  March 8, 2006 10:05 
Level set & distance functions  Renato.  Main CFD Forum  7  February 7, 2006 07:46 
A problem about setting boundary conditions  lyang  Main CFD Forum  0  September 19, 1999 18:29 