Package solvcon :: Package io :: Module block :: Class BlockFormat
[hide private]
[frames] | no frames]

Class BlockFormat

source code

 object --+    
          |    
core.Format --+
              |
             BlockFormat
Known Subclasses:

A class for fundamental facilities for I/O intrinsic mesh format (blk). A blk file is in general composed by (i) meta-data, (ii) group list, (iii) boundary condition list, and (iv) binary arrays. The saved arrays can be compressed. The compression must be applied to all or none of the arrays. Each of the derived classes represents a version of format.

There is only one object method: _save_meta(), since it needs to access object for meta-data. All other methods are either class methods or static methods.

Nested Classes [hide private]
  __metaclass__
Sum the length of all META_ entries of bases and derived classes; only collect from 1 level of parents.
Instance Methods [hide private]
 
__init__(self, **kw)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
save(self, blk, stream)
Save the block object into a file.
source code
solvcon.block.Block
load(self, stream, bcmapper)
Load block from stream with BC mapper applied.
source code

Inherited from core.Format: read_meta

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_save_group(cls, blk, stream)
Returns: nothing.
source code
 
_save_bclist(cls, blk, stream)
Returns: nothing.
source code
 
_save_boundcond(cls, compressor, blk, stream)
Returns: nothing.
source code
list
_load_group(cls, meta, lines, blk)
Returns: BC information.
source code
list
_load_bclist(cls, meta, lines, blk)
Returns: BC information.
source code
 
_load_connectivity(cls, meta, stream, blk)
Returns: nothing.
source code
 
_load_type(cls, meta, stream, blk)
Returns: nothing.
source code
 
_load_geometry(cls, meta, stream, blk, extra=True)
Returns: nothing.
source code
 
_load_boundcond(cls, meta, bcsinfo, fpdtype, stream, blk)
Returns: nothing.
source code

Inherited from core.Format (private): _get_textpart, _parse_meta

Static Methods [hide private]
 
_convert_bc(name_mapper, blk)
Convert boundary condition object into proper types.
source code
 
_construct_subarrays(meta, blk)
Returns: nothing.
source code

Inherited from core.Format (private): _read_array, _write_array

Class Variables [hide private]
  FILE_HEADER = '-*- solvcon blk mesh file -*-'
header of the format; must be overridden.
  meta_length
length of all META_ entries; calculated by FormatMeta.

Inherited from core.Format: BINARY_MARKER, FORMAT_REV, READ_BLOCK, SPEC_OF_META

Instance Variables [hide private]
  compressor
the compression to use: '', 'gz', or 'bz2'
  fpdtype
specified fpdtype for I/O.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kw)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

save(self, blk, stream)

source code 

Save the block object into a file.

Parameters:
  • blk (solvcon.block.Block) - to-be-written block object.
  • stream (file or str) - file object or file name to be read.

load(self, stream, bcmapper)

source code 

Load block from stream with BC mapper applied.

Parameters:
  • stream (file or str) - file object or file name to be read.
  • bcmapper (dict) - BC type mapper.
Returns: solvcon.block.Block
the read block object.

_save_group(cls, blk, stream)
Class Method

source code 
Parameters:
  • blk (solvcon.block.Block) - block object to alter.
  • stream (file) - output stream.
Returns:
nothing.

_save_bclist(cls, blk, stream)
Class Method

source code 
Parameters:
  • blk (solvcon.block.Block) - block object to alter.
  • stream (file) - output stream.
Returns:
nothing.

_save_boundcond(cls, compressor, blk, stream)
Class Method

source code 
Parameters:
  • compressor (str) - the compression to use: '', 'gz', or 'bz2'
  • blk (solvcon.block.Block) - block object to alter.
  • stream (file or str) - file object or file name to be read.
Returns:
nothing.

_load_group(cls, meta, lines, blk)
Class Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • lines (list) - text data
  • blk (solvcon.block.Block) - Block object to load to.
Returns: list
BC information.

_load_bclist(cls, meta, lines, blk)
Class Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • lines (list) - text data
  • blk (solvcon.block.Block) - Block object to load to.
Returns: list
BC information.

_load_connectivity(cls, meta, stream, blk)
Class Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • stream (file) - input stream.
  • blk (solvcon.block.Block) - block object to alter.
Returns:
nothing.

_load_type(cls, meta, stream, blk)
Class Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • stream (file) - input stream.
  • blk (solvcon.block.Block) - block object to alter.
Returns:
nothing.

_load_geometry(cls, meta, stream, blk, extra=True)
Class Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • stream (file) - input stream.
  • blk (solvcon.block.Block) - block object to alter.
  • extra (bool) - load extra geometry data.
Returns:
nothing.

_load_boundcond(cls, meta, bcsinfo, fpdtype, stream, blk)
Class Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • bcsinfo (list) - list for information tuples for BCs.
  • fpdtype (numpy.dtype) - fpdtype for the to-be-created BC objects.
  • stream (file) - input stream.
  • blk (solvcon.block.Block) - block object to alter.
Returns:
nothing.

_convert_bc(name_mapper, blk)
Static Method

source code 

Convert boundary condition object into proper types.

Parameters:
  • name_mapper (dict) - map name to bc type and value dictionary; the two objects are organized in a tuple.
  • blk (solvcon.block.Block) - to-be-written Block object.
Returns:
nothing.

_construct_subarrays(meta, blk)
Static Method

source code 
Parameters:
  • meta (solvcon.gendata.AttributeDict) - meta information dictionary.
  • blk (solvcon.block.Block) - block object to alter.
Returns:
nothing.