1*fc37ad8cSJames Wright# Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2*fc37ad8cSJames Wright# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 3*fc37ad8cSJames Wright# All Rights reserved. See files LICENSE and NOTICE for details. 4*fc37ad8cSJames Wright# 5*fc37ad8cSJames Wright# This file is part of CEED, a collection of benchmarks, miniapps, software 6*fc37ad8cSJames Wright# libraries and APIs for efficient high-order finite element and spectral 7*fc37ad8cSJames Wright# element discretizations for exascale applications. For more information and 8*fc37ad8cSJames Wright# source code availability see http://github.com/ceed 9*fc37ad8cSJames Wright# 10*fc37ad8cSJames Wright# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11*fc37ad8cSJames Wright# a collaborative effort of two U.S. Department of Energy organizations (Office 12*fc37ad8cSJames Wright# of Science and the National Nuclear Security Administration) responsible for 13*fc37ad8cSJames Wright# the planning and preparation of a capable exascale ecosystem, including 14*fc37ad8cSJames Wright# software, applications, hardware, advanced system engineering and early 15*fc37ad8cSJames Wright# testbed platforms, in support of the nation's exascale computing imperative. 16*fc37ad8cSJames Wright 17*fc37ad8cSJames Wrightimport re 18*fc37ad8cSJames Wrightimport pandas as pd 19*fc37ad8cSJames Wrightfrom pathlib import Path 20*fc37ad8cSJames Wright 21*fc37ad8cSJames Wright# Regex to parse STDOUT of the navierstokes run 22*fc37ad8cSJames Wrightlogreg = re.compile( 23*fc37ad8cSJames Wright r".*(?:^Degree of FEM Space: (\d+)).*(?:^Global FEM nodes: (\d{2,})).*(?:^dm_plex_box_faces: (\S+)).*(?:^Time taken for solution: (\d*\.?\d+)).*(?:^Relative Error: (\d*\.?\d+))", 24*fc37ad8cSJames Wright re.DOTALL | re.MULTILINE, 25*fc37ad8cSJames Wright) 26*fc37ad8cSJames Wright 27*fc37ad8cSJames Wright 28*fc37ad8cSJames Wrightdef parseFile(file): 29*fc37ad8cSJames Wright """Returns dictionary of parsed logfile contents. 30*fc37ad8cSJames Wright 31*fc37ad8cSJames Wright Parameters 32*fc37ad8cSJames Wright ---------- 33*fc37ad8cSJames Wright file : Path-like object 34*fc37ad8cSJames Wright Path to the file to be parsed. 35*fc37ad8cSJames Wright 36*fc37ad8cSJames Wright Returns 37*fc37ad8cSJames Wright ------- 38*fc37ad8cSJames Wright dict 39*fc37ad8cSJames Wright Values of "dofs", "time", "error", "degree", and "box_faces"' 40*fc37ad8cSJames Wright """ 41*fc37ad8cSJames Wright 42*fc37ad8cSJames Wright values = {} 43*fc37ad8cSJames Wright with file.open() as filer: 44*fc37ad8cSJames Wright filestring = filer.read() 45*fc37ad8cSJames Wright match = logreg.match(filestring) 46*fc37ad8cSJames Wright values["degree"] = match[1] 47*fc37ad8cSJames Wright values["dofs"] = match[2] 48*fc37ad8cSJames Wright box_faceStr = match[3] 49*fc37ad8cSJames Wright values["time"] = match[4] 50*fc37ad8cSJames Wright values["error"] = match[5] 51*fc37ad8cSJames Wright 52*fc37ad8cSJames Wright # Splitting box_face argument str into individual entries 53*fc37ad8cSJames Wright box_faceList = box_faceStr.split(",") 54*fc37ad8cSJames Wright for i, box_face in enumerate(box_faceList): 55*fc37ad8cSJames Wright values["box_face" + str(i)] = box_face 56*fc37ad8cSJames Wright 57*fc37ad8cSJames Wright return values 58*fc37ad8cSJames Wright 59*fc37ad8cSJames Wright 60*fc37ad8cSJames Wrightif __name__ == "__main__": 61*fc37ad8cSJames Wright # Directory location of log files 62*fc37ad8cSJames Wright runlogDir = Path("./") 63*fc37ad8cSJames Wright 64*fc37ad8cSJames Wright results = pd.DataFrame() 65*fc37ad8cSJames Wright for file in runlogDir.glob("*.log"): 66*fc37ad8cSJames Wright values = parseFile(file) 67*fc37ad8cSJames Wright results = results.append(values, ignore_index=True) 68*fc37ad8cSJames Wright 69*fc37ad8cSJames Wright # Convert string values to numeric type 70*fc37ad8cSJames Wright results = results.apply(lambda col: pd.to_numeric(col, errors="coerce")) 71