Chi-Tech
test/modules/DFEM_Diffusion/dDiffusion_2D_3a_analytical_coef.lua
--############################################### Setup mesh
nodes={}
N=100
L=2
xmin = -L/2
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
function D_coef(i,x,y,z)
return 3.0 + x + y
end
function Q_ext(i,x,y,z)
return x*x
end
function Sigma_a(i,x,y,z)
return x*y*y
end
-- Setboundary IDs
-- xmin,xmax,ymin,ymax,zmin,zmax
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 material properties
--#### DFEM solver
chiDFEMDiffusionSetBCProperty(phys1,"boundary_type",e_bndry,"dirichlet",0.0)
chiDFEMDiffusionSetBCProperty(phys1,"boundary_type",w_bndry,"dirichlet",0.0)
chiDFEMDiffusionSetBCProperty(phys1,"boundary_type",n_bndry,"dirichlet",0.0)
chiDFEMDiffusionSetBCProperty(phys1,"boundary_type",s_bndry,"dirichlet",0.0)
--############################################### Get field functions
fflist,count = chiSolverGetFieldFunctionList(phys1)
--############################################### Export VTU
if (master_export == nil) then
chiExportFieldFunctionToVTK(fflist[1],"CFEMDiff2D_analytic_coef","flux")
end
--############################################### Volume integrations
vol0 = chi_mesh.RPPLogicalVolume.Create({infx=true, infy=true, infz=true})
ffvol = chiFFInterpolationCreate(VOLUME)
chiFFInterpolationSetProperty(ffvol,OPERATION,OP_MAX)
chiFFInterpolationSetProperty(ffvol,LOGICAL_VOLUME,vol0)
chiFFInterpolationSetProperty(ffvol,ADD_FIELDFUNCTION,fflist[1])
chiLog(LOG_0,string.format("Max-value=%.6f", maxval))
virtual void Execute()
void chiDFEMDiffusionSetBCProperty(int SolverHandle, string PropertyName, varying Values)
Handle chiDFEMDiffusionSolverCreate()
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)
void chiVolumeMesherSetProperty(int PropertyIndex, varying PropertyValue)
void chiVolumeMesherSetMatIDToAll(int material_id)
void chiSolverExecute(int solver_handle)
void chiSolverInitialize(int solver_handle)
Definition: lua_functions.c:92
void chiSolverGetFieldFunctionList(int SolverHandle)
void chiExportFieldFunctionToVTK(int FFHandle, char BaseName)
void Set(VecDbl &x, const double &val)