exact_solution_nsdv.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of NS2DDV. %
% %
% Copyright(C) 2011-2018 C. Calgaro (caterina.calgaro@math.univ-lille1.fr) %
% E. Creusé (emmanuel.creuse@math.univ-lille1.fr) %
% T. Goudon (thierry.goudon@inria.fr) %
% A. Mouton (alexandre.mouton@math.univ-lille1.fr) %
% %
% NS2DDV is free software: you can redistribute it and/or modify it under the terms %
% of the GNU General Public License as published by the Free Software Foundation, %
% either version 3 of the License, or (at your option) any later version. %
% %
% NS2DDV is distributed in the hope that it will be useful, but WITHOUT ANY %
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A %
% PARTICULAR PURPOSE. See the GNU General Public License for more details. %
% %
% You should have received a copy of the GNU General Public License along with %
% NS2DDV. If not, see <http://www.gnu.org/licenses/>. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[p,u,rho] = exact_solution_nsdv(x, y, time, PARAMETERS)
% INPUT
% x x-coordinate of the point at which the exact solution has to be evaluated
% y y-coordinate of the point at which the exact solution has to be evaluated
% time Time value
% PARAMETERS List of simulation parameters
%
% OUTPUT
% p Exact pressure
% u Exact velocity
% rho Exact density
switch PARAMETERS.TESTCASE
case {'RTIN', 'CAEN', 'DROP'}
% No analytical solution : we answer 0
p = 0.;
u = zeros(1,2);
rho = 0.;
case {'EXAC'}
u = zeros(1,2);
u(:,1) = -y*cos(time);
u(:,2) = x*cos(time);
rho = 2. + cos(sin(time))*x + sin(sin(time))*y;
switch PARAMETERS.DOMAIN.GEOMETRY
case {'RECTANGLE'}
Lx = PARAMETERS.DOMAIN.XMAX-PARAMETERS.DOMAIN.XMIN;
Ly = PARAMETERS.DOMAIN.YMAX-PARAMETERS.DOMAIN.YMIN;
xx = 2*pi*(x-PARAMETERS.FE.NFX_X)/Lx;
yy = 2*pi*(y-PARAMETERS.FE.NFX_Y)/Ly;
p = sin(time) * sin(xx) * sin(yy);
case {'CIRCLE', 'DIHEDRON', 'FROM_FILE'}
error(sprintf('EXAC test case is only compatible with RECTANGLE domain geometry\n'));
otherwise
error(sprintf('Unknown domain geometry\n'));
end
case {'EXACNEU'}
switch PARAMETERS.DOMAIN.GEOMETRY
case {'RECTANGLE'}
Lx = PARAMETERS.DOMAIN.XMAX-PARAMETERS.DOMAIN.XMIN;
Ly = PARAMETERS.DOMAIN.YMAX-PARAMETERS.DOMAIN.YMIN;
xx = (x-PARAMETERS.DOMAIN.XMIN)/Lx;
yy = (y-PARAMETERS.DOMAIN.YMIN)/Ly;
u = zeros(1,2);
u(:,1) = sin(xx) * sin(yy+time);
u(:,2) = cos(xx) * cos(yy+time);
p = (1./(PARAMETERS.PHYSICAL.RE*Lx)) * cos(xx) * sin(yy+time);
rho = 1.;
otherwise
error(sprintf('Unknown test case.\n'));
end
end