Skip to content
Snippets Groups Projects
Commit b2e34ec0 authored by gergaud's avatar gergaud
Browse files

ajout TP EDP

parent 2244d864
No related branches found
No related tags found
No related merge requests found
File added
global PosWait;
global SizeWait;
global WaitBar;
present = isempty(PosWait)*isempty(SizeWait)*isempty(WaitBar);
if (present==0)
clear Hfig KcFrame WaitFrame black fig fy4 lightgreen orange red whitepaper
clear KcBar PosKc SizeKc WaitLabel blue fx4 lightblue magenta pink white
close(10)
end
PosWait = ''; SizeWait = ''; WaitBar = '';
clear PosWait SizeWait WaitBar present
\ No newline at end of file
global PosWait;
global SizeWait;
global WaitBar;
global PosKc;
global SizeKc;
global KcBar;
fig = 10;
figure(fig), clf
Hfig = gcf;
set( Hfig, 'Position', [1000, 600, 380, 100], 'Resize', 'off' );
% Define some default colors :
orange = [0.8 0.7 0.1];
magenta = [1.0 0.0 1.0];
pink = [0.8 0.5 0.7];
blue = [0.2 0.2 1.0];
lightblue = [0.5 0.7 0.8];
lightgreen = [0.2 0.8 0.3];
white = [1.0 1.0 1.0];
red = [1.0 0.0 0.0];
whitepaper = [0.9 0.9 0.6];
black = [0.0 0.0 0.0];
fx4 = 35; fy4 = 35;
WaitLabel = uicontrol( Hfig, ...
'Style', 'text', ...
'Position', [fx4+15 fy4+20 280 15], ...
'BackgroundColor', lightblue, ...
'ForegroundColor', blue, ...
'Visible', 'on', ...
'FontSize', [10], ...
'FontWeight', 'normal', ...
'HorizontalAlignment', 'center', ...
'String', 'Wait please ...' );
WaitFrame = uicontrol( Hfig, ...
'Style', 'frame', ...
'Position', [fx4+15 fy4+5 280 15], ...
'Visible', 'on', ...
'BackgroundColor', white );
PosWait = [fx4+16 fy4+6 1 13];
SizeWait = 278;
WaitBar = uicontrol( Hfig, ...
'Style', 'frame', ...
'Position', PosWait, ...
'Visible', 'off', ...
'ForegroundColor', red, ...
'BackgroundColor', red );
KcFrame = uicontrol( Hfig, ...
'Style', 'frame', ...
'Position', [fx4+15 fy4-10 280 15], ...
'Visible', 'on', ...
'BackgroundColor', white );
PosKc = [fx4+16 fy4-9 1 13];
SizeKc = 278;
KcBar = uicontrol( Hfig, ...
'Style', 'frame', ...
'Position', PosKc, ...
'Visible', 'off', ...
'ForegroundColor', blue, ...
'BackgroundColor', blue );
function [] = SetWait( jvp, n, Kc, KcExp )
global PosWait;
global SizeWait;
global WaitBar;
global PosKc;
global SizeKc;
global KcBar;
present = isempty(PosWait)*isempty(SizeWait)*isempty(WaitBar);
if (present~=0)
return
end
PosWait(3) = max( fix( (jvp/n)*SizeWait ), 1 );
set( WaitBar, 'Position', PosWait, 'Visible', 'on' ); drawnow;
if (nargin > 2)
present = isempty(PosKc)*isempty(SizeKc)*isempty(KcBar);
if (present~=0)
return
end
PosKc(3) = max( fix( (Kc/KcExp)*SizeKc ), 1 );
set( KcBar, 'Position', PosKc, 'Visible', 'on' ); drawnow;
end
function nbfig_out=plot_uh(uh,dx1,dx2,N1,N2,nbfig)
%
% Cette fonction affiche la solution de l'EDP
%
% Inputs
% ------
%
% uh : solution numérique de l'EDP.
%
% dx1 : pas d'espace dans la direction x1.
%
% dx2 : pas d'espace dans la direction x2.
%
% N1 : nombre de points de grille dans la direction x1.
%
% N2 : nombre de points de grilles dans la direction x2.
%
% nbfig : identifiant de la figure
%
% Outputs:
% -------
%
% nbfig_out : identifiant de la figure
%
% Construction de la grille pour l'affichage.
x1min=0.;
x1max=dx1*(N1+1);
x2min=0.;
x2max=dx2*(N2+1);
if(x1max==0)
disp('Erreur : L1=0')
return
else
rxy=x2max/x1max;
end
x1=x1min:dx1:x1max;
x2=x2min:dx2:x2max;
[X,Y]=meshgrid(x1,x2);
[m,n]=size(X);
% Mise au format 2D de la solution.
Z=zeros(N2+2,N1+2);
Z(2:N2+1,2:N1+1)=reshape(uh,N2,N1);
% Affichage
nbfig_out=nbfig;
figure(nbfig_out)
s=surf(X,Y,Z,'FaceAlpha',0.5);
s.EdgeColor='none';
pbaspect([1 rxy 1]);
colorbar;
xlabel('x_1')
ylabel('x_2')
zlabel('u')
end
function [uhref]=diffusivity(nu,L1,L2,N1,N2)
%
% Cette fonction résoud le problème du calcul d'une solution du Laplacien anisotrope.
%
% Inputs
% ------
%
% nu: [nu1;nu2] valeurs des paramètres de diffusivité.
%
% L1 : longeur du domaine dans la direction x1.
%
% L2 : longueur du domaine dans la direction x2.
%
% N1 : nombre de points de grille dans la direction x1.
%
% N2 : nombre de points de grille dans la direction x2.
%
%
% Outputs:
% -------
%
% uhref : vecteur de taille N1*N2 contenant une approximation de la solution
%
% Ajout du repertoire Affichage à l'environnement
addpath('Affichage');
% Construction de la grille
dx1 = L1/(N1+1);
dx2 = L2/(N2+1);
% Calcul de la solution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calcul de la matrice du systeme
L = laplacian(nu,dx1,dx2,N1,N2);
% Calcul de l'approximation de la solution de l'EDP
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% TO DO %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%ù
uhref=zeros(N1*N2,1);
%Affichage de la solution approximee
fig_ref = plot_uh(uhref,dx1,dx2,N1,N2,2); drawnow;
end
function b=forcing(nu, dx1, dx2, N1, N2)
%
% Cette fonction construit le vecteur de forçage de l'EDP
%
% Inputs
% ------
%
% nu : nu=[nu1;nu2], coefficients de diffusivité dans les dierctions x1 et x2.
%
% dx1 : pas d'espace dans la direction x1.
%
% dx2 : pas d'espace dans la direction x2.
%
% N1 : nombre de points de grille dans la direction x1.
%
% N2 : nombre de points de grilles dans la direction x2.
%
% Outputs:
% -------
%
% b : vecteur de forçage (dimension N1N2)
%
%
% Initialisation
b=zeros(N1*N2,1);
%%%%%%%%%%%%%%%%%%%%%%
%%%%%% TO DO %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
end
function L = laplacian(nu,dx1,dx2,N1,N2)
%
% Cette fonction construit la matrice de l'opérateur Laplacien 2D anisotrope
%
% Inputs
% ------
%
% nu : nu=[nu1;nu2], coefficients de diffusivité dans les dierctions x1 et x2.
%
% dx1 : pas d'espace dans la direction x1.
%
% dx2 : pas d'espace dans la direction x2.
%
% N1 : nombre de points de grille dans la direction x1.
%
% N2 : nombre de points de grilles dans la direction x2.
%
% Outputs:
% -------
%
% L : Matrice de l'opérateur Laplacien (dimension N1N2 x N1N2)
%
%
% Initialisation
L=sparse([]);
%%%%%%%%%%%%%%%%%%%%%%
%%%%%% TO DO %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment