15 SolverSSOLIAXI::make_mesh()
19 std::ifstream ifs(
"../../gmsh/data/circle_r" + std::to_string(r) +
".msh");
25 SolverSSOLIAXI::fill_dirichlet_stack()
30 {
bid_axi, &dirichlet_function } };
34 {
bid_axi, &dirichlet_function } };
40 SolverSSOLIAXI::mark_materials()
45 for (
unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; f++) {
46 if (std::abs(cell->center().norm()) <
a) {
47 if ((abs(cell->face(f)->vertex(0).norm() -
a) <
eps) &&
48 (abs(cell->face(f)->vertex(1).norm() -
a) <
eps)) {
49 cell->face(f)->set_user_index(1);
50 cell->set_user_index(1);
54 if (cell->center().norm() >
rd)
55 if (std::abs(cell->face(f)->vertex(1).norm() -
56 cell->face(f)->vertex(0).norm()) <
eps)
57 cell->face(f)->set_all_manifold_ids(1);
65 SolverSSOLIAXI::data_slice(std::string fname)
67 GridGenerator::hyper_cube(triangulation_slice, 0.0 +
eps,
b -
eps);
68 triangulation_slice.refine_global(nr_slice_global_refs);
70 dof_handler_slice.reinit(triangulation_slice);
71 dof_handler_slice.distribute_dofs(fe_slice);
72 solution_slice.reinit(dof_handler_slice.n_dofs());
77 VectorTools::interpolate(dof_handler_slice, potential, solution_slice);
79 DataOut<1, 2> data_out;
81 data_out.attach_dof_handler(dof_handler_slice);
82 data_out.add_data_vector(solution_slice,
"solution_slice");
83 data_out.build_patches();
85 std::ofstream out(fname +
"_slice" +
".gpi");
87 data_out.write_gnuplot(out);
92 SolverSSOLIAXI::solve()
100 control.enable_history_data();
102 GrowingVectorMemory<Vector<double>> memory;
103 SolverCG<Vector<double>> cg(control, memory);
105 PreconditionJacobi<SparseMatrix<double>> preconditioner;
116 const std::vector<double> history_data = control.get_history_data();
118 std::ofstream ofs(fname +
"_cg_convergence.csv");
121 for (
auto item : history_data) {
122 ofs << i <<
", " << item <<
"\n";
double b
The radius of the outer boundary of the problem domain.
const types::boundary_id bid_infty
The ID of the curved section of the boundary of the problem domain. The boundary ID is set in the geo...
const types::boundary_id bid_axi
The ID of the straight section of the boundary of the problem domain. The boundary ID is set in the g...
const BoundaryConditionType type_of_bc
Switches between two boundary conditions options.
double a
The radius of the coil.
const bool log_cg_convergence
If set to true, saves the residual at each iteration of the CG solver. The names of the files fit the...
const double rd
The radius of the circle that encloses the rectangle in the middle of the mesh.
const double eps
Two values in double format are considered to be equal if the absolute value of their difference is l...
std::map< types::boundary_id, const Function< dim > * > dirichlet_stack
A map that contains pairs of boundary IDs and the corresponding Dirichlet boundary conditions.
Triangulation< dim > triangulation
The mesh.
DoFHandler< dim > dof_handler
The degrees-of-freedom handler.
Vector< double > system_rhs
The system right-hand side vector.
Vector< double > solution
The solution vector, i.e., degrees of freedom yielded by the simulation.
AffineConstraints< double > constraints
The constraints associated with the Dirichlet boundary conditions.
SparseMatrix< double > system_matrix
The system matrix.