76{
77 cout << "\n";
78 cout << "=== BVP: finite-difference solution of Troesch eqn ==\n";
79 cout << "\n";
80
81 Example::Troesch_equation<double, double> problem;
82 Example::Troesch_left_BC <double> BC_left;
83 Example::Troesch_right_BC<double> BC_right;
84
85 double left = 0.0;
86 double right = 1.0;
87
88 unsigned N = 151;
89
91
92 const double tol = 1.e-4;
93
94
95 problem.c = 5.0;
97
98
99 for ( unsigned i = 0; i < N; ++i )
100 {
101 double y = ode.solution().coord( i );
102
103 ode.solution()( i,
f ) = y;
104
105 ode.solution()( i,
fd ) = 1;
106 }
107
108
109 try
110 {
111 ode.solve2();
112 }
113 catch (const std::runtime_error &error )
114 {
115 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
116 return 1;
117 }
118
119
120 const double diff = std::abs( ode.solution().get_interpolated_vars(0.5)[
f] - 0.55437396E-01 );
121
122
123 if ( diff > tol )
124 {
125 cout << "\033[1;31;48m * FAILED \033[0m\n";
126 cout << "Real problem error " << diff << "\n";
127 return 1;
128 }
129 else
130 {
131 cout << "\033[1;32;48m * PASSED \033[0m\n";
132 return 0;
133 }
134}
An DenseVector class – a dense vector object.
A templated object for real/complex vector system of first-order ordinary differential equations.
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...