# Path: postproclib/postproc.py
# class PostProc:
# 
#     def __str__(self):
#         string =  ('\nAvailable outputs in ' + self.resultsdir + ' include:\n\n')
#         string += ('\t{0:^24s}\t{1:>10s}\n'.format('field', 'records'))
#         #string += ('\t{0:^24s}\t{1:^10s}\n'.format('-'*24, '-'*10))
#         for key,field in sorted(self.plotlist.items()):
#             line = '\t{0:<24s}=\t{1:>10f},\n'.format(key, field.maxrec)
#             string += line
#         return string 
# 
# Path: postproclib/pplexceptions.py
# class NoResultsInDir(Exception):
#     pass


import os
from .lammpsfields import *
from .postproc import PostProc
from .pplexceptions import NoResultsInDir 
                     'Density': LAMMPS_dField,
                     'Velocity': LAMMPS_vField,
                     'Momentum': LAMMPS_momField,
                     'Temperature': LAMMPS_TField,
                     'Pressure': LAMMPS_PressureField,
                     'Shear Stess': LAMMPS_ShearStressField,
        	         'Kinetic Energy': LAMMPS_KineticEnergyField,    
                     'Potential Energy': LAMMPS_PotentialEnergyField,
                     'Total Energy': LAMMPS_TotalEnergyField
                    }


        #Try to get fnames from log.lammps
        fname = ""
        logfile = self.resultsdir + "/log.lammps"
        if (os.path.isfile(logfile)):
            with open(logfile, "r") as f:
                n = "3dgrid"
                for l in f:
                    if ("chunk/atom bin/3d") in l:
                       n=l.split()[1]
                    if n in l and "ave/chunk" in l:
                       indx = l.find("file")
                       if indx != -1:
                           fname = l[indx:].split()[1]
                       else:
                           print(("logfile ", logfile, " appears to be corrupted " + 
                                 "so cannot determine output filename"))
        else:
            #print(("logfile ", logfile, " not found"))

# Path: postproclib/postproc.py
# class PostProc:
# 
#     def __str__(self):
#         string =  ('\nAvailable outputs in ' + self.resultsdir + ' include:\n\n')
#         string += ('\t{0:^24s}\t{1:>10s}\n'.format('field', 'records'))
#         #string += ('\t{0:^24s}\t{1:^10s}\n'.format('-'*24, '-'*10))
#         for key,field in sorted(self.plotlist.items()):
#             line = '\t{0:<24s}=\t{1:>10f},\n'.format(key, field.maxrec)
#             string += line
#         return string 
# 
# Path: postproclib/pplexceptions.py
# class NoResultsInDir(Exception):
#     pass


# Path: postproclib/lammpspostproc.py
import os
from .lammpsfields import *
from .postproc import PostProc
from .pplexceptions import NoResultsInDir 

                     'Density': LAMMPS_dField,
                     'Velocity': LAMMPS_vField,
                     'Momentum': LAMMPS_momField,
                     'Temperature': LAMMPS_TField,
                     'Pressure': LAMMPS_PressureField,
                     'Shear Stess': LAMMPS_ShearStressField,
        	         'Kinetic Energy': LAMMPS_KineticEnergyField,    
                     'Potential Energy': LAMMPS_PotentialEnergyField,
                     'Total Energy': LAMMPS_TotalEnergyField
                    }


        #Try to get fnames from log.lammps
        fname = ""
        logfile = self.resultsdir + "/log.lammps"
        if (os.path.isfile(logfile)):
            with open(logfile, "r") as f:
                n = "3dgrid"
                for l in f:
                    if ("chunk/atom bin/3d") in l:
                       n=l.split()[1]
                    if n in l and "ave/chunk" in l:
                       indx = l.find("file")
                       if indx != -1:
                           fname = l[indx:].split()[1]
                       else:
                           print(("logfile ", logfile, " appears to be corrupted " + 
                                 "so cannot determine output filename"))
        else:
            #print(("logfile ", logfile, " not found"))

            raise NoResultsInDir