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
8num_procs = 1
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=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({ node_sets = {nodes} })
34chi_mesh.MeshGenerator.Execute(meshgen1)
35
36--############################################### Set Material IDs
37chiVolumeMesherSetMatIDToAll(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","PWLC")
50chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-4)
51
52--############################################### Set boundary conditions
53chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","vacuum")
54chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","vacuum")
55
56--############################################### Initialize and Execute Solver
57chiDiffusionInitialize(phys1)
58chiDiffusionExecute(phys1)
59
60--############################################### Get field functions
61fftemp,count = chiSolverGetFieldFunctionList(phys1)
62
63--############################################### Line plot
64ffi0 = chiFFInterpolationCreate(LINE)
65curffi = ffi0;
66chiFFInterpolationSetProperty(curffi,LINE_FIRSTPOINT,0.0,0.0,0.0+xmin)
67chiFFInterpolationSetProperty(curffi,LINE_SECONDPOINT,0.0,0.0, 2.0+xmin)
68chiFFInterpolationSetProperty(curffi,LINE_NUMBEROFPOINTS, 1000)
69chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
70
71chiFFInterpolationInitialize(curffi)
72chiFFInterpolationExecute(curffi)
73
74--############################################### Volume integrations
75vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
76ffi1 = chiFFInterpolationCreate(VOLUME)
77curffi = ffi1
78chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
79chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
80chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
81
82chiFFInterpolationInitialize(curffi)
83chiFFInterpolationExecute(curffi)
84maxval = chiFFInterpolationGetValue(curffi)
85
86chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
87
88--############################################### Exports
89if (master_export == nil) then
90 chiFFInterpolationExportPython(ffi0)
91end
92
93--############################################### Plots
94if (chi_location_id == 0 and master_export == nil) then
95 local handle = io.popen("python ZLFFI00.py")
96end\endcode
97*/
98
99