|
Peano
|
Parser for Peano block file output. More...
Public Member Functions | |
| __init__ (self, file_path, set_identifier, subdomain_number, show_progress=False, patch_filter=None) | |
| show_progress: Boolean Print a single-line, in-place progress bar (percentage plus patch count) to the terminal while parse_file() works through this file's patches - | |
| __repr__ (self) | |
| parse_file (self) | |
| Read file and return cell data, dimensions, number of degrees of freedom and number of unknowns. | |
| render_or_validate_for_each_unknown (self, render_or_validate) | |
| We need to call the render function for each filter on a variety of attributes, and then return them if they are modified. | |
Data Fields | |
| file_path | |
| patch_filter | |
| is_data_associated_to_cell | |
| dimensions | |
| file_format | |
| set_identifier | |
| subdomain_number | |
| parsed | |
| file_contains_patches | |
| show_progress | |
| unknown_attributes | |
Protected Attributes | |
| _doubles_per_patch | |
Private Member Functions | |
| __parse_meta_data_region (self, current_line, file_object, end_condition) | |
| Pass in file object, move it along and return it. | |
| __read_values (self, unknown_name, file_object) | |
| Read the quantities of one patch of one dataset. | |
| __skip_values_if_binary (self, current_line, file_object) | |
| If current_line opens the quantities of a dataset in a binary file, step over them. | |
| __record_doubles_per_patch (self, current_line, file_object, end_condition) | |
| Binary files only: Run through a metadata block of a dataset which we do not parse and remember how many doubles each of its patches holds, so we can step over them. | |
| __parse_patch_region (self, current_line, file_object, end_condition="end patch") | |
| Pass in file object, run it until we encounter the end condition, and then return it. | |
| __count_patches (self) | |
| Quick pre-scan (just a substring search per line, no numpy parsing) to count "begin patch" occurrences, i.e. | |
| __print_progress (self, current, total) | |
| Render current/total as an in-place, single-line percentage/bar on the terminal (\r-terminated, so nothing else may write to stdout while this runs -. | |
Parser for Peano block file output.
This class should be instantiated from within the Visualiser class. This class should be called once per patch file that contains patch data that we want to render. The main method that is called is parse_file().
This method doesn't return anything. Rather, it sets unknown_attributes to capture all the patch data for each of the unknowns that we find.
Then, the Visualiser class will steal this data, and combine it into its own helper class.
file_path: String String of input file path (including filename and extension)
dimensions: Integer Dimension of domains
mapping: series of d-dimensional tuples Distorts the domain
set_identifier: String Can be empty to parse everything.
unknown_attributes: Dict{ String, UnknownAttributes } Dictionary that has the names of each unknown we wanna capture as its keys, and the values are the helper class which captures dimensions, cell data etc. Each of the unknowns should be listed during the metadata part of the patch file, ie between "begin cell-metadata" and "end cell-metadata".
Definition at line 208 of file PatchFileParser.py.
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.__init__ | ( | self, | |
| file_path, | |||
| set_identifier, | |||
| subdomain_number, | |||
show_progress = False, |
|||
patch_filter = None |
|||
| ) |
show_progress: Boolean Print a single-line, in-place progress bar (percentage plus patch count) to the terminal while parse_file() works through this file's patches -
patch_filter: Callable (offset, size) -> Boolean, or None If set, parse_file() calls this predicate on each patch as soon as it has read the patch's offset and size, and skips the patch's values without converting them if the predicate returns False. This is way cheaper than parsing everything and throwing the data away afterwards, if a postprocessing script needs only a few patches (
Definition at line 246 of file PatchFileParser.py.
|
private |
Quick pre-scan (just a substring search per line, no numpy parsing) to count "begin patch" occurrences, i.e.
the number of cells/patches this file holds, so parse_file() can show progress against a known total instead of an estimate. Reads the file a second time, but that is negligible next to the actual parse below, which parses a numpy array per patch.
Definition at line 483 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_path.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().

|
private |
Pass in file object, move it along and return it.
Definition at line 302 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser._doubles_per_patch, convert::data::PatchData.dimensions, convert::data::Variable.dimensions, mghype.api.matrixgenerators.DLinear.DLinear.dimensions, mghype.api.matrixgenerators.DLinearMassIdentity.DLinearMassIdentity.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobatto.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.dimensions, mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.dimensions, api.solvers.DiscontinuousGalerkinDiscretisation.DiscontinuousGalerkinDiscretisation.dimensions, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.dimensions, tarch.plotter.api.input.PatchFileParser.PatchFileParser.dimensions, tarch::reader::PeanoTextPatchFileReader::Header.dimensions, equations.acoustic.Acoustic.dimensions, equations.advection.Advection.dimensions, equations.elastic.Elastic.dimensions, equations.equation.Equation.dimensions, equations.euler.Euler.dimensions, equations.swe.SWE_W_Bathymetry.dimensions, equations.swe.SWE_WO_Bathymetry.dimensions, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.is_data_associated_to_cell, tarch.plotter.api.input.PatchFileParser.PatchFileParser.is_data_associated_to_cell, and tarch.plotter.api.input.PatchFileParser.PatchFileParser.unknown_attributes.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().

|
private |
Pass in file object, run it until we encounter the end condition, and then return it.
We assume that current_line == "begin patch file" at this stage
This is where we read the actual data
Definition at line 404 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser.__read_values(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__skip_values_if_binary(), convert::data::PatchData.dimensions, convert::data::Variable.dimensions, mghype.api.matrixgenerators.DLinear.DLinear.dimensions, mghype.api.matrixgenerators.DLinearMassIdentity.DLinearMassIdentity.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobatto.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.dimensions, mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.dimensions, api.solvers.DiscontinuousGalerkinDiscretisation.DiscontinuousGalerkinDiscretisation.dimensions, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.dimensions, tarch.plotter.api.input.PatchFileParser.PatchFileParser.dimensions, tarch::reader::PeanoTextPatchFileReader::Header.dimensions, equations.acoustic.Acoustic.dimensions, equations.advection.Advection.dimensions, equations.elastic.Elastic.dimensions, equations.equation.Equation.dimensions, equations.euler.Euler.dimensions, equations.swe.SWE_W_Bathymetry.dimensions, equations.swe.SWE_WO_Bathymetry.dimensions, tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_contains_patches, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.is_data_associated_to_cell, tarch.plotter.api.input.PatchFileParser.PatchFileParser.is_data_associated_to_cell, tarch.plotter.api.input.PatchFileParser.PatchFileParser.patch_filter, tarch.plotter.api.output.PointProbe.PointProbe.patch_filter, tarch.plotter.api.output.Visualiser.Visualiser.patch_filter, tarch.plotter.api.input.PatchFileParser.PatchFileParser.set_identifier, tarch.plotter.api.input.Patch.Patch.subdomain_number, tarch.plotter.api.input.PatchFileParser.PatchFileParser.subdomain_number, and tarch.plotter.api.input.PatchFileParser.PatchFileParser.unknown_attributes.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().


|
private |
Render current/total as an in-place, single-line percentage/bar on the terminal (\r-terminated, so nothing else may write to stdout while this runs -.
Definition at line 501 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().

|
private |
Read the quantities of one patch of one dataset.
The line "begin cell-values" or "begin vertex-values" has just been read.
Definition at line 358 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser._doubles_per_patch, and tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_format.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region().

|
private |
Binary files only: Run through a metadata block of a dataset which we do not parse and remember how many doubles each of its patches holds, so we can step over them.
Definition at line 383 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser._doubles_per_patch, convert::data::PatchData.dimensions, convert::data::Variable.dimensions, mghype.api.matrixgenerators.DLinear.DLinear.dimensions, mghype.api.matrixgenerators.DLinearMassIdentity.DLinearMassIdentity.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobatto.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.dimensions, mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.dimensions, api.solvers.DiscontinuousGalerkinDiscretisation.DiscontinuousGalerkinDiscretisation.dimensions, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.dimensions, tarch.plotter.api.input.PatchFileParser.PatchFileParser.dimensions, tarch::reader::PeanoTextPatchFileReader::Header.dimensions, equations.acoustic.Acoustic.dimensions, equations.advection.Advection.dimensions, equations.elastic.Elastic.dimensions, equations.equation.Equation.dimensions, equations.euler.Euler.dimensions, equations.swe.SWE_W_Bathymetry.dimensions, and equations.swe.SWE_WO_Bathymetry.dimensions.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().

| tarch.plotter.api.input.PatchFileParser.PatchFileParser.__repr__ | ( | self | ) |
Definition at line 299 of file PatchFileParser.py.
|
private |
If current_line opens the quantities of a dataset in a binary file, step over them.
Definition at line 369 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser._doubles_per_patch, and tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_format.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region().

| tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file | ( | self | ) |
Read file and return cell data, dimensions, number of degrees of freedom and number of unknowns.
set_identifier: String Name of the set of unknowns we want to extract. If this is the empty string then I parse all content.
Definition at line 519 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser.__count_patches(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_meta_data_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__print_progress(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__record_doubles_per_patch(), convert::data::PatchData.dimensions, convert::data::Variable.dimensions, mghype.api.matrixgenerators.DLinear.DLinear.dimensions, mghype.api.matrixgenerators.DLinearMassIdentity.DLinearMassIdentity.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobatto.dimensions, mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.dimensions, mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.dimensions, api.solvers.DiscontinuousGalerkinDiscretisation.DiscontinuousGalerkinDiscretisation.dimensions, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.dimensions, tarch.plotter.api.input.PatchFileParser.PatchFileParser.dimensions, tarch::reader::PeanoTextPatchFileReader::Header.dimensions, equations.acoustic.Acoustic.dimensions, equations.advection.Advection.dimensions, equations.elastic.Elastic.dimensions, equations.equation.Equation.dimensions, equations.euler.Euler.dimensions, equations.swe.SWE_W_Bathymetry.dimensions, equations.swe.SWE_WO_Bathymetry.dimensions, tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_format, tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_path, tarch.plotter.api.input.PatchFileParser.UnknownAttributes.is_data_associated_to_cell, tarch.plotter.api.input.PatchFileParser.PatchFileParser.is_data_associated_to_cell, tarch.plotter.api.input.PatchFileParser.PatchFileParser.parsed, tarch.plotter.api.input.PatchFileParser.PatchFileParser.set_identifier, tarch.plotter.api.input.PatchFileParser.PatchFileParser.show_progress, tarch.plotter.api.output.PointProbe.PointProbe.show_progress, tarch.plotter.api.output.Visualiser.Visualiser.show_progress, and tarch.plotter.api.output.VTUUnstructuredGrid.VTUUnstructuredGrid.show_progress.

| tarch.plotter.api.input.PatchFileParser.PatchFileParser.render_or_validate_for_each_unknown | ( | self, | |
| render_or_validate | |||
| ) |
We need to call the render function for each filter on a variety of attributes, and then return them if they are modified.
We do this in a functional style, ie the Visualiser class contains all of the filters we wish to apply, and we pass the render function that we intend to use back to this layer. Ugly, but we need to do some looping over the different unknowns we see in the patch files, and I thought it best to hide that from the parse_snapshot region of the vis code.
The same apply for the validate function from the Visualiser file as well.
Definition at line 642 of file PatchFileParser.py.
References tarch.plotter.api.input.PatchFileParser.PatchFileParser.unknown_attributes.
|
protected |
Definition at line 284 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_meta_data_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__read_values(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__record_doubles_per_patch(), and tarch.plotter.api.input.PatchFileParser.PatchFileParser.__skip_values_if_binary().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.dimensions |
Definition at line 279 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_meta_data_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__record_doubles_per_patch(), tarch.plotter.api.input.PatchFileParser.UnknownAttributes._initialise_default_mapping_if_no_mapping_specified(), mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.convert_index_to_dim(), equations.euler.Euler.eigenvalues(), mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.eval_integral(), equations.elastic.Elastic.flux(), equations.euler.Euler.flux(), mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.get_boundary_matrix(), mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.get_cell_from_face_matrix(), mghype.api.matrixgenerators.DLinear.DLinear.get_cell_identity_matrix(), mghype.api.matrixgenerators.DLinearMassIdentity.DLinearMassIdentity.get_cell_identity_matrix(), mghype.api.matrixgenerators.DLinear.DLinear.get_cell_mass_matrix(), mghype.api.matrixgenerators.DLinear.DLinear.get_cell_system_matrix_for_laplacian(), mghype.api.matrixgenerators.DLinearMassIdentity.DLinearMassIdentity.get_cell_system_matrix_for_laplacian(), mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.get_deriv(), mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.get_points_for_dimension(), mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.get_polynomial(), mghype.api.matrixgenerators.GaussLobatto.GaussLobattoMatrixFree.get_projection_matrices(), mghype.api.matrixgenerators.MatrixGenerator.MatrixGenerator.get_weights_for_dimension(), matrices.DgGenerator.getCellToFaceMatrix(), api.solvers.DiscontinuousGalerkinDiscretisation.DiscontinuousGalerkinDiscretisation.nodes_per_cell(), api.solvers.DiscontinuousGalerkinDiscretisation.DiscontinuousGalerkinDiscretisation.nodes_per_face(), and tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_contains_patches |
Definition at line 289 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_format |
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.file_path |
Definition at line 276 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__count_patches(), and tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.is_data_associated_to_cell |
Definition at line 278 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_meta_data_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), tarch.plotter.api.input.PatchFileParser.UnknownAttributes._initialise_default_mapping_if_no_mapping_specified(), and tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.parsed |
Definition at line 288 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.patch_filter |
Definition at line 277 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), and tarch.plotter.api.output.Visualiser.Visualiser.parse_snapshot().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.set_identifier |
Definition at line 286 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), and tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.show_progress |
Definition at line 290 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.parse_file(), and tarch.plotter.api.output.Visualiser.Visualiser.parse_snapshot().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.subdomain_number |
Definition at line 287 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), and tarch.plotter.api.input.Patch.Patch.__repr__().
| tarch.plotter.api.input.PatchFileParser.PatchFileParser.unknown_attributes |
Definition at line 297 of file PatchFileParser.py.
Referenced by tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_meta_data_region(), tarch.plotter.api.input.PatchFileParser.PatchFileParser.__parse_patch_region(), and tarch.plotter.api.input.PatchFileParser.PatchFileParser.render_or_validate_for_each_unknown().