@@ -8,9 +8,9 @@ using Interpolations
8
8
# These are routines that help to create a LaMEM marker files from a ParaviewData structure, which can be used to perform geodynamic simulations
9
9
# We also include routines with which we can read LaMEM *.pvtr files into julia
10
10
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
14
14
15
15
"""
16
16
Structure that holds information about the LaMEM grid (usually read from an input file).
@@ -164,14 +164,14 @@ end
164
164
165
165
166
166
"""
167
- Grid::LaMEM_grid = ReadLaMEM_InputFile (file, args::Union{String,Nothing}=nothing)
167
+ Grid::LaMEM_grid = readLaMEM_InputFile (file, args::Union{String,Nothing}=nothing)
168
168
169
169
Parses a LaMEM input file and stores grid information in the `Grid` structure.
170
170
Optionally, you can pass LaMEM command-line arguments as well.
171
171
172
172
# Example 1
173
173
```julia
174
- julia> Grid = ReadLaMEM_InputFile ("SaltModels.dat")
174
+ julia> Grid = readLaMEM_InputFile ("SaltModels.dat")
175
175
LaMEM Grid:
176
176
nel : (32, 32, 32)
177
177
marker/cell : (3, 3, 3)
@@ -183,7 +183,7 @@ z ϵ [-2.0 : 0.0]
183
183
184
184
# Example 2 (with command-line arguments)
185
185
```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")
187
187
LaMEM Grid:
188
188
nel : (64, 32, 32)
189
189
marker/cell : (3, 3, 3)
@@ -194,7 +194,7 @@ LaMEM Grid:
194
194
```
195
195
196
196
"""
197
- function ReadLaMEM_InputFile (file; args:: Union{String,Nothing} = nothing )
197
+ function readLaMEM_InputFile (file; args:: Union{String,Nothing} = nothing )
198
198
199
199
# read information from file
200
200
nmark_x = ParseValue_LaMEM_InputFile (file," nmark_x" ,Int64, args= args);
@@ -368,34 +368,34 @@ function Base.show(io::IO, d::LaMEM_grid)
368
368
end
369
369
370
370
"""
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)
372
372
373
373
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.
374
374
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.
375
375
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 `.
377
377
378
378
# Example
379
379
380
380
```
381
- julia> Grid = ReadLaMEM_InputFile ("LaMEM_input_file.dat")
381
+ julia> Grid = readLaMEM_InputFile ("LaMEM_input_file.dat")
382
382
julia> Phases = zeros(Int32,size(Grid.X));
383
383
julia> Temp = ones(Float64,size(Grid.X));
384
384
julia> Model3D = CartData(Grid, (Phases=Phases,Temp=Temp))
385
- julia> Save_LaMEMMarkersParallel (Model3D)
385
+ julia> save_LaMEMMarkersParallel (Model3D)
386
386
Writing LaMEM marker file -> ./markers/mdb.00000000.dat
387
387
```
388
388
If you want to create a LaMEM input file for multiple processors:
389
389
```
390
- julia> Save_LaMEMMarkersParallel (Model3D, PartitioningFile="ProcessorPartitioning_4cpu_1.2.2.bin")
390
+ julia> save_LaMEMMarkersParallel (Model3D, PartitioningFile="ProcessorPartitioning_4cpu_1.2.2.bin")
391
391
Writing LaMEM marker file -> ./markers/mdb.00000000.dat
392
392
Writing LaMEM marker file -> ./markers/mdb.00000001.dat
393
393
Writing LaMEM marker file -> ./markers/mdb.00000002.dat
394
394
Writing LaMEM marker file -> ./markers/mdb.00000003.dat
395
395
```
396
396
397
397
"""
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 )
399
399
400
400
x = ustrip .(Grid. x. val[:,1 ,1 ]);
401
401
y = ustrip .(Grid. y. val[1 ,:,1 ]);
@@ -425,7 +425,7 @@ function Save_LaMEMMarkersParallel(Grid::CartData; PartitioningFile=empty, direc
425
425
else
426
426
Nprocx,Nprocy,Nprocz,
427
427
xc,yc,zc,
428
- nNodeX,nNodeY,nNodeZ = GetProcessorPartitioning (PartitioningFile, is64bit= is64bit)
428
+ nNodeX,nNodeY,nNodeZ = getProcessorPartitioning (PartitioningFile, is64bit= is64bit)
429
429
if verbose
430
430
@show Nprocx,Nprocy,Nprocz, xc,yc,zc, nNodeX,nNodeY,nNodeZ
431
431
end
@@ -557,13 +557,13 @@ function PetscBinaryWrite_Vec(filename, A)
557
557
end
558
558
559
559
"""
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)
561
561
562
562
Reads a LaMEM processor partitioning file, used to create marker files, and returns the parallel layout.
563
563
By default this is done for a 32bit PETSc installation, which will fail if you actually use a 64bit version.
564
564
565
565
"""
566
- function GetProcessorPartitioning (filename; is64bit= false )
566
+ function getProcessorPartitioning (filename; is64bit= false )
567
567
568
568
if is64bit
569
569
typ= Int64
@@ -606,12 +606,12 @@ end
606
606
607
607
608
608
"""
609
- coord, Data_3D_Arrays, Name_Vec = ReadData_VTR (fname)
609
+ coord, Data_3D_Arrays, Name_Vec = readData_VTR (fname)
610
610
611
611
Reads a VTR (structured grid) VTK file `fname` and extracts the coordinates, data arrays and names of the data.
612
612
In general, this only contains a piece of the data, and one should open a `*.pvtr` file to retrieve the full data
613
613
"""
614
- function ReadData_VTR (fname, FullSize)
614
+ function readData_VTR (fname, FullSize)
615
615
file = open (fname, " r" )
616
616
617
617
header = true
@@ -815,13 +815,13 @@ function ReadBinaryData(file::IOStream, start_bin::Int64, Offset::Int64, BytesTo
815
815
end
816
816
817
817
"""
818
- Data::ParaviewData = ReadData_PVTR (fname, dir)
818
+ Data::ParaviewData = readData_PVTR (fname, dir)
819
819
820
820
Reads a parallel, rectilinear, `*.vts` file with the name `fname` and located in `dir` and create a 3D `Data` struct from it.
821
821
822
822
# Example
823
823
```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/")
825
825
ParaviewData
826
826
size : (33, 33, 33)
827
827
x ϵ [ -3.0 : 3.0]
@@ -830,7 +830,7 @@ ParaviewData
830
830
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)
831
831
```
832
832
"""
833
- function ReadData_PVTR (fname, dir)
833
+ function readData_PVTR (fname, dir)
834
834
file = open (joinpath (dir,fname), " r" )
835
835
836
836
header = true
@@ -860,9 +860,9 @@ function ReadData_PVTR(fname, dir)
860
860
fname_piece = line_strip[1 : id_end]
861
861
862
862
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);
864
864
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);
866
866
coord_x[ix] = coord_x1[ix];
867
867
coord_y[iy] = coord_y1[iy];
868
868
coord_z[iz] = coord_z1[iz];
@@ -925,11 +925,11 @@ function ReadData_PVTR(fname, dir)
925
925
end
926
926
927
927
"""
928
- Save_LaMEMTopography (Topo::CartData, filename::String)
928
+ save_LaMEMTopography (Topo::CartData, filename::String)
929
929
930
930
This writes a topography file `Topo` for use in LaMEM, which should have size `(nx,ny,1)` and contain the field `:Topography`
931
931
"""
932
- function Save_LaMEMTopography (Topo:: CartData , filename:: String )
932
+ function save_LaMEMTopography (Topo:: CartData , filename:: String )
933
933
934
934
if (size (Topo. z. val,3 ) != 1 )
935
935
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)
972
972
end
973
973
974
974
"""
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)
976
976
977
977
This executes LaMEM for the input file `LaMEM_input` & creates a parallel partitioning file for `NumProc` processors.
978
978
The directory where the LaMEM binary is can be specified; if not it is assumed to be in the current directory.
979
979
Likewise for the `mpiexec` directory (if not specified it is assumed to be available on the command line).
980
980
981
981
"""
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 )
983
983
984
984
# Create string to execute LaMEM
985
985
mpi_str = MPI_dir* " mpiexec -n $(NumProc) "
0 commit comments