Compadre  1.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GMLS_Manifold.py.in
Go to the documentation of this file.
1 import subprocess
2 import os
3 import re
4 import math
5 import sys
6 import argparse
7 
8 parser = argparse.ArgumentParser(description='convert files by adding cell centroids and ID (for cubed-sphere)')
9 parser.add_argument('--porder', dest='porder', type=int, default=3, help='polynomial degree for basis')
10 parser.add_argument('--grids', dest='grids', type=int, default=2, help='number of grids for refinement sequence')
11 parser.add_argument('--solver-type', dest='solver_type', type=int, default=1, help='solver type (int)')
12 parser.add_argument('--in-trilinos', dest='in_trilinos', type=str, default='false', help='whether being called from inside of Trilinos')
13 args = parser.parse_args()
14 
15 def check_bounds(porder, rate):
16  if (porder=="1"):
17  if rate<3 and rate>.9:
18  return True
19  else:
20  return False
21  else:
22  if rate>float(porder)-1.2:
23  return True
24  else:
25  return False
26 
27 num_target_sites = 100
28 porder = args.porder
29 grids = args.grids
30 solver_type = args.solver_type
31 
32 errors = []
33 
34 target_operators=("Tangent Bundle", "Point Value", "Laplace-Beltrami", "Gaussian Curvature", "Surface Gradient \(Ambient\)", "Surface Vector \(VectorBasis\)", "Surface Divergence \(VectorBasis\)", "Surface Vector \(ScalarClones\)", "Surface Divergence \(ScalarClones\)")#, "Surface Gradient (Manifold)",
35 for operator in target_operators:
36  errors.append([])
37 
38 for grid_num in range(grids):
39  with open(os.devnull, 'w') as devnull:
40  exe_name=""
41  if args.in_trilinos.lower()=="true":
42  exe_name = "@CMAKE_CURRENT_BINARY_DIR@/Compadre_GMLS_Manifold_Test.exe"
43  else:
44  exe_name = "@CMAKE_CURRENT_BINARY_DIR@/GMLS_Manifold_Test"
45  output_commands = [exe_name,"%d"%porder,"%d"%num_target_sites,"3","%d"%(20*num_target_sites*pow(4,grid_num)),str(solver_type),"1","0","--kokkos-threads=4"]
46  print(output_commands)
47  output = subprocess.check_output(output_commands, stderr=devnull)
48  #print(output)
49  for key, operator in enumerate(target_operators):
50  m = re.search('(?<=%s Error: )[0-9]+\.?[0-9]*(?:[Ee]\ *-?\ *[0-9]+)?'%operator, output.decode('utf-8'))
51  try:
52  errors[key].append(float(m.group(0)))
53  except:
54  print("Program exited early. Regular expression search for error failed.")
55  exit(-1)
56 
57 print(errors)
58 
59 for key, operator in enumerate(target_operators):
60  print("\n\n%s rates: porder:%s\n============="%(operator.replace('\\',''), porder))
61  for i in range(1,len(errors[key])):
62  if (errors[key][i]!=0):
63  rate = math.log(errors[key][i]/errors[key][i-1])/math.log(.5)
64  print(str(rate) + ", " + str(errors[key][i]) + ", " + str(errors[key][i-1]))
65  assert(check_bounds(porder, rate))
66  else:
67  print("NaN - Division by zero")
68 
69 print("Passed.")
70 sys.exit(0)
import subprocess import os import re import math import sys import argparse parser
import subprocess import os import re import math import sys import argparse d d num_target_sites
if(some_conditions_for_a_user_defined_operation)
import subprocess import os import re import math import sys import argparse d porder
import subprocess import os import re import math import sys import argparse d d str(solver_type)