Skip to content

Non-cubic voxel field #11

Closed
Closed

Description

@jameslehoux

Anistropic voxels are sometimes used for datasets. It would be useful for OpenImpala to be able to solve on these non-cubic fields. This would require the re-writing part of the cell flux kernal to allow for different sized walls.


Migrated from original repository: kramergroup#30

Activity

  1. jameslehoux commented on Feb 27, 2026

    @jameslehoux
    Author

    Update on Anisotropic Grid Support in TortuosityHypre

    (Status as of 2025-04-24)

    This update summarizes the current status and required work to fully support non-cubic voxels (anisotropic grids where dx, dy, dz cell dimensions may differ) within the TortuosityHypre class.

    Current Status:

    • ✅ Matrix Setup: The C++ code (setupMatrixEquation) correctly retrieves grid spacings (dx, dy, dz) from the amrex::Geometry object. It calculates the necessary dxinv_sq ($[1/dx^2, 1/dy^2, 1/dz^2]$) array and correctly passes it to the Fortran kernel tortuosity_fillmtx. The Fortran kernel, in turn, correctly utilizes dxinv_sq to assemble the anisotropic Laplacian matrix (A) and RHS (b) for the HYPRE solver.

    Required Updates / TODO:

    The primary remaining task is to modify the post-processing calculations performed after the potential field ($\phi$) is solved by HYPRE. These calculations currently might implicitly assume cubic voxels. They need explicit handling of potentially different dx, dy, dz:

    • Gradient Calculation ($\nabla \phi$):
      • Ensure all finite difference formulas for gradient components explicitly use the correct spacing (dx, dy, or dz) in the denominator based on the derivative direction (e.g., (phi[i+1] - phi[i-1]) / (2*dx)).
    • Flux Calculation & Integration:
      • Physical flux density calculations ($J = -\sigma \nabla \phi$) rely on the correctly calculated gradient.
      • Calculating total flux through faces requires multiplying the normal flux density component by the correct face area:
        • X-face area: dy * dz
        • Y-face area: dx * dz
        • Z-face area: dx * dy
      • This is crucial for functions like global_fluxes().
    • Averaging / Normalization:
      • Volume averages or integrations must use the correct voxel volume: V = dx * dy * dz.
      • Calculations involving the physical length of the domain must use the appropriate dimension multiplied by the number of cells (e.g., total X-length Lx = Nx * dx).
    • Key Affected Functions:
      • global_fluxes() (requires correct gradients and face areas).
      • value() (requires correct normalization, potentially using results from global_fluxes or performing its own averaging).
      • Any other internal helper functions involved in these post-processing steps.

    Next Steps:

    1. Audit the C++ code, focusing on global_fluxes(), value(), and related functions, to identify all locations performing the calculations listed above.
    2. Modify these calculations to explicitly use dx, dy, and dz obtained from the m_geom object.
    3. Develop and add test cases specifically using anisotropic grids to validate the implementation.
  2. jameslehoux commented on Nov 17, 2026

    @jameslehoux
    Author

    Resolved in #304 and shipped in v4.6.0: non-cubic / anisotropic voxel spacing (dx, dy, dz) is now supported end-to-end across C++ (TortuosityHypre, TortuosityMLMG, EffectiveDiffusivityHypre, SpecificSurfaceArea), Python (voxel_size=(dz, dy, dx)), the pure-Python fallback solver, and the CLI (--voxel-size DX DY DZ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions