Skip to content

Commit 21c8df6

Browse files
committed
Adapt keepParticleSingletonDim Exporter/API to particle modularization
1 parent 9ee1541 commit 21c8df6

19 files changed

+37
-30
lines changed

include/cadet/SolutionExporter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CADET_API ISolutionExporter
6363
* @details If particles are lumped to a single element, the singleton particle shell dimension can be removed.
6464
* @return @c true if particles are always represented by a single element, otherwise @c false
6565
*/
66-
virtual bool isParticleLumped() const CADET_NOEXCEPT = 0;
66+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT = 0;
6767

6868
/**
6969
* @brief Returns whether the primary coordinate is always a single element

include/common/SolutionRecorderImpl.hpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
5858
InternalStorageUnitOpRecorder(UnitOpIdx idx) : _cfgSolution({false, false, false, true, false, false, false}),
5959
_cfgSolutionDot({false, false, false, false, false, false, false}), _cfgSensitivity({false, false, false, true, false, false, false}),
6060
_cfgSensitivityDot({false, false, false, true, false, false, false}), _storeTime(false), _storeCoordinates(false), _splitComponents(true), _splitPorts(true),
61-
_singleAsMultiPortUnitOps(false), _keepBulkSingletonDim(true), _keepParticleSingletonDim(true), _curCfg(nullptr), _nComp(0), _nVolumeDof(0), _nAxialCells(0), _nRadialCells(0),
61+
_singleAsMultiPortUnitOps(false), _keepBulkSingletonDim(true), _curCfg(nullptr), _nComp(0), _nVolumeDof(0), _nAxialCells(0), _nRadialCells(0),
6262
_nInletPorts(0), _nOutletPorts(0), _numTimesteps(0), _numSens(0), _unitOp(idx), _needsReAlloc(false), _axialCoords(0), _radialCoords(0), _particleCoords(0)
6363
{
6464
}
@@ -125,19 +125,20 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
125125
_nOutletPorts = exporter.numOutletPorts();
126126

127127
_keepBulkSingletonDim = exporter.hasPrimaryExtent();
128-
_keepParticleSingletonDim = !exporter.isParticleLumped();
129128

130129
_nAxialCells = exporter.numPrimaryCoordinates();
131130
_nRadialCells = exporter.numSecondaryCoordinates();
132131

133132
// Query particle type specific structure
134133
const unsigned int numParTypes = exporter.numParticleTypes();
134+
_keepParticleSingletonDim.resize(numParTypes, 0u);
135135
_nParShells.resize(numParTypes, 0u);
136136
_nBoundStates.resize(numParTypes, 0u);
137137
for (unsigned int i = 0; i < numParTypes; ++i)
138138
{
139139
_nParShells[i] = exporter.numParticleShells(i);
140140
_nBoundStates[i] = exporter.numBoundStates(i);
141+
_keepParticleSingletonDim[i] = !exporter.isParticleLumped(i);
141142
}
142143

143144
// Obtain coordinates
@@ -350,7 +351,7 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
350351
unsigned int offset = 0;
351352
for (std::size_t pt = 0; pt < _nParShells.size(); ++pt)
352353
{
353-
if (_nParShells[pt] == 0 || (!_keepParticleSingletonDim && (_nParShells[pt] == 1)))
354+
if (_nParShells[pt] == 0 || (!_keepParticleSingletonDim[pt] && (_nParShells[pt] == 1)))
354355
continue;
355356

356357
oss.str("");
@@ -449,10 +450,10 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
449450
inline void treatSingleAsMultiPortUnitOps(bool smp) CADET_NOEXCEPT { _singleAsMultiPortUnitOps = smp; }
450451

451452
inline bool keepBulkSingletonDim() const CADET_NOEXCEPT { return _keepBulkSingletonDim; }
452-
inline void keepBulkSingletonDim(bool keepSingleton) CADET_NOEXCEPT { _keepBulkSingletonDim = keepSingleton; }
453+
inline void setKeepBulkSingletonDim(bool keepSingleton) CADET_NOEXCEPT { _keepBulkSingletonDim = keepSingleton; }
453454

454-
inline bool keepParticleSingletonDim() const CADET_NOEXCEPT { return _keepParticleSingletonDim; }
455-
inline void keepParticleSingletonDim(bool keepSingleton) CADET_NOEXCEPT { _keepParticleSingletonDim = keepSingleton; }
455+
inline bool keepParticleSingletonDim(unsigned int parType) const CADET_NOEXCEPT { return _keepParticleSingletonDim[parType]; }
456+
inline void setKeepParticleSingletonDim(bool keepSingleton) CADET_NOEXCEPT { std::fill(_keepParticleSingletonDim.begin(), _keepParticleSingletonDim.end(), keepSingleton); }
456457

457458
inline UnitOpIdx unitOperation() const CADET_NOEXCEPT { return _unitOp; }
458459
inline void unitOperation(UnitOpIdx idx) CADET_NOEXCEPT { _unitOp = idx; }
@@ -754,7 +755,7 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
754755
{
755756
if (_nParShells[0] >= 1)
756757
{
757-
if ((_nParShells[0] == 1) && _keepParticleSingletonDim)
758+
if ((_nParShells[0] == 1) && _keepParticleSingletonDim[0])
758759
layout.push_back(_nParShells[0]);
759760
else if (_nParShells[0] > 1)
760761
layout.push_back(_nParShells[0]);
@@ -779,12 +780,12 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
779780
std::size_t layoutSize = layout.size();
780781
if (hasParticleShells)
781782
{
782-
if ((_nParShells[parType] == 1) && !_keepParticleSingletonDim)
783+
if ((_nParShells[parType] == 1) && !_keepParticleSingletonDim[parType])
783784
{
784785
layout[layoutSize - 2] = _nComp;
785786
--layoutSize;
786787
}
787-
else if ((_nParShells[parType] == 1) && _keepParticleSingletonDim)
788+
else if ((_nParShells[parType] == 1) && _keepParticleSingletonDim[parType])
788789
layout[layout.size() - 2] = _nParShells[parType];
789790
else if (_nParShells[parType] > 1)
790791
layout[layout.size() - 2] = _nParShells[parType];
@@ -814,7 +815,7 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
814815
{
815816
if (_nParShells[0] >= 1)
816817
{
817-
if ((_nParShells[0] == 1) && _keepParticleSingletonDim)
818+
if ((_nParShells[0] == 1) && _keepParticleSingletonDim[0])
818819
layout.push_back(_nParShells[0]);
819820
else if (_nParShells[0] > 1)
820821
layout.push_back(_nParShells[0]);
@@ -839,9 +840,9 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
839840
std::size_t layoutSize = layout.size();
840841
if (hasParticleShells)
841842
{
842-
if ((_nParShells[parType] == 1) && !_keepParticleSingletonDim)
843+
if ((_nParShells[parType] == 1) && !_keepParticleSingletonDim[0])
843844
--layoutSize;
844-
else if ((_nParShells[parType] == 1) && _keepParticleSingletonDim)
845+
else if ((_nParShells[parType] == 1) && _keepParticleSingletonDim[0])
845846
layout[layout.size() - 2] = _nParShells[parType];
846847
else if (_nParShells[parType] > 1)
847848
layout[layout.size() - 2] = _nParShells[parType];
@@ -934,7 +935,7 @@ class InternalStorageUnitOpRecorder : public ISolutionRecorder
934935
bool _splitPorts;
935936
bool _singleAsMultiPortUnitOps;
936937
bool _keepBulkSingletonDim;
937-
bool _keepParticleSingletonDim;
938+
std::vector<bool> _keepParticleSingletonDim;
938939

939940
StorageConfig const* _curCfg;
940941
Storage* _curStorage;

src/libcadet/api/CAPIv1.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ namespace v1
610610
if (nParShells) \
611611
*nParShells = unitRec->numParticleShells(parType); \
612612
if (keepParticleSingletonDimension) \
613-
*keepParticleSingletonDimension = unitRec->keepParticleSingletonDim(); \
613+
*keepParticleSingletonDimension = unitRec->keepParticleSingletonDim(static_cast<unsigned int>(parType)); \
614614
if (nComp) \
615615
*nComp = unitRec->numComponents(); \
616616
if (data) \
@@ -648,7 +648,7 @@ namespace v1
648648
if (nParShells) \
649649
*nParShells = unitRec->numParticleShells(parType); \
650650
if (keepParticleSingletonDim) \
651-
*keepParticleSingletonDim = unitRec->keepParticleSingletonDim(); \
651+
*keepParticleSingletonDim = unitRec->keepParticleSingletonDim(static_cast<unsigned int>(parType)); \
652652
if (nBound) \
653653
*nBound = unitRec->numBoundStates(); \
654654
if (data) \
@@ -967,7 +967,7 @@ namespace v1
967967
return cdtDataNotStored;
968968
}
969969

970-
bool keepParticleSingletonDimension = unitRec->keepParticleSingletonDim();
970+
bool keepParticleSingletonDimension = unitRec->keepParticleSingletonDim(static_cast<unsigned int>(parType));
971971

972972
if (nCoords)
973973
*nCoords = unitRec->numParticleShells(parType);

src/libcadet/model/ColumnModel1D.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class ColumnModel1D : public UnitOperationBase
389389
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return true; }
390390
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return _disc.strideBound[_disc.nParType] > 0; }
391391
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
392-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return false; }
392+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return _model._particles[parType]->isParticleLumped(); }
393393
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return true; }
394394

395395
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _disc.nComp; }

src/libcadet/model/GeneralRateModel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class GeneralRateModel : public UnitOperationBase
464464
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return true; }
465465
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return _disc.strideBound[_disc.nParType] > 0; }
466466
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
467-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return false; }
467+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return false; }
468468
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return true; }
469469

470470
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _disc.nComp; }

src/libcadet/model/GeneralRateModel2D.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class GeneralRateModel2D : public UnitOperationBase
413413
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return true; }
414414
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return _disc.strideBound[_disc.nParType] > 0; }
415415
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
416-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return false; }
416+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return false; }
417417
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return true; }
418418

419419
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _disc.nComp; }

src/libcadet/model/GeneralRateModelDG.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class GeneralRateModelDG : public UnitOperationBase
389389
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return true; }
390390
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return _disc.strideBound[_disc.nParType] > 0; }
391391
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
392-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return false; }
392+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return false; }
393393
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return true; }
394394

395395
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _disc.nComp; }

src/libcadet/model/InletModel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class InletModel : public IUnitOperation
176176
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return false; }
177177
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return false; }
178178
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
179-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return false; }
179+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return false; }
180180
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return false; }
181181

182182
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _nComp; }

src/libcadet/model/LumpedRateModelWithPores.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class LumpedRateModelWithPores : public UnitOperationBase
394394
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return true; }
395395
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return _disc.strideBound[_disc.nParType] > 0; }
396396
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
397-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return true; }
397+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return true; }
398398
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return true; }
399399

400400
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _disc.nComp; }

src/libcadet/model/LumpedRateModelWithPoresDG.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class LumpedRateModelWithPoresDG : public UnitOperationBase
356356
virtual bool hasParticleMobilePhase() const CADET_NOEXCEPT { return true; }
357357
virtual bool hasSolidPhase() const CADET_NOEXCEPT { return _disc.strideBound[_disc.nParType] > 0; }
358358
virtual bool hasVolume() const CADET_NOEXCEPT { return false; }
359-
virtual bool isParticleLumped() const CADET_NOEXCEPT { return true; }
359+
virtual bool isParticleLumped(unsigned int parType) const CADET_NOEXCEPT { return true; }
360360
virtual bool hasPrimaryExtent() const CADET_NOEXCEPT { return true; }
361361

362362
virtual unsigned int numComponents() const CADET_NOEXCEPT { return _disc.nComp; }

0 commit comments

Comments
 (0)