The integer part%sp that referenced the species index has been

substituted for a pointer to the species.
This commit is contained in:
Jorge Gonzalez 2021-03-28 15:55:26 +02:00
commit ec128902ad
13 changed files with 94 additions and 87 deletions

View file

@ -7,7 +7,7 @@ MODULE moduleSpecies
TYPE, ABSTRACT:: speciesGeneric
CHARACTER(:), ALLOCATABLE:: name
REAL(8):: m=0.D0, weight=0.D0
INTEGER:: sp=0
INTEGER:: n=0
END TYPE speciesGeneric
TYPE, EXTENDS(speciesGeneric):: speciesNeutral
@ -37,7 +37,7 @@ MODULE moduleSpecies
TYPE particle
REAL(8):: r(1:3) !Position
REAL(8):: v(1:3) !Velocity
INTEGER:: sp !Particle species id
CLASS(speciesGeneric), POINTER:: species !Pointer to species associated with this particle
INTEGER:: vol !Index of element in which the particle is located
REAL(8):: xi(1:3) !Logical coordinates of particle in element e_p.
LOGICAL:: n_in !Flag that indicates if a particle is in the domain
@ -48,6 +48,7 @@ MODULE moduleSpecies
!Number of old particles
INTEGER:: nPartOld
!Number of injected particles
INTEGER:: nPartInj
!Arrays that contain the particles
TYPE(particle), ALLOCATABLE, DIMENSION(:), TARGET:: partOld !array of particles from previous iteration
@ -60,15 +61,18 @@ MODULE moduleSpecies
CHARACTER(:), ALLOCATABLE:: speciesName
INTEGER:: sp
INTEGER:: n
INTEGER:: s
sp = 0
DO n = 1, nSpecies
IF (speciesName == species(n)%obj%name) THEN
sp = species(n)%obj%sp
EXIT
DO s = 1, nSpecies
IF (speciesName == species(s)%obj%name) THEN
sp = species(s)%obj%n
EXIT !If a species is found, exit the loop
END IF
END DO
!If no species is found, call a critical error
IF (sp == 0) CALL criticalError('Species ' // speciesName // ' not found.', 'speciesName2Index')
@ -83,7 +87,7 @@ MODULE moduleSpecies
TYPE(particle), INTENT(inout):: part
IF (ASSOCIATED(self%ion)) THEN
part%sp = self%ion%sp
part%species => self%ion
ELSE
CALL criticalError('No ion defined for species' // self%name, 'ionizeNeutral')
@ -101,7 +105,7 @@ MODULE moduleSpecies
TYPE(particle), INTENT(inout):: part
IF (ASSOCIATED(self%ion)) THEN
part%sp = self%ion%sp
part%species => self%ion
ELSE
CALL criticalError('No ion defined for species' // self%name, 'ionizeCharged')
@ -119,7 +123,7 @@ MODULE moduleSpecies
TYPE(particle), INTENT(inout):: part
IF (ASSOCIATED(self%neutral)) THEN
part%sp = self%neutral%sp
part%species => self%neutral
ELSE
CALL criticalError('No neutral defined for species' // self%name, 'neutralizeCharged')