Dear John

On Tue, 26 Aug 2008, John Peterson wrote:

Unfortunately the error is not a linear function in general, even
though the approximate solution may be.

Yes. I was thinking about the case where the 'exact' solution is just a solution on a finer grid, in which case (if I understand the code correctly) the computation is performed on the fine grid and hence the 'error' is actually contained in the ansatz space. Of course, you could not know what I was thinking about.

Please find attached the new patch that corrects the error I made in parallel for the L-infty norm. After all, I did not change the name of the L_INF norm since I think the result of the discussion is that this is the most sensible approximation and that it naturally corresponds to the approximation that is done for the other norms, too. Additionally, I added some comments that clarify this to the user.

Best Regards,

Tim

--
Dr. Tim Kroeger                                        Phone +49-421-218-7710
[EMAIL PROTECTED], [EMAIL PROTECTED]  Fax   +49-421-218-4236

MeVis Research GmbH, Universitaetsallee 29, 28359 Bremen, Germany

Amtsgericht Bremen HRB 16222
Geschaeftsfuehrer: Prof. Dr. H.-O. Peitgen
Index: include/enums/enum_norm_type.h
===================================================================
--- include/enums/enum_norm_type.h      (Revision 3002)
+++ include/enums/enum_norm_type.h      (Arbeitskopie)
@@ -35,6 +35,9 @@
                    H1             = 1,
                    H2             = 2,
 
+                   L1             = 5,
+                    L_INF          = 6,
+
                    H1_SEMINORM    = 10,
                    H2_SEMINORM    = 11,
 
Index: include/solvers/exact_solution.h
===================================================================
--- include/solvers/exact_solution.h    (Revision 3002)
+++ include/solvers/exact_solution.h    (Arbeitskopie)
@@ -68,7 +68,7 @@
    * must be initialized with an EquationSystems
    * object.
    */
-  ExactSolution (EquationSystems& es);
+  ExactSolution (const EquationSystems& es);
 
   /**
    * Destructor.
@@ -81,7 +81,7 @@
    * allows the user to attach a second EquationSystems
    * object with a reference fine grid solution.
    */
-  void attach_reference_solution (EquationSystems* es_fine);
+  void attach_reference_solution (const EquationSystems* es_fine);
 
   /**
    * Attach function similar to system.h which
@@ -142,6 +142,25 @@
                const std::string& unknown_name);
   
   /**
+   * This function returns the integrated L1 error for the system
+   * sys_name for the unknown unknown_name.  Note that no error computations
+   * are actually performed, you must call compute_error() for that.
+   */
+  Number l1_error(const std::string& sys_name,
+               const std::string& unknown_name);
+  
+  /**
+  /**
+   * This function returns the integrated L_INF error for the system
+   * sys_name for the unknown unknown_name.  Note that no error computations
+   * are actually performed, you must call compute_error() for that.
+   * Note also that the result (as for for the other norms as well) is
+   * not exact, but an approximation based on the chosen quadrature rule.
+   */
+  Number l_inf_error(const std::string& sys_name,
+               const std::string& unknown_name);
+  
+  /**
    * This function computes and returns the H1 error for the system
    * sys_name for the unknown unknown_name.  Note that no error computations
    * are actually performed, you must call compute_error() for that.
@@ -161,6 +180,8 @@
    * This function returns the error in the requested norm for the system
    * sys_name for the unknown unknown_name.  Note that no error computations
    * are actually performed, you must call compute_error() for that.
+   * Note also that the result is not exact, but an approximation
+   * based on the chosen quadrature rule.
    */
   Number error_norm(const std::string& sys_name,
                    const std::string& unknown_name,
@@ -234,13 +255,13 @@
    * Constant reference to the \p EquationSystems object
    * used for the simulation.
    */
-  EquationSystems& _equation_systems;
+  const EquationSystems& _equation_systems;
 
   /**
    * Constant pointer to the \p EquationSystems object
    * containing the fine grid solution.
    */
-  EquationSystems* _equation_systems_fine;
+  const EquationSystems* _equation_systems_fine;
 
   /**
    * Extra order to use for quadrature rule
Index: src/solvers/exact_solution.C
===================================================================
--- src/solvers/exact_solution.C        (Revision 3002)
+++ src/solvers/exact_solution.C        (Arbeitskopie)
@@ -35,7 +35,7 @@
 #include "tensor_value.h"
 #include "vector_value.h"
 
-ExactSolution::ExactSolution(EquationSystems& es) :
+ExactSolution::ExactSolution(const EquationSystems& es) :
   _exact_value (NULL),
   _exact_deriv (NULL),
   _exact_hessian (NULL),
@@ -68,7 +68,7 @@
 }
 
 
-void ExactSolution::attach_reference_solution (EquationSystems* es_fine)
+void ExactSolution::attach_reference_solution (const EquationSystems* es_fine)
 {
   libmesh_assert (es_fine != NULL);
   _equation_systems_fine = es_fine;
@@ -206,6 +206,10 @@
       return std::sqrt(error_vals[1]);
     case H2_SEMINORM:
       return std::sqrt(error_vals[2]);
+    case L1:
+      return error_vals[3];
+    case L_INF:
+      return error_vals[4];
     // Currently only Sobolev norms/seminorms are supported
     default:
       libmesh_error();
@@ -238,6 +242,46 @@
 
 
 
+Number ExactSolution::l1_error(const std::string& sys_name,
+                              const std::string& unknown_name)
+{
+  
+  // Check the inputs for validity, and get a reference
+  // to the proper location to store the error
+  std::vector<Number>& error_vals = this->_check_inputs(sys_name,
+                                                       unknown_name);
+  
+  // Return the square root of the first component of the
+  // computed error.
+  return error_vals[3];
+}
+
+
+
+
+
+
+
+Number ExactSolution::l_inf_error(const std::string& sys_name,
+                              const std::string& unknown_name)
+{
+  
+  // Check the inputs for validity, and get a reference
+  // to the proper location to store the error
+  std::vector<Number>& error_vals = this->_check_inputs(sys_name,
+                                                       unknown_name);
+  
+  // Return the square root of the first component of the
+  // computed error.
+  return error_vals[4];
+}
+
+
+
+
+
+
+
 Number ExactSolution::h1_error(const std::string& sys_name,
                               const std::string& unknown_name)
 {
@@ -347,7 +391,7 @@
   const MeshBase& _mesh = computed_system.get_mesh();
 
   // Zero the error before summation
-  error_vals = std::vector<Number>(3, 0.);
+  error_vals = std::vector<Number>(5, 0.);
 
   // get the EquationSystems parameters for use with _exact_value
   const Parameters& parameters = this->_equation_systems.parameters;
@@ -463,8 +507,10 @@
 
          // Add the squares of the error to each contribution
          error_vals[0] += JxW[qp]*libmesh_norm(val_error);
+         Real norm = sqrt(libmesh_norm(val_error));
+         error_vals[3] += JxW[qp]*norm;
+         if(error_vals[4]<norm) { error_vals[4] = norm; }
 
-
          // Compute the value of the error in the gradient at this
          // quadrature point
           Gradient exact_grad;
@@ -497,6 +543,10 @@
        } // end qp loop
     } // end element loop
 
-  // Add up the error values on all processors
+  // Add up the error values on all processors, except for the L-infty
+  // norm, for which the maximum is computed.
+  Number l_infty_norm = error_vals[4];
+  Parallel::max(l_infty_norm);
   Parallel::sum(error_vals);
+  error_vals[4] = l_infty_norm;
 }
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to