Chi-Tech
test_modules_Diffusion_Diffusion2D_2Unstructured_IP_lua.h
Go to the documentation of this file.
1
/** \page test_modules_Diffusion_Diffusion2D_2Unstructured_IP_lua test/modules/Diffusion/Diffusion2D_2Unstructured_IP.lua
2
\ingroup LuaInputExamples
3
4
\code
5
-- 2D Diffusion test with Dirichlet BCs.
6
-- SDM: PWLD
7
-- Test: Max-value=0.29685
8
num_procs = 4
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
meshgen1 = chi_mesh.MeshGenerator.Create
24
({
25
inputs =
26
{
27
chi_mesh.FromFileMeshGenerator.Create
28
({
29
filename = "../../../resources/TestMeshes/TriangleMesh2x2.obj"
30
})
31
}
32
})
33
chi_mesh.MeshGenerator.Execute(meshgen1)
34
35
--############################################### Set Material IDs
36
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
37
chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
38
chiVolumeMesherSetupOrthogonalBoundaries()
39
40
41
--############################################### Add materials
42
materials = {}
43
materials[0] = chiPhysicsAddMaterial("Test Material");
44
45
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
46
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
47
48
--############################################### Setup Physics
49
phys1 = chiDiffusionCreateSolver()
50
chiSolverSetBasicOption(phys1,"discretization_method","PWLD_MIP")
51
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
52
53
--############################################### Set boundary conditions
54
--chiDiffusionSetProperty(phys1,"boundary_type",0,"reflecting",1.0)
55
--chiDiffusionSetProperty(phys1,"boundary_type",1,"vacuum",2.0)
56
--chiDiffusionSetProperty(phys1,"boundary_type",2,"reflecting",3.0)
57
--chiDiffusionSetProperty(phys1,"boundary_type",3,"vacuum",4.0)
58
59
--############################################### Initialize and Execute Solver
60
chiDiffusionInitialize(phys1)
61
chiDiffusionExecute(phys1)
62
63
--############################################### Get field functions
64
fftemp,count = chiSolverGetFieldFunctionList(phys1)
65
66
--############################################### Slice plot
67
slice2 = chiFFInterpolationCreate(SLICE)
68
chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.025)
69
chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fftemp[1])
70
71
chiFFInterpolationInitialize(slice2)
72
chiFFInterpolationExecute(slice2)
73
74
--############################################### Line plot
75
line0 = chiFFInterpolationCreate(LINE)
76
chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,-1.0,0.01,0.0)
77
chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT, 1.0,0.01,0.0)
78
chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
79
chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fftemp[1])
80
81
chiFFInterpolationInitialize(line0)
82
chiFFInterpolationExecute(line0)
83
84
--############################################### Volume integrations
85
ffi1 = chiFFInterpolationCreate(VOLUME)
86
curffi = ffi1
87
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
88
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
89
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
90
91
chiFFInterpolationInitialize(curffi)
92
chiFFInterpolationExecute(curffi)
93
maxval = chiFFInterpolationGetValue(curffi)
94
95
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
96
97
--############################################### Exports
98
if (master_export == nil) then
99
chiFFInterpolationExportPython(slice2)
100
chiFFInterpolationExportPython(line0)
101
102
chiExportFieldFunctionToVTK(fftemp,"ZPhi")
103
end
104
105
--############################################### Plots
106
if ((master_export == nil) and (chi_location_id == 0)) then
107
local handle = io.popen("python3 ZPFFI00.py")
108
local handle = io.popen("python3 ZLFFI10.py")
109
end
110
\endcode
111
*/
112
113
doc
generated_files
test
modules
Diffusion
test_modules_Diffusion_Diffusion2D_2Unstructured_IP_lua.h
Generated by
1.9.3