Commit 6b2f909b authored by mozul's avatar mozul
Browse files

Squashed 'src/' content from commit 80af6d1

git-subtree-dir: src
git-subtree-split: 80af6d1044b89475ca6edf2e67b9cafdb5b709d7
parents
# Compiling ExternalModels library :
#conditionnal uncache of MATLIB_LIBRARY !
#IF( NOT OLD_MATLIB_VERSION STREQUAL MATLIB_VERSION )
# SET(OLD_MATLIB_VERSION ${MATLIB_VERSION} CACHE INTERNAL "Previous value for MATLIB_VERSION")
# SET(MATLIB_LIBRARY "MATLIB_LIBRARY-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
#ENDIF( NOT OLD_MATLIB_VERSION STREQUAL MATLIB_VERSION )
if(${MATLIB_VERSION} STREQUAL "off")
message(STATUS "No external models library used")
set(LMGC90_BINDINGS_MODELS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/Std_ExternalModels.f90 PARENT_SCOPE)
set(LMGC90_BINDINGS_MODELS_TARGET_LIBS PARENT_SCOPE)
else()
set(LMGC90_BINDINGS_MODELS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/MatLib_ExternalModels.f90 PARENT_SCOPE)
if(MATLIB_LIBRARY)
message(STATUS "Matlib Library used : " ${MATLIB_LIBRARY})
set(LMGC90_BINDINGS_MODELS_TARGET_LIBS ${MATLIB_LIBRARY} PARENT_SCOPE)
else(MATLIB_LIBRARY)
set(LMGC90_BINDINGS_MODELS_TARGET_LIBS matlib PARENT_SCOPE)
endif(MATLIB_LIBRARY)
endif()
#add_library(lmgc_bindings_models ${LMGC90_BINDINGS_MODELS_SRCS})
#target_link_libraries(lmgc_bindings_models lmgc_core_shared ${LMGC90_BINDINGS_MODELS_TARGET_LIBS})
# Compiling ExternalDetection library :
set(LMGC90_BINDINGS_DETECTION_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/Std_ExternalDetection.f90)
set(LMGC90_BINDINGS_DETECTION_TARGET_LIBS)
add_library(lmgc_bindings_detection ${LMGC90_BINDINGS_DETECTION_SRCS})
target_link_libraries(lmgc_bindings_detection ${LMGC90_BINDINGS_DETECTION_TARGET_LIBS})
# Compiling User library :
set(LMGC90_BINDINGS_USER_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/User.f90)
set(LMGC90_BINDINGS_USER_TARGET_LIBS ${LAPACK_LIBRARIES})
add_library(lmgc_bindings_user ${LMGC90_BINDINGS_USER_SRCS})
target_link_libraries(lmgc_bindings_user ${LMGC90_BINDINGS_USER_TARGET_LIBS})
####################################################################################
# Compiling Sparse ExternalLinearAlgebra library :
####################################################################################
if(${MUMPS_VERSION} STREQUAL "none") # if mumps not asked
# if no mumps asked
message(STATUS "No sparse linear algebra library used")
set(LMGC90_BINDINGS_SPARSE_LA_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/Std_SparseLinearAlgebra.f90)
#set(LMGC90_BINDINGS_SPARSE_LA_TARGET_LIBS)
add_library(lmgc_bindings_sparse_la ${LMGC90_BINDINGS_SPARSE_LA_SRCS})
else(${MUMPS_VERSION} STREQUAL "none")
if(${MUMPS_VERSION} STREQUAL "sequential")
# if sequential mumps asked look for libraries
set(SEARCH_MPISEQ TRUE)
set(WITH_MUMPS TRUE)
find_package(MUMPS REQUIRED)
# set WITH_MPI if not already set
if( NOT WITH_MPI)
SET(WITH_MPI ON)
endif( NOT WITH_MPI)
elseif(${MUMPS_VERSION} STREQUAL "parallel")
# if parallel mumps asked look for libraries
set(WITH_MUMPS TRUE)
set(SEARCH_MPISEQ FALSE)
find_package(MUMPS REQUIRED)
# find corresponding module
find_file(LMGC90_BINDINGS_SPARSE_LA_SRCS
NAMES "Mumps_SparseLinearAlgebra.f90"
PATHS ${CMAKE_SOURCE_DIR}/contribs/lapack_LinearAlgebra
NO_DEFAULT_PATH
)
# error if WITH_MPI is not already set
if( NOT WITH_MPI)
message(FATAL_ERROR "Use of parallel sparse linear algebra found, but no option WITH_MPI. Make sure to enable WITH_MPI option and provide a 'mpif90' compiler in CMAKE_Fortran_COMPILER variable (or use a sequential version)")
endif( NOT WITH_MPI)
endif(${MUMPS_VERSION} STREQUAL "sequential")
# find corresponding module
find_file(LMGC90_BINDINGS_SPARSE_LA_SRCS
NAMES "Mumps_SparseLinearAlgebra.f90"
PATHS ${CMAKE_SOURCE_DIR}/contribs/lapack_LinearAlgebra
NO_DEFAULT_PATH
)
message(STATUS "Sparse linear algebra include path found: ${MUMPS_INCLUDE_DIRS}")
message(STATUS "Sparse linear algebra libraries found: ${MUMPS_LIBRARIES}")
message(STATUS "Sparse linear algebra libraries user add : ${ADD_MUMPS_LIBRARIES}")
message(STATUS "Sparse linear algebra binding found: ${LMGC90_BINDINGS_SPARSE_LA_SRCS}")
INCLUDE_DIRECTORIES( ${MUMPS_INCLUDE_DIRS} )
add_library(lmgc_bindings_sparse_la ${LMGC90_BINDINGS_SPARSE_LA_SRCS})
target_link_libraries(lmgc_bindings_sparse_la ${MUMPS_LIBRARIES} ${ADD_MUMPS_LIBRARIES})
endif(${MUMPS_VERSION} STREQUAL "none")
# Compiling ExternalFEM library :
if(EXT_FEM_VERSION STREQUAL "none")
set(LMGC90_BINDINGS_FEM_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/Std_ExternalFEM.f90)
set(LMGC90_BINDINGS_FEM_TARGET_LIBS)
add_library(lmgc_bindings_FEM ${LMGC90_BINDINGS_FEM_SRCS})
target_link_libraries(lmgc_bindings_FEM ${LMGC90_BINDINGS_FEM_TARGET_LIBS})
else()
FIND_PACKAGE(ExternalFEM_FOR_LMGC REQUIRED)
message(STATUS "EXT_FEM Library used : ${EXT_FEM_LIBRARY}")
message(STATUS "EXT_FEM binding found : ${EXT_FEM_F90_MODULE}")
set(LMGC90_BINDINGS_FEM_SRCS ${EXT_FEM_F90_MODULE})
set(LMGC90_BINDINGS_FEM_TARGET_LIBS ${EXT_FEM_LIBRARY})
add_library(lmgc_bindings_FEM ${LMGC90_BINDINGS_FEM_SRCS})
target_link_libraries(lmgc_bindings_FEM ${LMGC90_BINDINGS_FEM_TARGET_LIBS})
message(STATUS "EXT_FEM_WRAP files found : ${EXT_FEM_WRAP_SRC} ${EXT_FEM_WRAP_HEADER}")
#\todo : the variables EXT_WRAP_USER_* store only one variable... it should holds
# a list instead (so that the wrap_user.* files could be generated with the cat command
set(EXT_WRAP_USER_SRC ${EXT_FEM_WRAP_SRC} PARENT_SCOPE)
set(EXT_WRAP_USER_HEADER ${EXT_FEM_WRAP_HEADER} PARENT_SCOPE)
endif()
####################################################################################
This diff is collapsed.
module ExternalDetection
!use utilites
!use polyr
implicit none
contains
! la routine de detection qui va bien
subroutine detection_indian(id1,id2,adist,nb_ctc,PT_CTC,overlap,n)!,t,s)
integer :: id1, id2, nb_ctc
real(kind=8) :: adist
real(kind=8), dimension(:,:), pointer :: PT_CTC, n
real(kind=8), dimension(:), pointer :: overlap
print *," Error : you are trying to use an external detection function, but you are only calling a empty declaration"
!call logmes(" Error : you are trying to use an external detection function, but you are only calling a empty declaration")
end subroutine detection_indian
end module ExternalDetection
!>binding of an external fem code
module ExternalFEM
implicit none
contains
!------------------------------------------------------------------------
subroutine externalFEM_increment(time,time_step)
implicit none
real(kind=8) :: time,time_step
!
! PEL initialisation du temps et pas de temps
!
! call PELupdateBeforeTimeIteration(time,time_step)
end subroutine
!------------------------------------------------------------------------
subroutine externalFEM_compute_bulk
implicit none
!
! PEL calcule l etat, les forces interieures, ...
!
! call PELupdateBeforeNewtonIteration
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_compute_free_vlocy
implicit none
integer :: ibdyty
!
! PEL calcule la vitesse libre
! Vfree = M**-1()
!
! call PELcomputeallVfree
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_get_free_vlocy(ibdyty,vfree)
implicit none
integer :: ibdyty
real(kind=8),dimension(:) :: vfree
!
! on recupere les Vfree
!
! print*,'Corps=',ibdyty
! call PELgetVfree(ibdyty,bdyty(ibdyty)%Vfree)
! print*,'Vfree=',Vfree
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_check_convergence(iconv)
implicit none
integer :: iconv
!
! PEL calcule la norme de convergence et dit si ca CV (1) ou non (0)
!
! call PELcheckconvergence(iconv)
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
!subroutine externalFEM_check_stop(istop)
! implicit none
! integer :: istop,iconv
!
! PEL donne un critère d arret: oui (1) ou non (0)
!
!
! call PELcheckstop(iconv)
! istop = 1 - iconv
!
!end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_update_bulk(istop)
implicit none
integer :: istop
!
! PEL a converge pour les comportements volumiques/surfaciques
! il actualise les degres de liberte et son etat: gradient,flux,variables internes/externes
!
! call PELupdateAfterTimeIteration()
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_comp_vlocy_mecaMAILx(ibdyty,R,V)
!
! called by vitrad
!
implicit none
integer :: ibdyty
real(kind=8),dimension(:) :: R,V
! call PELcomputeVaux(ibdyty,R,V)
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_compute_V(ibdyty,R,V)
implicit none
integer :: ibdyty
real(kind=8),dimension(:) :: R,V
! PEL calcule Vf=Vfree+M**-1 Reac
!
! call PELcomputeV(ibdyty,R)
!fp on recupere V
! call PELgetV(ibdyty,V)
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_update_position
implicit none
!
! PEL met a jour les deplacements Xf = Xm + (h*theta*Vf)
!
! call PELupdateAfterNewtonIteration()
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_get_kinematic(ID,nb_nodes,ux,uy,uz,vx,vy,vz)
implicit none
integer :: ID,nb_nodes
real(kind=8),dimension(nb_nodes) :: ux,uy,uz,vx,vy,vz
! call PELgetkine(ID,ux,uy,uz,vx,vy,vz)
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine externalFEM_get_nbval(nb_val)
implicit none
integer :: nb_val
! call PELNbVarSave(nb_val)
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
SUBROUTINE externalFEM_get_nameval(ival,name)
IMPLICIT NONE
INTEGER :: ival
CHARACTER(len=5) :: name
! CALL PELgetNameSave(ival,name)
END SUBROUTINE
!------------------------------------------------------------------------
subroutine externalFEM_get_val(ID,nb_nodes,nb_val,val)
implicit none
integer :: ID,nb_nodes,nb_val,ival
real(kind=8),dimension(nb_nodes,nb_val) :: val
do ival=1,nb_val
! call PELgetvaluesave(ID,ival,val(:,ival))
enddo
end subroutine
!------------------------------------------------------------------------
subroutine ExternalFEM_terminate
implicit none
! call PELterminate
end subroutine
end module
module ExternalModels
! additional module in order to use the MatLib modelling library
use utilities
!use bulk_behaviour
use models, only : get_nb_models , &
get_nb_ppsets , &
get_ppset_value, &
get_eleop_id , &
get_eleop_value, &
get_eleop_value_bypps
implicit none
private
! map between lmgc90 ppset and matlib ppset
integer,dimension(:),allocatable :: external_ppset
! wrap
public init_external_models,check_external_ppset, clean_memory
! internal API
public compute_external_pg,set_ortho_frame
contains
!
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine init_External_Models
implicit none
integer :: ibehav,imodel,ippset,id
character(len=5) :: isext
!123456789012345678901234567
character(len=27) :: IAM='models::init_external_model'
call logmes('Entering : '//IAM)
!fd on pousse les modeles dans la librairie externe
do imodel=1,get_nb_models()
id = get_eleop_id(imodel,'isext')
if ( id /= 0) then
isext = get_eleop_value(imodel,id)
if (isext == 'yes__') then
call push_model(imodel)
endif
endif
enddo
call logmes('Living : '//IAM)
end subroutine
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine push_model(imodel)
!
! declarations pour la matlib
! Dans le conteneur des variables externes on trouve les gradients et les flux.
! L'operateur tangent a donc sa taille
!
! Dans le conteneur des variables internes ont trouve des variables internes ET
! des variables cachees necessaires a la matlib
!
! le modele elastique standard prend en compte la dilatation dans l'absolue il
! doit permettre un couplage faible
!
! le modele thermoelastique permet les couplages forts
!
implicit none
integer :: imodel
logical,save :: is_first_time=.true.
integer*4 :: i,imodelz,itmp,zdim,lchaine
character(len=80) :: chaine
character(len=5) :: kinematic,formulation,material,anisotropy
character(len=5) :: cplth
!123456789012345678901234567
character(len=27) :: IAM='models::load_external_model'
call logmes('Entering : '//IAM)
call faterr(iam,'Error: no external models available')
end subroutine push_model
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine check_external_ppset
implicit none
integer :: ibehav,imodel,ippset,nb_ppsets,iext_ppset
character(len=5) :: isext
!1234567890123456789012345678
character(len=28) :: IAM='models::check_external_ppset'
call logmes('Entering : '//IAM)
nb_ppsets = get_nb_ppsets()
if (nb_ppsets == 0) return
allocate(external_ppset(nb_ppsets))
external_ppset = 0
!fd on charge les materiaux
iext_ppset = 0
do ippset=1,get_nb_ppsets()
isext = get_eleop_value_bypps(ippset,'isext')
if (isext == 'yes__') then
iext_ppset = iext_ppset + 1
external_ppset(ippset)=iext_ppset
call get_ppset_value(ippset,imodel,ibehav)
!fd deja fait call push_external_model(imodel)
!fd old version
! call push_external_behaviour(ibehav)
! call check_external_model(ibehav,imodel)
!fd new version on a maintenant un set de parametres materiau par pg
!fd ce qui va permettre de les faires varier avec la T par exemple
call push_behaviour(ippset)
call check_ppset(ippset)
endif
end do
call logmes('Living : '//IAM)
end subroutine check_external_ppset
!------------------------------------------------------------------------
!------------------------------------------------------------------------
subroutine push_behaviour(ippset)
!fd attention new ibehav est remplace par le numero de ppset externe
!
implicit none
!123456789012345678901234567890123456789
character(len=30) :: IAM='ExternalModels::push_behaviour'
integer :: ibehav,ippset,iext_ppset,inull
real(kind=8) :: rho
real(kind=8) :: alpha,Tref_meca,Tref_ther,Tini_ther
real(kind=8) :: sphv,coco
integer :: anisotropy
real(kind=8),dimension(21) :: coeff
INTEGER :: iso_hard,cine_hard,visco_plas
REAL(kind=8), DIMENSION(10) :: crit_coeff
REAL(kind=8), DIMENSION(80) :: isoh_coeff
REAL(kind=8), DIMENSION(1) :: cinh_coeff
REAL(kind=8), DIMENSION(3) :: vplas_coeff
character(len=30) :: chaine
integer*4 :: lchaine,iext_ppset_z
logical :: is_external
call LOGMES('Entering : '//IAM)
call faterr(iam,'Error: no external behaviour available')
end subroutine push_behaviour
!------------------------------------------------------------------------
subroutine check_ppset(ippset)
implicit none
integer :: ippset,iext_ppset,imodel,inull
integer*4 :: iext_ppset_z,imodel_z,lchaine
character(len=80) :: chaine
!123456789012345678901234567
character(len=27) :: IAM='ExternalModels::check_ppset'
call LOGMES('Entering : '//IAM)
call faterr(iam,'Error: no ppset to check')
end subroutine check_ppset
!------------------------------------------------------------------------
!------------------------------------------------------------------------
SUBROUTINE compute_external_pg(ppsnb,extP_lbl,extP_len,ivalue,extP_val,extP_nb, &
GRAD0,FLUX0,INTERNAL0, &
GRAD1,FLUX1,INTERNAL1, &
D,H,calcD)
! zone de stockage: gradient,flux,internal,operateur tangent
real(kind=8),dimension(:) :: GRAD0,FLUX0,INTERNAL0
real(kind=8),dimension(:) :: GRAD1,FLUX1,INTERNAL1
real(kind=8),dimension(:),allocatable :: De
real(kind=8),dimension(:,:),pointer :: D
real(kind=8) :: H
! parametres externes
character(len=30),dimension(:) :: extP_lbl
integer*4 ,dimension(:) :: extP_len
real(kind=8) ,dimension(:) :: extP_val
integer*4 :: extP_nb, calcD
!fd
integer :: inull,ppsnb ,mdlnb ,nb_external
integer*4 :: ppsnb_z,mdlnb_z,ivalue
!fd
!12345678901234567890123456789012345
character(len=35) :: IAM='ExternalModels::compute_external_pg'
call faterr(iam,'Error: nothing to do')
END SUBROUTINE
subroutine set_ortho_frame(ippset,frame)
implicit none
integer ,intent(in) :: ippset
real(kind=8),intent(in) :: frame(:,:)
!1234567890123456789012345678901
character(len=31) :: IAM='ExternalModels::set_ortho_frame'
call faterr(iam,'Error: nothing to do')
end subroutine
subroutine clean_memory()
implicit none
if( allocated(external_ppset) ) deallocate(external_ppset)
end subroutine
end module
module SparseLinearAlgebra
implicit none
private
type, public :: G_sparse_matrix
private
logical :: empty = .true.
!type(dmumps_struc) :: mumps_par
end type G_sparse_matrix
public sparse_declare, &
sparse_build, &
sparse_solve, &
sparse_erase