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/ppc_m" + std::to_string(m) + "_r" +
22  std::to_string(r) + ".msh");
23 
24  gridin.read_msh(ifs);
25 
26  renumber_boundaries();
27 
28  Solver<2>::triangulation.reset_all_manifolds();
29 
30  for (auto cell : Solver<2>::triangulation.active_cell_iterators()) {
31  for (unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; ++f) {
32  if (cell->face(f)->at_boundary()) {
33  if (cell->face(f)->boundary_id() == bid_left)
34  cell->face(f)->set_all_manifold_ids(mfid_left);
35 
36  if (cell->face(f)->boundary_id() == bid_right)
37  cell->face(f)->set_all_manifold_ids(mfid_right);
38 
39  if (cell->face(f)->boundary_id() == bid_infty)
40  cell->face(f)->set_all_manifold_ids(mfid_infty);
41  }
42  }
43  }
44 
45  Solver<2>::triangulation.set_manifold(mfid_left, circle_left);
46  Solver<2>::triangulation.set_manifold(mfid_right, circle_right);
47  Solver<2>::triangulation.set_manifold(mfid_infty, circle_infty);
48 }
49 
50 template<>
51 void
53 {
54  GridIn<3> gridin;
55  gridin.attach_triangulation(Solver<3>::triangulation);
56 
57  std::ifstream ifs("../../gmsh/data/shell_m" + std::to_string(m) + "_r" +
58  std::to_string(r) + ".msh");
59 
60  gridin.read_msh(ifs);
61 
62  renumber_boundaries();
63 
64  Solver<3>::triangulation.set_all_manifold_ids(mfid_infty);
65  Solver<3>::triangulation.set_manifold(mfid_infty, sphere);
66 }
67 
68 template<>
69 void
71 {
72 // See also #if BC_TYPE__ preprocessor directives
73 // in abc/include/settings.hpp
74 #if BC_TYPE__ == 0
75  // Neumann boundary condition on the outer boundary.
76  dirichlet_stack = { { bid_left, &dirichlet_function_left },
77  { bid_right, &dirichlet_function_right } };
78 #endif
79 #if BC_TYPE__ == 1
80  // Dirichlet boundary condition on the outer boundary.
81  dirichlet_stack = { { bid_left, &dirichlet_function_left },
82  { bid_right, &dirichlet_function_right },
83  { bid_infty, &dirichlet_function_infty } };
84 #endif
85 #if BC_TYPE__ == 2
86  // ABC on the outer boundary.
87  dirichlet_stack = { { bid_left, &dirichlet_function_left },
88  { bid_right, &dirichlet_function_right } };
89 #endif
90 }
91 
92 template<>
93 void
95 {
96 // See also #if BC_TYPE__ preprocessor directives
97 // in abc/include/settings.hpp
98 #if BC_TYPE__ == 0
99  // Neumann boundary condition on the outer boundary.
100  dirichlet_stack = { { bid_in, &dirichlet_function_in } };
101 #endif
102 #if BC_TYPE__ == 1
103  // Dirichlet boundary condition on the outer boundary.
104  dirichlet_stack = { { bid_in, &dirichlet_function_in },
105  { bid_infty, &dirichlet_function_infty } };
106 #endif
107 #if BC_TYPE__ == 2
108  // ABC boundary condition on the outer boundary.
109  dirichlet_stack = { { bid_in, &dirichlet_function_in } };
110 #endif
111 }
Implements the solver of the Asymptotic boundary condition (abc/) numerical experiment.
Definition: solver.hpp:41
Triangulation< dim > triangulation
The mesh.