Chi-Tech
test/modules/Diffusion/Diffusion3D_1Poly_IP.lua
-- 3D Diffusion test with Dirichlet and Reflecting BCs.
-- SDM: PWLC
-- Test: Max-value=0.29492
num_procs = 4
--############################################### Check num_procs
if (check_num_procs==nil and chi_number_of_processes ~= num_procs) then
chiLog(LOG_0ERROR,"Incorrect amount of processors. " ..
"Expected "..tostring(num_procs)..
". Pass check_num_procs=false to override if possible.")
os.exit(false)
end
--############################################### Setup mesh
nodes={}
N=32
L=2.0
xmin = -1.0
dx = L/N
for i=1,(N+1) do
k=i-1
nodes[i] = xmin + k*dx
end
znodes={}
for i=1,11 do
znodes[i] = 0.0 + (i-1)*0.2/10
end
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes,nodes,znodes} })
--############################################### Set Material IDs
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
--############################################### Add materials
materials = {}
materials[0] = chiPhysicsAddMaterial("Test Material");
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
--############################################### Setup Physics
chiSolverSetBasicOption(phys1,"discretization_method","PWLD_MIP")
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-6)
--############################################### Set boundary conditions
chiDiffusionSetProperty(phys1,"boundary_type","ZMIN","reflecting")
chiDiffusionSetProperty(phys1,"boundary_type","ZMAX","reflecting")
--############################################### Initialize and Execute Solver
--
--############################################### Get field functions
fflist,count = chiSolverGetFieldFunctionList(phys1)
--############################################### Slice plot
slice1 = chiFFInterpolationCreate(SLICE)
chiFFInterpolationSetProperty(slice1,SLICE_POINT,0.008,0.0,0.0)
chiFFInterpolationSetProperty(slice1,SLICE_BINORM,0.0,0.0,1.0)
chiFFInterpolationSetProperty(slice1,SLICE_TANGENT,0.0,-1.0,0.0)
chiFFInterpolationSetProperty(slice1,SLICE_NORMAL,1.0,0.0,0.0)
chiFFInterpolationSetProperty(slice1,ADD_FIELDFUNCTION,fflist[1])
slice2 = chiFFInterpolationCreate(SLICE)
chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.024)
chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fflist[1])
--############################################### Line plot
chiFFInterpolationSetProperty(line0,LINE_FIRSTPOINT,-1.0,0.0,0.025)
chiFFInterpolationSetProperty(line0,LINE_SECONDPOINT, 1.0,0.0,0.025)
chiFFInterpolationSetProperty(line0,LINE_NUMBEROFPOINTS, 100)
chiFFInterpolationSetProperty(line0,ADD_FIELDFUNCTION,fflist[1])
--############################################### Volume integrations
curffi = ffi1
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fflist[1])
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
--############################################### Exports
if (master_export == nil) then
chiExportFieldFunctionToVTK(fflist[1],"ZPhi3D","Temperature")
end
--############################################### Plots
if (chi_location_id == 0 and master_export == nil) then
local handle = io.popen("python ZPFFI10.py")
local handle = io.popen("python ZLFFI20.py")
print("Execution completed")
end
#define ZMAX
virtual void Execute()
Success chiDiffusionInitialize(int SolverHandle)
void chiDiffusionSetProperty(int SolverHandle, string PropertyName, varying Values)
Handle chiDiffusionCreateSolver()
Success chiDiffusionExecute(int SolverHandle)
void chiFFInterpolationExportPython(int FFIHandle, char BaseName)
Handle chiFFInterpolationCreate(int FFITypeIndex)
void chiFFInterpolationExecute(int FFIHandle)
void chiFFInterpolationGetValue(int FFIHandle)
void chiFFInterpolationInitialize(int FFIHandle)
Handle chiFFInterpolationSetProperty(int FFIHandle, int PropertyIndex)
void chiLog(int LogType, char LogMsg)
MaterialHandle chiPhysicsAddMaterial(char Name)
void chiPhysicsMaterialAddProperty(int MaterialHandle, int PropertyIndex)
void chiPhysicsMaterialSetProperty(int MaterialHandle, int PropertyIndex, int OperationIndex, varying Information)
void chiVolumeMesherSetProperty(int PropertyIndex, varying PropertyValue)
void chiVolumeMesherSetupOrthogonalBoundaries()
void chiSolverSetBasicOption(int solver_handle, string option_name, varying option_value)
void chiSolverGetFieldFunctionList(int SolverHandle)
void chiExportFieldFunctionToVTK(int FFHandle, char BaseName)
void Set(VecDbl &x, const double &val)