169 Trace_file.open(
"RESLT/trace.dat");
175 Circle* inner_circle_pt=
new Circle(x_c,y_c,a);
179 TriangleMeshClosedCurve* outer_boundary_pt=0;
181 unsigned n_segments = 20;
182 Vector<TriangleMeshCurveSection*> outer_boundary_line_pt(4);
186 Vector<Vector<double> > vertex_coord(2);
187 for(
unsigned i=0;i<2;i++)
189 vertex_coord[i].resize(2);
193 vertex_coord[0][0]=-2.0;
194 vertex_coord[0][1]=-2.0;
195 vertex_coord[1][0]=-2.0;
196 vertex_coord[1][1]=2.0;
199 unsigned boundary_id=2;
200 outer_boundary_line_pt[0] =
new TriangleMeshPolyLine(vertex_coord,
204 vertex_coord[0][0]=-2.0;
205 vertex_coord[0][1]=2.0;
206 vertex_coord[1][0]=2.0;
207 vertex_coord[1][1]=2.0;
211 outer_boundary_line_pt[1] =
new TriangleMeshPolyLine(vertex_coord,
215 vertex_coord[0][0]=2.0;
216 vertex_coord[0][1]=2.0;
217 vertex_coord[1][0]=2.0;
218 vertex_coord[1][1]=-2.0;
222 outer_boundary_line_pt[2] =
new TriangleMeshPolyLine(vertex_coord,
226 vertex_coord[0][0]=2.0;
227 vertex_coord[0][1]=-2.0;
228 vertex_coord[1][0]=-2.0;
229 vertex_coord[1][1]=-2.0;
233 outer_boundary_line_pt[3] =
new TriangleMeshPolyLine(vertex_coord,
237 outer_boundary_pt =
new TriangleMeshPolygon(outer_boundary_line_pt);
241 Vector<TriangleMeshCurveSection*> inner_boundary_line_pt(2);
244 double s_start = 0.0;
245 double s_end = MathematicalConstants::Pi;
247 inner_boundary_line_pt[0]=
248 new TriangleMeshCurviLine(inner_circle_pt,
255 s_start = MathematicalConstants::Pi;
256 s_end = 2.0*MathematicalConstants::Pi;
258 inner_boundary_line_pt[1]=
259 new TriangleMeshCurviLine(inner_circle_pt,
268 Vector<TriangleMeshClosedCurve*> hole_pt(1);
269 Vector<double> hole_coords(2);
272 hole_pt[0]=
new TriangleMeshClosedCurve(inner_boundary_line_pt,
279 TriangleMeshParameters triangle_mesh_parameters(outer_boundary_pt);
282 triangle_mesh_parameters.internal_closed_curve_pt() = hole_pt;
285 triangle_mesh_parameters.element_area() = 0.1;
290 Bulk_mesh_pt=
new RefineableTriangleMesh<ELEMENT>(triangle_mesh_parameters);
293 Bulk_mesh_pt->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
296 Bulk_mesh_pt->min_permitted_error()=0.00004;
297 Bulk_mesh_pt->max_permitted_error()=0.0001;
302 Bulk_mesh_pt=
new TriangleMesh<ELEMENT>(triangle_mesh_parameters);
307 add_sub_mesh(Bulk_mesh_pt);
316 this->mesh_pt()->output(
"global_mesh.dat");
317 this->mesh_pt()->output_boundaries(
"global_mesh_boundary.dat");
320 unsigned n_element = this->mesh_pt()->nelement();
321 for(
unsigned e=0;e<n_element;e++)
324 PMLHelmholtzEquations<2> *el_pt =
325 dynamic_cast<PMLHelmholtzEquations<2>*
>(mesh_pt()->element_pt(e));
332 apply_boundary_conditions();
335 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
456 ofstream some_file,some_file2;
465 snprintf(filename,
sizeof(filename),
"%s/soln%i.dat",doc_info.directory().c_str(),
467 some_file.open(filename);
468 Bulk_mesh_pt->output(some_file,npts);
473 snprintf(filename,
sizeof(filename),
"%s/coarse_soln%i.dat",doc_info.directory().c_str(),
475 some_file.open(filename);
476 unsigned npts_coarse=2;
477 Bulk_mesh_pt->output(some_file,npts_coarse);
483 snprintf(filename,
sizeof(filename),
"%s/pml_soln%i.dat",doc_info.directory().c_str(),
485 some_file.open(filename);
486 PML_top_mesh_pt->output(some_file,npts);
487 PML_right_mesh_pt->output(some_file,npts);
488 PML_bottom_mesh_pt->output(some_file,npts);
489 PML_left_mesh_pt->output(some_file,npts);
490 PML_top_right_mesh_pt->output(some_file,npts);
491 PML_bottom_right_mesh_pt->output(some_file,npts);
492 PML_top_left_mesh_pt->output(some_file,npts);
493 PML_bottom_left_mesh_pt->output(some_file,npts);
501 Bulk_mesh_pt->compute_norm(norm);
502 Trace_file << norm << std::endl;
534 unsigned int left_boundary_id = 2;
537 unsigned int top_boundary_id = 3;
540 unsigned int right_boundary_id = 4;
543 unsigned int bottom_boundary_id = 5;
546 unsigned n_x_right_pml = 3;
549 unsigned n_y_top_pml = 3;
552 unsigned n_x_left_pml = 3;
555 unsigned n_y_bottom_pml = 3;
560 double width_x_right_pml = 0.2;
561 double width_y_top_pml = 0.2;
562 double width_x_left_pml = 0.2;
563 double width_y_bottom_pml = 0.2;
567 TwoDimensionalPMLHelper::create_right_pml_mesh
568 <PMLLayerElement<ELEMENT> >
569 (Bulk_mesh_pt,right_boundary_id,
570 n_x_right_pml, width_x_right_pml);
572 TwoDimensionalPMLHelper::create_top_pml_mesh
573 <PMLLayerElement<ELEMENT> >
574 (Bulk_mesh_pt, top_boundary_id,
575 n_y_top_pml, width_y_top_pml);
577 TwoDimensionalPMLHelper::create_left_pml_mesh
578 <PMLLayerElement<ELEMENT> >
579 (Bulk_mesh_pt, left_boundary_id,
580 n_x_left_pml, width_x_left_pml);
582 TwoDimensionalPMLHelper::create_bottom_pml_mesh
583 <PMLLayerElement<ELEMENT> >
584 (Bulk_mesh_pt, bottom_boundary_id,
585 n_y_bottom_pml, width_y_bottom_pml);
588 add_sub_mesh(PML_right_mesh_pt);
589 add_sub_mesh(PML_top_mesh_pt);
590 add_sub_mesh(PML_left_mesh_pt);
591 add_sub_mesh(PML_bottom_mesh_pt);
594 PML_top_right_mesh_pt =
595 TwoDimensionalPMLHelper::create_top_right_pml_mesh
596 <PMLLayerElement<ELEMENT> >
597 (PML_right_mesh_pt, PML_top_mesh_pt,
598 Bulk_mesh_pt, right_boundary_id);
600 PML_bottom_right_mesh_pt =
601 TwoDimensionalPMLHelper::create_bottom_right_pml_mesh
602 <PMLLayerElement<ELEMENT> >
603 (PML_right_mesh_pt, PML_bottom_mesh_pt,
604 Bulk_mesh_pt, right_boundary_id);
606 PML_top_left_mesh_pt =
607 TwoDimensionalPMLHelper::create_top_left_pml_mesh
608 <PMLLayerElement<ELEMENT> >
609 (PML_left_mesh_pt, PML_top_mesh_pt,
610 Bulk_mesh_pt, left_boundary_id);
612 PML_bottom_left_mesh_pt =
613 TwoDimensionalPMLHelper::create_bottom_left_pml_mesh
614 <PMLLayerElement<ELEMENT> >
615 (PML_left_mesh_pt, PML_bottom_mesh_pt,
616 Bulk_mesh_pt, left_boundary_id);
619 add_sub_mesh(PML_top_right_mesh_pt);
620 add_sub_mesh(PML_bottom_right_mesh_pt);
621 add_sub_mesh(PML_top_left_mesh_pt);
622 add_sub_mesh(PML_bottom_left_mesh_pt);