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
8num_procs = 2
9-- KBA-partitioning
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=100
25L=2.0
26xmin = 0.0
27dx = L/N
28for i=1,(N+1) do
29 k=i-1
30 nodes[i] = xmin + k*dx
31end
32
33meshgen1 = 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})
42chi_mesh.MeshGenerator.Execute(meshgen1)
43
44--############################################### Set Material IDs
45chiVolumeMesherSetMatIDToAll(0)
46chiVolumeMesherSetupOrthogonalBoundaries()
47
48
49--############################################### Add materials
50materials = {}
51materials[0] = chiPhysicsAddMaterial("Test Material");
52
53chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
54chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
55
56
57
58--############################################### Setup Physics
59phys1 = chiDiffusionCreateSolver();
60chiSolverSetBasicOption(phys1,"discretization_method","PWLC")
61chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-4)
62
63chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","vacuum")
64chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","vacuum")
65
66
67--############################################### Initialize and Execute Solver
68chiDiffusionInitialize(phys1)
69chiDiffusionExecute(phys1)
70
71--############################################### Get field functions
72fftemp,count = chiSolverGetFieldFunctionList(phys1)
73
74--############################################### Line plot
75ffi0 = chiFFInterpolationCreate(LINE)
76curffi = ffi0;
77chiFFInterpolationSetProperty(curffi,LINE_FIRSTPOINT,0.0,0.0,0.0+xmin)
78chiFFInterpolationSetProperty(curffi,LINE_SECONDPOINT,0.0,0.0, 2.0+xmin)
79chiFFInterpolationSetProperty(curffi,LINE_NUMBEROFPOINTS, 1000)
80chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
81
82chiFFInterpolationInitialize(curffi)
83chiFFInterpolationExecute(curffi)
84
85--############################################### Volume integrations
86vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
87ffi1 = chiFFInterpolationCreate(VOLUME)
88curffi = ffi1
89chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
90chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
91chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
92
93chiFFInterpolationInitialize(curffi)
94chiFFInterpolationExecute(curffi)
95maxval = chiFFInterpolationGetValue(curffi)
96
97chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
98
99--############################################### Exports
100if (master_export == nil) then
101 chiFFInterpolationExportPython(ffi0)
102end
103
104if (chi_location_id == 0 and master_export == nil) then
105
106 local handle = io.popen("python ZLFFI00.py")
107end
108\endcode
109*/
110
111