|
| 1 | +//----------------------------------------------------------- |
| 2 | +// |
| 3 | +// Copyright (C) 2014 by the deal.II authors |
| 4 | +// |
| 5 | +// This file is subject to LGPL and may not be distributed |
| 6 | +// without copyright and license information. Please refer |
| 7 | +// to the file deal.II/doc/license.html for the text and |
| 8 | +// further information on this license. |
| 9 | +// |
| 10 | +//----------------------------------------------------------- |
| 11 | + |
| 12 | +#include <deal.II/opencascade/manifold_lib.h> |
| 13 | +#include <deal.II/opencascade/utilities.h> |
| 14 | +#include "singular_kernel_integral.h" |
| 15 | +#include "tests.h" |
| 16 | + |
| 17 | +int |
| 18 | +main() |
| 19 | +{ |
| 20 | + initlog(); |
| 21 | + |
| 22 | + //we start selecting a mapping degree |
| 23 | + double mapping_degree = 2; |
| 24 | + //we also import a CAD geometry of a portion of a cylinder to integrate on curved cell |
| 25 | + std::string cad_filename = std::string(SOURCE_DIR)+"/testData/Revolution_1.iges"; |
| 26 | + TopoDS_Shape surface = OpenCASCADE::read_IGES(cad_filename, 1e-3); |
| 27 | + OpenCASCADE::NormalToMeshProjectionManifold<2,3> manifold(surface, 1e-7); |
| 28 | + // the next lines are in case we want to run the test with NURBSPatchManifold |
| 29 | + // and --- possibly --- with MappingManifold. But there is some work to do to make it work |
| 30 | +// std::vector<TopoDS_Face> occ_faces; |
| 31 | +// std::vector<TopoDS_Edge> occ_edges; |
| 32 | +// std::vector<TopoDS_Vertex> occ_vertices; |
| 33 | +// OpenCASCADE::extract_geometrical_shapes(surface, occ_faces, occ_edges, occ_vertices); |
| 34 | +// OpenCASCADE::NURBSPatchManifold<2,3> manifold(occ_faces[0], 1e-7); |
| 35 | + |
| 36 | + |
| 37 | + // and now we generate a grid and use it to distribute dofs |
| 38 | + Triangulation<2,3> triangulation; |
| 39 | + |
| 40 | + std::vector<Point<3> > vertices; |
| 41 | + std::vector<CellData<2> > cells; |
| 42 | + SubCellData subcelldata; |
| 43 | + |
| 44 | +// Flat |
| 45 | + |
| 46 | + vertices.resize(4); |
| 47 | + vertices[0](0)=1.0; |
| 48 | + vertices[0](1)=0.0; |
| 49 | + vertices[0](2)=0.0; |
| 50 | + vertices[1](0)=1.0; |
| 51 | + vertices[1](1)=2.0; |
| 52 | + vertices[1](2)=0.0; |
| 53 | + vertices[2](0)=0.0; |
| 54 | + vertices[2](1)=0.0; |
| 55 | + vertices[2](2)=1.0; |
| 56 | + vertices[3](0)=0.0; |
| 57 | + vertices[3](1)=2.0; |
| 58 | + vertices[3](2)=1.0; |
| 59 | + |
| 60 | + |
| 61 | + cells.resize(1); |
| 62 | + |
| 63 | + cells[0].vertices[0]=0; |
| 64 | + cells[0].vertices[1]=1; |
| 65 | + cells[0].vertices[2]=2; |
| 66 | + cells[0].vertices[3]=3; |
| 67 | + |
| 68 | + GridTools::delete_unused_vertices (vertices, cells, subcelldata); |
| 69 | + GridTools::consistently_order_cells(cells); |
| 70 | + |
| 71 | + // here's the triangulation set up |
| 72 | + triangulation.create_triangulation(vertices, cells, subcelldata ); |
| 73 | + |
| 74 | + triangulation.set_all_manifold_ids(0); |
| 75 | + triangulation.set_manifold(0, manifold); |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + // we will need a codimension one finite element and |
| 80 | + // the corresponding dof handler |
| 81 | + // we use zeroth order fe_dgq because in the integral the hypersingular kernel must not be multiplied by the shape function. Thus, |
| 82 | + // we multiply it by a constant shape function |
| 83 | + FE_DGQ<2,3> fe(0); |
| 84 | + DoFHandler<2,3> dof_handler(triangulation); |
| 85 | + dof_handler.distribute_dofs(fe); |
| 86 | + MappingQ<2,3> mapping(mapping_degree); |
| 87 | + |
| 88 | + // The test cases are taken from |
| 89 | + //M. Guiggiani, G. Krishnasamy, T. J. Rudolphi & F. J. Rizzo,A general algorithm for the numerical solution of hypersingular boundary integral equations, JOURNAL OF APPLIED MECHANICS-TRANSACTIONS OF THE ASME,vol. 59,pp 604-614,tot.pag 11,1992 |
| 90 | + |
| 91 | + // Case 4.2a |
| 92 | + Point<2> singularity_location_in_parametric_plane_1(0.5,0.5); |
| 93 | + // Case 4.2b |
| 94 | + Point<2> singularity_location_in_parametric_plane_2(0.66*.5+.5,0.0*.5+.5); |
| 95 | + // Case 4.2c |
| 96 | + Point<2> singularity_location_in_parametric_plane_3(0.66*.5+.5,0.66*.5+.5); |
| 97 | + |
| 98 | + |
| 99 | + std::vector<Tensor<1,3> > I; |
| 100 | + |
| 101 | + for (const auto &cell : dof_handler.active_cell_iterators()) |
| 102 | + { |
| 103 | + deallog<<"Case: 4.1a"<<std::endl; |
| 104 | + SingularKernelIntegral sing_kernel_integrator_1(cell, fe, mapping, singularity_location_in_parametric_plane_1); |
| 105 | + I = sing_kernel_integrator_1.evaluate_VkNj_integrals(); |
| 106 | + //std::vector<Tensor<1,3> > I = sing_kernel_integrator.evaluate_WkNj_integrals(); |
| 107 | + deallog<<std::setprecision(15); |
| 108 | + deallog<<"Result : "<<I[0][2]*4*dealii::numbers::PI<<" Exact: "<<-0.343807*4*dealii::numbers::PI<<std::endl; |
| 109 | + deallog<<"Abs Err: "<<-0.343807*4*dealii::numbers::PI-I[0][2]*4*dealii::numbers::PI<<std::endl; |
| 110 | + deallog<<"Rel Err: "<<fabs(-0.343807*4*dealii::numbers::PI-I[0][2]*4*dealii::numbers::PI)/fabs(-0.343807*4*dealii::numbers::PI)<<std::endl; |
| 111 | + |
| 112 | + |
| 113 | + deallog<<"Case: 4.1b"<<std::endl; |
| 114 | + SingularKernelIntegral sing_kernel_integrator_2(cell, fe, mapping, singularity_location_in_parametric_plane_2); |
| 115 | + I = sing_kernel_integrator_2.evaluate_VkNj_integrals(); |
| 116 | + //std::vector<Tensor<1,3> > I = sing_kernel_integrator.evaluate_WkNj_integrals(); |
| 117 | + deallog<<std::setprecision(15); |
| 118 | + deallog<<"Result : "<<I[0][2]*4*dealii::numbers::PI<<" Exact: "<<-0.497099*4*dealii::numbers::PI<<std::endl; |
| 119 | + deallog<<"Abs Err: "<<-0.497099*4*dealii::numbers::PI-I[0][2]*4*dealii::numbers::PI<<std::endl; |
| 120 | + deallog<<"Rel Err: "<<fabs(-0.497099*4*dealii::numbers::PI-I[0][2]*4*dealii::numbers::PI)/fabs(-0.497099*4*dealii::numbers::PI)<<std::endl; |
| 121 | + |
| 122 | + |
| 123 | + deallog<<"Case: 4.1c"<<std::endl; |
| 124 | + SingularKernelIntegral sing_kernel_integrator_3(cell, fe, mapping, singularity_location_in_parametric_plane_3); |
| 125 | + I = sing_kernel_integrator_3.evaluate_VkNj_integrals(); |
| 126 | + //std::vector<Tensor<1,3> > I = sing_kernel_integrator.evaluate_WkNj_integrals(); |
| 127 | + deallog<<std::setprecision(15); |
| 128 | + deallog<<"Result : "<<I[0][2]*4*dealii::numbers::PI<<" Exact: "<<-0.877214*4*dealii::numbers::PI<<std::endl; |
| 129 | + deallog<<"Abs Err: "<<-0.877214*4*dealii::numbers::PI-I[0][2]*4*dealii::numbers::PI<<std::endl; |
| 130 | + deallog<<"Rel Err: "<<fabs(-0.877214*4*dealii::numbers::PI-I[0][2]*4*dealii::numbers::PI)/fabs(-0.877214*4*dealii::numbers::PI)<<std::endl; |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +// strong integrals case a |
| 135 | +// deallog<<"Abs Err: "<<-2.114175-I[0][0]*4*dealii::numbers::PI<<std::endl; |
| 136 | +// deallog<<"Rel Err: "<<fabs(-2.114175-I[0][0]*4*dealii::numbers::PI)/fabs(-2.114175)<<std::endl; |
| 137 | + |
| 138 | + |
| 139 | +// strong integrals case b |
| 140 | +// deallog<<"Abs Err: "<<-1.935711-I[0][0]*4*dealii::numbers::PI<<std::endl; |
| 141 | +// deallog<<"Rel Err: "<<fabs(-1.935711-I[0][0]*4*dealii::numbers::PI)/fabs(-1.935711)<<std::endl; |
| 142 | + |
| 143 | +// strong integrals case c |
| 144 | +// deallog<<"Abs Err: "<<.8790179-I[0][0]*4*dealii::numbers::PI<<std::endl; |
| 145 | +// deallog<<"Rel Err: "<<fabs(.8790179-I[0][0]*4*dealii::numbers::PI)/fabs(.8790179)<<std::endl; |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + } |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | +} |
0 commit comments