Skip to content

Commit 67a46eb

Browse files
committed
Rename nCol to nElem in DG units (#406)
1 parent 6e77217 commit 67a46eb

12 files changed

+330
-332
lines changed

src/libcadet/model/GeneralRateModelDG-LinearSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int GeneralRateModelDG::linearSolve(double t, double alpha, double outerTol, dou
141141

142142
// Handle inlet DOFs:
143143
// Inlet at z = 0 for forward flow, at z = L for backward flow.
144-
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nCol - 1u) * idxr.strideColCell();
144+
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nElem - 1u) * idxr.strideColCell();
145145

146146
for (int comp = 0; comp < _disc.nComp; comp++) {
147147
for (int node = 0; node < (_disc.exactInt ? _disc.nNodes : 1); node++) {

src/libcadet/model/GeneralRateModelDG.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ bool GeneralRateModelDG::configureModelDiscretization(IParameterProvider& paramP
157157
_disc.nNodes = _disc.polyDeg + 1;
158158

159159
if (paramProvider.exists("NELEM"))
160-
_disc.nCol = paramProvider.getInt("NELEM");
160+
_disc.nElem = paramProvider.getInt("NELEM");
161161
else if (paramProvider.exists("NCOL"))
162-
_disc.nCol = std::max(1u, paramProvider.getInt("NCOL") / _disc.nNodes); // number of elements is rounded down
162+
_disc.nElem = std::max(1u, paramProvider.getInt("NCOL") / _disc.nNodes); // number of elements is rounded down
163163
else
164164
throw InvalidParameterException("Specify field NELEM (or NCOL)");
165165

166-
if (_disc.nCol < 1)
166+
if (_disc.nElem < 1)
167167
throw InvalidParameterException("Number of column elements must be at least 1!");
168168

169-
_disc.nPoints = _disc.nNodes * _disc.nCol;
169+
_disc.nPoints = _disc.nNodes * _disc.nElem;
170170

171171
int polynomial_integration_mode = 0;
172172
if (paramProvider.exists("EXACT_INTEGRATION"))
@@ -507,7 +507,7 @@ bool GeneralRateModelDG::configureModelDiscretization(IParameterProvider& paramP
507507
}
508508

509509
unsigned int strideColNode = _disc.nComp;
510-
const bool transportSuccess = _convDispOp.configureModelDiscretization(paramProvider, helper, _disc.nComp, polynomial_integration_mode, _disc.nCol, _disc.polyDeg, strideColNode);
510+
const bool transportSuccess = _convDispOp.configureModelDiscretization(paramProvider, helper, _disc.nComp, polynomial_integration_mode, _disc.nElem, _disc.polyDeg, strideColNode);
511511

512512
_disc.curSection = -1;
513513

@@ -1797,7 +1797,7 @@ void GeneralRateModelDG::multiplyWithJacobian(const SimulationTime& simTime, con
17971797

17981798
// Map inlet DOFs to the column inlet (first bulk cells)
17991799
// Inlet at z = 0 for forward flow, at z = L for backward flow.
1800-
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nCol - 1u) * idxr.strideColCell();
1800+
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nElem - 1u) * idxr.strideColCell();
18011801

18021802
for (unsigned int comp = 0; comp < _disc.nComp; comp++) {
18031803
for (unsigned int node = 0; node < (_disc.exactInt ? _disc.nNodes : 1); node++) {

src/libcadet/model/GeneralRateModelDG.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class GeneralRateModelDG : public UnitOperationBase
261261
struct Discretization
262262
{
263263
unsigned int nComp; //!< Number of components
264-
unsigned int nCol; //!< Number of column cells
264+
unsigned int nElem; //!< Number of DG elements
265265
unsigned int polyDeg; //!< polynomial degree of column elements
266266
unsigned int nNodes; //!< Number of nodes per column cell
267267
unsigned int nPoints; //!< Number of discrete column Points
@@ -779,10 +779,10 @@ class GeneralRateModelDG : public UnitOperationBase
779779
*/
780780
virtual int writePrimaryCoordinates(double* coords) const
781781
{
782-
for (unsigned int i = 0; i < _disc.nCol; i++) {
782+
for (unsigned int i = 0; i < _disc.nElem; i++) {
783783
for (unsigned int j = 0; j < _disc.nNodes; j++) {
784784
// mapping
785-
coords[i * _disc.nNodes + j] = _model._convDispOp.cellLeftBound(i) + 0.5 * (static_cast<double>(_model._convDispOp.columnLength()) / static_cast<double>(_disc.nCol)) * (1.0 + _model._convDispOp.LGLnodes()[j]);
785+
coords[i * _disc.nNodes + j] = _model._convDispOp.elemLeftBound(i) + 0.5 * (static_cast<double>(_model._convDispOp.columnLength()) / static_cast<double>(_disc.nElem)) * (1.0 + _model._convDispOp.LGLnodes()[j]);
786786
}
787787
}
788788
return _disc.nPoints;
@@ -1669,7 +1669,7 @@ class GeneralRateModelDG : public UnitOperationBase
16691669

16701670
linalg::BandedEigenSparseRowIterator jacIt(_globalJac, idxr.offsetCp(ParticleTypeIndex{ parType }, ParticleIndex{ colNode }) + idxr.strideParShell(parType) * 2); // row iterator starting at third cell, first component
16711671

1672-
// insert all (nCol - 4) inner cell blocks
1672+
// insert all (nElem - 4) inner cell blocks
16731673
for (unsigned int cell = 2; cell < _disc.nParCell[parType] - 2; cell++)
16741674
insertParJacBlock(_disc.DGjacParDispBlocks[_disc.offsetMetric[parType] + cell], jacIt, idxr, parDiff, parSurfDiff, invBetaP, _binding[parType]->reactionQuasiStationarity(), parType, 1u, -(idxr.strideParShell(parType) + idxr.strideParNode(parType)));
16751675
}

src/libcadet/model/LumpedRateModelWithPoresDG-InitialConditions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ namespace cadet
856856
// instead of the *negative* one. Fortunately, we are dealing with linear systems,
857857
// which means that we can just negate the solution.
858858
double* const yDotSlice = vecStateYdot + idxr.offsetC();
859-
for (unsigned int i = 0; i < _disc.nCol * _disc.nComp; ++i)
859+
for (unsigned int i = 0; i < _disc.nElem * _disc.nComp; ++i)
860860
yDotSlice[i] = -resSlice[i];
861861
}
862862

src/libcadet/model/LumpedRateModelWithPoresDG-LinearSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int LumpedRateModelWithPoresDG::linearSolve(double t, double alpha, double outer
128128

129129
// Handle inlet DOFs:
130130
// Inlet at z = 0 for forward flow, at z = L for backward flow.
131-
unsigned int offInlet = (_convDispOp.forwardFlow()) ? 0 : (_disc.nCol - 1u) * idxr.strideColCell();
131+
unsigned int offInlet = (_convDispOp.forwardFlow()) ? 0 : (_disc.nElem - 1u) * idxr.strideColCell();
132132

133133
for (int comp = 0; comp < _disc.nComp; comp++) {
134134
for (int node = 0; node < (_disc.exactInt ? _disc.nNodes : 1); node++) {

src/libcadet/model/LumpedRateModelWithPoresDG.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ bool LumpedRateModelWithPoresDG::configureModelDiscretization(IParameterProvider
175175
_disc.nNodes = _disc.polyDeg + 1;
176176

177177
if (paramProvider.exists("NELEM"))
178-
_disc.nCol = paramProvider.getInt("NELEM");
178+
_disc.nElem = paramProvider.getInt("NELEM");
179179
else if (paramProvider.exists("NCOL"))
180-
_disc.nCol = std::max(1u, paramProvider.getInt("NCOL") / _disc.nNodes); // number of elements is rounded down
180+
_disc.nElem = std::max(1u, paramProvider.getInt("NCOL") / _disc.nNodes); // number of elements is rounded down
181181
else
182182
throw InvalidParameterException("Specify field NELEM (or NCOL)");
183183

184-
if (_disc.nCol < 1)
184+
if (_disc.nElem < 1)
185185
throw InvalidParameterException("Number of column elements must be at least 1!");
186186

187-
_disc.nPoints = _disc.nNodes * _disc.nCol;
187+
_disc.nPoints = _disc.nNodes * _disc.nElem;
188188

189189
int polynomial_integration_mode = 0;
190190
if (paramProvider.exists("EXACT_INTEGRATION"))
@@ -296,7 +296,7 @@ bool LumpedRateModelWithPoresDG::configureModelDiscretization(IParameterProvider
296296
paramProvider.popScope();
297297

298298
const unsigned int strideNode = _disc.nComp;
299-
const bool transportSuccess = _convDispOp.configureModelDiscretization(paramProvider, helper, _disc.nComp, polynomial_integration_mode, _disc.nCol, _disc.polyDeg, strideNode);
299+
const bool transportSuccess = _convDispOp.configureModelDiscretization(paramProvider, helper, _disc.nComp, polynomial_integration_mode, _disc.nElem, _disc.polyDeg, strideNode);
300300

301301
_disc.curSection = -1;
302302

@@ -1066,7 +1066,7 @@ int LumpedRateModelWithPoresDG::residualBulk(double t, unsigned int secIdx, Stat
10661066
{
10671067
for (unsigned int col = 0; col < _disc.nPoints; ++col, y += idxr.strideColNode())
10681068
{
1069-
const ColumnPosition colPos{ (0.5 + static_cast<double>(col)) / static_cast<double>(_disc.nCol), 0.0, 0.0 };
1069+
const ColumnPosition colPos{ (0.5 + static_cast<double>(col)) / static_cast<double>(_disc.nElem), 0.0, 0.0 };
10701070

10711071
linalg::BandedEigenSparseRowIterator jac(_globalJacDisc, col * idxr.strideColNode());
10721072
// static_cast should be sufficient here, but this statement is also analyzed when wantJac = false
@@ -1282,7 +1282,7 @@ void LumpedRateModelWithPoresDG::multiplyWithJacobian(const SimulationTime& simT
12821282

12831283
// Map inlet DOFs to the column inlet (first bulk cells)
12841284
// Inlet at z = 0 for forward flow, at z = L for backward flow.
1285-
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nCol - 1u) * idxr.strideColCell();
1285+
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nElem - 1u) * idxr.strideColCell();
12861286

12871287
for (unsigned int comp = 0; comp < _disc.nComp; comp++) {
12881288
for (unsigned int node = 0; node < (_disc.exactInt ? _disc.nNodes : 1); node++) {

src/libcadet/model/LumpedRateModelWithPoresDG.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class LumpedRateModelWithPoresDG : public UnitOperationBase
244244
unsigned int nComp; //!< Number of components
245245

246246
bool exactInt; //!< 1 for exact integration, 0 for LGL quadrature
247-
unsigned int nCol; //!< Number of column cells
247+
unsigned int nElem; //!< Number of column cells
248248
unsigned int polyDeg; //!< polynomial degree
249249
unsigned int nNodes; //!< Number of nodes per cell
250250
unsigned int nPoints; //!< Number of discrete Points
@@ -408,10 +408,10 @@ class LumpedRateModelWithPoresDG : public UnitOperationBase
408408
*/
409409
virtual int writePrimaryCoordinates(double* coords) const
410410
{
411-
for (unsigned int i = 0; i < _disc.nCol; i++) {
411+
for (unsigned int i = 0; i < _disc.nElem; i++) {
412412
for (unsigned int j = 0; j < _disc.nNodes; j++) {
413413
// mapping
414-
coords[i * _disc.nNodes + j] = _model._convDispOp.cellLeftBound(i) + 0.5 * (static_cast<double>(_model._convDispOp.columnLength()) / static_cast<double>(_disc.nCol)) * (1.0 + _model._convDispOp.LGLnodes()[j]);
414+
coords[i * _disc.nNodes + j] = _model._convDispOp.elemLeftBound(i) + 0.5 * (static_cast<double>(_model._convDispOp.columnLength()) / static_cast<double>(_disc.nElem)) * (1.0 + _model._convDispOp.LGLnodes()[j]);
415415
}
416416
}
417417
return _disc.nPoints;
@@ -483,9 +483,9 @@ class LumpedRateModelWithPoresDG : public UnitOperationBase
483483
Indexer idxr(_disc);
484484

485485
for (unsigned int parType = 0; parType < _disc.nParType; parType++) {
486-
for (unsigned int nCol = 0; nCol < _disc.nPoints; nCol++) {
486+
for (unsigned int nElem = 0; nElem < _disc.nPoints; nElem++) {
487487

488-
int offset = idxr.offsetCp(ParticleTypeIndex{ parType }, ParticleIndex{ nCol }) - idxr.offsetC(); // inlet DOFs not included in Jacobian
488+
int offset = idxr.offsetCp(ParticleTypeIndex{ parType }, ParticleIndex{ nElem }) - idxr.offsetC(); // inlet DOFs not included in Jacobian
489489

490490
// add dense nComp * nBound blocks, since all solid and liquid entries can be coupled through binding.
491491
for (unsigned int parState = 0; parState < _disc.nComp + _disc.strideBound[parType]; parState++) {
@@ -511,12 +511,12 @@ class LumpedRateModelWithPoresDG : public UnitOperationBase
511511
int offP = idxr.offsetCp(ParticleTypeIndex{ parType }) - idxr.offsetC(); // inlet DOFs not included in Jacobian
512512

513513
// add dependency of c^b, c^p and flux on another
514-
for (unsigned int nCol = 0; nCol < _disc.nPoints; nCol++) {
514+
for (unsigned int nElem = 0; nElem < _disc.nPoints; nElem++) {
515515
for (unsigned int comp = 0; comp < _disc.nComp; comp++) {
516516
// c^b on c^b entry already set
517-
tripletList.push_back(T(offC + nCol * _disc.nComp + comp, offP + nCol * idxr.strideParBlock(parType) + comp, 0.0)); // c^b on c^p
517+
tripletList.push_back(T(offC + nElem * _disc.nComp + comp, offP + nElem * idxr.strideParBlock(parType) + comp, 0.0)); // c^b on c^p
518518
// c^p on c^p entry already set
519-
tripletList.push_back(T(offP + nCol * idxr.strideParBlock(parType) + comp, offC + nCol * _disc.nComp + comp, 0.0)); // c^p on c^b
519+
tripletList.push_back(T(offP + nElem * idxr.strideParBlock(parType) + comp, offC + nElem * _disc.nComp + comp, 0.0)); // c^p on c^b
520520
}
521521
}
522522
}

src/libcadet/model/LumpedRateModelWithPoresDG2D.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,12 @@ class LumpedRateModelWithPoresDG2D : public UnitOperationBase
445445
int offP = idxr.offsetCp(ParticleTypeIndex{ parType }) - idxr.offsetC(); // inlet DOFs not included in Jacobian
446446

447447
// add dependency of c^b, c^p and flux on another
448-
for (unsigned int nCol = 0; nCol < _disc.nBulkPoints; nCol++) {
448+
for (unsigned int node = 0; node < _disc.nBulkPoints; node++) {
449449
for (unsigned int comp = 0; comp < _disc.nComp; comp++) {
450450
// c^b on c^b entry already set
451-
tripletList.push_back(T(offC + nCol * _disc.nComp + comp, offP + nCol * idxr.strideParBlock(parType) + comp, 0.0)); // c^b on c^p
451+
tripletList.push_back(T(offC + node * _disc.nComp + comp, offP + node * idxr.strideParBlock(parType) + comp, 0.0)); // c^b on c^p
452452
// c^p on c^p entry already set
453-
tripletList.push_back(T(offP + nCol * idxr.strideParBlock(parType) + comp, offC + nCol * _disc.nComp + comp, 0.0)); // c^p on c^b
453+
tripletList.push_back(T(offP + node * idxr.strideParBlock(parType) + comp, offC + node * _disc.nComp + comp, 0.0)); // c^p on c^b
454454
}
455455
}
456456
}

src/libcadet/model/LumpedRateModelWithoutPoresDG.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ namespace cadet
6565

6666
unsigned int LumpedRateModelWithoutPoresDG::numDofs() const CADET_NOEXCEPT
6767
{
68-
// Column bulk DOFs: nCol * nNodes * nComp mobile phase and nCol * nNodes * (sum boundStates) solid phase
68+
// Column bulk DOFs: nElem * nNodes * nComp mobile phase and nElem * nNodes * (sum boundStates) solid phase
6969
// Inlet DOFs: nComp
7070
return _disc.nPoints * (_disc.nComp + _disc.strideBound) + _disc.nComp;
7171
}
7272

7373
unsigned int LumpedRateModelWithoutPoresDG::numPureDofs() const CADET_NOEXCEPT
7474
{
75-
// Column bulk DOFs: nCol * nNodes * nComp mobile phase and nCol * nNodes * (sum boundStates) solid phase
75+
// Column bulk DOFs: nElem * nNodes * nComp mobile phase and nElem * nNodes * (sum boundStates) solid phase
7676
return _disc.nPoints * (_disc.nComp + _disc.strideBound);
7777
}
7878

@@ -130,16 +130,16 @@ namespace cadet
130130
_disc.nNodes = _disc.polyDeg + 1;
131131

132132
if (paramProvider.exists("NELEM"))
133-
_disc.nCol = paramProvider.getInt("NELEM");
133+
_disc.nElem = paramProvider.getInt("NELEM");
134134
else if (paramProvider.exists("NCOL"))
135-
_disc.nCol = std::max(1u, paramProvider.getInt("NCOL") / _disc.nNodes); // number of elements is rounded down
135+
_disc.nElem = std::max(1u, paramProvider.getInt("NCOL") / _disc.nNodes); // number of elements is rounded down
136136
else
137137
throw InvalidParameterException("Specify field NELEM (or NCOL)");
138138

139-
if (_disc.nCol < 1)
139+
if (_disc.nElem < 1)
140140
throw InvalidParameterException("Number of column elements must be at least 1!");
141141

142-
_disc.nPoints = _disc.nNodes * _disc.nCol;
142+
_disc.nPoints = _disc.nNodes * _disc.nElem;
143143

144144
int polynomial_integration_mode = 0;
145145
if (paramProvider.exists("EXACT_INTEGRATION"))
@@ -165,16 +165,16 @@ namespace cadet
165165
#endif
166166

167167
// Allocate space for initial conditions
168-
_initC.resize(_disc.nCol * _disc.nNodes * _disc.nComp);
169-
_initQ.resize(_disc.nCol * _disc.nNodes * _disc.strideBound);
168+
_initC.resize(_disc.nElem * _disc.nNodes * _disc.nComp);
169+
_initQ.resize(_disc.nElem * _disc.nNodes * _disc.strideBound);
170170

171171
// Create nonlinear solver for consistent initialization
172172
configureNonlinearSolver(paramProvider);
173173

174174
paramProvider.popScope();
175175

176176
const unsigned int strideNode = _disc.nComp + _disc.strideBound;
177-
const bool transportSuccess = _convDispOp.configureModelDiscretization(paramProvider, helper, _disc.nComp, polynomial_integration_mode, _disc.nCol, _disc.polyDeg, strideNode);
177+
const bool transportSuccess = _convDispOp.configureModelDiscretization(paramProvider, helper, _disc.nComp, polynomial_integration_mode, _disc.nElem, _disc.polyDeg, strideNode);
178178

179179
_disc.curSection = -1;
180180

@@ -761,7 +761,7 @@ namespace cadet
761761

762762
// Map inlet DOFs to the column inlet (first bulk cells)
763763
// Inlet at z = 0 for forward flow, at z = L for backward flow.
764-
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nCol - 1u) * idxr.strideColCell();
764+
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nElem - 1u) * idxr.strideColCell();
765765

766766
for (unsigned int comp = 0; comp < _disc.nComp; comp++) {
767767
for (unsigned int node = 0; node < (_disc.exactInt ? _disc.nNodes : 1); node++) {
@@ -888,7 +888,7 @@ namespace cadet
888888

889889
// Handle inlet DOFs:
890890
// Inlet at z = 0 for forward flow, at z = L for backward flow.
891-
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nCol - 1u) * idxr.strideColCell();
891+
unsigned int offInlet = _convDispOp.forwardFlow() ? 0 : (_disc.nElem - 1u) * idxr.strideColCell();
892892

893893
for (unsigned int comp = 0; comp < _disc.nComp; comp++) {
894894
for (unsigned int node = 0; node < (_disc.exactInt ? _disc.nNodes : 1); node++) {

src/libcadet/model/LumpedRateModelWithoutPoresDG.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ namespace cadet
207207
{
208208
public:
209209
unsigned int nComp; //!< Number of components
210-
unsigned int nCol; //!< Number of column cells
210+
unsigned int nElem; //!< Number of column cells
211211
unsigned int polyDeg; //!< polynomial degree
212212
unsigned int nNodes; //!< Number of nodes per cell
213213
unsigned int nPoints; //!< Number of discrete Points
@@ -340,10 +340,10 @@ namespace cadet
340340
*/
341341
virtual int writePrimaryCoordinates(double* coords) const
342342
{
343-
for (unsigned int i = 0; i < _disc.nCol; i++) {
343+
for (unsigned int i = 0; i < _disc.nElem; i++) {
344344
for (unsigned int j = 0; j < _disc.nNodes; j++) {
345345
// mapping
346-
coords[i * _disc.nNodes + j] = _model._convDispOp.cellLeftBound(i) + 0.5 * (static_cast<double>(_model._convDispOp.columnLength()) / static_cast<double>(_disc.nCol)) * (1.0 + _model._convDispOp.LGLnodes()[j]);
346+
coords[i * _disc.nNodes + j] = _model._convDispOp.elemLeftBound(i) + 0.5 * (static_cast<double>(_model._convDispOp.columnLength()) / static_cast<double>(_disc.nElem)) * (1.0 + _model._convDispOp.LGLnodes()[j]);
347347
}
348348
}
349349
return _disc.nPoints;

0 commit comments

Comments
 (0)