<commit_before>static char help[] =
"Solves a 3D structured-grid advection-diffusion problem with DMDA\n"
"and SNES.  Option prefix -ad3_...  The equation is\n"
"    - eps Laplacian u + W . Grad u = f\n"
"on the domain  [-1,1]^3,  with boundary conditions:\n"
"    u(1,y,z) = g(y,z)\n"
"    u(-1,y,z) = u(x,-1,z) = u(x,1,z) = 0\n"
"    u periodic in z\n"
"Significant restrictions are:\n"
"    * only Dirichlet boundary conditions are demonstrated\n"
"    * f(x,y,z), g(y,z), W(x,y,z) must be given by formulas\n"
"    * FIXME  only centered and first-order-upwind differences for advection\n"
"An exact solution is used to evaluate numerical error:\n"
"    u(x,y,z) = U(x) sin(E (y+1)) sin(F (z+1))\n"
"where  U(x) = (exp((x+1)/eps) - 1) / (exp(2/eps) - 1)\n"
"and constants E,F so that homogeneous/periodic boundary conditions\n"
"are satisfied.  The problem solved has  W=<1,0,0>,  g(y,z) = u(1,y,z),\n"
"and f(x,y,z) = eps lambda^2 u(x,y,z)  where  lambda^2 = E^2 + F^2.\n\n";

/* evidence for convergence plus some feedback on iterations, but bad KSP iterations because GMRES+BJACOBI+ILU:
  $ for LEV in 0 1 2 3 4 5 6; do timer mpiexec -n 4 ./ad3 -snes_monitor -snes_converged_reason -ksp_converged_reason -ksp_rtol 1.0e-14 -da_refine $LEV; done

can go to LEV 7 if -ksp_type bicg or -ksp_type bcgs  ... GMRES is mem hog

eventually untuned algebraic multigrid is superior (tip-over point at -da_refine 6):
$ timer ./ad3 -snes_monitor -ksp_converged_reason -ksp_rtol 1.0e-11 -da_refine 6 -pc_type gamg
$ timer ./ad3 -snes_monitor -ksp_converged_reason -ksp_rtol 1.0e-11 -da_refine 6

all of these work:
  ./ad3 -snes_monitor -ksp_type preonly -pc_type lu
  "                   -snes_fd
  "                   -snes_mf
  "                   -snes_mf_operator

FIXME: multigrid?
*/

#include <petsc.h>

//STARTSETUP
typedef struct {<commit_msg>minor: help string<commit_after>static char help[] =
"Solves a 3D linear advection-diffusion problem with structured-grid (DMDA)\n"
"and SNES.  Option prefix -ad3_...  The equation is\n"
"    - eps Laplacian u + W . Grad u = f\n"
"on the domain  [-1,1]^3  with boundary conditions:\n"
"    u(1,y,z) = g(y,z)\n"
"    u(-1,y,z) = u(x,-1,z) = u(x,1,z) = 0\n"
"    u periodic in z\n"
"Significant restrictions are:\n"
"    * only Dirichlet and periodic boundary conditions are demonstrated\n"
"    * f(x,y,z), g(y,z), W(x,y,z) must be given by formulas\n"
"    * FIXME  only centered and first-order-upwind differences for advection\n"
"An exact solution is used to evaluate numerical error:\n"
"    u(x,y,z) = U(x) sin(E (y+1)) sin(F (z+1))\n"
"where  U(x) = (exp((x+1)/eps) - 1) / (exp(2/eps) - 1)\n"
"and constants E,F so that homogeneous/periodic boundary conditions\n"
"are satisfied.  The problem solved has  W=<1,0,0>,  g(y,z) = u(1,y,z),\n"
"and f(x,y,z) = eps lambda^2 u(x,y,z)  where  lambda^2 = E^2 + F^2.\n\n";

/* evidence for convergence plus some feedback on iterations, but bad KSP iterations because GMRES+BJACOBI+ILU:
  $ for LEV in 0 1 2 3 4 5 6; do timer mpiexec -n 4 ./ad3 -snes_monitor -snes_converged_reason -ksp_converged_reason -ksp_rtol 1.0e-14 -da_refine $LEV; done

can go to LEV 7 if -ksp_type bicg or -ksp_type bcgs  ... GMRES is mem hog

eventually untuned algebraic multigrid is superior (tip-over point at -da_refine 6):
$ timer ./ad3 -snes_monitor -ksp_converged_reason -ksp_rtol 1.0e-11 -da_refine 6 -pc_type gamg
$ timer ./ad3 -snes_monitor -ksp_converged_reason -ksp_rtol 1.0e-11 -da_refine 6

all of these work:
  ./ad3 -snes_monitor -ksp_type preonly -pc_type lu
  "                   -snes_fd
  "                   -snes_mf
  "                   -snes_mf_operator

FIXME: multigrid?
*/

#include <petsc.h>

//STARTSETUP
typedef struct {
{'fraction_non_alphanumeric': 0.14254975793437333, 'fraction_numerical': 0.027972027972027972, 'mean_word_length': 3.1139380530973453, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1241202', 'n_tokens_mistral': 1594, 'n_tokens_neox': 1508, 'n_words': 439}