# Core structure
The core code is everything MoCSI does between reading your configuration and writing the output. Four systems make up the architecture:
Behind the scenes, shared infrastructure — the chain system, the module factory, abstract base classes, IO helpers — ties these four systems together. Most users don't interact with it directly; contributors do. The per-timestep flow is shown below:
## Grid creation
Despite currently only supporting one-dimensional equations, the grid creation offers many capabilities. It happens in two stages: first the bounding surface is created, then the depth discretization starting from that surface is performed.
The default case is a single-facet bounding surface (a true one-dimensional model). If VTK is present on the user's machine, a path to a shape model in any VTK-supported file type can be passed and the shape model is loaded as the bounding surface.
For the depth discretization, the user can specify either the element length or the element count and maximum depth for uniform meshes. For non-uniform depth discretization, the user supplies a `.csv` file containing the node depths.
After both stages complete, the code creates the FEM elements to fill the given specification and assembles the global matrices. Implementation details and the currently available element types are described in the [FEM section](mathematical_background/finite_element_method).
## Simulation class
The main functionality and structure of MoCSI lives in the simulation class (often referred to as `Sim` / `SimClass` in the documentation). It owns the main simulation loop and the map object storing all field variables. For most applications the default simulation class yields satisfying results. If the default is inadequate for your use case, a custom simulation class with a custom main loop can be written by inheriting from the abstract base simulation class.
## Solver
Currently the only available solver is the [Tridiagonal Matrix Algorithm](mathematical_background/tdma_solver). Every one-dimensional discretization MoCSI currently supports produces a tridiagonal global matrix. For multi-facet simulations, MoCSI still builds one global matrix, with each one-dimensional facet occupying an independent block on the diagonal.
## Snapshots
MoCSI can create snapshots after a simulation and load them when starting a new one. Snapshots are meant as complete restoration points so simulations can be run piecewise. A snapshot file contains the final temperature field plus every entry in both the simulation `.ini` and the module `.ini` files — which also makes them useful as a record of exactly how a simulation was configured.