Skip to content

Commit 8d9747f

Browse files
committed
use common enum
1 parent 297be10 commit 8d9747f

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

src/phase.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ module phase
6262
DAMAGE_ISOBRITTLE, &
6363
DAMAGE_ANISOBRITTLE, &
6464
THERMAL_SOURCE_DISSIPATION, &
65-
THERMAL_SOURCE_EXTERNALHEAT
65+
THERMAL_SOURCE_EXTERNALHEAT, &
66+
CHEMICAL_QUADENERGY
6667
end enum
6768

6869

src/phase_chemical.f90

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
real(pREAL) :: V_m = 0.0_pREAL !< molar volume
88
end type tChemicalParameters
99

10-
enum, bind(c); enumerator :: &
11-
CHEMICAL_UNDEFINED_ID ,&
12-
CHEMICAL_QUADENERGY_ID
13-
end enum
14-
15-
integer(kind(CHEMICAL_UNDEFINED_ID)), dimension(:), allocatable :: &
10+
integer(kind(UNDEFINED)), dimension(:), allocatable :: &
1611
chemical_energy
1712

1813
type :: tDataContainer ! ?? not very telling name. Better: "fieldQuantities" ??
@@ -85,8 +80,7 @@ module subroutine chemical_init(phases)
8580
print'(/,a)', ' <<<+- phase:chemical init -+>>>'
8681

8782
allocate(current(size(phases)))
88-
!allocate(chemicalState(size(phases)))
89-
allocate(chemical_energy(size(phases)),source=CHEMICAL_UNDEFINED_ID)
83+
allocate(chemical_energy(size(phases)),source=UNDEFINED)
9084
allocate(param(size(phases)))
9185

9286
phases => config_material%get_dict('phase')
@@ -97,11 +91,11 @@ module subroutine chemical_init(phases)
9791
end do
9892

9993
!initialize chemical energy model
100-
where(quadEnergy_init()) chemical_energy = CHEMICAL_QUADENERGY_ID
94+
where(quadEnergy_init()) chemical_energy = CHEMICAL_QUADENERGY
10195

10296
do ph = 1,size(phases)
10397
Nmembers = count(material_ID_phase == ph)
104-
if (chemical_energy(ph) == CHEMICAL_UNDEFINED_ID) then
98+
if (chemical_energy(ph) == UNDEFINED) then
10599
allocate(current(ph)%C(1,Nmembers),source=0.0_pREAL)
106100
allocate(current(ph)%dot_C(1,Nmembers),source=0.0_pREAL)
107101
allocate(current(ph)%C0(1,Nmembers),source=0.0_pREAL)
@@ -116,6 +110,7 @@ end subroutine chemical_init
116110
!< @brief Calculates composition for constituent.
117111
!----------------------------------------------------------------------------------------------
118112
module function phase_calculate_composition(mu,co,ce) result(conc)
113+
119114
real(pREAL), intent(in), dimension(:) :: mu
120115
integer, intent(in) :: co, ce
121116
real(pREAL), dimension(:), allocatable :: conc
@@ -124,49 +119,51 @@ module function phase_calculate_composition(mu,co,ce) result(conc)
124119
integer :: &
125120
ph, en
126121

122+
127123
ph = material_ID_phase(co,ce)
128124
en = material_entry_phase(co,ce)
129125

130126
mu_chemical = mu
131127
chemicalEnergyType: select case (chemical_energy(ph))
132128

133-
case (CHEMICAL_QUADENERGY_ID)
134-
conc = quadEnergy_composition(mu_chemical,ph,en)
135-
case default
136-
conc = [0.0_pREAL]
129+
case (CHEMICAL_QUADENERGY)
130+
conc = quadEnergy_composition(mu_chemical,ph,en)
137131

138132
end select chemicalEnergyType
139133

140134
end function phase_calculate_composition
141135

142136

143137
!----------------------------------------------------------------------------------------------
144-
!< @brief Retrieves composition for constituent
138+
!< @brief Retrieves composition for constituent.
145139
!----------------------------------------------------------------------------------------------
146140
module function phase_get_mobility(co,ce) result(mobility)
141+
147142
integer, intent(in) :: co, ce
148143
real(pREAL), dimension(:,:),allocatable :: mobility
149144

150145
integer :: &
151146
ph, en
152147

148+
153149
ph = material_ID_phase(co,ce)
154150
en = material_entry_phase(co,ce)
155151

156152
chemicalEnergyType: select case (chemical_energy(ph))
157153

158-
case (CHEMICAL_QUADENERGY_ID)
159-
mobility = quadEnergy_mobility(ph,en)
154+
case (CHEMICAL_QUADENERGY)
155+
mobility = quadEnergy_mobility(ph,en)
160156

161157
end select chemicalEnergyType
162158

163159
end function phase_get_mobility
164160

165161

166162
!----------------------------------------------------------------------------------------------
167-
!< @brief Retrieves composition tangent for constituent
163+
!< @brief Retrieves composition tangent for constituent.
168164
!----------------------------------------------------------------------------------------------
169165
module function phase_compositionTangent(mu,co,ce) result(comp_tangent)
166+
170167
real(pREAL), dimension(:), intent(in) :: mu
171168
integer, intent(in) :: co, ce
172169
real(pREAL), dimension(:,:),allocatable :: comp_tangent
@@ -175,14 +172,15 @@ module function phase_compositionTangent(mu,co,ce) result(comp_tangent)
175172
integer :: &
176173
ph, en
177174

175+
178176
ph = material_ID_phase(co,ce)
179177
en = material_entry_phase(co,ce)
180178

181179
mu_chemical = mu
182180
chemicalEnergyType: select case (chemical_energy(ph))
183181

184-
case (CHEMICAL_QUADENERGY_ID)
185-
comp_tangent = quadEnergy_compositionTangent(mu_chemical,ph,en)
182+
case (CHEMICAL_QUADENERGY)
183+
comp_tangent = quadEnergy_compositionTangent(mu_chemical,ph,en)
186184

187185
end select chemicalEnergyType
188186

@@ -212,12 +210,12 @@ module subroutine chemical_result(group,ph)
212210
integer, intent(in) :: ph
213211

214212

215-
if (chemical_energy(ph) /= CHEMICAL_UNDEFINED_ID) &
213+
if (chemical_energy(ph) /= UNDEFINED) &
216214
call result_closeGroup(result_addGroup(group//'chemical'))
217215

218216
chemicalEnergyType: select case (chemical_energy(ph))
219217

220-
case (CHEMICAL_QUADENERGY_ID)
218+
case (CHEMICAL_QUADENERGY)
221219
call quadEnergy_results(ph,current(ph)%C,group//'chemical/')
222220

223221
end select chemicalEnergyType

0 commit comments

Comments
 (0)