|
[Sponsors] |
Translating a Bisection Method writtern in Matlab to Gmsh! |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 26, 2017, 17:35 |
Translating a Bisection Method writtern in Matlab to Gmsh!
|
#1 |
Member
OpenFoam
Join Date: Jun 2016
Posts: 82
Rep Power: 9 |
Hi,
I have written a Bisection method code in Matlab, and I really want to write in Gmsh if that possible. I have read that Gmsh doesn't support the so-called while loop, so I implemented it in Matlab using for loop. Is there any why to implemented in Gmsh. The code is below; Code:
clear all;clc;close all % ------------------------------------------------------------------------- format long n = 30; L = 2; Start = 0.012; i = 0:1:(n-1-1); %-------------------------------------------------------------------------- Function = @(r) L-sum(Start.*r.^i); % anaymos function low = 0; high = pi/2; tol = 0.00001; mid = (low+high)/2; for ii=1:ceil(log2(1/tol)) if Function(mid)*Function(high) < 0 % Solution is within upper half low = mid; else % Solution is within lower half high = mid; end fprintf('Solution lies within [%6.4f, %6.4f]; \n',[low high]); mid = (low+high)/2; end display(mid) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SIMPLE method with matlab | houkensjtu | Main CFD Forum | 9 | August 15, 2013 07:28 |
[Gmsh] discretizer - gmshToFoam | Andyjoe | OpenFOAM Meshing & Mesh Conversion | 13 | March 14, 2012 04:35 |
Code for most powerfull FDV Method | D.S.Nasan | Main CFD Forum | 6 | September 4, 2008 02:08 |
matlab code galerkin method? | Mink | Main CFD Forum | 3 | May 23, 2007 06:03 |
Gudunow method in matlab | student | Main CFD Forum | 2 | November 6, 2004 08:32 |