157 Vector<double> zeta(1);
160 Vector<double> posn(2);
163 double x_center = 0.0;
164 double y_center = 0.0;
167 Ellipse * outer_boundary_ellipse_pt =
new Ellipse(A,B);
170 TriangleMeshClosedCurve* closed_curve_pt=0;
174 bool polygon_for_outer_boundary=
false;
176 polygon_for_outer_boundary=
true;
178 if (polygon_for_outer_boundary)
182 double unit_zeta = 0.5*MathematicalConstants::Pi/double(n_seg);
186 Vector<TriangleMeshCurveSection*> boundary_polyline_pt(2);
189 Vector<Vector<double> > bound_coords(n_seg+1);
193 for(
unsigned ipoint=0; ipoint<n_seg+1;ipoint++)
196 bound_coords[ipoint].resize(2);
199 zeta[0]=unit_zeta*double(ipoint);
200 outer_boundary_ellipse_pt->position(zeta,posn);
201 bound_coords[ipoint][0]=posn[0]+x_center;
202 bound_coords[ipoint][1]=posn[1]+y_center;
206 unsigned boundary_id=0;
207 boundary_polyline_pt[0]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
212 for(
unsigned ipoint=0; ipoint<n_seg+1;ipoint++)
215 bound_coords[ipoint].resize(2);
218 zeta[0]=(unit_zeta*double(ipoint))+0.5*MathematicalConstants::Pi;
219 outer_boundary_ellipse_pt->position(zeta,posn);
220 bound_coords[ipoint][0]=posn[0]+x_center;
221 bound_coords[ipoint][1]=posn[1]+y_center;
226 boundary_polyline_pt[1]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
231 TriangleMeshPolygon *outer_polygon =
232 new TriangleMeshPolygon(boundary_polyline_pt);
236 enable_redistribution_of_segments_between_polylines();
239 closed_curve_pt = outer_polygon;
248 Vector<TriangleMeshCurveSection*> outer_curvilinear_boundary_pt(2);
252 double zeta_start=0.0;
253 double zeta_end=MathematicalConstants::Pi;
255 unsigned boundary_id=0;
256 outer_curvilinear_boundary_pt[0]=
new TriangleMeshCurviLine(
257 outer_boundary_ellipse_pt,zeta_start,zeta_end,nsegment,boundary_id);
261 zeta_start=MathematicalConstants::Pi;
262 zeta_end=2.0*MathematicalConstants::Pi;
265 outer_curvilinear_boundary_pt[1]=
new TriangleMeshCurviLine(
266 outer_boundary_ellipse_pt,zeta_start,zeta_end,nsegment,boundary_id);
273 new TriangleMeshClosedCurve(outer_curvilinear_boundary_pt);
280 Vector<TriangleMeshClosedCurve*> hole_pt(2);
290 Ellipse* polygon_ellipse_pt=
new Ellipse(A,B);
294 double unit_zeta = MathematicalConstants::Pi/double(n_seg);
298 Vector<TriangleMeshCurveSection*> hole_polyline_pt(2);
305 Vector<Vector<double> > bound_hole(n_seg+1);
306 for(
unsigned ipoint=0; ipoint<n_seg+1;ipoint++)
309 bound_hole[ipoint].resize(2);
312 zeta[0]=unit_zeta*double(ipoint);
313 polygon_ellipse_pt->position(zeta,posn);
314 bound_hole[ipoint][0]=posn[0]+x_center;
315 bound_hole[ipoint][1]=posn[1]+y_center;
319 unsigned boundary_id=2;
322 hole_polyline_pt[0] =
new TriangleMeshPolyLine(bound_hole,boundary_id);
327 for(
unsigned ipoint=0; ipoint<n_seg+1;ipoint++)
330 bound_hole[ipoint].resize(2);
333 zeta[0]=(unit_zeta*double(ipoint))+MathematicalConstants::Pi;
334 polygon_ellipse_pt->position(zeta,posn);
335 bound_hole[ipoint][0]=posn[0]+x_center;
336 bound_hole[ipoint][1]=posn[1]+y_center;
343 hole_polyline_pt[1] =
new TriangleMeshPolyLine(bound_hole,boundary_id);
350 Vector<double> hole_center(2);
351 hole_center[0]=x_center;
352 hole_center[1]=y_center;
354 hole_pt[0] =
new TriangleMeshPolygon(hole_polyline_pt, hole_center);
363 Ellipse* ellipse_pt=
new Ellipse(A,B);
366 Vector<TriangleMeshCurveSection*> curvilinear_boundary_pt(2);
371 double zeta_start=0.0;
372 double zeta_end=MathematicalConstants::Pi;
373 unsigned nsegment=10;
375 curvilinear_boundary_pt[0]=
new TriangleMeshCurviLine(
376 ellipse_pt,zeta_start,zeta_end,
377 nsegment,boundary_id);
381 zeta_start=MathematicalConstants::Pi;
382 zeta_end=2.0*MathematicalConstants::Pi;
385 curvilinear_boundary_pt[1]=
new TriangleMeshCurviLine(
386 ellipse_pt,zeta_start,zeta_end,
387 nsegment,boundary_id);
392 Vector<double> hole_coords(2);
395 Vector<TriangleMeshClosedCurve*> curvilinear_hole_pt(1);
397 new TriangleMeshClosedCurve(curvilinear_boundary_pt,
412 TriangleMeshParameters triangle_mesh_parameters(closed_curve_pt);
415 triangle_mesh_parameters.internal_closed_curve_pt() = hole_pt;
418 double uniform_element_area=0.2;
419 triangle_mesh_parameters.element_area() = uniform_element_area;
423 RefineableTriangleMesh<ELEMENT>(triangle_mesh_parameters);
426 Problem::mesh_pt()=My_mesh_pt;
429 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
430 My_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
433 My_mesh_pt->max_element_size()=0.2;
434 My_mesh_pt->min_element_size()=0.002;
437 complete_problem_setup();
441 snprintf(filename,
sizeof(filename),
"RESLT/trace.dat");
442 Trace_file.open(filename);
445 oomph_info <<
"Number of equations: "
446 << this->assign_eqn_numbers() << std::endl;
537 std::string& comment)
546 snprintf(filename,
sizeof(filename),
"RESLT/soln%i.dat",Doc_info.number());
547 some_file.open(filename);
548 this->My_mesh_pt->output(some_file,npts);
549 some_file <<
"TEXT X = 22, Y = 92, CS=FRAME T = \""
550 << comment <<
"\"\n";
555 snprintf(filename,
sizeof(filename),
"RESLT/exact_soln%i.dat",Doc_info.number());
556 some_file.open(filename);
562 snprintf(filename,
sizeof(filename),
"RESLT/boundaries%i.dat",Doc_info.number());
563 some_file.open(filename);
564 My_mesh_pt->output_boundaries(some_file);
570 double error,norm,dummy_error,zero_norm;
571 snprintf(filename,
sizeof(filename),
"RESLT/error%i.dat",Doc_info.number());
572 some_file.open(filename);
577 dummy_error,zero_norm);
581 oomph_info <<
"\nNorm of error : " << sqrt(error) << std::endl;
582 oomph_info <<
"Norm of exact solution: " << sqrt(norm) << std::endl;
583 oomph_info <<
"Norm of computed solution: " << sqrt(dummy_error) << std::endl;
584 Trace_file << sqrt(norm) <<
" " << sqrt(dummy_error) << std::endl;