4.1.1.9.1.1. pyfem.util.BaseModule module
Base module for PyFEM.
This module provides the BaseModule class, which serves as the base class for modules in the PyFEM framework. It handles initialization of module properties and provides utility methods for logging and timing module execution.
The BaseModule automatically detects whether it’s a solver module and provides appropriate logging levels. It also manages nested property hierarchies from configuration objects.
- class BaseModule(props: Any)[source]
Bases:
objectBase class for all PyFEM modules.
This class provides common functionality for modules including: - Automatic detection of module type (solver vs. non-solver) - Property management from configuration objects - Consistent logging with timing information - Support for hierarchical property organization
- isSolver
True if this module is a solver, False otherwise.
- Type:
bool
- type
The class name of the module.
- Type:
str
- myProps
The properties dictionary for this module from the configuration.
- Parameters:
props – A properties object containing configuration. Can have nested attributes or a currentModule attribute specifying the module name.
- writeHeader(cycle: int | None = None) None[source]
Write a header message at the start of module execution.
Logs module name and step information. Solver modules use info-level logging with decorative separators, while non-solver modules use debug-level logging.
- Parameters:
cycle (int, optional) – The step/cycle number to include in the header. If provided, will be formatted as “step: {cycle}”. Defaults to None.
- Side Effects:
Records start time in self.t0 for later timing calculations
Logs to logger.info or logger.debug depending on module type
Write a footer message at the end of module execution.
Logs timing information for both the current step and total execution time. Solver modules use info-level logging, while non-solver modules use debug-level logging.
- Parameters:
globdat (Any) – Global data object containing startTime attribute for the overall simulation start time.
- Side Effects:
Logs step and total elapsed times via logger
Uses self.t0 (set by writeHeader) as start time reference