samplemaker / freefem_matlab_octave_plot Goto Github PK
View Code? Open in Web Editor NEWExamples how to plot FreeFem++ simulation results from within matlab and octave
License: GNU General Public License v3.0
Examples how to plot FreeFem++ simulation results from within matlab and octave
License: GNU General Public License v3.0
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)
Potentially affected: fftet2grid
Line:
if ((Va>=-1e-12) && (Vb>=-1e-12) && (Vc>=-1e-12) && (Vd>=-1e-12)){
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.