12 #ifndef SolverSLDII_H__
13 #define SolverSLDII_H__
15 #define BOOST_ALLOW_DEPRECATED_HEADERS
17 #include <deal.II/base/function.h>
18 #include <deal.II/grid/grid_in.h>
19 #include <deal.II/grid/grid_out.h>
20 #include <deal.II/grid/grid_tools.h>
21 #include <deal.II/grid/manifold_lib.h>
23 #include <deal.II/numerics/fe_field_function.h>
25 #include "exact_solution.hpp"
26 #include "settings.hpp"
27 #include "static_scalar_solver.hpp"
29 #define TMR(__name) TimerOutput::Scope timer_section(timer, __name)
31 using namespace StaticScalarSolver;
61 unsigned int mapping_degree,
72 project_exact_solution,
84 const std::string fname;
87 const Functions::ZeroFunction<dim> dirichlet;
89 SphericalManifold<dim> sphere;
91 virtual void make_mesh() override final;
92 virtual
void fill_dirichlet_stack() override final;
93 virtual
void solve() override final;
95 void mark_materials();
102 switch (type_of_bc) {
119 std::string fname_mesh =
120 (dim == 2) ?
"../../gmsh/data/square_r" + std::to_string(r) +
".msh"
121 :
"../../gmsh/data/cube_r" + std::to_string(r) +
".msh";
123 std::ifstream ifs(fname_mesh);
124 gridin.read_msh(ifs);
136 if (cell->center().norm() < a) {
138 cell->set_material_id(mid_1);
139 }
else if (cell->center().norm() < b) {
141 cell->set_material_id(mid_2);
144 cell->set_material_id(mid_3);
147 for (
unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f) {
148 double dif_norm_a = 0.0;
149 double dif_norm_b = 0.0;
150 double dif_norm = 0.0;
151 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; v++) {
152 dif_norm_a += std::abs(cell->face(f)->vertex(v).norm() - a);
153 dif_norm_b += std::abs(cell->face(f)->vertex(v).norm() - b);
154 dif_norm += std::abs(cell->face(f)->vertex(0).norm() -
155 cell->face(f)->vertex(v).norm());
158 if ((dif_norm_a < eps) && (std::abs(cell->center().norm()) < a)) {
160 cell->face(f)->set_user_index(1);
161 cell->set_user_index(1);
164 if ((dif_norm_b < eps) && (std::abs(cell->center().norm()) < b)) {
166 cell->face(f)->set_user_index(2);
167 cell->set_user_index(2);
170 if ((dif_norm < eps) && (cell->center().norm() > rd1) &&
171 (cell->center().norm() < b))
172 cell->face(f)->set_all_manifold_ids(1);
188 if (log_cg_convergence)
189 control.enable_history_data();
191 GrowingVectorMemory<Vector<double>> memory;
192 SolverCG<Vector<double>> cg(control, memory);
194 PreconditionJacobi<SparseMatrix<double>> preconditioner;
204 if (log_cg_convergence) {
205 const std::vector<double> history_data = control.get_history_data();
207 std::ofstream ofs(fname +
"_cg_convergence.csv");
210 for (
auto item : history_data) {
211 ofs << i <<
", " << item <<
"\n";
Describes exact solution, , of the Magnetostatic shield - 2 (sld-ii/) numerical experiment in two and...
Global settings for the Magnetostatic shield - 2 (sld-ii/) numerical experiment.
Implements the Magnetostatic shield - 2 (sld-ii/) numerical experiment.
SolverSLDII(unsigned int p, unsigned int mapping_degree, unsigned int r, std::string fname)
Solves static scalar boundary value problem.
void run()
Runs the simulation.