[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-i18n-doc
Subject:    Re: how to omit messages from translation in docbook ?
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2015-02-25 13:04:04
Message-ID: 201502251404.07776.caslav.ilic () gmx ! net
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi Fei,

I fixed it, I attach the patch (from the version you gave me to my fixed
version). Now it works for the Onera M6 case, with my gradient computation
scripts. There were two main problems:

One problem was the use of sum_restp in the expression for fac_an, it should
have been res_tp instead. This I found by more carefully deriving the
expression again.

The other problem was that bface_offset was missing in the target pressure
function, so it was storing computed derivatives in wrong locations. This I
found by comparing again with other gJ_* functions.

-- 
Chusslove Illich (Часлав Илић)

["madj-fix-01.diff" (text/x-patch)]

diff -ur taudir.svn.17901.mf1/src/deformation/modules/linear_elastic/linear_elastic_deform.h \
taudir.svn.17901.mf1.ci1/src/deformation/modules/linear_elastic/linear_elastic_deform.h
                
--- taudir.svn.17901.mf1/src/deformation/modules/linear_elastic/linear_elastic_deform.h	2014-08-08 \
                13:50:07.000000000 +0200
+++ taudir.svn.17901.mf1.ci1/src/deformation/modules/linear_elastic/linear_elastic_deform.h	2015-02-17 \
10:23:46.864858000 +0100 @@ -54,6 +54,10 @@
       mesh adjoint equation, is useful to automatically differentiate solution
       files by creating the final filename. **/
   char cost_fn_name[MAX_LINE_LEN + 1];
+
+  /** whether to update parameter file and how. **/
+  int update_parameters;
+  int update_parameters_mode;
 } ElasticParams;
 
 ElasticParams *get_elastic_params(void);
diff -ur taudir.svn.17901.mf1/src/deformation/modules/linear_elastic/linear_elastic_deform_main.c \
taudir.svn.17901.mf1.ci1/src/deformation/modules/linear_elastic/linear_elastic_deform_main.c
                
--- taudir.svn.17901.mf1/src/deformation/modules/linear_elastic/linear_elastic_deform_main.c	2014-08-08 \
                13:50:07.000000000 +0200
+++ taudir.svn.17901.mf1.ci1/src/deformation/modules/linear_elastic/linear_elastic_deform_main.c	2015-02-17 \
14:07:29.254981080 +0100 @@ -34,6 +34,7 @@
  *
  ******************************************************************************/
 static ElasticParams param;
+static char para_filename[TAU_MAX_FILENAME_LEN + 1];
 
 /***************************************************************************//**
  * Setting of default parameters for linear elastic based grid deformation.
@@ -49,6 +50,8 @@
   strcpy(param.Amatrix_filename, "(none)");
   strcpy(param.io_prefix,        "(none)");
   strcpy(param.cost_fn_name,     "(none)");
+  param.update_parameters = TRUE;
+  param.update_parameters_mode = FALSE;
 } /* default_elastic_params() */
 
 /*******************************************************************************
@@ -93,6 +96,14 @@
       "Cost function", STRING_PARAM, 
       TRUE, &param.cost_fn_name
     },
+    {
+      "Automatic parameter update (0/1)", INTEGER_PARAM,
+      TRUE, &param.update_parameters,
+    },
+    {
+      "Automatic parameter update mode (0/1)", INTEGER_PARAM,
+      TRUE, &param.update_parameters_mode
+    },
     {NULL, -1}
   };
   strcpy(dummy, "-");
@@ -103,6 +114,7 @@
 
   para_file_created = read_parameters(parafilename, parameter, NULL);
   write_settings(parameter);
+  strcpy(para_filename, parafilename);
 
   /*----------------------------------------------------------------------------
   | Initialize the PETSc library if necessary.
@@ -147,6 +159,9 @@
   char filename[TAU_MAX_FILENAME_LEN + 1];
   int n_entries = 0, n_columns = 0;
   int err_msg = FALSE;
+  /*const char *module_name = get_module_name();*//* apparently not set */
+  const char *module_name = "(unnamed-module)";
+  char params_tobewritten[TAU_MAX_FILENAME_LEN * 32] = "";
 
   /*----------------------------------------------------------------------------
   | File suffix for parallel applications is grid like
@@ -303,6 +318,14 @@
                                     3,
                                     &(lambda_g[0][0]));
 
+    if(param.update_parameters == TRUE)
+    {
+      set_parameter_update_mode(param.update_parameters_mode);
+      add_paramline_2str(params_tobewritten, TAU_MAX_FILENAME_LEN * 32,
+                         "Sensitivity restart-data prefix:", output_filename);
+      update_parameter(para_filename, module_name, params_tobewritten);
+    }
+
     check_free(lambda_g);
   } /* if(adjoint == TRUE) */
 
diff -ur taudir.svn.17901.mf1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_boundary_forces.c \
taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_boundary_forces.c
                
--- taudir.svn.17901.mf1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_boundary_forces.c	2015-02-16 \
                15:06:49.000000000 +0100
+++ taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_boundary_forces.c	2015-02-25 \
13:48:43.791286344 +0100 @@ -768,19 +768,20 @@
 *
 *******************************************************************************/
 void gJ_cost_target_pressure(const TauDualGrid *dualgrid,
-                            TauBdryPart *bp,
-                            ConstPrim primvar,
-                            const int cost_fct,
-                            const TauDouble sum_areatp,
-                            const TauDouble sum_restp,
-                            TauDouble (*bdidn)[3],
-                            TauDouble (*drdn)[3])
+                             TauBdryPart *bp,
+                             ConstPrim primvar,
+                             const int cost_fct,
+                             const TauDouble sum_areatp,
+                             const TauDouble sum_restp,
+                             const int bface_offset,
+                             TauDouble (*bdidn)[3])
 {
   /* Reference values. */
   const DimlessOutputRefState *output_ref = get_output_references();
   const TauDouble inv_areatp = (sum_areatp > 0.0) ? (1.0 / sum_areatp) : 0.0,
                   fac_cp = 2.0 / SQR(output_ref->velocity),
-                  p_bdry = output_ref->outer_pressure;
+                  p_bdry = output_ref->outer_pressure,
+                  res_tp = sum_restp * inv_areatp;
 
   /* Geometry and targets. */
   const TauIndex *fpoint = bp->bedat->fpoint;
@@ -819,19 +820,15 @@
                     twcp = target_wcp[wp],
                     cp = (primvar[wp][IP] - p_bdry) * fac_cp;
     TauDouble fac_an;
+    int bfidx;
 
     fac_an = globals.restp.average
-             ? inv_areatp * ((SQR(cp - tcp) - sum_restp) * twcp / da)
+             ? inv_areatp * ((SQR(cp - tcp) - res_tp) * twcp / da)
              : 0.0;
-    bdidn[bface][0] += fac_an * anx;
-    bdidn[bface][1] += fac_an * any;
-    bdidn[bface][2] += fac_an * anz;
-
-    /*--------------------------------------------------------------------------
-    | For the moment drdn contributions are zero; but in the future
-    | there may be some spatial interpolation of target pressure.
-    --------------------------------------------------------------------------*/
-    (void) drdn;
+    bfidx = bface_offset + bface;
+    bdidn[bfidx][0] += fac_an * anx;
+    bdidn[bfidx][1] += fac_an * any;
+    bdidn[bfidx][2] += fac_an * anz;
   } /* for(bface = 0; bface < nfaces; bface++) */
 
 } /* bpart_target_pressure_dIdx() */
diff -ur taudir.svn.17901.mf1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_solver_interface.h \
taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_solver_interface.h
                
--- taudir.svn.17901.mf1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_solver_interface.h	2015-02-16 \
                15:06:49.000000000 +0100
+++ taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/Grid_Jacobian/grid_jacobian_solver_interface.h	2015-02-25 \
13:48:26.216531157 +0100 @@ -174,17 +174,15 @@
 * @param[in,out] bdidn Derivatives of cost function with respect to boundary
 *                      face normal. Dimension is the sum of all boundary
 *                      faces.
-* @param[in,out] drdn Derivatives of cost function with respect to inner
-*                     face normals.
 *******************************************************************************/
 void gJ_cost_target_pressure(const TauDualGrid *dualgrid,
-                            TauBdryPart *bp,
-                            ConstPrim primvar,
-                            const int cost_fct,
-                            const TauDouble sum_areatp,
-                            const TauDouble sum_restp,
-                            TauDouble (*bdidn)[3],
-                            TauDouble (*drdn)[3]);
+                             TauBdryPart *bp,
+                             ConstPrim primvar,
+                             const int cost_fct,
+                             const TauDouble sum_areatp,
+                             const TauDouble sum_restp,
+                             const int bface_offset,
+                             TauDouble (*bdidn)[3]);
 
 /***************************************************************************//**
 * Derivatives of face area with respect to face normals which are simply the
diff -ur taudir.svn.17901.mf1/src/PTau3d/Solver/grid_jacobian_cost_function.c \
                taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/grid_jacobian_cost_function.c
                
--- taudir.svn.17901.mf1/src/PTau3d/Solver/grid_jacobian_cost_function.c	2015-02-16 \
                15:06:49.000000000 +0100
+++ taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/grid_jacobian_cost_function.c	2015-02-25 \
13:54:50.928398000 +0100 @@ -93,13 +93,13 @@
     {
       if(t->target_pressure != NULL)
     	  gJ_cost_target_pressure(dualgrid,
-    			                  bp,
-    			                  primvar,
-    			                  cost_fct,
-    			                  sum_areatp,
-    			                  sum_restp,
-    			                  bdidn,
-    			                  dIdx);
+                                  bp,
+                                  primvar,
+                                  cost_fct,
+                                  sum_areatp,
+                                  sum_restp,
+                                  count,
+                                  bdidn);
     }
     else
     {
@@ -136,9 +136,9 @@
                               dIdx,
                               drdn,
                               dIdv);
-
-      count += bp->bedat->nfaces;
     }
+
+    count += bp->bedat->nfaces;
   }
   free_scaleforces_parameters(&SFP);
 
diff -ur taudir.svn.17901.mf1/src/PTau3d/Solver/include/grid_jacobian_solver_interface.h \
                taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/include/grid_jacobian_solver_interface.h
                
--- taudir.svn.17901.mf1/src/PTau3d/Solver/include/grid_jacobian_solver_interface.h	2015-02-16 \
                15:06:49.000000000 +0100
+++ taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/include/grid_jacobian_solver_interface.h	2015-02-25 \
13:48:26.216531157 +0100 @@ -174,17 +174,15 @@
 * @param[in,out] bdidn Derivatives of cost function with respect to boundary
 *                      face normal. Dimension is the sum of all boundary
 *                      faces.
-* @param[in,out] drdn Derivatives of cost function with respect to inner
-*                     face normals.
 *******************************************************************************/
 void gJ_cost_target_pressure(const TauDualGrid *dualgrid,
-                            TauBdryPart *bp,
-                            ConstPrim primvar,
-                            const int cost_fct,
-                            const TauDouble sum_areatp,
-                            const TauDouble sum_restp,
-                            TauDouble (*bdidn)[3],
-                            TauDouble (*drdn)[3]);
+                             TauBdryPart *bp,
+                             ConstPrim primvar,
+                             const int cost_fct,
+                             const TauDouble sum_areatp,
+                             const TauDouble sum_restp,
+                             const int bface_offset,
+                             TauDouble (*bdidn)[3]);
 
 /***************************************************************************//**
 * Derivatives of face area with respect to face normals which are simply the
diff -ur taudir.svn.17901.mf1/src/PTau3d/Solver/monitor_bdry.c \
                taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/monitor_bdry.c
--- taudir.svn.17901.mf1/src/PTau3d/Solver/monitor_bdry.c	2015-02-16 \
                15:06:49.000000000 +0100
+++ taudir.svn.17901.mf1.ci1/src/PTau3d/Solver/monitor_bdry.c	2015-02-18 \
13:38:14.242247931 +0100 @@ -266,10 +266,6 @@
   TauDouble sum_z, sum_tp;
   TauDouble sgn = get_ref_frame_sign();
 
-  const Monitor_list *monlist = get_monitor_list();
-  TauDouble sum_areatp        = monlist[SUM_AREA_TP].value;
-  TauDouble rtp               = (sum_areatp > 0) ? (1. / sum_areatp) : 0.;
-
   ScaleForcesParams *SFP = init_scaleforces_parameters();
 
   /*----------------------------------------------------------------------------
@@ -298,6 +294,8 @@
       int  map = bp->map->thismap;
       const TauDouble bp_az  = bp->integral_part[BP_AREA_Z];
       const TauDouble rbp_az = (bp_az > 0.) ?  1. / bp_az : 0.0;
+      const TauDouble tp = bp->integral_part[BP_AREA_TP];
+      const TauDouble rtp = (tp > 0) ? (1. / tp) : 0.;
       const TauDouble rtpw = globals.restp.average ? rtp : 1.0;
 
       bdryint->map_val[map][BP_LIFT_P] +=
@@ -314,7 +312,8 @@
                                       bp->integral_part[BP_SIDEF_V] * SFP->rdef;
       bdryint->map_val[map][BP_AREA_Z] += bp->integral_part[BP_AREA_Z];
 
-      bdryint->map_val[map][BP_RES_TP] += bp->integral_part[BP_RES_TP]  * rtpw;
+      bdryint->map_val[map][BP_RES_TP] += bp->integral_part[BP_RES_TP];
+      bdryint->map_val[map][BP_RES_TP] *= rtpw;
 
       bdryint->map_val[map][BP_AREA_TP]+= bp->integral_part[BP_AREA_TP];
 


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic