Skip to content

Commit

Permalink
add individual automesh arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuMoalic committed Oct 24, 2023
1 parent 22bd7a5 commit ed50e37
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down
37 changes: 25 additions & 12 deletions engine/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ed50e37

Please sign in to comment.