16 #include "vtkfigFrame.h" 17 #include "vtkfigDataSet.h" 18 #include "vtkfigGridView.h" 19 #include "vtkfigScalarView.h" 20 #include "vtkfigXYPlot.h" 51 auto frame=vtkfig::Frame::New();
52 frame->SetSize(800,800);
53 frame->SetLayout(2,2);
55 auto gridview=vtkfig::GridView::New();
56 frame->AddFigure(gridview,0);
58 auto solview=vtkfig::ScalarView::New();
59 frame->AddFigure(solview,1);
61 auto errplot=vtkfig::XYPlot::New();
62 frame->AddFigure(errplot,2);
63 errplot->SetXTitle(
"log10(h)");
64 errplot->SetYTitle(
"log10(error)");
66 auto timeplot=vtkfig::XYPlot::New();
67 frame->AddFigure(timeplot,3);
68 timeplot->SetXTitle(
"log10(N)");
69 timeplot->SetYTitle(
"log10(time)");
74 std::vector<double> H;
75 std::vector<double> N;
76 std::vector<double> TAsm;
77 std::vector<double> TLuf;
78 std::vector<double> TLus;
79 std::vector<double> TGen;;
82 std::vector<double> L2Error;
83 std::vector<double> H1Error;
86 for (
int iref=0;iref<maxref;iref++)
89 double h_intended=0.5*pow(2.0,-iref);
90 double vol= h_intended*h_intended*0.25;
99 printf(
"h_intended: %8.3g h_max: %8.3g\n",h_intended,hmax);
124 for (
int i=0; i<nnodes;i++)
128 exact[i]=sin(M_PI*x)*sin(M_PI*y);
129 source[i]=2.0*M_PI*M_PI*exact[i];
147 Solver.
solve(Sol,Rhs);
153 printf(
"h: %8.3e l2: %8.3e h1: %8.3e\n",hmax,l2error,h1error);
154 H.push_back(log10(hmax));
155 H1Error.push_back(log10(h1error));
156 L2Error.push_back(log10(l2error));
158 printf(
"time/ms gen: %8.3f asm: %8.3f luf: %8.3f lus: %8.3f\n",
159 t_gen*1000.0, t_asm*1000.0, t_luf*1000.0, t_lus*1000.0);
161 N.push_back(log10(grid.
npoints()));;
162 TAsm.push_back(log10(t_asm));
163 TLuf.push_back(log10(t_luf));
164 TLus.push_back(log10(t_lus));
165 TGen.push_back(log10(t_gen));
169 auto griddata=numcxx::vtkfigDataSet(grid);
170 griddata->SetPointScalar(Sol ,
"Sol");
172 gridview->SetData(griddata);
173 solview->SetData(griddata,
"Sol");
175 frame->SetFrameTitle(
"iref="+std::to_string(iref));
187 errplot->SetLegendPosition(0.7,0.4);
188 errplot->SetXRange(x0,x1);
189 errplot->SetYRange(-6,0);
192 errplot->SetPlotLineType(
"-");
193 errplot->SetPlotMarkerType(
"o");
194 errplot->SetMarkerSize(2);
197 errplot->SetPlotColor(0.2,0.5,0.2);
198 errplot->SetPlotLegend(
"O(h**2)");
199 errplot->AddPlot(X,OH2);
200 errplot->SetPlotColor(0.5,0.2,0.2);
201 errplot->SetPlotLegend(
"O(h)");
202 errplot->AddPlot(X,OH1);
204 errplot->SetPlotColor(0.0,0.5,0);
205 errplot->SetPlotLegend(
"L2");
207 errplot->AddPlot(H,L2Error);
208 errplot->SetPlotLegend(
"H1");
209 errplot->SetPlotColor(0.5,0,0);
210 errplot->AddPlot(H,H1Error);
225 timeplot->SetLegendPosition(0.3,0.6);
226 timeplot->SetLegendSize(0.15,0.3);
227 timeplot->SetXRange(n0,n1);
228 timeplot->SetYRange(t0,t1);
232 timeplot->SetPlotLineType(
"-");
233 timeplot->SetPlotMarkerType(
"o");
234 timeplot->SetMarkerSize(2);
237 timeplot->SetPlotLegend(
"Gen");
238 timeplot->SetPlotColor(0.5,0,0);
239 timeplot->AddPlot(N,TGen);
241 timeplot->SetPlotLegend(
"Asm");
242 timeplot->SetPlotColor(0.0,0.5,0);
243 timeplot->AddPlot(N,TAsm);
245 timeplot->SetPlotLegend(
"LU fact");
246 timeplot->SetPlotColor(0.0,0.0,0.5);
247 timeplot->AddPlot(N,TLuf);
249 timeplot->SetPlotLegend(
"LU solve");
250 timeplot->SetPlotColor(0.25,0.25,0);
251 timeplot->AddPlot(N,TLus);
253 timeplot->SetPlotLegend(
"O(N**(3/2))");
254 timeplot->SetPlotColor(0.0,0.0,1.0);
255 timeplot->AddPlot(XN1,ON32);
257 timeplot->SetPlotLegend(
"O(N)");
258 timeplot->SetPlotColor(1.0,0,0);
259 timeplot->AddPlot(XN,ON1);;
double l2norm(const numcxx::SimpleGrid &grid, const numcxx::DArray1 &u)
Class collecting data for the description of piecewise linear geometries.
Sparse matrix class using CRS storage scheme.
void set_regionpoints(const std::initializer_list< std::initializer_list< double >> &il)
Set member via intializer list.
void set_regionvolumes(const std::initializer_list< double > &il)
Set member via intializer list.
Header for simple grid data class.
void solve(TArray< T > &Sol, const TArray< T > &Rhs)
Solve LU factorized system.
const TArray2< double > & get_points() const
Get array of point coordinates.
Main header of the library.
void set_points(const std::initializer_list< std::initializer_list< double >> &il)
Set member via intializer list.
void set_regionnumbers(const std::initializer_list< int > &il)
Set member via intializer list.
void assemble_heat_problem(const numcxx::SimpleGrid &Grid, const numcxx::DArray1 &BCfac, const numcxx::DArray1 &BCval, const numcxx::DArray1 &Source, const numcxx::DArray1 &Kappa, numcxx::DSparseMatrix &SGlobal, numcxx::DArray1 &Rhs)
void set_bfaces(const std::initializer_list< std::initializer_list< int >> &il)
Set member via intializer list.
void set_bfaceregions(const std::initializer_list< int > &il)
Set member via intializer list.
One dimensional array class.
Class containing data for simple grid data structure.
Header for adapter beteween vtkfig dataset and simple grid.
double cpu_clock()
cpu time in seconds
Bridge class for using umfpack as solver for vmatrix.
void calc_hminmax(double &hmin, double &hmax) const
Calculate some grid data.
double h1norm(const numcxx::SimpleGrid &grid, const numcxx::DArray1 &u)
const int npoints() const
Return number of points.
const double Dirichlet
BC value marking Dirichlet boundary condition.
void update()
Perform actual computation of LU factorization.