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