GithubHelp home page GithubHelp logo

samplemaker / freefem_matlab_octave_plot Goto Github PK

View Code? Open in Web Editor NEW
22.0 7.0 13.0 4.59 MB

Examples how to plot FreeFem++ simulation results from within matlab and octave

License: GNU General Public License v3.0

MATLAB 78.02% C 21.98%
octave octave-functions matlab plot 2d-plot freefem freefem-3d 3d-plot contour-plot surf-plot

freefem_matlab_octave_plot's People

Contributors

samplemaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

freefem_matlab_octave_plot's Issues

Make movie with data from Freefem++

When I export the numerical solutions from Freefem++ (heat equation with periodic boundary condition). I would like to make one movie to represent the profile of temperature and save in Avi format. The code as below, the movie is not includ "x axis", "title", the "colorbar", I think maybe the reason is the function "ffpdeplot". could you help to improve it? Thanks a lot.

// heats.edp
real t=0;
real dt = 0.001,T=1;
real D=0.1;
mesh Th=square(30,30,[2xpi,2ypi]);
fespace Vh(Th,P1,periodic=[[2,y],[4,y],[1,x],[3,x]]);
Vh uh,uold,vh;
func f=sin(x+pi/4.)cos(y+pi/2.);
problem Heat(uh,vh) = int2d(Th)(uhvh/dt+ Ddx(uh) * dx(vh) + Ddy(uh) * dy(vh) )
-int2d(Th)(uold*vh/dt);

savemesh(Th,"periodic.msh");
Vh u0=0.1exp(-10(x-pi)^2-10*(y-pi)^2);
uold=u0;
int round = 0;
while (t + dt/2. < T)
{
t = t+ dt;
round++;
Heat;
uold=uh;

if(round % 200 == 0)
{
plot(uh,fill=true,value=true);
{
ofstream file("periodic"+round+".txt");
int nbvertices = Th.nv;
for (int i=0; i<nbvertices; i++){
file << uh(Th(i).x, Th(i).y) << "\n";
}
}
}
}
%%%%%%%%%%%%%%%%%%%%

clear all;
addpath('ffmatlib');
%Reads a FreeFem++ mesh created with the savemesh(Th,"mesh.msh"); command
[p,b,t,nv,nbe,nt,labels]=ffreadmesh('periodic.msh');
%Reads the PDE data
[u2]=ffreaddata('periodic200.txt');
[u4]=ffreaddata('periodic400.txt');
[u6]=ffreaddata('periodic600.txt');
[u8]=ffreaddata('periodic800.txt');
[u10]=ffreaddata('periodic1000.txt');

%%%%% 2D Patch (density map) Plot + Contour

theAxes=axis;
fmat=moviein(5);
ffpdeplot(p,b,t, ...
'XYData',u2, ...
'Mesh','off', ...
'Boundary','on', ...
'Contour','on', ...
'Title','Patch Plot + Contour');
fmat(:,1)=getframe;
ffpdeplot(p,b,t, ...
'XYData',u4, ...
'Mesh','off', ...
'Boundary','on', ...
'Contour','on', ...
'Title','Patch Plot + Contour');
fmat(:,2)=getframe;
ffpdeplot(p,b,t, ...
'XYData',u6, ...
'Mesh','off', ...
'Boundary','on', ...
'Contour','on', ...
'Title','Patch Plot + Contour');
fmat(:,3)=getframe;
ffpdeplot(p,b,t, ...
'XYData',u8, ...
'Mesh','off', ...
'Boundary','on', ...
'Contour','on', ...
'Title','Patch Plot + Contour');
fmat(:,4)=getframe;
ffpdeplot(p,b,t, ...
'XYData',u10, ...
'Mesh','off', ...
'Boundary','on', ...
'Contour','on', ...
'Title','Patch Plot + Contour');
fmat(:,5)=getframe;
figure()
movie(fmat,5)

%%make movie
%%%%%%%%%%%%%%%%%%%%%%%%
aviobj=VideoWriter('heats.avi');
open(aviobj)
for ii=1:5
currFrame(ii)=fmat(:,ii);
writeVideo(aviobj,currFrame(ii));
end
close(aviobj)

Periodic Boundary Conditions numerical solution data to matlab

I would like to sove one Heat equation with Periodic Boundary Conditions. When I got the numerical solution, how to output the data to plot the figure in Matlab?
Because the degrees of numerical solution is less the number of nodes in the mesh. In this case the code can not run. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.