Logbook  (07-04-2025)
Static problems
solver.cpp
1 /******************************************************************************
2  * Copyright (C) Siarhei Uzunbajakau, 2023.
3  *
4  * This program is free software. You can use, modify, and redistribute it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation, either version 3 or (at your option) any later version.
7  * This program is distributed without any warranty.
8  *
9  * Refer to COPYING.LESSER for more details.
10  ******************************************************************************/
11 
12 #include "solver.hpp"
13 
14 template<>
15 void
17 {
18  GridIn<2> gridin;
19  gridin.attach_triangulation(Solver<2>::triangulation);
20 
21  std::ifstream ifs("../../gmsh/data/cylinder_r" + std::to_string(r) + ".msh");
22  gridin.read_msh(ifs);
23 
24  for (auto cell : Solver<2>::triangulation.active_cell_iterators()) {
25  if (std::abs(cell->center()[0]) < a) {
26  for (unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; ++f) {
27  double dif_norm = 0.0;
28  for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_face; ++v) {
29  dif_norm += std::abs(cell->face(f)->vertex(v)[0] - a);
30  }
31 
32  if (dif_norm < eps) {
33  cell->face(f)->set_user_index(2);
34  cell->set_user_index(1);
35  }
36  }
37  }
38  }
39  GridGenerator::hyper_cube(triangulation_slice, 0.0, b);
40 }
41 
42 template<>
43 void
45 {
46  GridIn<2> gridin;
47  gridin.attach_triangulation(Solver<2>::triangulation);
48 
49  std::ifstream ifs("../../gmsh/data/sphere_r" + std::to_string(r) + ".msh");
50  gridin.read_msh(ifs);
51 
52  Solver<2>::triangulation.reset_all_manifolds();
53 
54  for (auto cell : Solver<2>::triangulation.active_cell_iterators()) {
55  for (unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; ++f) {
56  double dif_norm = 0.0;
57  for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_face; v++)
58  dif_norm += std::abs(cell->face(f)->vertex(0).norm() -
59  cell->face(f)->vertex(v).norm());
60 
61  if ((dif_norm < eps) && (cell->center().norm() > rd)) {
62 
63  cell->face(f)->set_all_manifold_ids(1);
64 
65  double dif_norm_a = 0.0;
66  for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_face; v++)
67  dif_norm_a += std::abs(cell->face(f)->vertex(v).norm() - a);
68 
69  if ((dif_norm < eps) && (std::abs(cell->center().norm()) < a)) {
70  cell->face(f)->set_user_index(2);
71  cell->set_user_index(1);
72  }
73  }
74  }
75  }
76 
77  Solver<2>::triangulation.set_manifold(1, sphere);
78 
79  GridGenerator::hyper_cube(triangulation_slice, 0.0, b - 0.01);
80 }
Implements the Axisymmetric - surface charge (sch-axi/) numerical experiment.
Definition: solver.hpp:41
Triangulation< dim > triangulation
The mesh.