Chi-Tech
test_modules_Diffusion_Diffusion3D_4VTU_lua.h
Go to the documentation of this file.
1
/** \page test_modules_Diffusion_Diffusion3D_4VTU_lua test/modules/Diffusion/Diffusion3D_4VTU.lua
2
\ingroup LuaInputExamples
3
4
\code
5
-- 3D Diffusion test with Dirichlet and Reflecting BCs.
6
-- SDM: PWLC
7
-- Test: Max-value=0.07373
8
num_procs = 4
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
meshgen1 = chi_mesh.MeshGenerator.Create
24
({
25
inputs =
26
{
27
chi_mesh.FromFileMeshGenerator.Create
28
({
29
filename="tests/TestMesh.vtu"
30
}),
31
},
32
})
33
chi_mesh.MeshGenerator.Execute(meshgen1)
34
35
--############################################### Set Material IDs
36
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
37
chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,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","PWLD_MIP")
50
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
51
52
--############################################### Set boundary conditions
53
chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","reflecting")
54
chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","reflecting")
55
56
--############################################### Initialize and Execute Solver
57
chiDiffusionInitialize(phys1)
58
chiDiffusionExecute(phys1)
59
--
60
--############################################### Get field functions
61
fflist,count = chiSolverGetFieldFunctionList(phys1)
62
63
--############################################### Slice plot
64
slice1 = chiFFInterpolationCreate(SLICE)
65
66
chiFFInterpolationSetProperty(slice1,SLICE_POINT,0.008,0.0,0.0)
67
chiFFInterpolationSetProperty(slice1,SLICE_BINORM,0.0,0.0,1.0)
68
chiFFInterpolationSetProperty(slice1,SLICE_TANGENT,0.0,-1.0,0.0)
69
chiFFInterpolationSetProperty(slice1,SLICE_NORMAL,1.0,0.0,0.0)
70
chiFFInterpolationSetProperty(slice1,ADD_FIELDFUNCTION,fflist[1])
71
72
chiFFInterpolationInitialize(slice1)
73
chiFFInterpolationExecute(slice1)
74
75
slice2 = chiFFInterpolationCreate(SLICE)
76
chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.024)
77
chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fflist[1])
78
79
chiFFInterpolationInitialize(slice2)
80
chiFFInterpolationExecute(slice2)
81
82
--############################################### Line plot
83
line0 = chiFFInterpolationCreate(LINE)
84
chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,-1.0,0.0,0.025)
85
chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT, 1.0,0.0,0.025)
86
chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
87
chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fflist[1])
88
89
chiFFInterpolationInitialize(line0)
90
chiFFInterpolationExecute(line0)
91
92
--############################################### Volume integrations
93
ffi1 = chiFFInterpolationCreate(VOLUME)
94
curffi = ffi1
95
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
96
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
97
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fflist[1])
98
99
chiFFInterpolationInitialize(curffi)
100
chiFFInterpolationExecute(curffi)
101
maxval = chiFFInterpolationGetValue(curffi)
102
103
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
104
105
--############################################### Exports
106
if (master_export == nil) then
107
chiFFInterpolationExportPython(slice1)
108
chiFFInterpolationExportPython(slice2)
109
chiFFInterpolationExportPython(line0)
110
chiExportFieldFunctionToVTK(fflist[1],"ZPhi3D","Temperature")
111
end
112
113
--############################################### Plots
114
if (chi_location_id == 0 and master_export == nil) then
115
local handle = io.popen("python ZPFFI10.py")
116
local handle = io.popen("python ZLFFI20.py")
117
print("Execution completed")
118
end
119
\endcode
120
*/
121
122
doc
generated_files
test
modules
Diffusion
test_modules_Diffusion_Diffusion3D_4VTU_lua.h
Generated by
1.9.3