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
8
num_procs = 2
9
10
11
12
13
14
--############################################### Check num_procs
15
if (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)
20
end
21
22
--############################################### Setup mesh
23
nodes={}
24
N=100
25
L=2.0
26
xmin = 0.0
27
dx = L/N
28
for i=1,(N+1) do
29
k=i-1
30
nodes[i] = xmin + k*dx
31
end
32
33
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes} })
34
chi_mesh.MeshGenerator.Execute(meshgen1)
35
36
--############################################### Set Material IDs
37
chiVolumeMesherSetMatIDToAll(0)
38
chiVolumeMesherSetupOrthogonalBoundaries()
39
40
--############################################### Add materials
41
materials = {}
42
materials[0] = chiPhysicsAddMaterial("Test Material");
43
44
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
45
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
46
47
--############################################### Setup Physics
48
phys1 = chiDiffusionCreateSolver()
49
chiSolverSetBasicOption(phys1,"discretization_method","PWLD_MIP")
50
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
51
52
--############################################### Set boundary conditions
53
chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","dirichlet",0.0)
54
chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","dirichlet",0.0)
55
56
--############################################### Initialize and Execute Solver
57
chiDiffusionInitialize(phys1)
58
chiDiffusionExecute(phys1)
59
60
--############################################### Get field functions
61
fftemp,count = chiSolverGetFieldFunctionList(phys1)
62
63
--############################################### Line plot
64
line0 = chiFFInterpolationCreate(LINE)
65
chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,0.1,0.0,0.0)
66
chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT,0.1,0.0, 2.0)
67
chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
68
chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fftemp[1])
69
70
chiFFInterpolationInitialize(line0)
71
chiFFInterpolationExecute(line0)
72
73
--############################################### Volume integrations
74
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
75
ffi1 = chiFFInterpolationCreate(VOLUME)
76
curffi = ffi1
77
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
78
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
79
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
80
81
chiFFInterpolationInitialize(curffi)
82
chiFFInterpolationExecute(curffi)
83
maxval = chiFFInterpolationGetValue(curffi)
84
85
chiLog(LOG_0,string.format("Max-value=%.10f", maxval))
86
87
--############################################### Exports
88
if (master_export == nil) then
89
chiFFInterpolationExportPython(line0)
90
end
91
92
--############################################### Plots
93
if ((chi_location_id == 0) and (master_export == nil)) then
94
local handle = io.popen("python ZLFFI00.py")
95
end
96
\endcode
97
*/
98
99
doc
generated_files
test
modules
Diffusion
test_modules_Diffusion_Diffusion1D_IP_lua.h
Generated by
1.9.3