Loading [MathJax]/extensions/tex2jax.js
Compadre  1.6.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GMLS_Manifold.py.in
Go to the documentation of this file.
1 # @HEADER
2 # *****************************************************************************
3 # Compadre: COMpatible PArticle Discretization and REmap Toolkit
4 #
5 # Copyright 2018 NTESS and the Compadre contributors.
6 # SPDX-License-Identifier: BSD-2-Clause
7 # *****************************************************************************
8 # @HEADER
9 import subprocess
10 import os
11 import re
12 import math
13 import sys
14 import argparse
15 
16 parser = argparse.ArgumentParser(description='convert files by adding cell centroids and ID (for cubed-sphere)')
17 parser.add_argument('--porder', dest='porder', type=int, default=3, help='polynomial degree for basis')
18 parser.add_argument('--grids', dest='grids', type=int, default=2, help='number of grids for refinement sequence')
19 parser.add_argument('--solver-type', dest='solver_type', type=str, default='QR', help='solver type {QR,LU}')
20 parser.add_argument('--in-trilinos', dest='in_trilinos', type=str, default='false', help='whether being called from inside of Trilinos')
21 args = parser.parse_args()
22 
23 def check_bounds(porder, rate):
24  if (porder=="1"):
25  if rate<3 and rate>.9:
26  return True
27  else:
28  return False
29  else:
30  if rate>float(porder)-1.2:
31  return True
32  else:
33  return False
34 
35 num_target_sites = 100
36 porder = args.porder
37 grids = args.grids
38 solver_type = args.solver_type
39 
40 errors = []
41 
42 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)",
43 for operator in target_operators:
44  errors.append([])
45 
46 for grid_num in range(grids):
47  with open(os.devnull, 'w') as devnull:
48  exe_name=""
49  if args.in_trilinos.lower()=="true":
50  exe_name = "@CMAKE_CURRENT_BINARY_DIR@/Compadre_GMLS_Manifold_Test.exe"
51  else:
52  exe_name = "@CMAKE_CURRENT_BINARY_DIR@/GMLS_Manifold_Test"
53  output_commands = [exe_name,"--p","%d"%porder,"--nt","%d"%num_target_sites,"--d","3","--ns","%d"%(20*num_target_sites*pow(4,grid_num)),"--solver",str(solver_type),"--problem","MANIFOLD","@KOKKOS_THREADS_ARG@=4"]
54  print(output_commands)
55  output = subprocess.check_output(output_commands, stderr=devnull)
56  #print(output)
57  for key, operator in enumerate(target_operators):
58  m = re.search('(?<=%s Error: )[0-9]+\.?[0-9]*(?:[Ee]\ *-?\ *[0-9]+)?'%operator, output.decode('utf-8'))
59  try:
60  errors[key].append(float(m.group(0)))
61  except:
62  print("Program exited early. Regular expression search for error failed.")
63  exit(-1)
64 
65 print(errors)
66 
67 for key, operator in enumerate(target_operators):
68  print("\n\n%s rates: porder:%s\n============="%(operator.replace('\\',''), porder))
69  for i in range(1,len(errors[key])):
70  if (errors[key][i]!=0):
71  rate = math.log(errors[key][i]/errors[key][i-1])/math.log(.5)
72  print(str(rate) + ", " + str(errors[key][i]) + ", " + str(errors[key][i-1]))
73  assert(check_bounds(porder, rate))
74  else:
75  print("NaN - Division by zero")
76 
77 print("Passed.")
78 sys.exit(0)