101{
102 cout << "\n";
103 cout << "=== double_IBVP: non-constant mass matrix example ===\n";
104 cout << "\n";
105
106
107 Example::nonlinear problem;
108 Example::BC_lower BC_bottom;
109 Example::BC_upper BC_top;
110
111
112 double top = 1.0;
113 double bottom = 0.0;
114 double left = 0.0;
115 double right = 10.0;
116
117 unsigned ny = 11;
118 unsigned nx = 1001;
119
120 double t_end = 1.;
121 double dt = 0.01;
122
123
127 &BC_bottom, &BC_top );
128
129
130 for ( unsigned i = 0; i < nx; ++i )
131 {
132 for ( unsigned j = 0; j < ny; ++j )
133 {
134 nlin.solution()( i, j,
U ) = 0.0;
135 nlin.solution()( i, j,
Ud ) = 0.0;
136 }
137 }
138
139 double max_error( 0.0 );
140 int counter( 0 );
141 do
142 {
143
144 nlin.update_previous_solution();
145
146
147 double t_next = nlin.t() + dt;
148 for ( unsigned j = 0; j < ny; ++j )
149 {
150 double y = nlin.solution().coord( 0, j ).second;
151 nlin.solution()( 0, j,
U ) = t_next * y;
152 nlin.solution()( 0, j,
Ud ) = t_next;
153 }
154 nlin.step2( dt );
155 for ( unsigned i = 0; i < nx; ++i )
156 {
157 for ( unsigned j = 0; j < ny; ++j )
158 {
159 double x = nlin.solution().coord( i, j ).first;
160 double y = nlin.solution().coord( i, j ).second;
161 double exact_u = y * nlin.t() * exp( - x );
162 max_error = max( max_error, abs( exact_u - nlin.solution()( i, j,
U ) ) );
163 }
164 }
165 ++counter;
166 }
167 while ( nlin.t() < t_end );
168
169 const double tol( 1.e-4 );
170
171 if ( max_error > tol )
172 {
173 cout << "\033[1;31;48m * FAILED \033[0m\n";
174 cout << " Difference = " << max_error << "\n";
175 return 1;
176 }
177 else
178 {
179 cout << "\033[1;32;48m * PASSED \033[0m\n";
180 return 0;
181 }
182
183}
A templated object for real/complex vector system of unsteady 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...