15 #include "vtkfigFrame.h" 16 #include "vtkfigXYPlot.h" 21 inline double B(
double x)
23 if (std::fabs(x)<1.0e-10)
return 1.0;
24 return x/(std::exp(x)-1.0);
30 auto h=1.0/(double)(n-1);
36 for (
int k=0, l=1;k<n-1;k++,l++)
38 double g_kl=D*
B(v*h/D);
39 double g_lk=D*
B(-v*h/D);
60 auto h=1.0/(double)(n-1);
66 double g_kl=D - 0.5*(v*h);
67 double g_lk=D + 0.5*(v*h);
68 for (
int k=0, l=1;k<n-1;k++,l++)
91 auto h=1.0/(double)(n-1);
97 for (
int k=0, l=1;k<n-1;k++,l++)
133 auto frame=vtkfig::Frame::New();
134 frame->SetSize(800,800);
135 auto plot=vtkfig::XYPlot::New();
136 frame->AddFigure(plot);
138 for (
int iref=0;iref<maxref;iref++)
151 frame->SetFrameTitle(
"n="+std::to_string(n));
153 plot->ShowGrid(
false);
155 plot->SetXRange(0,1);
156 plot->SetYRange(-1,1);
158 plot->SetLegendPosition(0.3,0.7);
159 plot->SetPlotLineType(
"-");
162 plot->SetPlotColor(1,0,0);
163 plot->SetPlotLegend(
"exp");
164 plot->AddPlot(*X,Uexp);
166 plot->SetPlotColor(0,1,0);
167 plot->SetPlotLegend(
"upw");
168 plot->AddPlot(*X,Uupw);
170 plot->SetPlotColor(0,0,1);
171 plot->SetPlotLegend(
"cent");
172 plot->AddPlot(*X,Ucnt);
Sparse matrix class using CRS storage scheme.
void flush()
Re-create the internal data structure in order to accomodated all newly created elements.
size_t size() const
Obtain size of array.
void solve(TArray< T > &Sol, const TArray< T > &Rhs)
Solve LU factorized system.
Main header of the library.
void solve_expfit(double v, double D, numcxx::DArray1 &U)
std::shared_ptr< TArray1< T > > linspace(T x0, T x1, int n)
Create array of $n$ equally spaced entries.
void solve_upwind(double v, double D, numcxx::DArray1 &U)
One dimensional array class.
void solve_central(double v, double D, numcxx::DArray1 &U)
Bridge class for using umfpack as solver for vmatrix.
TArray1< double > DArray1
void update()
Perform actual computation of LU factorization.