# Step 4: element-definition-storage ## Read First Read these files before editing: - `/AGENTS.md` - `/docs/AGENT_RULES.md` - `/docs/ADR.md` - `/docs/ARCHITECTURE.md` - `/docs/implementation-plans/domain-model-foundation-implementation-plan.md` - `/include/fesa/core/Domain.hpp` - `/include/fesa/core/Node.hpp` - `/include/fesa/core/ModelTypes.hpp` - `/tests/core/domain_storage_test.cpp` ## Task Add element definition storage without implementing element stiffness or MITC4 formulation. Allowed files: - Create `/include/fesa/core/ElementDefinition.hpp` - Modify `/include/fesa/core/Domain.hpp` - Modify `/src/core/Domain.cpp` - Modify `/tests/core/domain_storage_test.cpp` Required behavior: - `ElementDefinition` stores `ElementId`, type enum/string for `MITC4`, four `NodeId` connectivity entries, and a `PropertyId`. - `Domain::addElement(ElementDefinition)` inserts an element. - Duplicate element ids throw `std::invalid_argument`. - Element connectivity must contain exactly four node ids for the MITC4 definition. - Adding an element with a missing node id throws `std::invalid_argument`. - `Domain::findElement(ElementId)` returns pointer or `nullptr`. - `Domain::element(ElementId)` returns const reference or throws `std::out_of_range`. - `Domain::elementCount()` returns the stored element count. ## Tests To Write First Write failing tests before production changes: - Add an element with four existing nodes and retrieve connectivity in order. - Duplicate element id throws. - Element referencing a missing node throws. - Missing element lookup follows the `findElement` and `element` contracts. Run targeted CTest and verify RED before implementation. ## Acceptance Criteria Run: ```powershell cmake --build build/msvc-debug --config Debug ctest --test-dir build/msvc-debug --output-on-failure -C Debug -R domain python scripts/validate_workspace.py ``` Update `/phases/domain-model-foundation/index.json` step 4 with `completed`, `error`, or `blocked`. ## Do Not - Do not implement element stiffness, Jacobians, shape functions, sparse assembly, or solver behavior. - Do not add parser behavior.