15 SolverMWR::make_mesh()
20 std::ifstream ifs(
"../../gmsh/data/circle_r" + std::to_string(r) +
".msh");
27 SolverMWR::fill_dirichlet_stack()
33 SolverMWR::mark_materials()
38 if (cell->center().norm() <
a) {
39 cell->set_material_id(
mid_1);
41 cell->set_material_id(
mid_2);
44 if (cell->center().norm() >
d1)
45 for (
unsigned int f = 0; f < GeometryInfo<2>::faces_per_cell; f++) {
46 double dif_norm = 0.0;
47 for (
unsigned int v = 1; v < GeometryInfo<2>::vertices_per_face; v++)
48 dif_norm += std::abs(cell->face(f)->vertex(0).norm() -
49 cell->face(f)->vertex(v).norm());
51 if ((dif_norm <
eps) && (cell->center().norm()))
52 cell->face(f)->set_all_manifold_ids(1);
60 SolverMWR::data_slice(std::string fname)
62 GridGenerator::hyper_cube(triangulation_slice, 0.0 +
eps,
b -
eps);
63 triangulation_slice.refine_global(nr_slice_global_refs);
65 dof_handler_slice.reinit(triangulation_slice);
66 dof_handler_slice.distribute_dofs(fe_slice);
67 solution_slice.reinit(dof_handler_slice.n_dofs());
72 VectorTools::interpolate(dof_handler_slice, potential, solution_slice);
74 DataOut<1, 2> data_out;
76 data_out.attach_dof_handler(dof_handler_slice);
77 data_out.add_data_vector(solution_slice,
"solution_slice");
78 data_out.build_patches();
80 std::ofstream out(fname +
"_slice" +
".gpi");
82 data_out.write_gnuplot(out);
95 control.enable_history_data();
97 GrowingVectorMemory<Vector<double>> memory;
98 SolverCG<Vector<double>> cg(control, memory);
100 PreconditionJacobi<SparseMatrix<double>> preconditioner;
111 const std::vector<double> history_data = control.get_history_data();
113 std::ofstream ofs(fname +
"_cg_convergence.csv");
116 for (
auto item : history_data) {
117 ofs << i <<
", " << item <<
"\n";
const double b
The radius of the outer boundary of the problem domain.
const double a
The radius of the wire.
const double eps
Two values in double format are considered to be equal if the absolute value of their difference is l...
const types::material_id mid_1
The ID of the material inside the wire.
const types::boundary_id bid
The ID of the boundary of the problem domain. The boundary ID is set in the geo files that are locate...
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 types::material_id mid_2
The ID of the material outside the wire.
const double d1
The half-side of the square in the middle of the mesh.
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.