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
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
23meshgen1 = chi_mesh.MeshGenerator.Create
24({
25 inputs =
26 {
27 chi_mesh.FromFileMeshGenerator.Create
28 ({
29 filename="tests/TestMesh.vtu"
30 }),
31 },
32})
33chi_mesh.MeshGenerator.Execute(meshgen1)
34
35--############################################### Set Material IDs
36vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
37chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
38chiVolumeMesherSetupOrthogonalBoundaries()
39
40--############################################### Add materials
41materials = {}
42materials[0] = chiPhysicsAddMaterial("Test Material");
43
44chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
45chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
46
47--############################################### Setup Physics
48phys1 = chiDiffusionCreateSolver()
49chiSolverSetBasicOption(phys1,"discretization_method","PWLD_MIP")
50chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
51
52--############################################### Set boundary conditions
53chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","reflecting")
54chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","reflecting")
55
56--############################################### Initialize and Execute Solver
57chiDiffusionInitialize(phys1)
58chiDiffusionExecute(phys1)
59--
60--############################################### Get field functions
61fflist,count = chiSolverGetFieldFunctionList(phys1)
62
63--############################################### Slice plot
64slice1 = chiFFInterpolationCreate(SLICE)
65
66chiFFInterpolationSetProperty(slice1,SLICE_POINT,0.008,0.0,0.0)
67chiFFInterpolationSetProperty(slice1,SLICE_BINORM,0.0,0.0,1.0)
68chiFFInterpolationSetProperty(slice1,SLICE_TANGENT,0.0,-1.0,0.0)
69chiFFInterpolationSetProperty(slice1,SLICE_NORMAL,1.0,0.0,0.0)
70chiFFInterpolationSetProperty(slice1,ADD_FIELDFUNCTION,fflist[1])
71
72chiFFInterpolationInitialize(slice1)
73chiFFInterpolationExecute(slice1)
74
75slice2 = chiFFInterpolationCreate(SLICE)
76chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.024)
77chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fflist[1])
78
79chiFFInterpolationInitialize(slice2)
80chiFFInterpolationExecute(slice2)
81
82--############################################### Line plot
83line0 = chiFFInterpolationCreate(LINE)
84chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,-1.0,0.0,0.025)
85chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT, 1.0,0.0,0.025)
86chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
87chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fflist[1])
88
89chiFFInterpolationInitialize(line0)
90chiFFInterpolationExecute(line0)
91
92--############################################### Volume integrations
93ffi1 = chiFFInterpolationCreate(VOLUME)
94curffi = ffi1
95chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
96chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
97chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fflist[1])
98
99chiFFInterpolationInitialize(curffi)
100chiFFInterpolationExecute(curffi)
101maxval = chiFFInterpolationGetValue(curffi)
102
103chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
104
105--############################################### Exports
106if (master_export == nil) then
107 chiFFInterpolationExportPython(slice1)
108 chiFFInterpolationExportPython(slice2)
109 chiFFInterpolationExportPython(line0)
110 chiExportFieldFunctionToVTK(fflist[1],"ZPhi3D","Temperature")
111end
112
113--############################################### Plots
114if (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")
118end
119\endcode
120*/
121
122