Chi-Tech
test/modules/Diffusion/Diffusion2D_1Poly_IP.lua
-- 2D Diffusion test with Vacuum and Reflecting BCs.
-- SDM: PWLD
-- Test: Max-value=2.50000
num_procs = 4
--Also tests integrating with a lua-function
--############################################### 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
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes,nodes} })
--############################################### Set Material IDs
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
e_vol = chi_mesh.RPPLogicalVolume.Create({xmin=0.99999,xmax=1000.0 , infy=true, infz=true})
w_vol = chi_mesh.RPPLogicalVolume.Create({xmin=-1000.0,xmax=-0.99999, infy=true, infz=true})
n_vol = chi_mesh.RPPLogicalVolume.Create({ymin=0.99999,ymax=1000.0 , infx=true, infz=true})
s_vol = chi_mesh.RPPLogicalVolume.Create({ymin=-1000.0,ymax=-0.99999, infx=true, infz=true})
e_bndry = "0"
w_bndry = "1"
n_bndry = "2"
s_bndry = "3"
--############################################### Add materials
materials = {}
materials[0] = chiPhysicsAddMaterial("Test Material");
chiPhysicsMaterialAddProperty(materials[0],SCALAR_VALUE)
chiPhysicsMaterialSetProperty(materials[0],SCALAR_VALUE,SINGLE_VALUE,1.0)
prop = chiPhysicsMaterialGetProperty(materials[0],SCALAR_VALUE)
if ((prop.is_empty ~=nil) and (not prop.is_empty)) then
print("Property table populated, value="..tostring(prop.value))
end
--############################################### Setup Physics
chiSolverSetBasicOption(phys1,"discretization_method","PWLD_MIP")
chiSolverSetBasicOption(phys1,"residual_tolerance",1.0e-8)
--############################################### Set boundary conditions
chiDiffusionSetProperty(phys1,"boundary_type",e_bndry,"vacuum")
chiDiffusionSetProperty(phys1,"boundary_type",w_bndry,"vacuum")
chiDiffusionSetProperty(phys1,"boundary_type",n_bndry,"reflecting")
chiDiffusionSetProperty(phys1,"boundary_type",s_bndry,"reflecting")
--############################################### Initialize and Execute Solver
--############################################### Get field functions
fftemp,count = chiSolverGetFieldFunctionList(phys1)
--############################################### Slice plot
slice2 = chiFFInterpolationCreate(SLICE)
chiFFInterpolationSetProperty(slice2,SLICE_POINT,0.0,0.0,0.025)
chiFFInterpolationSetProperty(slice2,ADD_FIELDFUNCTION,fftemp[1])
--############################################### Volume integrations
curffi = ffi1
chiFFInterpolationSetProperty(curffi,OPERATION,OP_MAX)
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
chiLog(LOG_0,string.format("Max-value=%.5f", maxval))
--==========================================
xwing=2.0
function IntegrateMaterialVolume(ff_value,mat_id)
return xwing
end
curffi = ffi2
chiFFInterpolationSetProperty(curffi,OPERATION,OP_SUM_LUA,"IntegrateMaterialVolume")
chiFFInterpolationSetProperty(curffi,LOGICAL_VOLUME,vol0)
chiFFInterpolationSetProperty(curffi,ADD_FIELDFUNCTION,fftemp[1])
--==========================================
--############################################### Exports
if (master_export == nil) then
end
--############################################### Plots
if (chi_location_id == 0 and master_export == nil) then
local handle = io.popen("python ZPFFI00.py")
end
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)
Lua chiPhysicsMaterialGetProperty(int MaterialHandle, int PropertyIndex)
void chiPhysicsMaterialSetProperty(int MaterialHandle, int PropertyIndex, int OperationIndex, varying Information)
void chiVolumeMesherSetProperty(int PropertyIndex, varying PropertyValue)
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)