Merge branch 'development' into feature/0DGrid

Conflicts:
	src/modules/mesh/moduleMesh.f90
This commit is contained in:
Jorge Gonzalez 2021-04-13 17:46:20 +02:00
commit 0ffdb8578a
11 changed files with 190 additions and 92 deletions

View file

@ -206,7 +206,6 @@ MODULE moduleInput
CALL config%get(object // '.WeightingScheme', WSType, found)
CALL solver%initWS(WSType)
!Makes tau(s) non-dimensional
tau = tau / ti_ref
tauMin = tauMin / ti_ref
@ -219,7 +218,6 @@ MODULE moduleInput
!Read initial state for species
CALL verboseError('Reading Initial state...')
CALL readInitial(config)
CALL checkStatus(config, "readInitial")
END SUBROUTINE readCase
@ -237,14 +235,21 @@ MODULE moduleInput
LOGICAL:: found
CHARACTER(:), ALLOCATABLE:: object
INTEGER:: nInitial
INTEGER:: i, p, e
INTEGER:: i, j, p, e
CHARACTER(LEN=2):: iString
CHARACTER(:), ALLOCATABLE:: spName
INTEGER:: sp
CHARACTER(:), ALLOCATABLE:: spFile
INTEGER:: stat
CHARACTER(100):: dummy
REAL(8):: density, velocity(1:3), temperature
CHARACTER(:), ALLOCATABLE:: filename
REAL(8), ALLOCATABLE, DIMENSION(:):: density, temperature
REAL(8), ALLOCATABLE, DIMENSION(:,:):: velocity
INTEGER, ALLOCATABLE, DIMENSION(:):: nodes
INTEGER:: nNodes
REAL(8), ALLOCATABLE, DIMENSION(:):: source, fPsi
!Density at the volume centroid
REAL(8):: densityCen
!Mean velocity and temperature at particle position
REAL(8):: velocityXi(1:3), temperatureXi
INTEGER:: nNewPart = 0.D0
TYPE(particle), POINTER:: partNew
REAL(8):: vTh
@ -260,38 +265,76 @@ MODULE moduleInput
CALL config%get(object // '.speciesName', spName, found)
sp = speciesName2Index(spName)
CALL config%get(object // '.initialState', spFile, found)
OPEN (10, FILE = path // spFile, ACTION = 'READ')
DO
READ(10, '(A)', IOSTAT = stat) dummy
!If EoF, exit reading
IF (stat /= 0) EXIT
!If comment, skip
IF (INDEX(dummy,'#') /= 0) CYCLE
!Go up one line
BACKSPACE(10)
!Read information
READ(10, *) e, density, velocity, temperature
!Reads node values at the nodes
filename = path // spFile
CALL mesh%readInitial(sp, filename, density, velocity, temperature)
!For each volume in the node, create corresponding particles
DO e = 1, mesh%numVols
!Scale variables
!Particles in cell volume
nNewPart = INT(density * (mesh%vols(e)%obj%volume*Vol_ref) / species(sp)%obj%weight)
!Non-dimensional velocity
velocity = velocity / v_ref
!Non-dimensional temperature
temperature = temperature / T_ref
!Non-dimensional thermal temperature
vTh = DSQRT(temperature/species(sp)%obj%m)
!Density at centroid of cell
nodes = mesh%vols(e)%obj%getNodes()
nNodes = SIZE(nodes)
!TODO: Procedure to obtain centroid from element (also for printing Electric Field)
fPsi = mesh%vols(e)%obj%fPsi((/0.D0, 0.D0, 0.D0/))
ALLOCATE(source(1:nNodes))
DO j = 1, nNodes
source(j) = density(nodes(j))
END DO
densityCen = DOT_PRODUCT(fPsi, source)
DEALLOCATE(fPsi)
!Calculate number of particles
nNewPart = INT(densityCen * (mesh%vols(e)%obj%volume*Vol_ref) / species(sp)%obj%weight)
!Allocate new particles
DO p = 1, nNewPart
ALLOCATE(partNew)
partNew%species => species(sp)%obj
partNew%v(1) = velocity(1) + vTh*randomMaxwellian()
partNew%v(2) = velocity(2) + vTh*randomMaxwellian()
partNew%v(3) = velocity(3) + vTh*randomMaxwellian()
partNew%vol = e
partNew%r = mesh%vols(e)%obj%randPos()
partNew%xi = mesh%vols(e)%obj%phy2log(partNew%r)
partNew%n_in = .TRUE.
partNew%weight = species(sp)%obj%weight
!Get mean velocity at particle position
fPsi = mesh%vols(e)%obj%fPsi(partNew%xi)
DO j = 1, nNodes
source(j) = velocity(nodes(j), 1)
END DO
velocityXi(1) = DOT_PRODUCT(fPsi, source)
DO j = 1, nNodes
source(j) = velocity(nodes(j), 2)
END DO
velocityXi(2) = DOT_PRODUCT(fPsi, source)
DO j = 1, nNodes
source(j) = velocity(nodes(j), 3)
END DO
velocityXi(3) = DOT_PRODUCT(fPsi, source)
velocityXi = velocityXi / v_ref
!Get temperature at particle position
DO j = 1, nNodes
source(j) = temperature(nodes(j))
END DO
temperatureXi = DOT_PRODUCT(fPsi, source)
temperatureXi = temperatureXi / T_ref
vTh = DSQRT(temperatureXi / species(sp)%obj%m)
partNew%v(1) = velocityXi(1) + vTh*randomMaxwellian()
partNew%v(2) = velocityXi(2) + vTh*randomMaxwellian()
partNew%v(3) = velocityXi(3) + vTh*randomMaxwellian()
partNew%vol = e
IF (ASSOCIATED(meshForMCC, mesh)) THEN
partNew%volColl = partNew%vol
ELSE
partNew%volColl = findCellBrute(meshColl, partNew%r)
END IF
partNew%n_in = .TRUE.
partNew%weight = species(sp)%obj%weight
!If charged species, add qm to particle
SELECT TYPE(sp => species(sp)%obj)
TYPE IS (speciesCharged)
@ -305,8 +348,11 @@ MODULE moduleInput
!Assign particle to temporal list of particles
CALL partInitial%add(partNew)
END DO
DEALLOCATE(source)
END DO
END DO