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

[Gmsh] solving a matrix 2x2 inside the geo file!

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2017, 01:34
Default solving a matrix 2x2 inside the geo file!
  #1
Member
 
OpenFoam
Join Date: Jun 2016
Posts: 82
Rep Power: 9
CFD-Lover is on a distinguished road
Hello All,

I am working on a small problem in the geo file, which involves solving a matrix 2x2 to fit a polynomial. I was wondering if there is any way to do that. I have created the following code in Matlab and I want to do the same in the geo file

Code:
clear all;clc;close all
R = 0.509515; % m
R1 = 0.559467; % m
R2 = 0.579594; % m
L = 0;
L1 = -0.08568; 
L2 = 0.13974; 
hold on
plot([L L1 L2],[R R1 R2],'k.')

y = [R1-R;R2-R];
x = [L1^2 L1;L2^2 L2];
c = x\y;

x1 = linspace(-0.08568,0.13974,20);
for ii = 1:length(x1)
    y(ii) = c(1)*x1(ii)^2+c(2)*x1(ii)+R;
end
plot(x1,y)
Many thanks,
CFD-Lover is offline   Reply With Quote

Old   June 17, 2017, 02:04
Default
  #2
Member
 
OpenFoam
Join Date: Jun 2016
Posts: 82
Rep Power: 9
CFD-Lover is on a distinguished road
Can I for instance call a Matlab script through the .geo file in order to get the coefficients c1 and c2 that will be used in the geo file?

Thanks,
CFD-Lover is offline   Reply With Quote

Old   June 17, 2017, 06:44
Default
  #3
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Why you cannot put this simple analytic solution into geo:

\left[\begin{matrix}\left(- R + R_{1}\right) \left(\frac{L_{2}}{L_{1}^{2} \left(L_{1} - L_{2}\right)} + \frac{1}{L_{1}^{2}}\right) - \frac{- R + R_{2}}{L_{2} \left(L_{1} - L_{2}\right)}\\\frac{L_{1} \left(- R + R_{2}\right)}{L_{2} \left(L_{1} - L_{2}\right)} - \frac{L_{2} \left(- R + R_{1}\right)}{L_{1} \left(L_{1} - L_{2}\right)}\end{matrix}\right]

But it you REALLY want to call Matlab, you can use SystemCall function to call Matlab script, and parse output.
CFD-Lover likes this.
alexeym is offline   Reply With Quote

Old   June 17, 2017, 17:27
Thumbs up
  #4
Member
 
OpenFoam
Join Date: Jun 2016
Posts: 82
Rep Power: 9
CFD-Lover is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

Why you cannot put this simple analytic solution into geo:

\left[\begin{matrix}\left(- R + R_{1}\right) \left(\frac{L_{2}}{L_{1}^{2} \left(L_{1} - L_{2}\right)} + \frac{1}{L_{1}^{2}}\right) - \frac{- R + R_{2}}{L_{2} \left(L_{1} - L_{2}\right)}\\\frac{L_{1} \left(- R + R_{2}\right)}{L_{2} \left(L_{1} - L_{2}\right)} - \frac{L_{2} \left(- R + R_{1}\right)}{L_{1} \left(L_{1} - L_{2}\right)}\end{matrix}\right]

But it you REALLY want to call Matlab, you can use SystemCall function to call Matlab script, and parse output.
Hi Alexeym,

Why not, your formula works perfect. That's what I need for now.

Many thanks for the formula,
CFD-Lover 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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 03:30
chtMultiRegionSimpleFoam turbulent case Aditya Patil OpenFOAM Running, Solving & CFD 6 April 24, 2017 22:13
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 13:59
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 03:34


All times are GMT -4. The time now is 02:26.