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