Chi-Tech
test_modules_Diffusion_Diffusion1D_IP_lua.h
Go to the documentation of this file.
1/** \page test_modules_Diffusion_Diffusion1D_IP_lua test/modules/Diffusion/Diffusion1D_IP.lua
2\ingroup LuaInputExamples
3
4\code
5-- 1D Diffusion test with Dirichlet BCs
6-- SMD: PWLD
7-- Test: Max-value=0.5006523132
8num_procs = 2
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","PWLD_MIP")
50chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
51
52--############################################### Set boundary conditions
53chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","dirichlet",0.0)
54chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","dirichlet",0.0)
55
56--############################################### Initialize and Execute Solver
57chiDiffusionInitialize(phys1)
58chiDiffusionExecute(phys1)
59
60--############################################### Get field functions
61fftemp,count = chiSolverGetFieldFunctionList(phys1)
62
63--############################################### Line plot
64line0 = chiFFInterpolationCreate(LINE)
65chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,0.1,0.0,0.0)
66chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT,0.1,0.0, 2.0)
67chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
68chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fftemp[1])
69
70chiFFInterpolationInitialize(line0)
71chiFFInterpolationExecute(line0)
72
73--############################################### Volume integrations
74vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
75ffi1 = chiFFInterpolationCreate(VOLUME)
76curffi = ffi1
77chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
78chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
79chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
80
81chiFFInterpolationInitialize(curffi)
82chiFFInterpolationExecute(curffi)
83maxval = chiFFInterpolationGetValue(curffi)
84
85chiLog(LOG_0,string.format("Max-value=%.10f", maxval))
86
87--############################################### Exports
88if (master_export == nil) then
89 chiFFInterpolationExportPython(line0)
90end
91
92--############################################### Plots
93if ((chi_location_id == 0) and (master_export == nil)) then
94 local handle = io.popen("python ZLFFI00.py")
95end
96\endcode
97*/
98
99