cashocs.io.managers#

Output managers for cashocs.

Functions

cast(typ, val)

Cast a value to a type.

generate_output_str(db, precision)

Generates the string which can be written to console and file.

generate_summary_str(db, precision)

Generates a string for the summary of the optimization.

Classes

ConsoleManager(db, result_dir)

Management of the console output.

FileManager(db, result_dir)

Class for managing the human-readable output of cashocs.

IOManager(db, result_dir)

Abstract base class for input / output management.

MeshManager(db, result_dir)

Manages the output of meshes.

ResultManager(db, result_dir)

Class for managing the output of the optimization history.

TempFileManager(db, result_dir)

Class for managing temporary files.

XDMFFileManager(db, result_dir)

Class for managing visualization .xdmf files.

class cashocs.io.managers.ConsoleManager(db, result_dir)[source]#

Bases: IOManager

Management of the console output.

Initializes self.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – The directory, where the results are written to.

output()[source]#

Prints the output string to the console.

Return type:

None

output_summary()[source]#

Prints the summary in the console.

Return type:

None

post_process()#

The output operation which is performed as part of the postprocessing.

Parameters:

solver – The optimization algorithm.

Return type:

None

class cashocs.io.managers.FileManager(db, result_dir)[source]#

Bases: IOManager

Class for managing the human-readable output of cashocs.

Initializes self.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – The directory, where the results are written to.

output()[source]#

Saves the output string in a file.

Return type:

None

output_summary()[source]#

Save the summary in a file.

Return type:

None

post_process()#

The output operation which is performed as part of the postprocessing.

Parameters:

solver – The optimization algorithm.

Return type:

None

class cashocs.io.managers.IOManager(db, result_dir)[source]#

Bases: ABC

Abstract base class for input / output management.

Initializes self.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – Path to the directory, where the results are saved.

output()[source]#

The output operation, which is performed after every iteration.

Parameters:

solver – The optimization algorithm.

Return type:

None

output_summary()[source]#

The output operation, which is performed after convergence.

Parameters:

solver – The optimization algorithm.

Return type:

None

post_process()[source]#

The output operation which is performed as part of the postprocessing.

Parameters:

solver – The optimization algorithm.

Return type:

None

class cashocs.io.managers.MeshManager(db, result_dir)[source]#

Bases: IOManager

Manages the output of meshes.

Initializes the MeshManager class.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – The folder where the results are saved.

output()[source]#

Saves the mesh as checkpoint for each iteration.

Return type:

None

output_summary()#

The output operation, which is performed after convergence.

Parameters:

solver – The optimization algorithm.

Return type:

None

post_process()[source]#

Saves a copy of the optimized mesh in Gmsh format.

Return type:

None

class cashocs.io.managers.ResultManager(db, result_dir)[source]#

Bases: IOManager

Class for managing the output of the optimization history.

Initializes self.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – Path to the directory, where the results are saved.

output()[source]#

Saves the optimization history to a dictionary.

Return type:

None

output_summary()#

The output operation, which is performed after convergence.

Parameters:

solver – The optimization algorithm.

Return type:

None

post_process()[source]#

Saves the history of the optimization to a .json file.

Return type:

None

class cashocs.io.managers.TempFileManager(db, result_dir)[source]#

Bases: IOManager

Class for managing temporary files.

Initializes self.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – Path to the directory, where the results are saved.

output()#

The output operation, which is performed after every iteration.

Parameters:

solver – The optimization algorithm.

Return type:

None

output_summary()#

The output operation, which is performed after convergence.

Parameters:

solver – The optimization algorithm.

Return type:

None

post_process()[source]#

Deletes temporary files.

Return type:

None

class cashocs.io.managers.XDMFFileManager(db, result_dir)[source]#

Bases: IOManager

Class for managing visualization .xdmf files.

Initializes self.

Parameters:
  • db (database.Database) – The database of the problem.

  • result_dir (str) – Path to the directory, where the output files are saved in.

output()[source]#

Saves the variables to xdmf files.

Return type:

None

output_summary()#

The output operation, which is performed after convergence.

Parameters:

solver – The optimization algorithm.

Return type:

None

post_process()#

The output operation which is performed as part of the postprocessing.

Parameters:

solver – The optimization algorithm.

Return type:

None

cashocs.io.managers.generate_output_str(db, precision)[source]#

Generates the string which can be written to console and file.

Parameters:
  • db (database.Database) – The database of the problem.

  • precision (int) – The precision used for displaying the numbers.

Returns:

The output string, which is used later.

Return type:

str

cashocs.io.managers.generate_summary_str(db, precision)[source]#

Generates a string for the summary of the optimization.

Parameters:
  • db (database.Database) – The database of the problem.

  • precision (int) – The precision used for displaying the numbers.

Returns:

The summary string.

Return type:

str