Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Repository Guidelines
# Generato

Generato is a Wolfram Language code generator that produces C/C++ from symbolic tensor expressions using xAct.
Wolfram Language code generator that produces C/C++ from symbolic tensor expressions using xAct.

## Running

Expand All @@ -13,22 +13,25 @@ Generato file1.wl file2.wl # Multiple files
## Architecture

### Core (src/)
- **Context.wl** - Global state via `$CurrentContext`
- **Generato.wl** - Package loader, imports modules in dependency order
- **Context.wl** - Global state via `$CurrentContext`, accessor generation
- **Basic.wl** - Config, tensor utilities, SetEQN/SetEQNDelayed
- **ParseMode.wl** - Phase management, WithMode for scoped settings
- **ParseMode.wl** - Phase management, `WithMode[{...}, body]` for scoped settings
- **Component.wl** - Tensor component to varlist mapping
- **Varlist.wl** - Tensor definitions via ParseVarlist
- **Interface.wl** - Public API (DefTensors, GridTensors, TileTensors, TempTensors, SetComponents, PrintEquations, PrintInitializations)
- **Interface.wl** - Public API: DefTensors, GridTensors, TileTensors, TempTensors, SetComponents, PrintEquations, PrintInitializations
- **BackendCommon.wl** - Shared backend utilities
- **Writefile.wl** - Output buffering (SetMainPrint/GetMainPrint)
- **stencils/FiniteDifferenceStencils.wl** - Finite difference stencil generation

### Backends (codes/)
Each implements `PrintComponentInitialization` and `PrintComponentEquation`:
- CarpetX.wl, CarpetXGPU.wl, CarpetXPointDesc.wl, Carpet.wl, AMReX.wl, Nmesh.wl

### Key Patterns
- **State**: All in `$CurrentContext`; use `WithMode[{...}, body]` for scoped settings
- **Two phases**: SetComp (map components) then PrintComp (generate code)
- **Two phases**: SetComp (map components) → PrintComp (generate code)
- **Equations**: Use `SetEQN` normally; use `SetEQNDelayed` when RHS contains `If` statements

## Tests

Expand All @@ -37,7 +40,7 @@ wolframscript -script test/AllTests.wl # All tests
wolframscript -script test/AllTests.wl --unit-only # Unit tests only
```

## Wolframscript Tips
## Tips

Shell escaping with backticks causes errors. Use pipe instead:
```bash
Expand Down