7
const char *project_info =
8
R"(//! Project: Nonlinear PDE-1d with Dirichlet BCs, No. 1
10
//! --+----------+-----> x
22
//! $u_1(x)=\frac{3}{(2+x)^2}$
25
//! Boundary discretization method: does not apply
26
//! Linear solver: GSL all but GMRES (it does not work).
27
//! Nonlinear solver: GSL all.
38
mesh.set_boundaries({b0, b1});
40
DirichletBC bc0(b0, "0.75"), bc1(b1, "0.333333333333333333");
42
// Part 1: declaration of fields and functions
45
Function a("fa"), b("fb"), xs("exact_solution");
47
// Part 2: declaration and customization of PDE
50
pde.boundary_discretization_method = PDE::/*SYM_DIFF2;*/INWARD_DIFF3;
52
// Part 3: set PDE fields, BCs and functions
54
pde.set_BCs({bc1, bc0}, u);
55
pde.set_functions({f, a, b, xs});
57
a.set_implementation("0");
58
b.set_implementation("1./3.");
59
f.set_implementation("0");
60
xs.set_implementation("3/((2+x)*(2+x))");
62
// Part 4: set PDE equations
63
pde = Dxx[u] - 2.*u*u;
66
std::cout << (pde.linear_BCs() ? " has linear BCs" : " has nonlinear BCs") << '\n';
68
std::cout << (pde.linear_eqs() ? " has linear eqs" : " has nonlinear eqs") << '\n';
70
std::cout << (pde.linear() ? " is linear." : " is nonlinear.") << '\n';
72
// Part 5: set methods
73
pde.set_library("gsl");
74
pde.set_matrix_method("LU");
75
// hybrids, hybrid, dnewton, broyden, hybridsj, hybridj, newton, gnewton
76
pde.set_nonlinear_solver("newton");
79
pde.executable = "gsl1d_nl_1";
80
pde.compiler = "clang++";
81
pde.project_info = project_info;
82
pde.set_output("code/gsl1d_nl_1");
84
pde.generate_makefile();
86
catch (const std::string& msg)
88
std::cout << msg << std::endl;
91
catch (const char *msg)
93
std::cout << "Caught const char* exception!\n";
94
std::cout << msg << std::endl;