Skip to content

Commit

Permalink
All source codes with make files added.
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidrezanorouzi committed Dec 8, 2020
0 parents commit 001733a
Show file tree
Hide file tree
Showing 42 changed files with 17,376 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod/
bin/
obj/
Results/
.cemfDEM

48 changes: 48 additions & 0 deletions ProgramDefinedGeometry.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
!-------------- cemfDEM code: a dem simulation code ----------------------------
! D C enter of
! D M E ngineering and
! D M M ultiscale modeling of
! D M F luid flow
! EEEEEEEEM .ir
!------------------------------------------------------------------------------
! Copyright (C): cemf
! website: www.cemf.ir
!------------------------------------------------------------------------------
! This file is part of cemfDEM code. It is a free software for simulating
! granular flow. You can redistribute it and/or modify it under the terms of
! GNU General Public License version 3 or any other later versions.
!
! cemfDEM code is distributed to help others in their research in the field
! of granular flow, but WITHOUT ANY WARRANTY; without even the implied
! warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!------------------------------------------------------------------------------

subroutine ProgramDefinedGeometry( Geom )
use g_Geometry
use g_Line
implicit none
class(Geometry),intent(in):: Geom

!// locals
type(real3) p1, p2, p3, p4
type(PlaneWall) plane
type(CylinderWall) cyl
logical res

! Creates a cylindrical shell with radius 7.5 cm and length 20 cm whose main axis is y.
! the property type is 1
! the user_id of this shell wall is 1
res = cyl%CreateCylinder( 0.075_RK, 0.075_RK, p_line( real3(0.0, 0.0, 0.0), real3(0.0,0.2,0.0) ),24, 1, 1 )
call Geom%add_Cylinder( cyl )

! a plane with width of 15 cm with normal vector of (0,1,0).
! this plane is placed at the bottom of the cylinder shell.
! the property type is 1
! the user_id of this plane is 1
p1 = real3( -0.075, 0, -0.075)
p2 = real3( -0.075, 0, 0.075)
p3 = real3( 0.075, 0, 0.075)
p4 = real3( 0.075, 0, -0.075)
call Geom%add_PlaneWall( p1, p2, p3, p4, 1, 1 )

end subroutine
35 changes: 35 additions & 0 deletions User_Mark.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
!-------------- cemfDEM code: a dem simulation code ----------------------------
! D C enter of
! D M E ngineering and
! D M M ultiscale modeling of
! D M F luid flow
! EEEEEEEEM .ir
!------------------------------------------------------------------------------
! Copyright (C): cemf
! website: www.cemf.ir
!------------------------------------------------------------------------------
! This file is part of cemfDEM code. It is a free software for simulating
! granular flow. You can redistribute it and/or modify it under the terms of
! GNU General Public License version 3 or any other later versions.
!
! cemfDEM code is distributed to help others in their research in the field
! of granular flow, but WITHOUT ANY WARRANTY; without even the implied
! warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!------------------------------------------------------------------------------

function User_Mark( id, flag, ptype, dpos ) result (mark)
use g_TypeDef
implicit none

integer(IK),intent(in):: id, flag, ptype
type(real4),intent(in):: dpos
integer(IK) mark


mark = 1


return


end function
Binary file added cemfDEM
Binary file not shown.
97 changes: 97 additions & 0 deletions main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
!-------------- cemfDEM code: a dem simulation code ----------------------------
! D C enter of
! D M E ngineering and
! D M M ultiscale modeling of
! D M F luid flow
! EEEEEEEEM .ir
!------------------------------------------------------------------------------
! Copyright (C): cemf
! website: www.cemf.ir
!------------------------------------------------------------------------------
! This file is part of cemfDEM code. It is a free software for simulating
! granular flow. You can redistribute it and/or modify it under the terms of
! GNU General Public License version 3 or any other later versions.
!
! cemfDEM code is distributed to help others in their research in the field
! of granular flow, but WITHOUT ANY WARRANTY; without even the implied
! warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
!------------------------------------------------------------------------------


Program main
use g_DEMSystem
use g_stl_reader
use g_Prtcl_PureProperty
implicit none

integer(IK) i
real(RK) Y, pr
logical res
type(real3) minDomain, maxDomain
type(PS_Distribution), pointer:: PSD
type(PSD_Property), pointer:: PSDP
class(PhysicalProperty),pointer:: Property
class(Geometry), pointer:: geom
type(real3) p1, p2, p3, p4
type(PlaneWall) insPlane
type(PureProperty) prop
type(DEMS_Options) DEM_opt
type(DEMSystem) DEM

!//// Initial settings

! options and settings for DEM simulation
DEM_opt%gravity = real3( 0.0, -9.8 , 0.0 )
DEM_opt%SaveFreq = 1000
DEM_opt%RunName = "PackingMono"
DEM_opt%Res_Dir = "./Results/"
DEM_opt%OutputFileType = OP_Type_VTK + OP_Type_Tec
DEM_opt%CT_model = CTM_ConstantTorque
DEM_opt%CF_Type = CFT_LSD_l
DEM_opt%CS_Method = CSM_NBS_Munjiza !_Hrchl !
DEM_opt%PI_Method = PIM_AB3AM4
DEM_opt%PRI_Method= PIM_AB3AM4

!// properties of particles and walls
Y = 1000000.0_RK ! Young's modulus
pr = 0.23_RK ! Poisson's ratio
call prop%set_prop(2500.0_RK, Y , Y/(2*(1+pr)), pr , 0.0_RK)

! mono-sized particles, 8000 particles with size of 7 mm.
allocate(PSD)
PSD = PS_Distribution( 8000 , PSD_Uniform, 1 , 0.007_RK, 0.007_RK )

! associates particle size distribution with property
allocate(PSDP)
PSDP = PSD_Property( PSD , prop )
deallocate(PSD)

!//// main components of DEM system

!//// geometry
allocate(geom)
call ProgramDefinedGeometry(geom)
!//// Property
allocate( Property )
call Property%ParticleProperty( PSDP ) ! particles
call Property%WallProperty(1 , (/prop/) ) ! walls
call Property%PP_BinaryProp(DEM_opt, 0.2_RK, 0.1_RK, 0.8_RK, 0.8_RK) ! binary pp
call Property%PW_BinaryProp(DEM_opt, 0.3_RK, 0.1_RK, 0.8_RK, 0.8_RK) ! binary pw
!//// DEM system with particle insertion
! simulation domain
minDomain = real3(-0.08, -0.01, -0.08)
maxDomain = real3( 0.08 , 0.21 , 0.08)
! insertion plane
p1 = real3(-0.05, 0.18, -0.05)
p2 = real3(-0.05, 0.18, 0.05)
p3 = real3( 0.05, 0.18, 0.05)
p4 = real3( 0.05, 0.18, -0.05)
res = insPlane%CreateWall_nv(p4,p3,p2,p1)

! initializes DEM system, dt = 0.00001 s, insert in 130 k iterations with initial velocity of 0.2 m/s
call DEM%Initialize( 0.00001_RK, PSDP, insPlane, 130000 , 0.2_RK ,geom, Property, minDomain, maxDomain, DEM_opt )

!//// iteration loop for 2.5 seconds
call DEM%iterate(250000)

end program
208 changes: 208 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
#-------------- cemfDEM code: a dem simulation code ----------------------------
# D C enter of
# D M E ngineering and
# D M M ultiscale modeling of
# D M F luid flow
# EEEEEEEEM .ir
#------------------------------------------------------------------------------
# Copyright (C): cemf
# website: www.cemf.ir
#------------------------------------------------------------------------------
# This file is part of cemfDEM code. It is a free software for simulating
# granular flow. You can redistribute it and/or modify it under the terms of
# GNU General Public License version 3 or any other later versions.
#
# cemfDEM code is distributed to help others in their research in the field
# of granular flow, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# makefile to build the program
#------------------------------------------------------------------------------

FortC = gfortran # can be replaced with any standard fortran compiler
FFLAGS = -O3

INCLUDES =
ExeName=cemfDEM
LFLAGS =
LIBS=

#current (top most directory) of the code
BASEPATH =$(CURDIR)

# Relative paths to the directories
SRCDIR =$(BASEPATH)/src
OBJDIR =$(BASEPATH)/obj
MODDIR =$(BASEPATH)/mod
RESDIR =$(BASEPATH)/Results

Exe = $(ExeName)
# Put module files in the mod dir
FFLAGS += -J$(MODDIR)

# Search path for source code
VPATH = $(SRCDIR)


ifneq ($(MODDIR),)
$(shell test -d $(MODDIR) || mkdir -p $(MODDIR))
endif

ifneq ($(RESDIR),)
$(shell test -d $(RESDIR) || mkdir -p $(RESDIR))
endif

ifneq ($(OBJDIR),)
$(shell test -d $(OBJDIR) || mkdir -p $(OBJDIR))
endif


# You can also remove the full path part
modSRC = \
g_DEMSystem.f90 \
g_Prtcl_Integration.f90 \
g_Prtcl_DefaultValues.f90 \
g_TypeDef.f90 \
g_LogInfo.f90 \
g_Prtcl_OneStepIntegration.f90 \
g_Prtcl_MultiPointIntegration.f90 \
g_error_handling.f90 \
g_Prtcl_TwoStepIntegratoin.f90 \
g_ContactSearch.f90 \
g_Geometry.f90 \
g_PlaneWall.f90 \
g_Line.f90 \
g_CylinderWall.f90 \
g_stl_reader.f90 \
g_Prtcl_NBS.f90 \
g_Prtcl_CellBased.f90 \
g_Prtcl_SimWorld.f90 \
g_Prtcl_SimDomain.f90 \
g_Prtcl_ContactList.f90 \
g_LinkedList.f90 \
g_Prtcl_ContactInfo.f90 \
g_Prtcl_NBS_Munjiza.f90 \
g_Prtcl_Hrchl_NBS.f90 \
g_prtcl_Hrchl_Munjiza.f90 \
g_ContactSearchPW.f90 \
g_Prtcl_LSD_Model.f90 \
g_Prtcl_ContactForce.f90 \
g_Prtcl_Property.f90 \
g_Prtcl_pureProp.f90 \
g_MakePrtcls.f90 \
g_RandumNum.f90 \
g_Prtcl_NonLin_Model.f90 \
g_WallOutput.f90 \
g_timer.f90 \
g_Prtcl_Insertion.f90


exeSrc = main.f90 ProgramDefinedGeometry.f90 User_Mark.f90

# Replace .f90 with .o and append object dir
modOBJ_O = $(patsubst %.f90,%.o,$(modSRC))
modOBJ = $(addprefix $(OBJDIR)/,$(modOBJ_O))

# Replace .f90 with .O and append object dir
exeOBJ_O = $(patsubst %.f90,%.o,$(exeSrc))
exeOBJ = $(addprefix $(OBJDIR)/,$(exeOBJ_O))

allObjects = $(modOBJ) $(exeOBJ)


all: main

main:$(allObjects)
$(FortC) $(INCLUDES) -o $(Exe) $+ $(LFLAGS) $(LIBS)
@echo The executable $(Exe) has been built

$(OBJDIR)/%.o: %.f90
$(FortC) $(FFLAGS) $(INCLUDES) -c -o $@ $<


# Dependency tree for modules and other sources
$(OBJDIR)/main.o:$(OBJDIR)/g_DEMSystem.o $(OBJDIR)/g_stl_reader.o $(OBJDIR)/g_Prtcl_pureProp.o

$(OBJDIR)/ProgramDefinedGeometry.o:$(OBJDIR)/g_Geometry.o $(OBJDIR)/g_Line.o

$(OBJDIR)/userMark.o:$(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_DEMSystem.o: $(OBJDIR)/g_Prtcl_Integration.o $(OBJDIR)/g_ContactSearch.o $(OBJDIR)/g_ContactSearchPW.o $(OBJDIR)/g_Prtcl_LSD_Model.o $(OBJDIR)/g_Prtcl_NonLin_Model.o $(OBJDIR)/g_WallOutput.o $(OBJDIR)/g_timer.o $(OBJDIR)/g_Prtcl_Insertion.o

$(OBJDIR)/g_Prtcl_Integration.o: $(OBJDIR)/g_Prtcl_DefaultValues.o $(OBJDIR)/g_Prtcl_OneStepIntegration.o $(OBJDIR)/g_Prtcl_MultiPointIntegration.o $(OBJDIR)/g_Prtcl_TwoStepIntegratoin.o

$(OBJDIR)/g_Prtcl_DefaultValues.o:$(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_LogInfo.o

$(OBJDIR)/g_LogInfo.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_OneStepIntegration.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_MultiPointIntegration.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_error_handling.o $(OBJDIR)/g_Prtcl_OneStepIntegration.o

$(OBJDIR)/g_error_handling.o: $(OBJDIR)/g_Prtcl_DefaultValues.o

$(OBJDIR)/g_Prtcl_TwoStepIntegratoin.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_error_handling.o $(OBJDIR)/g_Prtcl_MultiPointIntegration.o

$(OBJDIR)/g_ContactSearch.o: $(OBJDIR)/g_Geometry.o $(OBJDIR)/g_Prtcl_NBS.o $(OBJDIR)/g_Prtcl_NBS_Munjiza.o $(OBJDIR)/g_Prtcl_Hrchl_NBS.o $(OBJDIR)/g_Prtcl_DefaultValues.o $(OBJDIR)/g_prtcl_Hrchl_Munjiza.o

$(OBJDIR)/g_Geometry.o: $(OBJDIR)/g_PlaneWall.o $(OBJDIR)/g_CylinderWall.o $(OBJDIR)/g_stl_reader.o

$(OBJDIR)/g_PlaneWall.o: $(OBJDIR)/g_Line.o $(OBJDIR)/g_Prtcl_DefaultValues.o $(OBJDIR)/g_error_handling.o

$(OBJDIR)/g_Line.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_CylinderWall.o: $(OBJDIR)/g_PlaneWall.o $(OBJDIR)/g_error_handling.o

$(OBJDIR)/g_stl_reader.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_Prtcl_DefaultValues.o

$(OBJDIR)/g_Prtcl_NBS.o: $(OBJDIR)/g_Prtcl_CellBased.o $(OBJDIR)/g_error_handling.o

$(OBJDIR)/g_Prtcl_CellBased.o: $(OBJDIR)/g_error_handling.o $(OBJDIR)/g_Prtcl_SimWorld.o

$(OBJDIR)/g_Prtcl_SimWorld.o: $(OBJDIR)/g_Prtcl_SimDomain.o $(OBJDIR)/g_Prtcl_ContactList.o $(OBJDIR)/g_Prtcl_DefaultValues.o

$(OBJDIR)/g_Prtcl_SimDomain.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_ContactList.o: $(OBJDIR)/g_LinkedList.o $(OBJDIR)/g_Prtcl_ContactInfo.o $(OBJDIR)/g_error_handling.o

$(OBJDIR)/g_LinkedList.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_ContactInfo.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_NBS_Munjiza.o: $(OBJDIR)/g_Prtcl_CellBased.o

$(OBJDIR)/g_Prtcl_Hrchl_NBS.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_error_handling.o $(OBJDIR)/g_Prtcl_CellBased.o $(OBJDIR)/g_Prtcl_NBS.o

$(OBJDIR)/g_prtcl_Hrchl_Munjiza.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_error_handling.o $(OBJDIR)/g_Prtcl_NBS_Munjiza.o

$(OBJDIR)/g_ContactSearchPW.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_Prtcl_ContactList.o $(OBJDIR)/g_Geometry.o

$(OBJDIR)/g_Prtcl_LSD_Model.o: $(OBJDIR)/g_Prtcl_ContactForce.o

$(OBJDIR)/g_Prtcl_ContactForce.o: $(OBJDIR)/g_Prtcl_Property.o $(OBJDIR)/g_Prtcl_ContactList.o $(OBJDIR)/g_Geometry.o

$(OBJDIR)/g_Prtcl_Property.o: $(OBJDIR)/g_Prtcl_pureProp.o $(OBJDIR)/g_MakePrtcls.o

$(OBJDIR)/g_Prtcl_pureProp.o: $(OBJDIR)/g_Prtcl_DefaultValues.o

$(OBJDIR)/g_MakePrtcls.o: $(OBJDIR)/g_Prtcl_pureProp.o $(OBJDIR)/g_error_handling.o $(OBJDIR)/g_RandumNum.o

$(OBJDIR)/g_RandumNum.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_NonLin_Model.o: $(OBJDIR)/g_Prtcl_LSD_Model.o

$(OBJDIR)/g_WallOutput.o: $(OBJDIR)/g_TypeDef.o $(OBJDIR)/g_PlaneWall.o

$(OBJDIR)/g_timer.o: $(OBJDIR)/g_TypeDef.o

$(OBJDIR)/g_Prtcl_Insertion.o: $(OBJDIR)/g_PlaneWall.o



clean:
rm -r -f $(allObjects) $(MODDIR)/*
@echo The build has been cleaned

vtkClean:
rm -f -r *.vtk $(RESDIR)/*.vtk *.plt $(RESDIR)*.plt
@echo The content of $(RESDIR) has been cleaned
Loading

0 comments on commit 001733a

Please sign in to comment.