Skip to content

Commit 46d6387

Browse files
committed
LaMEM_io.jl
1 parent d18db87 commit 46d6387

File tree

5 files changed

+63
-63
lines changed

5 files changed

+63
-63
lines changed

docs/src/man/lamem.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ The routines provided here have the following functionality:
1010
- Read a LaMEM timestep
1111

1212
```@docs
13-
GeophysicalModelGenerator.ReadLaMEM_InputFile
14-
GeophysicalModelGenerator.GetProcessorPartitioning
15-
GeophysicalModelGenerator.Save_LaMEMTopography
16-
GeophysicalModelGenerator.Save_LaMEMMarkersParallel
17-
GeophysicalModelGenerator.ReadData_PVTR
13+
GeophysicalModelGenerator.readLaMEM_InputFile
14+
GeophysicalModelGenerator.getProcessorPartitioning
15+
GeophysicalModelGenerator.save_LaMEMTopography
16+
GeophysicalModelGenerator.save_LaMEMMarkersParallel
17+
GeophysicalModelGenerator.readData_PVTR
1818
GeophysicalModelGenerator.LaMEM_grid
19-
GeophysicalModelGenerator.CreatePartitioningFile
19+
GeophysicalModelGenerator.createPartitioningFile
2020
```

src/LaMEM_io.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ using Interpolations
88
# These are routines that help to create a LaMEM marker files from a ParaviewData structure, which can be used to perform geodynamic simulations
99
# We also include routines with which we can read LaMEM *.pvtr files into julia
1010

11-
export LaMEM_grid, ReadLaMEM_InputFile
12-
export Save_LaMEMMarkersParallel, Save_LaMEMTopography
13-
export GetProcessorPartitioning, ReadData_VTR, ReadData_PVTR, CreatePartitioningFile
11+
export LaMEM_grid, readLaMEM_InputFile
12+
export save_LaMEMMarkersParallel, save_LaMEMTopography
13+
export getProcessorPartitioning, readData_VTR, readData_PVTR, createPartitioningFile
1414

1515
"""
1616
Structure that holds information about the LaMEM grid (usually read from an input file).
@@ -164,14 +164,14 @@ end
164164

165165

166166
"""
167-
Grid::LaMEM_grid = ReadLaMEM_InputFile(file, args::Union{String,Nothing}=nothing)
167+
Grid::LaMEM_grid = readLaMEM_InputFile(file, args::Union{String,Nothing}=nothing)
168168
169169
Parses a LaMEM input file and stores grid information in the `Grid` structure.
170170
Optionally, you can pass LaMEM command-line arguments as well.
171171
172172
# Example 1
173173
```julia
174-
julia> Grid = ReadLaMEM_InputFile("SaltModels.dat")
174+
julia> Grid = readLaMEM_InputFile("SaltModels.dat")
175175
LaMEM Grid:
176176
nel : (32, 32, 32)
177177
marker/cell : (3, 3, 3)
@@ -183,7 +183,7 @@ z ϵ [-2.0 : 0.0]
183183
184184
# Example 2 (with command-line arguments)
185185
```julia
186-
julia> Grid = ReadLaMEM_InputFile("SaltModels.dat", args="-nel_x 64 -coord_x -4,4")
186+
julia> Grid = readLaMEM_InputFile("SaltModels.dat", args="-nel_x 64 -coord_x -4,4")
187187
LaMEM Grid:
188188
nel : (64, 32, 32)
189189
marker/cell : (3, 3, 3)
@@ -194,7 +194,7 @@ LaMEM Grid:
194194
```
195195
196196
"""
197-
function ReadLaMEM_InputFile(file; args::Union{String,Nothing}=nothing )
197+
function readLaMEM_InputFile(file; args::Union{String,Nothing}=nothing )
198198

199199
# read information from file
200200
nmark_x = ParseValue_LaMEM_InputFile(file,"nmark_x",Int64, args=args);
@@ -368,34 +368,34 @@ function Base.show(io::IO, d::LaMEM_grid)
368368
end
369369

370370
"""
371-
Save_LaMEMMarkersParallel(Grid::CartData; PartitioningFile=empty, directory="./markers", verbose=true, is64bit=false)
371+
save_LaMEMMarkersParallel(Grid::CartData; PartitioningFile=empty, directory="./markers", verbose=true, is64bit=false)
372372
373373
Saves a LaMEM marker file from the `CartData` structure `Grid`. It must have a field called `Phases`, holding phase information (as integers) and optionally a field `Temp` with temperature info.
374374
It is possible to provide a LaMEM partitioning file `PartitioningFile`. If not, output is assumed to be for one processor. By default it is assumed that the partitioning file was generated on a 32bit PETSc installation. If `Int64` was used instead, set the flag.
375375
376-
The size of `Grid` should be consistent with what is provided in the LaMEM input file. In practice, the size of the mesh can be retrieved from a LaMEM input file using `ReadLaMEM_InputFile`.
376+
The size of `Grid` should be consistent with what is provided in the LaMEM input file. In practice, the size of the mesh can be retrieved from a LaMEM input file using `readLaMEM_InputFile`.
377377
378378
# Example
379379
380380
```
381-
julia> Grid = ReadLaMEM_InputFile("LaMEM_input_file.dat")
381+
julia> Grid = readLaMEM_InputFile("LaMEM_input_file.dat")
382382
julia> Phases = zeros(Int32,size(Grid.X));
383383
julia> Temp = ones(Float64,size(Grid.X));
384384
julia> Model3D = CartData(Grid, (Phases=Phases,Temp=Temp))
385-
julia> Save_LaMEMMarkersParallel(Model3D)
385+
julia> save_LaMEMMarkersParallel(Model3D)
386386
Writing LaMEM marker file -> ./markers/mdb.00000000.dat
387387
```
388388
If you want to create a LaMEM input file for multiple processors:
389389
```
390-
julia> Save_LaMEMMarkersParallel(Model3D, PartitioningFile="ProcessorPartitioning_4cpu_1.2.2.bin")
390+
julia> save_LaMEMMarkersParallel(Model3D, PartitioningFile="ProcessorPartitioning_4cpu_1.2.2.bin")
391391
Writing LaMEM marker file -> ./markers/mdb.00000000.dat
392392
Writing LaMEM marker file -> ./markers/mdb.00000001.dat
393393
Writing LaMEM marker file -> ./markers/mdb.00000002.dat
394394
Writing LaMEM marker file -> ./markers/mdb.00000003.dat
395395
```
396396
397397
"""
398-
function Save_LaMEMMarkersParallel(Grid::CartData; PartitioningFile=empty, directory="./markers", verbose=true, is64bit=false)
398+
function save_LaMEMMarkersParallel(Grid::CartData; PartitioningFile=empty, directory="./markers", verbose=true, is64bit=false)
399399

400400
x = ustrip.(Grid.x.val[:,1,1]);
401401
y = ustrip.(Grid.y.val[1,:,1]);
@@ -425,7 +425,7 @@ function Save_LaMEMMarkersParallel(Grid::CartData; PartitioningFile=empty, direc
425425
else
426426
Nprocx,Nprocy,Nprocz,
427427
xc,yc,zc,
428-
nNodeX,nNodeY,nNodeZ = GetProcessorPartitioning(PartitioningFile, is64bit=is64bit)
428+
nNodeX,nNodeY,nNodeZ = getProcessorPartitioning(PartitioningFile, is64bit=is64bit)
429429
if verbose
430430
@show Nprocx,Nprocy,Nprocz, xc,yc,zc, nNodeX,nNodeY,nNodeZ
431431
end
@@ -557,13 +557,13 @@ function PetscBinaryWrite_Vec(filename, A)
557557
end
558558

559559
"""
560-
nProcX,nProcY,nProcZ, xc,yc,zc, nNodeX,nNodeY,nNodeZ = GetProcessorPartitioning(filename; is64bit=false)
560+
nProcX,nProcY,nProcZ, xc,yc,zc, nNodeX,nNodeY,nNodeZ = getProcessorPartitioning(filename; is64bit=false)
561561
562562
Reads a LaMEM processor partitioning file, used to create marker files, and returns the parallel layout.
563563
By default this is done for a 32bit PETSc installation, which will fail if you actually use a 64bit version.
564564
565565
"""
566-
function GetProcessorPartitioning(filename; is64bit=false)
566+
function getProcessorPartitioning(filename; is64bit=false)
567567

568568
if is64bit
569569
typ=Int64
@@ -606,12 +606,12 @@ end
606606

607607

608608
"""
609-
coord, Data_3D_Arrays, Name_Vec = ReadData_VTR(fname)
609+
coord, Data_3D_Arrays, Name_Vec = readData_VTR(fname)
610610
611611
Reads a VTR (structured grid) VTK file `fname` and extracts the coordinates, data arrays and names of the data.
612612
In general, this only contains a piece of the data, and one should open a `*.pvtr` file to retrieve the full data
613613
"""
614-
function ReadData_VTR(fname, FullSize)
614+
function readData_VTR(fname, FullSize)
615615
file = open(fname, "r")
616616

617617
header = true
@@ -815,13 +815,13 @@ function ReadBinaryData(file::IOStream, start_bin::Int64, Offset::Int64, BytesTo
815815
end
816816

817817
"""
818-
Data::ParaviewData = ReadData_PVTR(fname, dir)
818+
Data::ParaviewData = readData_PVTR(fname, dir)
819819
820820
Reads a parallel, rectilinear, `*.vts` file with the name `fname` and located in `dir` and create a 3D `Data` struct from it.
821821
822822
# Example
823823
```julia
824-
julia> Data = ReadData_PVTR("Haaksbergen.pvtr", "./Timestep_00000005_3.35780500e-01/")
824+
julia> Data = readData_PVTR("Haaksbergen.pvtr", "./Timestep_00000005_3.35780500e-01/")
825825
ParaviewData
826826
size : (33, 33, 33)
827827
x ϵ [ -3.0 : 3.0]
@@ -830,7 +830,7 @@ ParaviewData
830830
fields: (:phase, :density, :visc_total, :visc_creep, :velocity, :pressure, :temperature, :dev_stress, :strain_rate, :j2_dev_stress, :j2_strain_rate, :plast_strain, :plast_dissip, :tot_displ, :yield, :moment_res, :cont_res)
831831
```
832832
"""
833-
function ReadData_PVTR(fname, dir)
833+
function readData_PVTR(fname, dir)
834834
file = open(joinpath(dir,fname), "r")
835835

836836
header = true
@@ -860,9 +860,9 @@ function ReadData_PVTR(fname, dir)
860860
fname_piece = line_strip[1:id_end]
861861

862862
if num_data_sets==1
863-
coord_x, coord_y, coord_z, Data_3D, Names, NumComp, ix,iy,iz = ReadData_VTR(joinpath(dir,fname_piece), FullSize);
863+
coord_x, coord_y, coord_z, Data_3D, Names, NumComp, ix,iy,iz = readData_VTR(joinpath(dir,fname_piece), FullSize);
864864
else
865-
coord_x1, coord_y1, coord_z1, Data_3D1, Names, NumComp, ix,iy,iz = ReadData_VTR(joinpath(dir,fname_piece), FullSize);
865+
coord_x1, coord_y1, coord_z1, Data_3D1, Names, NumComp, ix,iy,iz = readData_VTR(joinpath(dir,fname_piece), FullSize);
866866
coord_x[ix] = coord_x1[ix];
867867
coord_y[iy] = coord_y1[iy];
868868
coord_z[iz] = coord_z1[iz];
@@ -925,11 +925,11 @@ function ReadData_PVTR(fname, dir)
925925
end
926926

927927
"""
928-
Save_LaMEMTopography(Topo::CartData, filename::String)
928+
save_LaMEMTopography(Topo::CartData, filename::String)
929929
930930
This writes a topography file `Topo` for use in LaMEM, which should have size `(nx,ny,1)` and contain the field `:Topography`
931931
"""
932-
function Save_LaMEMTopography(Topo::CartData, filename::String)
932+
function save_LaMEMTopography(Topo::CartData, filename::String)
933933

934934
if (size(Topo.z.val,3) != 1)
935935
error("Not a valid `CartData' Topography file (size in 3rd dimension should be 1)")
@@ -972,14 +972,14 @@ function Save_LaMEMTopography(Topo::CartData, filename::String)
972972
end
973973

974974
"""
975-
CreatePartitioningFile(LaMEM_input::String, NumProc::Int64; LaMEM_dir::String=pwd(), LaMEM_options::String="", MPI_dir="", verbose=true)
975+
createPartitioningFile(LaMEM_input::String, NumProc::Int64; LaMEM_dir::String=pwd(), LaMEM_options::String="", MPI_dir="", verbose=true)
976976
977977
This executes LaMEM for the input file `LaMEM_input` & creates a parallel partitioning file for `NumProc` processors.
978978
The directory where the LaMEM binary is can be specified; if not it is assumed to be in the current directory.
979979
Likewise for the `mpiexec` directory (if not specified it is assumed to be available on the command line).
980980
981981
"""
982-
function CreatePartitioningFile(LaMEM_input::String,NumProc::Int64; LaMEM_dir::String=pwd(), LaMEM_options="", MPI_dir="", verbose=true)
982+
function createPartitioningFile(LaMEM_input::String,NumProc::Int64; LaMEM_dir::String=pwd(), LaMEM_options="", MPI_dir="", verbose=true)
983983

984984
# Create string to execute LaMEM
985985
mpi_str = MPI_dir*"mpiexec -n $(NumProc) "

src/Setup_geometry.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export addBox!, addSphere!, addEllipsoid!, addCylinder!, addLayer!, addPolygon!
3737
Parameters
3838
====
3939
- Phase - Phase array (consistent with Grid)
40-
- Grid - grid structure (usually obtained with ReadLaMEM_InputFile, but can also be other grid types)
40+
- Grid - grid structure (usually obtained with readLaMEM_InputFile, but can also be other grid types)
4141
- stripAxes - sets the axis for which we want the stripes. Default is (1,1,0) i.e. X, Y and not Z
4242
- stripeWidth - width of the stripe
4343
- stripeSpacing - space between two stripes
@@ -53,7 +53,7 @@ export addBox!, addSphere!, addEllipsoid!, addCylinder!, addLayer!, addPolygon!
5353
5454
Example: Box with striped phase and constant temperature & a dip angle of 10 degrees:
5555
```julia
56-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
56+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
5757
LaMEM Grid:
5858
nel : (32, 32, 32)
5959
marker/cell : (3, 3, 3)
@@ -155,7 +155,7 @@ Examples
155155
156156
Example 1) Box with constant phase and temperature & a dip angle of 10 degrees:
157157
```julia
158-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
158+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
159159
LaMEM Grid:
160160
nel : (32, 32, 32)
161161
marker/cell : (3, 3, 3)
@@ -174,7 +174,7 @@ julia> write_Paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
174174
175175
Example 2) Box with halfspace cooling profile
176176
```julia
177-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
177+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
178178
julia> Phases = zeros(Int32, size(Grid.X));
179179
julia> Temp = zeros(Float64, size(Grid.X));
180180
julia> addBox!(Phases,Temp,Grid, xlim=(0,500), zlim=(-50,0), phase=ConstantPhase(3), DipAngle=10, T=ConstantTemp(1000))
@@ -244,7 +244,7 @@ Parameters
244244
====
245245
- `Phase` - Phase array (consistent with Grid)
246246
- `Temp` - Temperature array (consistent with Grid)
247-
- `Grid` - grid structure (usually obtained with ReadLaMEM_InputFile, but can also be other grid types)
247+
- `Grid` - grid structure (usually obtained with readLaMEM_InputFile, but can also be other grid types)
248248
- `xlim` - left/right coordinates of box
249249
- `ylim` - front/back coordinates of box
250250
- `zlim` - bottom/top coordinates of box
@@ -257,7 +257,7 @@ Examples
257257
258258
Example 1) Layer with constant phase and temperature
259259
```julia
260-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
260+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
261261
LaMEM Grid:
262262
nel : (32, 32, 32)
263263
marker/cell : (3, 3, 3)
@@ -276,7 +276,7 @@ julia> write_Paraview(Model3D,"LaMEM_ModelSetup") # Save model to para
276276
277277
Example 2) Box with halfspace cooling profile
278278
```julia
279-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
279+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
280280
julia> Phases = zeros(Int32, size(Grid.X));
281281
julia> Temp = zeros(Float64, size(Grid.X));
282282
julia> addLayer!(Phases,Temp,Grid, zlim=(-50,0), phase=ConstantPhase(3), T=HalfspaceCoolingTemp())
@@ -343,7 +343,7 @@ Parameters
343343
====
344344
- Phase - Phase array (consistent with Grid)
345345
- Temp - Temperature array (consistent with Grid)
346-
- Grid - LaMEM grid structure (usually obtained with ReadLaMEM_InputFile)
346+
- Grid - LaMEM grid structure (usually obtained with readLaMEM_InputFile)
347347
- cen - center coordinates of sphere
348348
- radius - radius of sphere
349349
- phase - specifies the phase of the box. See `ConstantPhase()`,`LithosphericPhases()`
@@ -355,7 +355,7 @@ Example
355355
356356
Sphere with constant phase and temperature:
357357
```julia
358-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
358+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
359359
LaMEM Grid:
360360
nel : (32, 32, 32)
361361
marker/cell : (3, 3, 3)
@@ -407,7 +407,7 @@ Parameters
407407
====
408408
- Phase - Phase array (consistent with Grid)
409409
- Temp - Temperature array (consistent with Grid)
410-
- Grid - LaMEM grid structure (usually obtained with ReadLaMEM_InputFile)
410+
- Grid - LaMEM grid structure (usually obtained with readLaMEM_InputFile)
411411
- cen - center coordinates of sphere
412412
- axes - semi-axes of ellipsoid in X,Y,Z
413413
- Origin - the origin, used to rotate the box around. Default is the left-front-top corner
@@ -422,7 +422,7 @@ Example
422422
423423
Ellipsoid with constant phase and temperature, rotated 90 degrees and tilted by 45 degrees:
424424
```julia
425-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
425+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
426426
LaMEM Grid:
427427
nel : (32, 32, 32)
428428
marker/cell : (3, 3, 3)
@@ -490,7 +490,7 @@ Parameters
490490
====
491491
- Phase - Phase array (consistent with Grid)
492492
- Temp - Temperature array (consistent with Grid)
493-
- Grid - Grid structure (usually obtained with ReadLaMEM_InputFile)
493+
- Grid - Grid structure (usually obtained with readLaMEM_InputFile)
494494
- base - center coordinate of bottom of cylinder
495495
- cap - center coordinate of top of cylinder
496496
- radius - radius of the cylinder
@@ -503,7 +503,7 @@ Example
503503
504504
Cylinder with constant phase and temperature:
505505
```julia
506-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
506+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
507507
LaMEM Grid:
508508
nel : (32, 32, 32)
509509
marker/cell : (3, 3, 3)
@@ -583,7 +583,7 @@ Parameters
583583
====
584584
- `Phase` - Phase array (consistent with Grid)
585585
- `Temp` - Temperature array (consistent with Grid)
586-
- `Grid` - Grid structure (usually obtained with ReadLaMEM_InputFile)
586+
- `Grid` - Grid structure (usually obtained with readLaMEM_InputFile)
587587
- `xlim` - `x`-coordinate of the polygon points, same ordering as zlim, number of points unlimited
588588
- `ylim` - `y`-coordinate, limitation in length possible (two values (start and stop))
589589
- `zlim` - `z`-coordinate of the polygon points, same ordering as xlim, number of points unlimited
@@ -596,7 +596,7 @@ Example
596596
Polygon with constant phase and temperature:
597597
598598
```julia
599-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
599+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
600600
LaMEM Grid:
601601
nel : (32, 32, 32)
602602
marker/cell : (3, 3, 3)
@@ -677,7 +677,7 @@ Creates a generic volcano topography (cones and truncated cones)
677677
678678
Parameters
679679
====
680-
- Grid - LaMEM grid (created by ReadLaMEM_InputFile)
680+
- Grid - LaMEM grid (created by readLaMEM_InputFile)
681681
- center - x- and -coordinates of center of volcano
682682
- height - height of volcano
683683
- radius - radius of volcano
@@ -694,7 +694,7 @@ Example
694694
695695
Cylinder with constant phase and temperature:
696696
```julia
697-
julia> Grid = ReadLaMEM_InputFile("test_files/SaltModels.dat")
697+
julia> Grid = readLaMEM_InputFile("test_files/SaltModels.dat")
698698
LaMEM Grid:
699699
nel : (32, 32, 32)
700700
marker/cell : (3, 3, 3)
@@ -1209,7 +1209,7 @@ Parameters
12091209
- Z - Vertical coordinate array (consistent with Phase and Temp)
12101210
- s - LithosphericPhases
12111211
- Ztop - Vertical coordinate of top of model box
1212-
- Grid - Grid structure (usually obtained with ReadLaMEM_InputFile)
1212+
- Grid - Grid structure (usually obtained with readLaMEM_InputFile)
12131213
"""
12141214
function compute_Phase(Phase, Temp, X, Y, Z, s::LithosphericPhases; Ztop=0)
12151215
@unpack Layers, Phases, Tlab = s

0 commit comments

Comments
 (0)