diff --git a/HelmholtzEquation.m b/HelmholtzEquation.m index f6fd7540..28e5602f 100755 --- a/HelmholtzEquation.m +++ b/HelmholtzEquation.m @@ -12,7 +12,7 @@ % If RHS is given as input, c and d are not used. % % The in-homogeneous Helmholtz equation with variable coefficents in two spatial -% dimentions is +% dimensions is % % $$ a(x,y) f(x,y) - \nabla \cdot (b(x,y) \nabla f(x,y)) = c(x,y) - \nabla \cdot \nabla d(x,y) $$ % diff --git a/PlotResultsFromThicknessInversion.m b/PlotResultsFromThicknessInversion.m index 2e502fdd..8e0530d7 100755 --- a/PlotResultsFromThicknessInversion.m +++ b/PlotResultsFromThicknessInversion.m @@ -10,25 +10,25 @@ function PlotResultsFromThicknessInversion(CtrlVar,MUA,F,BCs,Priors,Meas,hest,ht -UaPlots(CtrlVar,MUA,F,hest,FigureTitle="hest") ; +UaPlots(CtrlVar,MUA,F,hest,FigureTitle="hest",CreateNewFigure=true) ; title("h estimated") hold on ; PlotGroundingLines(); if ~isempty(Priors.h) - UaPlots(CtrlVar,MUA,F,Priors.h,FigureTitle="hprior") ; title("h prior") + UaPlots(CtrlVar,MUA,F,Priors.h,FigureTitle="hprior",CreateNewFigure=true) ; title("h prior") hold on ; PlotGroundingLines(); end if ~isempty(Meas.h) - UaPlots(CtrlVar,MUA,F,Meas.h,FigureTitle="hmeas") ; + UaPlots(CtrlVar,MUA,F,Meas.h,FigureTitle="hmeas",CreateNewFigure=true) ; title("$h$ measured",Interpreter="latex") hold on ; PlotGroundingLines(); - UaPlots(CtrlVar,MUA,F,hest-Meas.h,FigureTitle="hest-hmeas") ; + UaPlots(CtrlVar,MUA,F,hest-Meas.h,FigureTitle="hest-hmeas",CreateNewFigure=true) ; title("$h$: estimated - measured ice thickness",Interpreter="latex") hold on ; PlotGroundingLines(); @@ -46,7 +46,7 @@ function PlotResultsFromThicknessInversion(CtrlVar,MUA,F,BCs,Priors,Meas,hest,ht UaPlots(CtrlVar,MUA,F,htrue,FigureTitle="h true") ; title("$h$ true",Interpreter="latex") axis tight - FindOrCreateFigure("compare") + FigCompare=FindOrCreateFigure("compare") ; clf(FigCompare) yyaxis left plot(htrue,hest,'.') hold on @@ -61,7 +61,8 @@ function PlotResultsFromThicknessInversion(CtrlVar,MUA,F,BCs,Priors,Meas,hest,ht title(sprintf("R2=%f",lm.Rsquared.Ordinary)); xlabel("h true") ; - UaPlots(CtrlVar,MUA,F,hest-htrue,FigureTitle="hest-htrue") ; title("hest-htrue") + UaPlots(CtrlVar,MUA,F,hest-htrue,FigureTitle="hest-htrue",CreateNewFigure=true) ; + title("hest-htrue") end diff --git a/html/HelmholtzEquation.html b/html/HelmholtzEquation.html index fd4c4fcd..1146d66b 100755 --- a/html/HelmholtzEquation.html +++ b/html/HelmholtzEquation.html @@ -1,103 +1,143 @@ - - - - - HelmholtzEquation
function [UserVar,f,lambda,HEmatrix,HErhs]=HelmholtzEquation(UserVar,CtrlVar,MUA,a,b,c,d,RHS)
-

Solves the in-homogeneous Helmholtz equation with variable coefficients in two dimentions:

$$  a(x,y) f(x,y) - \nabla \cdot (b(x,y) \nabla f(x,y)) = c(x,y) - \nabla \cdot \nabla d(x,y) $$

Also possible to specify the right-hand-side directly through

RHS
-

If RHS is given as input, c and d are not used.

The in-homogeneous Helmholtz equation with variable coefficents in two spatial dimentions is

$$  a(x,y) f(x,y) - \nabla \cdot (b(x,y) \nabla f(x,y)) = c(x,y) - \nabla \cdot \nabla  d(x,y) $$

which we can also write as

$$  a ( f - \tilde{f} ) - \nabla \cdot (b \nabla (f-\tilde{f})) = 0 $$

where $c= -a \tilde{f}$ and $d= -b \tilde{f}$, and $\tilde{f}$ is a given function

Examples:

Smooth a given field over a FE mesh:

  load('PIG-TWG-RestartFile.mat') ; CtrlVar=CtrlVarInRestartFile;
-  L=1e3 ;  % Smoothing length scale
-  [UserVar,SmoothedField]=HelmholtzEquation([],CtrlVar,MUA,1,L^2,F.B,0);
  figure(1) ; PlotMeshScalarVariable(CtrlVarInRestartFile,MUA,SmoothedField) ; title(' Smoothed field') ; xlabel('x (km)') ; ylabel('y (km)')
-  figure(2) ; PlotMeshScalarVariable(CtrlVarInRestartFile,MUA,F.B) ; title(' Original field')  ; xlabel('x (km)') ; ylabel('y (km)')
-  figure(3) ; PlotMeshScalarVariable(CtrlVarInRestartFile,MUA,SmoothedField-F.B) ; title(' Smoothed-Original')  ; xlabel('x (km)') ; ylabel('y (km)')
narginchk(7,8)
-
-
-[UserVar,HEmatrix,HErhs]=HelmholtzEquationAssembly(UserVar,CtrlVar,MUA,a,b,c,d);
-L=[] ; Lrhs=[] ; lambda=[]; f=[] ;
-
-if nargin==8 && ~isempty(RHS)
-    HErhs=RHS;
-end
-
-[f,lambda]=solveKApe(HEmatrix,L,HErhs,Lrhs,f,lambda,CtrlVar);
-f=full(f);
-
-%
-% MLC=BCs2MLC(CtrlVar,MUA,BCsTracer);
-% L=MLC.hL ; Lrhs=MLC.hRhs ; lambda=Lrhs*0;
-% [c1,lambda]=solveKApe(kv,L,rh,Lrhs,c0,lambda,CtrlVar);
-% c1=full(c1);
-
end
-
+HelmholtzEquation + + + + + + + +
+
+function [UserVar,f,lambda,HEmatrix,HErhs]=HelmholtzEquation(UserVar,CtrlVar,MUA,a,b,c,d,RHS)
+
+

Solves the in-homogeneous Helmholtz equation with variable coefficients in two dimensions:

+

+$$  a(x,y) f(x,y) - \nabla \cdot (b(x,y) \nabla f(x,y)) = c(x,y) - \nabla \cdot \nabla d(x,y) $$

+

Also possible to specify the right-hand-side directly through

+
RHS
+
+

If RHS is given as input, c and d are not used.

+

The in-homogeneous Helmholtz equation with variable coefficents in two spatial dimensions is

+

+$$  a(x,y) f(x,y) - \nabla \cdot (b(x,y) \nabla f(x,y)) = c(x,y) - \nabla \cdot \nabla  d(x,y) $$

+

which we can also write as

+

+$$  a ( f - \tilde{f} ) - \nabla \cdot (b \nabla (f-\tilde{f})) = 0 $$

+

where $c= -a \tilde{f}$ and $d= -b \tilde{f}$, and $\tilde{f}$ is a given function

+

Examples:

+

Smooth a given field over a FE mesh:

+
  load('PIG-TWG-RestartFile.mat') ; CtrlVar=CtrlVarInRestartFile;
+  L=1e3 ;  % Smoothing length scale
+  [UserVar,SmoothedField]=HelmholtzEquation([],CtrlVar,MUA,1,L^2,F.B,0);
+
  figure(1) ; PlotMeshScalarVariable(CtrlVarInRestartFile,MUA,SmoothedField) ; title(' Smoothed field') ; xlabel('x (km)') ; ylabel('y (km)')
+  figure(2) ; PlotMeshScalarVariable(CtrlVarInRestartFile,MUA,F.B) ; title(' Original field')  ; xlabel('x (km)') ; ylabel('y (km)')
+  figure(3) ; PlotMeshScalarVariable(CtrlVarInRestartFile,MUA,SmoothedField-F.B) ; title(' Smoothed-Original')  ; xlabel('x (km)') ; ylabel('y (km)')
+
narginchk(7,8)
+
+
+[UserVar,HEmatrix,HErhs]=HelmholtzEquationAssembly(UserVar,CtrlVar,MUA,a,b,c,d);
+L=[] ; Lrhs=[] ; lambda=[]; f=[] ;
+
+if nargin==8 && ~isempty(RHS)
+    HErhs=RHS;
+end
+
+[f,lambda]=solveKApe(HEmatrix,L,HErhs,Lrhs,f,lambda,CtrlVar);
+f=full(f);
+
+%
+% MLC=BCs2MLC(CtrlVar,MUA,BCsTracer);
+% L=MLC.hL ; Lrhs=MLC.hRhs ; lambda=Lrhs*0;
+% [c1,lambda]=solveKApe(kv,L,rh,Lrhs,c0,lambda,CtrlVar);
+% c1=full(c1);
+
+
Error using HelmholtzEquation
+Not enough input arguments.
+
+
+end
+
+ +
+ \ No newline at end of file +--> + +