Skip to content

Commit 6f0683a

Browse files
committed
outline of writer
1 parent c5b0fed commit 6f0683a

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

src/converter/TODO.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
TODO — Converter & Generator
2+
3+
1) Output refactor (modular writers)
4+
• Create src/converter/output/ with one file per case:
5+
• Writer.hpp (pure-virtual base)
6+
• WriterFactory.hpp/.cpp (string → writer)
7+
• Writer3DSMTM.cpp, Writer3DTM.cpp, Writer3DSM.cpp, … (one per gridType)
8+
• Move each giveXXXOutput(...) body from Grid into a dedicated Writer* class.
9+
• In Grid::giveOutput(name): auto w = WriterFactory::make(gridType); w->write(*this, name);
10+
• Keep legacy filenames/format intact (byte-for-byte if possible).
11+
12+
2) Standalone test harness (separate from OOFEM tests)
13+
• Add tests/ with structure:
14+
• tests/data/ (tiny inputs: minimal, periodic, cylinder, edge-cases)
15+
• tests/generator/ & tests/converter/ (test code)
16+
• Use CTest (already in CMake):
17+
• Add option(USE_GEN_TESTS ON) / option(USE_CONV_TESTS ON)
18+
• add_test(NAME gen_minimal COMMAND generator.exec tests/data/minimal.in)
19+
• Post-run scripts to verify:
20+
• file exists (e.g., oofem.in, .vtu)
21+
• line-count / regex sanity checks (no “undefined id”, etc.)
22+
• Provide a tiny golden-output compare:
23+
• tests/scripts/diff_trim.py (ignores whitespace, float tol via regex)
24+
25+
3) CI & build quality
26+
• GitHub Actions workflow:
27+
• matrix: {macOS, ubuntu} (release+asan)
28+
• cache Homebrew/apt deps (qhull)
29+
• run CTest and upload artifacts on failure
30+
• Add ASan/UBSan config:
31+
• -fsanitize=address,undefined -fno-omit-frame-pointer -g
32+
• CMake option: -DUSE_ASAN=ON
33+
34+
4) Input parsing robustness
35+
• Case-insensitive keywords (strcasecmp path):
36+
• Normalize to lowercase at parse boundary.
37+
• Ensure IntArray::resizeWithValues used where appending is intended.
38+
• Replace remaining raw fopen/printf with converter::fopen_or_die & std::string.
39+
40+
5) Performance checkpoints
41+
• Add timing macros around: point generation, octree insert, neighbor search, file write.
42+
• Optional: skip mirroring for far-boundary candidates (config flag).
43+
44+
6) Code health & safety
45+
• Ensure every new-allocated object is owned by a single container and freed in Grid dtor (already mostly done).
46+
• Verify GridLocalizer::init(...) is called exactly once and after bbox is valid.
47+
• Replace any growTo remnants with resize (or helpers ensure_size1).
48+
• Avoid shadowed virtuals: match base signatures (const-correctness, params).
49+
50+
7) Docs (lightweight for now)
51+
• Create docs/ with:
52+
• README.md (build/run, minimal examples)
53+
• inputs.md (keyword list, case-insensitive note, examples)
54+
• dev.md (layout, how Writers work, test rules)
55+
56+
8) Developer helpers
57+
• scripts/format.sh (uncrustify / clang-format with updated options)
58+
• scripts/run_gen.sh, scripts/run_conv.sh (with caffeinate on macOS)
59+
• scripts/profile.sh (simple perf/instruments/time wrapper)

src/converter/output/writer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
#include <string>
3+
class Grid;
4+
struct Writer {
5+
virtual ~Writer() = default;
6+
virtual void write(const Grid& grid, const std::string& baseName) = 0;
7+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
#include <memory>
3+
#include <string>
4+
struct Writer;
5+
std::unique_ptr<Writer> makeWriter(const std::string& gridTypeLower);

0 commit comments

Comments
 (0)