Chi-Tech
test_modules_Diffusion_Diffusion1D_KBA_lua.h
Go to the documentation of this file.
1
/** \page test_modules_Diffusion_Diffusion1D_KBA_lua test/modules/Diffusion/Diffusion1D_KBA.lua
2
\ingroup LuaInputExamples
3
4
\code
5
-- 1D Diffusion test with Vacuum BCs.
6
-- SDM: PWLC
7
-- Test: Max-value=2.50000
8
num_procs = 2
9
-- KBA-partitioning
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=100
25
L=2.0
26
xmin = 0.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
33
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create
34
({
35
node_sets = {nodes},
36
partitioner = chi.KBAGraphPartitioner.Create
37
({
38
nx = 1, ny=1, nz=2,
39
zcuts = {L/2}
40
})
41
})
42
chi_mesh.MeshGenerator.Execute(meshgen1)
43
44
--############################################### Set Material IDs
45
chiVolumeMesherSetMatIDToAll(0)
46
chiVolumeMesherSetupOrthogonalBoundaries()
47
48
49
--############################################### Add materials
50
materials = {}
51
materials[0] = chiPhysicsAddMaterial("Test Material");
52
53
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
54
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
55
56
57
58
--############################################### Setup Physics
59
phys1 = chiDiffusionCreateSolver();
60
chiSolverSetBasicOption(phys1,"discretization_method","PWLC")
61
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-4)
62
63
chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","vacuum")
64
chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","vacuum")
65
66
67
--############################################### Initialize and Execute Solver
68
chiDiffusionInitialize(phys1)
69
chiDiffusionExecute(phys1)
70
71
--############################################### Get field functions
72
fftemp,count = chiSolverGetFieldFunctionList(phys1)
73
74
--############################################### Line plot
75
ffi0 = chiFFInterpolationCreate(LINE)
76
curffi = ffi0;
77
chiFFInterpolationSetProperty(curffi,LINE_FIRSTPOINT,0.0,0.0,0.0+xmin)
78
chiFFInterpolationSetProperty(curffi,LINE_SECONDPOINT,0.0,0.0, 2.0+xmin)
79
chiFFInterpolationSetProperty(curffi,LINE_NUMBEROFPOINTS, 1000)
80
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
81
82
chiFFInterpolationInitialize(curffi)
83
chiFFInterpolationExecute(curffi)
84
85
--############################################### Volume integrations
86
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
87
ffi1 = chiFFInterpolationCreate(VOLUME)
88
curffi = ffi1
89
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
90
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
91
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
92
93
chiFFInterpolationInitialize(curffi)
94
chiFFInterpolationExecute(curffi)
95
maxval = chiFFInterpolationGetValue(curffi)
96
97
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
98
99
--############################################### Exports
100
if (master_export == nil) then
101
chiFFInterpolationExportPython(ffi0)
102
end
103
104
if (chi_location_id == 0 and master_export == nil) then
105
106
local handle = io.popen("python ZLFFI00.py")
107
end
108
\endcode
109
*/
110
111
doc
generated_files
test
modules
Diffusion
test_modules_Diffusion_Diffusion1D_KBA_lua.h
Generated by
1.9.3