How mvarga6/lcefe works
1. This repository is a CUDA/C++ scientific simulation code for liquid crystal elastomer finite element electrodynamics. The core architecture is a CPU orchestration layer that prepares mesh/material state, and a GPU compute layer that advances the simulation over time.
2. The main executable lives in src/main.cpp and is driven by runtime parameters from either command-line arguments or a parameter file. include/clparse.h, src/clparse.cpp, and the bundled extlib/cxxopts provide option parsing; include/parameters_reader.h / src/parameters_reader.cpp handle parameter-file input, including JSON via the bundled extlib/jsmn.
3. Mesh input is an important boundary. The repo contains Gmsh geometry sources in geo/ and many prebuilt meshes in Mesh/. extlib/gmsh_io supports reading Gmsh mesh data, and the README points to getmesh.h as the entry point for loading and reordering the mesh (get_mesh, gorder_tet).
4. CPU-side mesh representation is centered on NodeArray and TetArray in include/classstruct.h, with implementations in src/node_array.cpp and src/tet_array.cpp. These structures are used to optimize mesh ordering and organize node/tetrahedron data before it is transferred to the device.
5. A distinct packing boundary exists between host data and GPU data. The README calls out packdata.h as the place where mesh and initial conditions are copied into GPU-friendly arrays. Related headers like include/pointer.h, include/device_helpers.h, and include/kernel_constants.h suggest explicit management of device buffers and constants.
6. The physics layer is separated from orchestration. include/physics_model.h, include/physics_kernels.h, src/physics_model.cpp, src/physics_kernels.cpp, and src/selinger_physics.cpp encapsulate the material and force models, including the liquid-crystal coupling terms described in the README (density, alpha, cxxxx, cxxyy, cxyxy).
7. The simulation loop is coordinated by include/simulation_runner.h and src/simulation_runner.cpp, with the README explicitly noting rundynamics.h as the driver of the full dynamics loop. This layer is responsible for stepping time, invoking GPU kernels, and managing when output is produced.
8. GPU computation is split into at least two major kernels. The force path is described in the README as gpuForce.h, which depends on forcecalc.h, read_dev_data.h, getQ.h, and sendForce.h. The update path is updateKernel.h, which uses update_r.h and sumForce.h to integrate node positions from accumulated forces.
9. Director-field and energy calculations are first-class pieces of the model. Headers like include/director_field.h, include/getQ.h, include/getEnergy.h, include/getSurface.h, include/sumForce.h, and include/getAs.h indicate that the simulation repeatedly derives per-element director orientation, energy, surface terms, and force accumulation from the mesh state.
10. Output, logging, and diagnostics are separate from the solver. include/output_writer.h, include/printVTKframe.h, and include/parameters_writer.h suggest file-based results and visualization export, while include/logger.h, src/logger.cpp, src/console_logger.cpp, and include/performance_recorder.h / src/performance_recorder.cpp handle runtime logging and timing. The Performance/ directory stores timing data.
11. The repository is organized for experimentation rather than serving as a library. params/ contains scenario presets such as WareCross.json, aisin.json, and thinfilm4.json; scripts/ contains shell and job scripts for running angle, intensity, and rate experiments; and bin/printgpuinfo plus gpuinfo.cu indicate GPU capability inspection as part of the workflow.
12. legacy/ contains older implementations of mesh, force, and run-dynamics logic, which suggests the current codebase evolved from an earlier design but keeps historical code around for reference. For architecture diagrams, treat src/ + include/ as the active pipeline, Mesh/ + geo/ as input assets, params/ and scripts/ as experiment control, and Performance//output writers as the observation layer.
Main entry points: simulation_runner.cpp Simulation run · parameters_reader.cpp Param reader · pointer.h Pack data · main.cpp Main
Components 18
Active solver
Current CPU/GPU simulation pipeline in src/ and include/
- Main · Program entrypoint and startup orchestration
src/main.cpp - CLI parse · Command-line option parsing and parameter-file selection
src/clparse.cpp - Param reader · Reads simulation parameter files including JSON
src/parameters_reader.cpp - Mesh IO · Loads and reorders mesh data from Gmsh sources
include/getgmsh.h - Mesh arrays · CPU-side node and tetrahedron containers
include/classstruct.h - Mesh ops · Mesh representation and ordering helpers
src/mesh.cpp - Pack data · Prepares mesh and initial conditions for GPU transfer
include/pointer.h - Physics model · Material parameters and continuum model definitions
include/physics_model.h - Director field · Derives director orientation and related per-element state
include/director_field.h - Force path · Computes forces from field, energy, and surface terms
include/physics_kernels.h - Update kernel · Integrates positions from accumulated forces
include/updateKernel.h - Simulation run · Coordinates the full dynamics loop and kernel dispatch
src/simulation_runner.cpp
Inputs
Mesh assets and runtime parameter presets
- Mesh assets · Prebuilt meshes and geometry sources used for simulation setup
Mesh/SphericalShell1.msh - Scenarios · Preset experiment parameter files
params/WareCross.json
Output and diagnostics
Logging, timing, and exported results
- Output writer · Writes simulation outputs and visualization frames
include/output_writer.h - Logger · Runtime logging and console reporting
src/logger.cpp - Timing · Records and stores performance measurements
src/performance_recorder.cpp
Legacy layer
Older implementation kept for reference
- Legacy solver · Older mesh, packing, force, and dynamics implementation
legacy/rundynamics.h
Connections 19
- Main → CLI parse: reads args · Startup pulls runtime options from the command line
- Main → Param reader: loads config · Main initializes simulation parameters from file input
- CLI parse → Param reader: selects file · CLI can point to a parameter preset or override input
- Param reader → Simulation run: builds run · Parsed parameters feed the simulation runner
- Mesh assets → Mesh IO: provide mesh · Geometry and mesh files are the source boundary for loading
- Mesh IO → Mesh arrays: fills arrays · Imported mesh is organized into node and tetrahedron storage
- Mesh arrays → Mesh ops: processed by · Host mesh structures are optimized and reordered
- Mesh ops → Pack data: prepared for device · Processed mesh state is packed for GPU consumption
- Scenarios → Param reader: preset input · Scenario JSON files are read by the parameter loader
- Pack data → Physics model: attaches fields · Packed device data is combined with material model parameters
- Physics model → Director field: drives field · Physics model informs director-field calculations
- Director field → Force path: feeds state · Director orientation contributes to force and energy evaluation
- Force path → Update kernel: accumulates force · Force computation supplies inputs for the update kernel
- Update kernel → Simulation run: advances step · Kernel integration is controlled by the simulation loop
- Simulation run → Output writer: writes results · Time stepping triggers file output and visualization export
- Simulation run → Logger: logs run · Runner emits runtime diagnostics and status messages
- Simulation run → Timing: records timing · Execution phases are measured for performance tracking
- Legacy solver → Pack data: historical precursor · Legacy packing logic shows the older host-to-device boundary
- Legacy solver → Simulation run: historical precursor · Legacy run-dynamics code maps to the current simulation loop