From ed50e3766476aaf94b9fb957e4373e83798b873a Mon Sep 17 00:00:00 2001 From: Mathieu Moalic Date: Tue, 24 Oct 2023 11:22:53 +0200 Subject: [PATCH] add individual automesh arguments --- README.md | 2 +- engine/mesh.go | 37 +++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 774de43d..cfdf633b 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ print(job["ref paper"]) - Reorder GUI elements - Dark mode GUI - Check and warns the user for unoptimized mesh -- `AutoMesh = True` will optimize the shape for you (this function slightly changes the size and number of cells while keeping the total size of the system constant) +- `AutoMeshx = True`,`AutoMeshy = True`and `AutoMeshz = True` will optimize the corresponding mesh axis for you (this function slightly changes the size and number of cells while keeping the total size of the system constant) - Add chunking support as per the [zarr](https://zarr.readthedocs.io/en/stable/) documentation with the functions: - `SaveAsChunk(q Quantity, name string, rchunks RequestedChunking)` - `AutoSaveAsChunk(q Quantity, name string, period float64, rchunks RequestedChunking)` diff --git a/engine/mesh.go b/engine/mesh.go index a3ea3e2c..3c4b3aa4 100644 --- a/engine/mesh.go +++ b/engine/mesh.go @@ -21,12 +21,16 @@ var ( PBCx int PBCy int PBCz int - AutoMesh bool + AutoMeshx bool + AutoMeshy bool + AutoMeshz bool globalmesh_ data.Mesh ) func init() { - DeclVar("AutoMesh", &AutoMesh, "") + DeclVar("AutoMeshx", &AutoMeshx, "") + DeclVar("AutoMeshy", &AutoMeshy, "") + DeclVar("AutoMeshz", &AutoMeshz, "") DeclVar("Tx", &Tx, "") DeclVar("Ty", &Ty, "") DeclVar("Tz", &Tz, "") @@ -77,15 +81,24 @@ func SmoothMesh() { LogOut("Original mesh: ") LogOut("Cell size: ", dx, dy, dz) LogOut("Grid Size: ", Nx, Ny, Nz) - NewNx := closestSevenSmooth(Nx) - NewNy := closestSevenSmooth(Ny) - NewNz := closestSevenSmooth(Nz) - dx := dx * float64(Nx) / float64(NewNx) - dy := dy * float64(Ny) / float64(NewNy) - dz := dz * float64(Nz) / float64(NewNz) - Nx = NewNx - Ny = NewNy - Nz = NewNz + var dx float64 + var dy float64 + var dz float64 + if AutoMeshx { + NewNx := closestSevenSmooth(Nx) + dx = dx * float64(Nx) / float64(NewNx) + Nx = NewNx + } + if AutoMeshy { + NewNy := closestSevenSmooth(Ny) + dy = dy * float64(Ny) / float64(NewNy) + Ny = NewNy + } + if AutoMeshz { + NewNz := closestSevenSmooth(Nz) + dz = dz * float64(Nz) / float64(NewNz) + Nz = NewNz + } LogOut("Smoothed mesh: ") LogOut("Cell size: ", dx, dy, dz) LogOut("Grid Size: ", Nx, Ny, Nz) @@ -153,7 +166,7 @@ func CreateMesh() { SetTiDiNi(&Tz, &dz, &Nz, "z") ValidateGridSize() ValidateCellSize() - if AutoMesh { + if AutoMeshx || AutoMeshy || AutoMeshz { SmoothMesh() } globalmesh_ = *data.NewMesh(Nx, Ny, Nz, dx, dy, dz, PBCx, PBCy, PBCz)