Chi-Tech
test_modules_Diffusion_Diffusion3D_2Ortho_lua.h
Go to the documentation of this file.
1
/** \page test_modules_Diffusion_Diffusion3D_2Ortho_lua test/modules/Diffusion/Diffusion3D_2Ortho.lua
2
\ingroup LuaInputExamples
3
4
\code
5
-- 3D Diffusion test with Dirichlet and Reflecting BCs.
6
-- SDM: PWLC
7
-- Test: Max-value=0.29480
8
num_procs = 1
9
-- Uses extruder mesh
10
11
12
13
14
--############################################### Check num_procs
15
if (check_num_procs==nil and chi_number_of_processes ~= num_procs) then
16
chiLog(LOG_0ERROR,"Incorrect amount of processors. " ..
17
"Expected "..tostring(num_procs)..
18
". Pass check_num_procs=false to override if possible.")
19
os.exit(false)
20
end
21
22
--############################################### Setup mesh
23
L=2.0
24
N=32
25
ds=L/N
26
nodes={}
27
for k=0,N do
28
nodes[k+1] = -1.0 + ds*k
29
end
30
meshgen1 = chi_mesh.ExtruderMeshGenerator.Create
31
({
32
inputs =
33
{
34
chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes,nodes} }),
35
},
36
layers = {{z=0.2,n=2}}, -- layers
37
partitioner = chi.KBAGraphPartitioner.Create
38
({
39
nx = 2, ny=2, nz=1,
40
xcuts = {0.0}, ycuts = {0.0}
41
})
42
})
43
chi_mesh.MeshGenerator.Execute(meshgen1)
44
45
46
--############################################### Set Material IDs
47
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
48
chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
49
chiVolumeMesherSetupOrthogonalBoundaries()
50
51
--############################################### Add materials
52
materials = {}
53
materials[0] = chiPhysicsAddMaterial("Test Material");
54
55
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
56
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
57
58
--############################################### Setup Physics
59
phys1 = chiDiffusionCreateSolver()
60
chiSolverSetBasicOption(phys1,"discretization_method","PWLC")
61
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
62
63
--############################################### Set boundary conditions
64
chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","reflecting")
65
chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","reflecting")
66
67
--############################################### Initialize and Execute Solver
68
chiDiffusionInitialize(phys1)
69
chiDiffusionExecute(phys1)
70
71
--############################################### Get field functions
72
fftemp,count = chiSolverGetFieldFunctionList(phys1)
73
74
--############################################### Slice plot
75
slice1 = chiFFInterpolationCreate(SLICE)
76
chiFFInterpolationSetProperty(slice1,SLICE_POINT,0.008,0.0,0.0)
77
chiFFInterpolationSetProperty(slice1,SLICE_BINORM,0.0,0.0,1.0)
78
chiFFInterpolationSetProperty(slice1,SLICE_TANGENT,0.0,-1.0,0.0)
79
chiFFInterpolationSetProperty(slice1,SLICE_NORMAL,1.0,0.0,0.0)
80
chiFFInterpolationSetProperty(slice1,ADD_FIELDFUNCTION,fftemp[1])
81
82
chiFFInterpolationInitialize(slice1)
83
chiFFInterpolationExecute(slice1)
84
85
slice2 = chiFFInterpolationCreate(SLICE)
86
chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.025)
87
chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fftemp[1])
88
89
chiFFInterpolationInitialize(slice2)
90
chiFFInterpolationExecute(slice2)
91
92
--############################################### Line plot
93
line0 = chiFFInterpolationCreate(LINE)
94
chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,-1.0,0.0,0.025)
95
chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT, 1.0,0.0,0.025)
96
chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
97
chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fftemp[1])
98
99
chiFFInterpolationInitialize(line0)
100
chiFFInterpolationExecute(line0)
101
102
--############################################### Volume integrations
103
ffi1 = chiFFInterpolationCreate(VOLUME)
104
curffi = ffi1
105
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
106
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
107
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
108
109
chiFFInterpolationInitialize(curffi)
110
chiFFInterpolationExecute(curffi)
111
maxval = chiFFInterpolationGetValue(curffi)
112
113
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
114
115
--############################################### Exports
116
if (master_export == nil) then
117
chiFFInterpolationExportPython(slice1)
118
chiFFInterpolationExportPython(slice2)
119
chiFFInterpolationExportPython(line0)
120
chiExportFieldFunctionToVTK(fftemp,"ZPhi")
121
end
122
123
--############################################### Plots
124
if (chi_location_id == 0 and master_export == nil) then
125
local handle = io.popen("python3 ZPFFI00.py")
126
local handle = io.popen("python3 ZPFFI10.py")
127
local handle = io.popen("python3 ZLFFI20.py")
128
print("Execution completed")
129
end
130
131
\endcode
132
*/
133
134
doc
generated_files
test
modules
Diffusion
test_modules_Diffusion_Diffusion3D_2Ortho_lua.h
Generated by
1.9.3