-
Notifications
You must be signed in to change notification settings - Fork 13
/
kernel.py
executable file
·92 lines (74 loc) · 3.14 KB
/
kernel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
# Author: Octavio Castillo Reyes
# Contact: [email protected]
"""**PETGEM** kernel for 3D CSEM/MT forward modelling using high order vector elements."""
if __name__ == '__main__':
# ---------------------------------------------------------------
# Load python modules
# ---------------------------------------------------------------
import sys
import petsc4py
# ---------------------------------------------------------------
# PETSc init
# ---------------------------------------------------------------
petsc4py.init(sys.argv)
# ---------------------------------------------------------------
# Load python modules
# ---------------------------------------------------------------
# ---------------------------------------------------------------
# Load petgem modules (BSC)
# ---------------------------------------------------------------
from petgem.common import Print, InputParameters, Timers
from petgem.parallel import MPIEnvironment
from petgem.preprocessing import Preprocessing
from petgem.solver import Solver
from petgem.postprocessing import Postprocessing
# ---------------------------------------------------------------
# Load system setup (both parameters and dataset configuration)
# ---------------------------------------------------------------
# Obtain the MPI environment
par_env = MPIEnvironment()
# Import parameters file
input_setup = InputParameters(sys.argv[3], par_env)
# Initialize timers
Timers(input_setup.output['directory'])
# ---------------------------------------------------------------
# Print header
# ---------------------------------------------------------------
Print.header()
# ---------------------------------------------------------------
# Preprocessing
# ---------------------------------------------------------------
Print.master(' ')
Print.master(' Data preprocessing')
# Create a preprocessing instance and output directory
preprocessing = Preprocessing()
# Run preprocessing
preprocessing.run(input_setup)
# ---------------------------------------------------------------
# Solver
# ---------------------------------------------------------------
Print.master(' ')
Print.master(' Run modelling')
# Create a solver instance
solver = Solver()
# Setup solver (import files from preprocessing stage)
solver.setup(input_setup)
# Assembly linear system
solver.assembly(input_setup)
# Run solver (Ax=b)
solver.run(input_setup)
# Destroy solver
del solver
# ---------------------------------------------------------------
# Postprocessing
# ---------------------------------------------------------------
Print.master(' ')
Print.master(' Data postprocessing')
# Create a postprocessing instance
postprocessing = Postprocessing()
# Run postprocessing
postprocessing.run(input_setup)
# ---------------------------------------------------------------
# End of PETGEM kernel
# ---------------------------------------------------------------