📄 ex15.php
字号:
#include <B><FONT COLOR="#BC8F8F">"getpot.h"</FONT></B> #include <B><FONT COLOR="#BC8F8F">"exact_solution.h"</FONT></B> #include <B><FONT COLOR="#BC8F8F">"dof_map.h"</FONT></B> #include <B><FONT COLOR="#BC8F8F">"numeric_vector.h"</FONT></B> #include <B><FONT COLOR="#BC8F8F">"elem.h"</FONT></B> #include <B><FONT COLOR="#BC8F8F">"tensor_value.h"</FONT></B> <B><FONT COLOR="#228B22">void</FONT></B> assemble_biharmonic(EquationSystems& es, <B><FONT COLOR="#228B22">const</FONT></B> std::string& system_name); Number exact_2D_solution(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&); <I><FONT COLOR="#B22222">// unk_name, not needed);</FONT></I> Number exact_3D_solution(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Gradient exact_2D_derivative(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Gradient exact_3D_derivative(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Tensor exact_2D_hessian(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Tensor exact_3D_hessian(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Number forcing_function_2D(<B><FONT COLOR="#228B22">const</FONT></B> Point& p); Number forcing_function_3D(<B><FONT COLOR="#228B22">const</FONT></B> Point& p); Number (*exact_solution)(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Gradient (*exact_derivative)(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Tensor (*exact_hessian)(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <B><FONT COLOR="#228B22">const</FONT></B> std::string&); Number (*forcing_function)(<B><FONT COLOR="#228B22">const</FONT></B> Point& p); <B><FONT COLOR="#228B22">int</FONT></B> main(<B><FONT COLOR="#228B22">int</FONT></B> argc, <B><FONT COLOR="#228B22">char</FONT></B>** argv) { <B><FONT COLOR="#5F9EA0">libMesh</FONT></B>::init (argc, argv); #ifndef ENABLE_AMR <B><FONT COLOR="#5F9EA0">std</FONT></B>::cerr << <B><FONT COLOR="#BC8F8F">"ERROR: This example requires libMesh to be\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"compiled with AMR support!"</FONT></B> << std::endl; <B><FONT COLOR="#A020F0">return</FONT></B> 0; #<B><FONT COLOR="#A020F0">else</FONT></B> #ifndef ENABLE_SECOND_DERIVATIVES <B><FONT COLOR="#5F9EA0">std</FONT></B>::cerr << <B><FONT COLOR="#BC8F8F">"ERROR: This example requires the library to be "</FONT></B> << <B><FONT COLOR="#BC8F8F">"compiled with second derivatives support!"</FONT></B> << std::endl; <B><FONT COLOR="#A020F0">return</FONT></B> 0; #<B><FONT COLOR="#A020F0">else</FONT></B> { GetPot input_file(<B><FONT COLOR="#BC8F8F">"ex15.in"</FONT></B>); <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> max_r_level = input_file(<B><FONT COLOR="#BC8F8F">"max_r_level"</FONT></B>, 10); <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> max_r_steps = input_file(<B><FONT COLOR="#BC8F8F">"max_r_steps"</FONT></B>, 4); <B><FONT COLOR="#228B22">const</FONT></B> std::string approx_type = input_file(<B><FONT COLOR="#BC8F8F">"approx_type"</FONT></B>, <B><FONT COLOR="#BC8F8F">"HERMITE"</FONT></B>); <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> uniform_refine = input_file(<B><FONT COLOR="#BC8F8F">"uniform_refine"</FONT></B>, 0); <B><FONT COLOR="#228B22">const</FONT></B> Real refine_percentage = input_file(<B><FONT COLOR="#BC8F8F">"refine_percentage"</FONT></B>, 0.5); <B><FONT COLOR="#228B22">const</FONT></B> Real coarsen_percentage = input_file(<B><FONT COLOR="#BC8F8F">"coarsen_percentage"</FONT></B>, 0.5); <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> dim = input_file(<B><FONT COLOR="#BC8F8F">"dimension"</FONT></B>, 2); <B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> max_linear_iterations = input_file(<B><FONT COLOR="#BC8F8F">"max_linear_iterations"</FONT></B>, 10000); assert (dim == 2 || dim == 3); assert (dim == 2 || approx_type == <B><FONT COLOR="#BC8F8F">"HERMITE"</FONT></B>); Mesh mesh (dim); <B><FONT COLOR="#5F9EA0">std</FONT></B>::string output_file = <B><FONT COLOR="#BC8F8F">""</FONT></B>; <B><FONT COLOR="#A020F0">if</FONT></B> (dim == 2) output_file += <B><FONT COLOR="#BC8F8F">"2D_"</FONT></B>; <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (dim == 3) output_file += <B><FONT COLOR="#BC8F8F">"3D_"</FONT></B>; <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">"HERMITE"</FONT></B>) output_file += <B><FONT COLOR="#BC8F8F">"hermite_"</FONT></B>; <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">"SECOND"</FONT></B>) output_file += <B><FONT COLOR="#BC8F8F">"reducedclough_"</FONT></B>; <B><FONT COLOR="#A020F0">else</FONT></B> output_file += <B><FONT COLOR="#BC8F8F">"clough_"</FONT></B>; <B><FONT COLOR="#A020F0">if</FONT></B> (uniform_refine == 0) output_file += <B><FONT COLOR="#BC8F8F">"adaptive"</FONT></B>; <B><FONT COLOR="#A020F0">else</FONT></B> output_file += <B><FONT COLOR="#BC8F8F">"uniform"</FONT></B>; <B><FONT COLOR="#5F9EA0">std</FONT></B>::string gmv_file = output_file; gmv_file += <B><FONT COLOR="#BC8F8F">".gmv"</FONT></B>; output_file += <B><FONT COLOR="#BC8F8F">".m"</FONT></B>; <B><FONT COLOR="#5F9EA0">std</FONT></B>::ofstream out (output_file.c_str()); out << <B><FONT COLOR="#BC8F8F">"% dofs L2-error H1-error H2-error\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"e = [\n"</FONT></B>; <B><FONT COLOR="#A020F0">if</FONT></B> (dim == 2) { <B><FONT COLOR="#5F9EA0">MeshTools</FONT></B>::Generation::build_square(mesh, 2, 2); exact_solution = &exact_2D_solution; exact_derivative = &exact_2D_derivative; exact_hessian = &exact_2D_hessian; forcing_function = &forcing_function_2D; } <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (dim == 3) { <B><FONT COLOR="#5F9EA0">MeshTools</FONT></B>::Generation::build_cube(mesh, 2, 2, 2); exact_solution = &exact_3D_solution; exact_derivative = &exact_3D_derivative; exact_hessian = &exact_3D_hessian; forcing_function = &forcing_function_3D; } mesh.all_second_order(); <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type != <B><FONT COLOR="#BC8F8F">"HERMITE"</FONT></B>) <B><FONT COLOR="#5F9EA0">MeshTools</FONT></B>::Modification::all_tri(mesh); MeshRefinement mesh_refinement(mesh); mesh_refinement.refine_fraction() = refine_percentage; mesh_refinement.coarsen_fraction() = coarsen_percentage; mesh_refinement.max_h_level() = max_r_level; EquationSystems equation_systems (mesh); { LinearImplicitSystem& system = equation_systems.add_system<LinearImplicitSystem> (<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>); <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">"HERMITE"</FONT></B>) system.add_variable(<B><FONT COLOR="#BC8F8F">"u"</FONT></B>, THIRD, HERMITE); <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">"SECOND"</FONT></B>) system.add_variable(<B><FONT COLOR="#BC8F8F">"u"</FONT></B>, SECOND, CLOUGH); <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">"CLOUGH"</FONT></B>) system.add_variable(<B><FONT COLOR="#BC8F8F">"u"</FONT></B>, THIRD, CLOUGH); <B><FONT COLOR="#A020F0">else</FONT></B> error(); system.attach_assemble_function (assemble_biharmonic); equation_systems.init(); equation_systems.parameters.set<<B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B>> (<B><FONT COLOR="#BC8F8F">"linear solver maximum iterations"</FONT></B>) = max_linear_iterations; equation_systems.parameters.set<Real> (<B><FONT COLOR="#BC8F8F">"linear solver tolerance"</FONT></B>) = TOLERANCE * TOLERANCE * TOLERANCE; equation_systems.print_info(); } ExactSolution exact_sol(equation_systems); exact_sol.attach_exact_value(exact_solution); exact_sol.attach_exact_deriv(exact_derivative); exact_sol.attach_exact_hessian(exact_hessian); ExactSolution zero_sol(equation_systems); LinearImplicitSystem& system = equation_systems.get_system<LinearImplicitSystem>(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>); <B><FONT COLOR="#A020F0">for</FONT></B> (<B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B> r_step=0; r_step<max_r_steps; r_step++) { mesh.print_info(); equation_systems.print_info(); <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"Beginning Solve "</FONT></B> << r_step << std::endl; system.solve(); <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"Linear solver converged at step: "</FONT></B> << system.n_linear_iterations() << <B><FONT COLOR="#BC8F8F">", final residual: "</FONT></B> << system.final_linear_residual() << std::endl; exact_sol.compute_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>); zero_sol.compute_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>); <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"L2-Norm is: "</FONT></B> << zero_sol.l2_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl; <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"H1-Norm is: "</FONT></B> << zero_sol.h1_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl; <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"H2-Norm is: "</FONT></B> << zero_sol.h2_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl << std::endl; <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"L2-Error is: "</FONT></B> << exact_sol.l2_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl; <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"H1-Error is: "</FONT></B> << exact_sol.h1_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl; <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">"H2-Error is: "</FONT></B> << exact_sol.h2_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl << std::endl; out << equation_systems.n_active_dofs() << <B><FONT COLOR="#BC8F8F">" "</FONT></B> << exact_sol.l2_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << <B><FONT COLOR="#BC8F8F">" "</FONT></B> << exact_sol.h1_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << <B><FONT COLOR="#BC8F8F">" "</FONT></B> << exact_sol.h2_error(<B><FONT COLOR="#BC8F8F">"Biharmonic"</FONT></B>, <B><FONT COLOR="#BC8F8F">"u"</FONT></B>) << std::endl; <B><FONT COLOR="#A020F0">if</FONT></B> (r_step+1 != max_r_steps) { <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout << <B><FONT COLOR="#BC8F8F">" Refining the mesh..."</FONT></B> << std::endl; <B><FONT COLOR="#A020F0">if</FONT></B> (uniform_refine == 0) { ErrorVector error; LaplacianErrorEstimator error_estimator; error_estimator.estimate_error(system, error); mesh_refinement.flag_elements_by_elem_fraction (error); <B><FONT COLOR="#5F9EA0">std</FONT></B>::cerr << <B><FONT COLOR="#BC8F8F">"Mean Error: "</FONT></B> << error.mean() << <B><FONT COLOR="#5F9EA0">std</FONT></B>::endl; <B><FONT COLOR="#5F9EA0">std</FONT></B>::cerr << <B><FONT COLOR="#BC8F8F">"Error Variance: "</FONT></B> << error.variance() << <B><FONT COLOR="#5F9EA0">std</FONT></B>::endl; mesh_refinement.refine_and_coarsen_elements(); } <B><FONT COLOR="#A020F0">else</FONT></B> { mesh_refinement.uniformly_refine(1); } equation_systems.reinit (); } } GMVIO (mesh).write_equation_systems (gmv_file, equation_systems); out << <B><FONT COLOR="#BC8F8F">"];\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"hold on\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"loglog(e(:,1), e(:,2), 'bo-');\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"loglog(e(:,1), e(:,3), 'ro-');\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"loglog(e(:,1), e(:,4), 'go-');\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"xlabel('log(dofs)');\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"ylabel('log(error)');\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"title('C1 "</FONT></B> << approx_type << <B><FONT COLOR="#BC8F8F">" elements');\n"</FONT></B> << <B><FONT COLOR="#BC8F8F">"legend('L2-error', 'H1-error', 'H2-error');\n"</FONT></B>; } <B><FONT COLOR="#A020F0">return</FONT></B> libMesh::close (); #endif <I><FONT COLOR="#B22222">// #ifndef ENABLE_SECOND_DERIVATIVES</FONT></I> #endif <I><FONT COLOR="#B22222">// #ifndef ENABLE_AMR</FONT></I> } Number exact_2D_solution(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&) <I><FONT COLOR="#B22222">// unk_name, not needed</FONT></I> { <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); <B><FONT COLOR="#A020F0">return</FONT></B> 256.*(x-x*x)*(x-x*x)*(y-y*y)*(y-y*y); } Gradient exact_2D_derivative(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&) <I><FONT COLOR="#B22222">// unk_name, not needed</FONT></I> { <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); Gradient gradu; gradu(0) = 256.*2.*(x-x*x)*(1-2*x)*(y-y*y)*(y-y*y); gradu(1) = 256.*2.*(x-x*x)*(x-x*x)*(y-y*y)*(1-2*y); <B><FONT COLOR="#A020F0">return</FONT></B> gradu; } Tensor exact_2D_hessian(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&) <I><FONT COLOR="#B22222">// unk_name, not needed</FONT></I> { Tensor hessu; <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); hessu(0,0) = 256.*2.*(1-6.*x+6.*x*x)*(y-y*y)*(y-y*y); hessu(0,1) = 256.*4.*(x-x*x)*(1.-2.*x)*(y-y*y)*(1.-2.*y); hessu(1,1) = 256.*2.*(x-x*x)*(x-x*x)*(1.-6.*y+6.*y*y); hessu(1,0) = hessu(0,1); <B><FONT COLOR="#A020F0">return</FONT></B> hessu; } Number forcing_function_2D(<B><FONT COLOR="#228B22">const</FONT></B> Point& p) { <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); <B><FONT COLOR="#A020F0">return</FONT></B> 256. * 8. * (3.*((y-y*y)*(y-y*y)+(x-x*x)*(x-x*x)) + (1.-6.*x+6.*x*x)*(1.-6.*y+6.*y*y)); } Number exact_3D_solution(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&) <I><FONT COLOR="#B22222">// unk_name, not needed</FONT></I> { <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); <B><FONT COLOR="#228B22">const</FONT></B> Real z = p(2); <B><FONT COLOR="#A020F0">return</FONT></B> 4096.*(x-x*x)*(x-x*x)*(y-y*y)*(y-y*y)*(z-z*z)*(z-z*z); } Gradient exact_3D_derivative(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&) <I><FONT COLOR="#B22222">// unk_name, not needed</FONT></I> { Gradient gradu; <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); <B><FONT COLOR="#228B22">const</FONT></B> Real z = p(2); gradu(0) = 4096.*2.*(x-x*x)*(1.-2.*x)*(y-y*y)*(y-y*y)*(z-z*z)*(z-z*z); gradu(1) = 4096.*2.*(x-x*x)*(x-x*x)*(y-y*y)*(1.-2.*y)*(z-z*z)*(z-z*z); gradu(2) = 4096.*2.*(x-x*x)*(x-x*x)*(y-y*y)*(y-y*y)*(z-z*z)*(1.-2.*z); <B><FONT COLOR="#A020F0">return</FONT></B> gradu; } Tensor exact_3D_hessian(<B><FONT COLOR="#228B22">const</FONT></B> Point& p, <B><FONT COLOR="#228B22">const</FONT></B> Parameters&, <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I> <B><FONT COLOR="#228B22">const</FONT></B> std::string&) <I><FONT COLOR="#B22222">// unk_name, not needed</FONT></I> { Tensor hessu; <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); <B><FONT COLOR="#228B22">const</FONT></B> Real z = p(2); hessu(0,0) = 4096.*(2.-12.*x+12.*x*x)*(y-y*y)*(y-y*y)*(z-z*z)*(z-z*z); hessu(0,1) = 4096.*4.*(x-x*x)*(1.-2.*x)*(y-y*y)*(1.-2.*y)*(z-z*z)*(z-z*z); hessu(0,2) = 4096.*4.*(x-x*x)*(1.-2.*x)*(y-y*y)*(y-y*y)*(z-z*z)*(1.-2.*z); hessu(1,1) = 4096.*(x-x*x)*(x-x*x)*(2.-12.*y+12.*y*y)*(z-z*z)*(z-z*z); hessu(1,2) = 4096.*4.*(x-x*x)*(x-x*x)*(y-y*y)*(1.-2.*y)*(z-z*z)*(1.-2.*z); hessu(2,2) = 4096.*(x-x*x)*(x-x*x)*(y-y*y)*(y-y*y)*(2.-12.*z+12.*z*z); hessu(1,0) = hessu(0,1); hessu(2,0) = hessu(0,2); hessu(2,1) = hessu(1,2); <B><FONT COLOR="#A020F0">return</FONT></B> hessu; } Number forcing_function_3D(<B><FONT COLOR="#228B22">const</FONT></B> Point& p) { <B><FONT COLOR="#228B22">const</FONT></B> Real x = p(0); <B><FONT COLOR="#228B22">const</FONT></B> Real y = p(1); <B><FONT COLOR="#228B22">const</FONT></B> Real z = p(2); <B><FONT COLOR="#A020F0">retu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -