Skip to content

Commit b5a3024

Browse files
authored
Merge pull request #489 from lanl/jhp/nlambda
2 parents 1823d15 + ab81273 commit b5a3024

27 files changed

+30
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
### Infrastructure (changes irrelevant to downstream codes)
2727
- [[PR481]](https://github.com/lanl/singularity-eos/pull/481) Move mutable diagnostic variables in singularity-eos into optional indexable types in a lambda.
2828
- [[PR486]](https://github.com/lanl/singularity-eos/pull/486) Use default behavior for max_scratch_size and scratch_size in the eos base class
29+
- [[PR489]](https://github.com/lanl/singularity-eos/pull/489) Move default behavior for nlambda to the eos base class
2930

3031
### Removed (removing behavior/API/varaibles/...)
3132

python/module.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ py::class_<T> eos_class(py::module_ & m, std::string name) {
346346

347347
.def("MinimumDensity", &T::MinimumDensity)
348348
.def("MinimumTemperature", &T::MinimumTemperature)
349-
.def_property_readonly("nlambda", &T::nlambda)
349+
.def_property_readonly_static("nlambda", [](py::object) { return T::nlambda(); })
350350
.def_property_readonly_static("PreferredInput", [](py::object) { return T::PreferredInput(); })
351351
.def("PrintParams", &T::PrintParams)
352352
.def("DensityEnergyFromPressureTemperature", [](const T & self, const Real press, const Real temp, py::array_t<Real> lambda) {

singularity-eos/eos/eos_base.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ class EosBase {
811811
return 0;
812812
}
813813
static inline unsigned long max_scratch_size(const unsigned int nelements) { return 0; }
814+
constexpr static inline int nlambda() noexcept { return 0.; }
814815

815816
// JMM: EOS's which encapsulate a mix or reactions may wish to vary
816817
// this. For example, Helmholtz and StellarCollapse. This isn't the

singularity-eos/eos/eos_carnahan_starling.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ class CarnahanStarling : public EosBase<CarnahanStarling> {
230230
// Generic functions provided by the base class. These contain e.g. the vector
231231
// overloads that use the scalar versions declared here
232232
SG_ADD_BASE_CLASS_USINGS(CarnahanStarling)
233-
PORTABLE_INLINE_FUNCTION
234-
int nlambda() const noexcept { return 0; }
233+
235234
static constexpr unsigned long PreferredInput() { return _preferred_input; }
236235
PORTABLE_INLINE_FUNCTION void PrintParams() const {
237236
printf("Carnahan-Starling Parameters:\nGamma = %g\nCv = %g\nb = %g\nq = "

singularity-eos/eos/eos_davis.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ class DavisReactants : public EosBase<DavisReactants> {
167167
// Generic functions provided by the base class. These contain e.g. the vector
168168
// overloads that use the scalar versions declared here
169169
SG_ADD_BASE_CLASS_USINGS(DavisReactants)
170-
PORTABLE_INLINE_FUNCTION
171-
int nlambda() const noexcept { return 0; }
170+
172171
static constexpr unsigned long PreferredInput() { return _preferred_input; }
173172
PORTABLE_INLINE_FUNCTION void PrintParams() const {
174173
static constexpr char s1[]{"DavisReactants Params: "};
@@ -308,8 +307,7 @@ class DavisProducts : public EosBase<DavisProducts> {
308307
// Generic functions provided by the base class. These contain e.g. the vector
309308
// overloads that use the scalar versions declared here
310309
SG_ADD_BASE_CLASS_USINGS(DavisProducts)
311-
PORTABLE_INLINE_FUNCTION
312-
int nlambda() const noexcept { return 0; }
310+
313311
static constexpr unsigned long PreferredInput() { return _preferred_input; }
314312
static inline unsigned long scratch_size(std::string method, unsigned int nelements) {
315313
return 0;

singularity-eos/eos/eos_electrons.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ class IdealElectrons : public EosBase<IdealElectrons> {
192192
// here
193193
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
194194
SG_ADD_BASE_CLASS_USINGS(IdealElectrons)
195-
PORTABLE_INLINE_FUNCTION
196-
int nlambda() const noexcept { return 1; }
195+
constexpr static inline int nlambda() noexcept { return 1; }
197196
template <typename T>
198197
static inline constexpr bool NeedsLambda() {
199198
return std::is_same<T, IndexableTypes::MeanIonizationState>::value;

singularity-eos/eos/eos_eospac.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,6 @@ class EOSPAC : public EosBase<EOSPAC> {
11171117
}
11181118

11191119
static constexpr unsigned long PreferredInput() { return _preferred_input; }
1120-
PORTABLE_INLINE_FUNCTION int nlambda() const noexcept { return 0; }
11211120
inline void Finalize() {
11221121
using namespace EospacWrapper;
11231122
eosSafeDestroy(NT, tablehandle, Verbosity::Quiet);

singularity-eos/eos/eos_gruneisen.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ class Gruneisen : public EosBase<Gruneisen> {
156156
// overloads that use the scalar versions declared here
157157
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
158158
SG_ADD_BASE_CLASS_USINGS(Gruneisen)
159-
PORTABLE_INLINE_FUNCTION
160-
int nlambda() const noexcept { return 0; }
159+
161160
static constexpr unsigned long PreferredInput() { return _preferred_input; }
162161
PORTABLE_INLINE_FUNCTION void PrintParams() const {
163162
static constexpr char s1[]{"Gruneisen Params: "};

singularity-eos/eos/eos_helmholtz.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,7 @@ class Helmholtz : public EosBase<Helmholtz> {
458458
options_(rad, gas, coul, ion, ele, verbose, newton_raphson) {}
459459

460460
PORTABLE_INLINE_FUNCTION void CheckParams() const { electrons_.CheckParams(); }
461-
462-
PORTABLE_INLINE_FUNCTION int nlambda() const noexcept { return 3; }
461+
constexpr static inline int nlambda() noexcept { return 3; }
463462
template <typename T>
464463
static inline constexpr bool NeedsLambda() {
465464
return std::is_same<T, IndexableTypes::MeanAtomicMass>::value ||

singularity-eos/eos/eos_ideal.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ class IdealGas : public EosBase<IdealGas> {
173173
// overloads that use the scalar versions declared here
174174
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
175175
SG_ADD_BASE_CLASS_USINGS(IdealGas)
176-
PORTABLE_INLINE_FUNCTION
177-
int nlambda() const noexcept { return 0; }
176+
178177
static constexpr unsigned long PreferredInput() { return _preferred_input; }
179178
PORTABLE_INLINE_FUNCTION void PrintParams() const {
180179
printf("Ideal Gas Parameters:\nGamma = %g\nCv = %g\n", _gm1 + 1.0, _Cv);

singularity-eos/eos/eos_jwl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ class JWL : public EosBase<JWL> {
113113
// overloads that use the scalar versions declared here
114114
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
115115
SG_ADD_BASE_CLASS_USINGS(JWL)
116-
PORTABLE_INLINE_FUNCTION
117-
int nlambda() const noexcept { return 0; }
116+
118117
template <typename Indexer_t = Real *>
119118
PORTABLE_INLINE_FUNCTION void
120119
ValuesAtReferenceState(Real &rho, Real &temp, Real &sie, Real &press, Real &cv,

singularity-eos/eos/eos_mgusup.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ class MGUsup : public EosBase<MGUsup> {
152152
// overloads that use the scalar versions declared here
153153
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
154154
SG_ADD_BASE_CLASS_USINGS(MGUsup)
155-
PORTABLE_INLINE_FUNCTION
156-
int nlambda() const noexcept { return 0; }
155+
157156
static constexpr unsigned long PreferredInput() { return _preferred_input; }
158157
PORTABLE_INLINE_FUNCTION void PrintParams() const {
159158
static constexpr char st[]{"MGUsup Params: "};

singularity-eos/eos/eos_noble_abel.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ class NobleAbel : public EosBase<NobleAbel> {
180180
// overloads that use the scalar versions declared here
181181
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
182182
SG_ADD_BASE_CLASS_USINGS(NobleAbel)
183-
PORTABLE_INLINE_FUNCTION
184-
int nlambda() const noexcept { return 0; }
183+
185184
static constexpr unsigned long PreferredInput() { return _preferred_input; }
186185
PORTABLE_INLINE_FUNCTION void PrintParams() const {
187186
printf("Noble-Abel Parameters:\nGamma = %g\nCv = %g\nb = %g\nq = "

singularity-eos/eos/eos_powermg.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ class PowerMG : public EosBase<PowerMG> {
137137
// overloads that use the scalar versions declared here
138138
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
139139
SG_ADD_BASE_CLASS_USINGS(PowerMG)
140-
PORTABLE_INLINE_FUNCTION
141-
int nlambda() const noexcept { return 0; }
140+
142141
static constexpr unsigned long PreferredInput() { return _preferred_input; }
143142
PORTABLE_INLINE_FUNCTION void PrintParams() const {
144143
static constexpr char st[]{"PowerMG Params: "};

singularity-eos/eos/eos_sap_polynomial.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ class SAP_Polynomial : public EosBase<SAP_Polynomial> {
186186
// overloads that use the scalar versions declared here
187187
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
188188
SG_ADD_BASE_CLASS_USINGS(SAP_Polynomial)
189-
PORTABLE_INLINE_FUNCTION
190-
int nlambda() const noexcept { return 0; }
189+
191190
static constexpr unsigned long PreferredInput() { return _preferred_input; }
192191
PORTABLE_INLINE_FUNCTION void PrintParams() const {
193192
printf("SAP_Polynomial EOS Parameters:\n");

singularity-eos/eos/eos_spiner.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ class SpinerEOSDependsRhoT : public EosBase<SpinerEOSDependsRhoT> {
214214
PORTABLE_FORCEINLINE_FUNCTION
215215
Real MinimumPressure() const { return PMin_; }
216216

217-
PORTABLE_INLINE_FUNCTION
218-
int nlambda() const noexcept { return _n_lambda; }
217+
constexpr static inline int nlambda() noexcept { return _n_lambda; }
219218
template <typename T>
220219
static inline constexpr bool NeedsLambda() {
221220
using namespace IndexableTypes;
@@ -498,8 +497,7 @@ class SpinerEOSDependsRhoSie : public EosBase<SpinerEOSDependsRhoSie> {
498497
return rho_at_pmin_.interpToReal(toLog_(temp, lTOffset_));
499498
}
500499

501-
PORTABLE_INLINE_FUNCTION
502-
int nlambda() const noexcept { return _n_lambda; }
500+
constexpr static inline int nlambda() noexcept { return _n_lambda; }
503501
template <typename T>
504502
static inline constexpr bool NeedsLambda() {
505503
return std::is_same<T, IndexableTypes::LogDensity>::value;

singularity-eos/eos/eos_stellar_collapse.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ class StellarCollapse : public EosBase<StellarCollapse> {
235235
PORTABLE_FORCEINLINE_FUNCTION Real MinimumDensity() const { return rhoMin(); }
236236
PORTABLE_FORCEINLINE_FUNCTION Real MinimumTemperature() const { return TMin(); }
237237
PORTABLE_FORCEINLINE_FUNCTION Real MaximumDensity() const { return rhoMax(); }
238-
PORTABLE_INLINE_FUNCTION
239-
int nlambda() const noexcept { return _n_lambda; }
238+
constexpr static inline int nlambda() noexcept { return _n_lambda; }
240239
template <typename T>
241240
static inline constexpr bool NeedsLambda() {
242241
using namespace IndexableTypes;

singularity-eos/eos/eos_stiff.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ class StiffGas : public EosBase<StiffGas> {
166166
// overloads that use the scalar versions declared here
167167
SG_ADD_BASE_CLASS_USINGS(StiffGas)
168168
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
169-
PORTABLE_INLINE_FUNCTION
170-
int nlambda() const noexcept { return 0; }
169+
171170
static constexpr unsigned long PreferredInput() { return _preferred_input; }
172171
PORTABLE_INLINE_FUNCTION void PrintParams() const {
173172
printf("Stiff Gas Parameters:\nGamma = %g\nCv = %g\nPinf = %g\nq = "

singularity-eos/eos/eos_variant.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,8 @@ class Variant {
13211321
eos_);
13221322
}
13231323

1324-
PORTABLE_INLINE_FUNCTION
1325-
int nlambda() const noexcept {
1324+
PORTABLE_FORCEINLINE_FUNCTION
1325+
int nlambda() noexcept {
13261326
return mpark::visit([](const auto &eos) { return eos.nlambda(); }, eos_);
13271327
}
13281328

singularity-eos/eos/eos_vinet.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ class Vinet : public EosBase<Vinet> {
144144
// overloads that use the scalar versions declared here
145145
SG_ADD_BASE_CLASS_USINGS(Vinet)
146146
SG_ADD_DEFAULT_MEAN_ATOMIC_FUNCTIONS(_AZbar)
147-
PORTABLE_INLINE_FUNCTION
148-
int nlambda() const noexcept { return 0; }
147+
149148
static constexpr unsigned long PreferredInput() { return _preferred_input; }
150149
PORTABLE_INLINE_FUNCTION void PrintParams() const {
151150
static constexpr char st[]{"Vinet Params: "};

singularity-eos/eos/modifiers/eos_unitsystem.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ class UnitSystem : public EosBase<UnitSystem<T>> {
431431
std::forward<Transform>(transform));
432432
}
433433

434-
PORTABLE_INLINE_FUNCTION
435-
int nlambda() const noexcept { return t_.nlambda(); }
434+
constexpr static inline int nlambda() noexcept { return T::nlambda(); }
436435
template <typename Indexable>
437436
static inline constexpr bool NeedsLambda() {
438437
return T::template NeedsLambda<Indexable>();

singularity-eos/eos/modifiers/floored_energy.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ class FlooredEnergy : public EosBase<FlooredEnergy<T>> {
295295
std::forward<Transform>(transform));
296296
}
297297

298-
PORTABLE_INLINE_FUNCTION
299-
int nlambda() const noexcept { return t_.nlambda(); }
298+
constexpr static inline int nlambda() noexcept { return T::nlambda(); }
300299

301300
static constexpr unsigned long PreferredInput() { return T::PreferredInput(); }
302301

singularity-eos/eos/modifiers/ramps_eos.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ class BilinearRampEOS : public EosBase<BilinearRampEOS<T>> {
442442
std::forward<Transform>(transform));
443443
}
444444

445-
PORTABLE_INLINE_FUNCTION
446-
int nlambda() const noexcept { return t_.nlambda(); }
445+
constexpr static inline int nlambda() noexcept { return T::nlambda(); }
447446
template <typename Indexable>
448447
static inline constexpr bool NeedsLambda() {
449448
return T::template NeedsLambda<Indexable>();

singularity-eos/eos/modifiers/relativistic_eos.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ class RelativisticEOS : public EosBase<RelativisticEOS<T>> {
146146
t_.FillEos(rho, temp, energy, press, cv, bmod, output, lambda);
147147
}
148148

149-
PORTABLE_INLINE_FUNCTION
150-
int nlambda() const noexcept { return t_.nlambda(); }
149+
constexpr static inline int nlambda() noexcept { return T::nlambda(); }
151150
template <typename Indexable>
152151
static inline constexpr bool NeedsLambda() {
153152
return T::template NeedsLambda<Indexable>();

singularity-eos/eos/modifiers/scaled_eos.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,7 @@ class ScaledEOS : public EosBase<ScaledEOS<T>> {
309309
std::forward<Transform>(transform));
310310
}
311311

312-
PORTABLE_INLINE_FUNCTION
313-
int nlambda() const noexcept { return t_.nlambda(); }
312+
constexpr static inline int nlambda() noexcept { return T::nlambda(); }
314313
template <typename Indexable>
315314
static inline constexpr bool NeedsLambda() {
316315
return T::template NeedsLambda<Indexable>();

singularity-eos/eos/modifiers/shifted_eos.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ class ShiftedEOS : public EosBase<ShiftedEOS<T>> {
300300
std::forward<Transform>(transform));
301301
}
302302

303-
PORTABLE_INLINE_FUNCTION
304-
int nlambda() const noexcept { return t_.nlambda(); }
303+
constexpr static inline int nlambda() noexcept { return T::nlambda(); }
305304
template <typename Indexable>
306305
static inline constexpr bool NeedsLambda() {
307306
return T::template NeedsLambda<Indexable>();

singularity-eos/eos/modifiers/zsplit_eos.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ class ZSplit : public EosBase<ZSplit<ztype, T>> {
224224
sie *= scale;
225225
}
226226

227-
PORTABLE_INLINE_FUNCTION
228-
int nlambda() const noexcept { return 1 + t_.nlambda(); }
227+
constexpr static inline int nlambda() noexcept { return 1 + T::nlambda(); }
229228
template <typename Indexable>
230229
static inline constexpr bool NeedsLambda() {
231230
return std::is_same<Indexable, IndexableTypes::MeanIonizationState>::value ||
@@ -282,7 +281,7 @@ class ZSplit : public EosBase<ZSplit<ztype, T>> {
282281
if constexpr (is_indexable_v<Indexer_t, IndexableTypes::MeanIonizationState>) {
283282
return std::max(0.0, lambda[IndexableTypes::MeanIonizationState()]);
284283
} else {
285-
return std::max(0.0, lambda[t_.nlambda()]);
284+
return std::max(0.0, lambda[T::nlambda()]);
286285
}
287286
}
288287
// TODO(JMM): Runtime?

0 commit comments

Comments
 (0)