Skip to content

Commit

Permalink
working prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
CWillberg committed Mar 29, 2024
1 parent a38cafd commit 2daaa7f
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions src/Physics/Material/Material_Models/Correspondence_UMAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function compute_stresses(datamanager::Module, nodes::Union{SubArray,Vector{Int6
coords = datamanager.get_field("Coordinates")
rot_N = datamanager.get_field("Rotation", "N")
rot_NP1 = datamanager.get_field("Rotation", "NP1")
function_name::String = material_parameter["UMAT name"]

# Number of normal stress components at this point
ndi = dof
# Number of engineering shear stress components
Expand All @@ -214,7 +214,7 @@ function compute_stresses(datamanager::Module, nodes::Union{SubArray,Vector{Int6
for iID in nodes
stress_NP1[iID, :, :] = UMAT_interface
rotNP1[iID, :, :] = Geometry.rotation_tensor(angles[iID, :])
UMAT_interface(material_parameter["file"], function_name, stress_temp, statev[iID, :], DDSDDE, SSE, SPD, SCD, RPL, DDSDDT, DRPLDE, DRPLDT, matrix_to_voigt(strain_N[iID, :, :]), matrix_to_voigt(strain_increment[iID, :, :]), time, dt, temperature_N[iID], temperature_increment[iID], PREDEF[iID, :], DPRED[iID, :], CMNAME, ndi, nshr, ntens, nstatev, props, nprops, coords[iID, :], rot_NP1[iID, :, :] - rot_N[iID, :, :], not_supported_float, not_supported_float, DFGRD0, DFGRD1, not_supported_int, not_supported_int, not_supported_int, not_supported_int, not_supported_int, not_supported_int)
UMAT_interface(material_parameter["file"], material_parameter["UMAT name"] , stress_temp, statev[iID, :], DDSDDE, SSE, SPD, SCD, RPL, DDSDDT, DRPLDE, DRPLDT, matrix_to_voigt(strain_N[iID, :, :]), matrix_to_voigt(strain_increment[iID, :, :]), time, dt, temperature_N[iID], temperature_increment[iID], PREDEF[iID, :], DPRED[iID, :], CMNAME, ndi, nshr, ntens, nstatev, props, nprops, coords[iID, :], rot_NP1[iID, :, :] - rot_N[iID, :, :], not_supported_float, not_supported_float, DFGRD0, DFGRD1, not_supported_int, not_supported_int, not_supported_int, not_supported_int, not_supported_int, not_supported_int)
stress_NP1[iID, :, :] = voigt_to_matrix(stress_temp)
end
# CORRESPONDENCE::UMATINT(sigmaNP1LocVoigt, statev, DDSDDE, &SSE, &SPD, &SCD, &RPL,
Expand Down Expand Up @@ -249,32 +249,27 @@ Example:
"""
function UMAT_interface(filename::String, function_name::String, STRESS::Vector{Float64}, STATEV::Vector{Float64}, DDSDDE::Matrix{Float64}, SSE::Float64, SPD::Float64, SCD::Float64, RPL::Float64, DDSDDT::Vector{Float64}, DRPLDE::Vector{Float64}, DRPLDT::Float64, STRAN::Vector{Float64}, DSTRAN::Vector{Float64}, TIME::Float64, DTIME::Float64, TEMP::Float64, DTEMP::Float64, PREDEF::Vector{Float64}, DPRED::Vector{Float64}, CMNAME::Cstring, NDI::Int64, NSHR::Int64, NTENS::Int64, NSTATEV::Int64, PROPS::Vector{Float64}, NPROPS::Int64, COORDS::Vector{Float64}, DROT::Matrix{Float64}, PNEWDT::Float64, CELENT::Float64, DFGRD0::Matrix{Float64}, DFGRD1::Matrix{Float64}, NOEL::Int64, NPT::Int64, LAYER::Int64, KSPT::Int64, JSTEP::Int64, KINC::Int64)

global libname = filename

# TODO dynamicall change folders and subroutine name
ccall((:umattest_, "./src/Physics/Material/UMATs/libusertest.so"), Cvoid, (Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64}, Ref{Float64},
Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64},
Ref{Float64}, Ref{Float64}, Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Cstring, Ref{Int64}, Ref{Int64},
Ref{Int64}, Ref{Int64}, Ptr{Float64}, Ref{Int64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64},
Ptr{Float64}, Ptr{Float64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}),
STRESS, STATEV, DDSDDE, SSE, SPD, SCD, RPL, DDSDDT, DRPLDE, DRPLDT, STRAN, DSTRAN, TIME, DTIME, TEMP, DTEMP, PREDEF, DPRED, CMNAME, NDI,
NSHR, NTENS, NSTATEV, PROPS, NPROPS, COORDS, DROT, PNEWDT, CELENT, DFGRD0, DFGRD1, NOEL, NPT, LAYER, KSPT, JSTEP, KINC)

# ccall((:umattest_, "./src/Physics/Material/UMATs/libusertest.so"), Cvoid, (Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64}, Ref{Float64},
#sub_name = set_subroutine_caller(function_name)
#test=":umattest_"
#f=eval(:test)
expr = :(ccall((:umattest_, $filename), Cvoid,
(Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64}, Ref{Float64},
Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64},
Ref{Float64}, Ref{Float64}, Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Cstring, Ref{Int64}, Ref{Int64},
Ref{Int64}, Ref{Int64}, Ptr{Float64}, Ref{Int64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64},
Ptr{Float64}, Ptr{Float64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}),
$STRESS, $STATEV, $DDSDDE, $SSE, $SPD, $SCD, $RPL, $DDSDDT, $DRPLDE, $DRPLDT, $STRAN, $DSTRAN, $TIME, $DTIME, $TEMP, $DTEMP, $PREDEF, $DPRED, $CMNAME, $NDI,
$NSHR, $NTENS, $NSTATEV, $PROPS, $NPROPS, $COORDS, $DROT, $PNEWDT, $CELENT, $DFGRD0, $DFGRD1, $NOEL, $NPT, $LAYER, $KSPT, $JSTEP, $KINC))
eval(expr)
end


# TODO Subroutine not hard coded
# # sub_name::Symbol = set_subroutine_caller(function_name)
# # println()
# # expr = :(ccall((:$sub_name, $filename), Cvoid,
# (Ptr{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64}, Ref{Float64},
# Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64},
# Ref{Float64}, Ref{Float64}, Ref{Float64}, Ptr{Float64}, Ptr{Float64}, Cstring, Ref{Int64}, Ref{Int64},
# Ref{Int64}, Ref{Int64}, Ptr{Float64}, Ref{Int64}, Ptr{Float64}, Ptr{Float64}, Ref{Float64}, Ref{Float64},
# Ptr{Float64}, Ptr{Float64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}, Ref{Int64}),
# $STRESS, $STATEV, $DDSDDE, $SSE, $SPD, $SCD, $RPL, $DDSDDT, $DRPLDE, $DRPLDT, $STRAN, $DSTRAN, $TIME, $DTIME, $TEMP, $DTEMP, $PREDEF, $DPRED, $CMNAME, $NDI,
# $NSHR, $NTENS, $NSTATEV, $PROPS, $NPROPS, $COORDS, $DROT, $PNEWDT, $CELENT, $DFGRD0, $DFGRD1, $NOEL, $NPT, $LAYER, $KSPT, $JSTEP, $KINC))
# eval(expr)

# # sub_name::Symbol = set_subroutine_caller(function_name)


"""
function set_subroutine_caller(sub_name::String)
Expand All @@ -288,7 +283,7 @@ Converts each letter in the string `str` to its corresponding lowercase equivale
"""

function set_subroutine_caller(sub_name::String)
return eval(Meta.parse(":"*lowercase(sub_name)*"_"))
return eval(Meta.parse(":"*(lowercase(sub_name))*"_"))
end


Expand Down

0 comments on commit 2daaa7f

Please sign in to comment.