⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex15.php

📁 一个用来实现偏微分方程中网格的计算库
💻 PHP
📖 第 1 页 / 共 5 页
字号:
  #include <B><FONT COLOR="#BC8F8F">&quot;getpot.h&quot;</FONT></B>  #include <B><FONT COLOR="#BC8F8F">&quot;exact_solution.h&quot;</FONT></B>  #include <B><FONT COLOR="#BC8F8F">&quot;dof_map.h&quot;</FONT></B>  #include <B><FONT COLOR="#BC8F8F">&quot;numeric_vector.h&quot;</FONT></B>  #include <B><FONT COLOR="#BC8F8F">&quot;elem.h&quot;</FONT></B>  #include <B><FONT COLOR="#BC8F8F">&quot;tensor_value.h&quot;</FONT></B>    <B><FONT COLOR="#228B22">void</FONT></B> assemble_biharmonic(EquationSystems&amp; es,                        <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp; system_name);      Number exact_2D_solution(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,  		         <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,   <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  		         <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;,  <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  		         <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;); <I><FONT COLOR="#B22222">// unk_name, not needed);</FONT></I>    Number exact_3D_solution(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);    Gradient exact_2D_derivative(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);    Gradient exact_3D_derivative(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);    Tensor exact_2D_hessian(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);    Tensor exact_3D_hessian(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);    Number forcing_function_2D(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p);    Number forcing_function_3D(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p);    Number (*exact_solution)(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);  Gradient (*exact_derivative)(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);  Tensor (*exact_hessian)(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; p,    <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;);  Number (*forcing_function)(<B><FONT COLOR="#228B22">const</FONT></B> Point&amp; 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 &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;ERROR: This example requires libMesh to be\n&quot;</FONT></B>              &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;compiled with AMR support!&quot;</FONT></B>              &lt;&lt; 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 &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;ERROR: This example requires the library to be &quot;</FONT></B>  	    &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;compiled with second derivatives support!&quot;</FONT></B>  	    &lt;&lt; std::endl;    <B><FONT COLOR="#A020F0">return</FONT></B> 0;  #<B><FONT COLOR="#A020F0">else</FONT></B>      {            GetPot input_file(<B><FONT COLOR="#BC8F8F">&quot;ex15.in&quot;</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">&quot;max_r_level&quot;</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">&quot;max_r_steps&quot;</FONT></B>, 4);      <B><FONT COLOR="#228B22">const</FONT></B> std::string approx_type  = input_file(<B><FONT COLOR="#BC8F8F">&quot;approx_type&quot;</FONT></B>,  						<B><FONT COLOR="#BC8F8F">&quot;HERMITE&quot;</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">&quot;uniform_refine&quot;</FONT></B>, 0);      <B><FONT COLOR="#228B22">const</FONT></B> Real refine_percentage =  		    input_file(<B><FONT COLOR="#BC8F8F">&quot;refine_percentage&quot;</FONT></B>, 0.5);      <B><FONT COLOR="#228B22">const</FONT></B> Real coarsen_percentage =  		    input_file(<B><FONT COLOR="#BC8F8F">&quot;coarsen_percentage&quot;</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">&quot;dimension&quot;</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">&quot;max_linear_iterations&quot;</FONT></B>, 10000);        assert (dim == 2 || dim == 3);        assert (dim == 2 || approx_type == <B><FONT COLOR="#BC8F8F">&quot;HERMITE&quot;</FONT></B>);        Mesh mesh (dim);            <B><FONT COLOR="#5F9EA0">std</FONT></B>::string output_file = <B><FONT COLOR="#BC8F8F">&quot;&quot;</FONT></B>;        <B><FONT COLOR="#A020F0">if</FONT></B> (dim == 2)        output_file += <B><FONT COLOR="#BC8F8F">&quot;2D_&quot;</FONT></B>;      <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (dim == 3)        output_file += <B><FONT COLOR="#BC8F8F">&quot;3D_&quot;</FONT></B>;        <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">&quot;HERMITE&quot;</FONT></B>)        output_file += <B><FONT COLOR="#BC8F8F">&quot;hermite_&quot;</FONT></B>;      <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">&quot;SECOND&quot;</FONT></B>)        output_file += <B><FONT COLOR="#BC8F8F">&quot;reducedclough_&quot;</FONT></B>;      <B><FONT COLOR="#A020F0">else</FONT></B>        output_file += <B><FONT COLOR="#BC8F8F">&quot;clough_&quot;</FONT></B>;        <B><FONT COLOR="#A020F0">if</FONT></B> (uniform_refine == 0)        output_file += <B><FONT COLOR="#BC8F8F">&quot;adaptive&quot;</FONT></B>;      <B><FONT COLOR="#A020F0">else</FONT></B>        output_file += <B><FONT COLOR="#BC8F8F">&quot;uniform&quot;</FONT></B>;        <B><FONT COLOR="#5F9EA0">std</FONT></B>::string gmv_file = output_file;      gmv_file += <B><FONT COLOR="#BC8F8F">&quot;.gmv&quot;</FONT></B>;      output_file += <B><FONT COLOR="#BC8F8F">&quot;.m&quot;</FONT></B>;        <B><FONT COLOR="#5F9EA0">std</FONT></B>::ofstream out (output_file.c_str());      out &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;% dofs     L2-error     H1-error      H2-error\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;e = [\n&quot;</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 = &amp;exact_2D_solution;          exact_derivative = &amp;exact_2D_derivative;          exact_hessian = &amp;exact_2D_hessian;          forcing_function = &amp;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 = &amp;exact_3D_solution;          exact_derivative = &amp;exact_3D_derivative;          exact_hessian = &amp;exact_3D_hessian;          forcing_function = &amp;forcing_function_3D;        }        mesh.all_second_order();        <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type != <B><FONT COLOR="#BC8F8F">&quot;HERMITE&quot;</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&amp; system =  	equation_systems.add_system&lt;LinearImplicitSystem&gt; (<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>);          <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">&quot;HERMITE&quot;</FONT></B>)          system.add_variable(<B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>, THIRD, HERMITE);        <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">&quot;SECOND&quot;</FONT></B>)          system.add_variable(<B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>, SECOND, CLOUGH);        <B><FONT COLOR="#A020F0">else</FONT></B> <B><FONT COLOR="#A020F0">if</FONT></B> (approx_type == <B><FONT COLOR="#BC8F8F">&quot;CLOUGH&quot;</FONT></B>)          system.add_variable(<B><FONT COLOR="#BC8F8F">&quot;u&quot;</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&lt;<B><FONT COLOR="#228B22">unsigned</FONT></B> <B><FONT COLOR="#228B22">int</FONT></B>&gt;  		      (<B><FONT COLOR="#BC8F8F">&quot;linear solver maximum iterations&quot;</FONT></B>) =                        max_linear_iterations;          equation_systems.parameters.set&lt;Real&gt;  		      (<B><FONT COLOR="#BC8F8F">&quot;linear solver tolerance&quot;</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&amp; system =         equation_systems.get_system&lt;LinearImplicitSystem&gt;(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</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&lt;max_r_steps; r_step++)        {          mesh.print_info();          equation_systems.print_info();    	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;Beginning Solve &quot;</FONT></B> &lt;&lt; r_step &lt;&lt; std::endl;  	  	system.solve();    	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;Linear solver converged at step: &quot;</FONT></B>  		  &lt;&lt; system.n_linear_iterations()  		  &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;, final residual: &quot;</FONT></B>  		  &lt;&lt; system.final_linear_residual()  		  &lt;&lt; std::endl;    	exact_sol.compute_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>);  	zero_sol.compute_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>);    	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;L2-Norm is: &quot;</FONT></B>  		  &lt;&lt; zero_sol.l2_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>)  		  &lt;&lt; std::endl;  	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;H1-Norm is: &quot;</FONT></B>  		  &lt;&lt; zero_sol.h1_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>)  		  &lt;&lt; std::endl;  	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;H2-Norm is: &quot;</FONT></B>  		  &lt;&lt; zero_sol.h2_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>)  		  &lt;&lt; std::endl  		  &lt;&lt; std::endl;  	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;L2-Error is: &quot;</FONT></B>  		  &lt;&lt; exact_sol.l2_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>)  		  &lt;&lt; std::endl;  	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;H1-Error is: &quot;</FONT></B>  		  &lt;&lt; exact_sol.h1_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>)  		  &lt;&lt; std::endl;  	<B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;H2-Error is: &quot;</FONT></B>  		  &lt;&lt; exact_sol.h2_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>)  		  &lt;&lt; std::endl  		  &lt;&lt; std::endl;    	out &lt;&lt; equation_systems.n_active_dofs() &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot; &quot;</FONT></B>  	    &lt;&lt; exact_sol.l2_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>) &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot; &quot;</FONT></B>  	    &lt;&lt; exact_sol.h1_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>) &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot; &quot;</FONT></B>  	    &lt;&lt; exact_sol.h2_error(<B><FONT COLOR="#BC8F8F">&quot;Biharmonic&quot;</FONT></B>, <B><FONT COLOR="#BC8F8F">&quot;u&quot;</FONT></B>) &lt;&lt; std::endl;    	<B><FONT COLOR="#A020F0">if</FONT></B> (r_step+1 != max_r_steps)  	  {  	    <B><FONT COLOR="#5F9EA0">std</FONT></B>::cout &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;  Refining the mesh...&quot;</FONT></B> &lt;&lt; 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 &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;Mean Error: &quot;</FONT></B> &lt;&lt; error.mean() &lt;&lt;  				<B><FONT COLOR="#5F9EA0">std</FONT></B>::endl;  		<B><FONT COLOR="#5F9EA0">std</FONT></B>::cerr &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;Error Variance: &quot;</FONT></B> &lt;&lt; error.variance() &lt;&lt;  				<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 &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;];\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;hold on\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;loglog(e(:,1), e(:,2), 'bo-');\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;loglog(e(:,1), e(:,3), 'ro-');\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;loglog(e(:,1), e(:,4), 'go-');\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;xlabel('log(dofs)');\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;ylabel('log(error)');\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;title('C1 &quot;</FONT></B> &lt;&lt; approx_type &lt;&lt; <B><FONT COLOR="#BC8F8F">&quot; elements');\n&quot;</FONT></B>  	&lt;&lt; <B><FONT COLOR="#BC8F8F">&quot;legend('L2-error', 'H1-error', 'H2-error');\n&quot;</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&amp; p,  		         <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,  <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  		         <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  		         <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;) <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&amp; p,  			     <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,  <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  			     <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  			     <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;) <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&amp; p,  			<B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,  <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  			<B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  			<B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;) <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&amp; 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&amp; p,  		         <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,  <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  		         <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  		         <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;) <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&amp; p,  			     <B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,  <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  			     <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  			     <B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;) <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&amp; p,  			<B><FONT COLOR="#228B22">const</FONT></B> Parameters&amp;,  <I><FONT COLOR="#B22222">// parameters, not needed</FONT></I>  			<B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;, <I><FONT COLOR="#B22222">// sys_name, not needed</FONT></I>  			<B><FONT COLOR="#228B22">const</FONT></B> std::string&amp;) <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&amp; 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 + -