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  cell->set_material_id(mid_2);
27  } else {
28  cell->set_material_id(mid_1);
29  }
30  }
31 
32  GridGenerator::hyper_cube(triangulation_slice, 0.0, b);
33 }
34 
35 template<>
36 void
38 {
39  GridIn<2> gridin;
40  gridin.attach_triangulation(Solver<2>::triangulation);
41 
42  std::ifstream ifs("../../gmsh/data/sphere_r" + std::to_string(r) + ".msh");
43  gridin.read_msh(ifs);
44 
45  Solver<2>::triangulation.reset_all_manifolds();
46 
47  for (auto cell : Solver<2>::triangulation.active_cell_iterators()) {
48 
49  if (cell->center().norm() < a)
50  cell->set_material_id(mid_2);
51 
52  for (unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; ++f) {
53  double dif_norm = 0.0;
54  for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_face; v++)
55  dif_norm += std::abs(cell->face(f)->vertex(0).norm() -
56  cell->face(f)->vertex(v).norm());
57 
58  if ((dif_norm < eps) && (cell->center().norm() > rd))
59  cell->face(f)->set_all_manifold_ids(1);
60  }
61  }
62 
63  Solver<2>::triangulation.set_manifold(1, sphere);
64 
65  GridGenerator::hyper_cube(triangulation_slice, 0.0, b - 0.01);
66 }
Implements the Axisymmetric - volume charge (rho-axi/) numerical experiment.
Definition: solver.hpp:41
Triangulation< dim > triangulation
The mesh.