Chi-Tech
test_modules_Diffusion_Diffusion3D_1Poly_lua.h
Go to the documentation of this file.
1
/** \page test_modules_Diffusion_Diffusion3D_1Poly_lua test/modules/Diffusion/Diffusion3D_1Poly.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
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
nodes={}
24
N=32
25
L=2.0
26
xmin = -1.0
27
dx = L/N
28
for i=1,(N+1) do
29
k=i-1
30
nodes[i] = xmin + k*dx
31
end
32
znodes={}
33
for i=1,11 do
34
znodes[i] = 0.0 + (i-1)*0.2/10
35
end
36
37
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes,nodes,znodes} })
38
chi_mesh.MeshGenerator.Execute(meshgen1)
39
40
--############################################### Set Material IDs
41
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
42
chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
43
chiVolumeMesherSetupOrthogonalBoundaries()
44
45
--############################################### Add materials
46
materials = {}
47
materials[0] = chiPhysicsAddMaterial("Test Material");
48
49
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
50
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
51
52
--############################################### Setup Physics
53
phys1 = chiDiffusionCreateSolver();
54
chiSolverSetBasicOption(phys1,"discretization_method","PWLC")
55
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
56
57
--############################################### Set boundary conditions
58
chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","reflecting")
59
chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","reflecting")
60
61
--############################################### Initialize and Execute Solver
62
chiDiffusionInitialize(phys1)
63
chiDiffusionExecute(phys1)
64
65
--############################################### Get field functions
66
fftemp,count = chiSolverGetFieldFunctionList(phys1)
67
68
--############################################### Slice plot
69
slice1 = chiFFInterpolationCreate(SLICE)
70
--chiFFInterpolationSetProperty(slice1,SLICE_POINT,0.0,0.0,0.025)
71
chiFFInterpolationSetProperty(slice1,SLICE_POINT,0.008,0.0,0.0)
72
chiFFInterpolationSetProperty(slice1,SLICE_BINORM,0.0,0.0,1.0)
73
chiFFInterpolationSetProperty(slice1,SLICE_TANGENT,0.0,-1.0,0.0)
74
chiFFInterpolationSetProperty(slice1,SLICE_NORMAL,1.0,0.0,0.0)
75
chiFFInterpolationSetProperty(slice1,ADD_FIELDFUNCTION,fftemp[1])
76
77
chiFFInterpolationInitialize(slice1)
78
chiFFInterpolationExecute(slice1)
79
80
slice2 = chiFFInterpolationCreate(SLICE)
81
chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.025)
82
chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fftemp[1])
83
84
chiFFInterpolationInitialize(slice2)
85
chiFFInterpolationExecute(slice2)
86
87
--############################################### Line plot
88
line0 = chiFFInterpolationCreate(LINE)
89
chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,-1.0,0.0,0.025)
90
chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT, 1.0,0.0,0.025)
91
chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
92
chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fftemp[1])
93
94
chiFFInterpolationInitialize(line0)
95
chiFFInterpolationExecute(line0)
96
97
--############################################### Volume integrations
98
ffi1 = chiFFInterpolationCreate(VOLUME)
99
curffi = ffi1
100
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
101
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
102
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
103
104
chiFFInterpolationInitialize(curffi)
105
chiFFInterpolationExecute(curffi)
106
maxval = chiFFInterpolationGetValue(curffi)
107
108
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
109
110
--############################################### Exports
111
if (master_export == nil) then
112
chiFFInterpolationExportPython(slice1)
113
chiFFInterpolationExportPython(slice2)
114
chiFFInterpolationExportPython(line0)
115
chiExportFieldFunctionToVTK(fftemp,"ZPhi")
116
end
117
118
--############################################### Plots
119
if (chi_location_id == 0 and master_export == nil) then
120
local handle = io.popen("python3 ZPFFI00.py")
121
local handle = io.popen("python3 ZPFFI10.py")
122
local handle = io.popen("python3 ZLFFI20.py")
123
print("Execution completed")
124
end
125
\endcode
126
*/
127
128
doc
generated_files
test
modules
Diffusion
test_modules_Diffusion_Diffusion3D_1Poly_lua.h
Generated by
1.9.3