@@ -386,8 +386,7 @@ void GeneralRateModelDG::consistentInitialState(const SimulationTime& simTime, d
386
386
active* const localAdY = adJac.adY ? adJac.adY + localOffsetToParticle + localOffsetInParticle : nullptr ;
387
387
388
388
// r (particle) coordinate of current node
389
- const double r = static_cast <double >(_disc.deltaR [type]) * std::floor (node / _disc.nParNode [type])
390
- + 0.5 * static_cast <double >(_disc.deltaR [type]) * (1 + _disc.parNodes [type][node % _disc.nParNode [type]]);
389
+ const double r = _parDiffOp.relativeCoordinate (type, node);
391
390
const ColumnPosition colPos{ z, 0.0 , r };
392
391
393
392
// Determine whether nonlinear solver is required
@@ -398,8 +397,8 @@ void GeneralRateModelDG::consistentInitialState(const SimulationTime& simTime, d
398
397
linalg::selectVectorSubset (qShell - _disc.nComp , mask, solution);
399
398
400
399
// Save values of conserved moieties
401
- const double epsQ = 1.0 - static_cast <double >(_parPorosity[type]);
402
- linalg::conservedMoietiesFromPartitionedMask (mask, _disc.nBound + type * _disc.nComp , _disc.nComp , qShell - _disc.nComp , conservedQuants, static_cast <double >(_parPorosity[type]), epsQ);
400
+ const double epsQ = 1.0 - static_cast <double >(_parDiffOp. _parPorosity [type]);
401
+ linalg::conservedMoietiesFromPartitionedMask (mask, _disc.nBound + type * _disc.nComp , _disc.nComp , qShell - _disc.nComp , conservedQuants, static_cast <double >(_parDiffOp. _parPorosity [type]), epsQ);
403
402
404
403
std::function<bool (double const * const , linalg::detail::DenseMatrixBase&)> jacFunc;
405
404
@@ -478,7 +477,7 @@ void GeneralRateModelDG::consistentInitialState(const SimulationTime& simTime, d
478
477
continue ;
479
478
}
480
479
481
- mat.native (rIdx, rIdx) = static_cast <double >(_parPorosity[type]);
480
+ mat.native (rIdx, rIdx) = static_cast <double >(_parDiffOp. _parPorosity [type]);
482
481
483
482
for (unsigned int bnd = 0 ; bnd < _disc.nBound [_disc.nComp * type + comp]; ++bnd, ++bndIdx)
484
483
{
@@ -526,7 +525,7 @@ void GeneralRateModelDG::consistentInitialState(const SimulationTime& simTime, d
526
525
continue ;
527
526
}
528
527
529
- mat.native (rIdx, rIdx) = static_cast <double >(_parPorosity[type]);
528
+ mat.native (rIdx, rIdx) = static_cast <double >(_parDiffOp. _parPorosity [type]);
530
529
531
530
for (unsigned int bnd = 0 ; bnd < _disc.nBound [_disc.nComp * type + comp]; ++bnd, ++bndIdx)
532
531
{
@@ -573,7 +572,7 @@ void GeneralRateModelDG::consistentInitialState(const SimulationTime& simTime, d
573
572
continue ;
574
573
}
575
574
576
- r[rIdx] = static_cast <double >(_parPorosity[type]) * x[rIdx] - conservedQuants[rIdx];
575
+ r[rIdx] = static_cast <double >(_parDiffOp. _parPorosity [type]) * x[rIdx] - conservedQuants[rIdx];
577
576
578
577
for (unsigned int bnd = 0 ; bnd < _disc.nBound [_disc.nComp * type + comp]; ++bnd, ++bndIdx)
579
578
{
@@ -714,9 +713,8 @@ void GeneralRateModelDG::consistentInitialTimeDerivative(const SimulationTime& s
714
713
if (_binding[type]->dependsOnTime ())
715
714
{
716
715
// r (particle) coordinate of current node (particle radius normed to 1) - needed in externally dependent adsorption kinetic
717
- const double r = (static_cast <double >(_disc.deltaR [type]) * std::floor (j / _disc.nParNode [type])
718
- + 0.5 * static_cast <double >(_disc.deltaR [type]) * (1 + _disc.parNodes [type][j % _disc.nParNode [type]]))
719
- / (static_cast <double >(_parRadius[type]) - static_cast <double >(_parCoreRadius[type]));
716
+ const double r = _parDiffOp.relativeCoordinate (type, j);
717
+
720
718
_binding[type]->timeDerivativeQuasiStationaryFluxes (simTime.t , simTime.secIdx ,
721
719
ColumnPosition{ z, 0.0 , r },
722
720
qShellDot - _disc.nComp , qShellDot, dFluxDt, tlmAlloc);
@@ -799,7 +797,7 @@ void GeneralRateModelDG::consistentInitialTimeDerivative(const SimulationTime& s
799
797
*/
800
798
void GeneralRateModelDG::leanConsistentInitialState (const SimulationTime& simTime, double * const vecStateY, const AdJacobianParams& adJac, double errorTol, util::ThreadLocalStorage& threadLocalMem)
801
799
{
802
- if (isSectionDependent (_parDiffusionMode) || isSectionDependent (_parSurfDiffusionMode))
800
+ if (isSectionDependent (_parDiffOp. _parDiffusionMode ) || isSectionDependent (_parDiffOp. _parSurfDiffusionMode ))
803
801
LOG (Warning) << " Lean consistent initialization is not appropriate for section-dependent pore and surface diffusion" ;
804
802
805
803
BENCH_SCOPE (_timerConsistentInit);
@@ -832,8 +830,7 @@ void GeneralRateModelDG::leanConsistentInitialState(const SimulationTime& simTim
832
830
const int localOffsetInParticle = static_cast <int >(shell) * idxr.strideParNode (type) + idxr.strideParLiquid ();
833
831
double * const qShell = vecStateY + localOffsetToParticle + localOffsetInParticle;
834
832
// r (particle) coordinate of current node
835
- const double r = static_cast <double >(_disc.deltaR [type]) * std::floor (shell / _disc.nParNode [type])
836
- + 0.5 * static_cast <double >(_disc.deltaR [type]) * (1 + _disc.parNodes [type][shell % _disc.nParNode [type]]);
833
+ const double r = _parDiffOp.relativeCoordinate (type, shell);
837
834
const ColumnPosition colPos{ z, 0.0 , r};
838
835
839
836
// Perform consistent initialization that does not require a full fledged nonlinear solver (that may fail or damage the current state vector)
@@ -843,7 +840,6 @@ void GeneralRateModelDG::leanConsistentInitialState(const SimulationTime& simTim
843
840
} CADET_PARFOR_END;
844
841
}
845
842
}
846
-
847
843
}
848
844
849
845
/* *
@@ -889,7 +885,7 @@ void GeneralRateModelDG::leanConsistentInitialState(const SimulationTime& simTim
889
885
*/
890
886
void GeneralRateModelDG::leanConsistentInitialTimeDerivative (double t, double const * const vecStateY, double * const vecStateYdot, double * const res, util::ThreadLocalStorage& threadLocalMem)
891
887
{
892
- if (isSectionDependent (_parDiffusionMode) || isSectionDependent (_parSurfDiffusionMode))
888
+ if (isSectionDependent (_parDiffOp. _parDiffusionMode ) || isSectionDependent (_parDiffOp. _parSurfDiffusionMode ))
893
889
LOG (Warning) << " Lean consistent initialization is not appropriate for section-dependent pore and surface diffusion" ;
894
890
895
891
BENCH_SCOPE (_timerConsistentInit);
@@ -1272,7 +1268,7 @@ void GeneralRateModelDG::solveBulkTimeDerivativeSystem(const SimulationTime& sim
1272
1268
void GeneralRateModelDG::leanConsistentInitialSensitivity (const SimulationTime& simTime, const ConstSimulationState& simState,
1273
1269
std::vector<double *>& vecSensY, std::vector<double *>& vecSensYdot, active const * const adRes, util::ThreadLocalStorage& threadLocalMem)
1274
1270
{
1275
- if (isSectionDependent (_parDiffusionMode) || isSectionDependent (_parSurfDiffusionMode))
1271
+ if (isSectionDependent (_parDiffOp. _parDiffusionMode ) || isSectionDependent (_parDiffOp. _parSurfDiffusionMode ))
1276
1272
LOG (Warning) << " Lean consistent initialization is not appropriate for section-dependent pore and surface diffusion" ;
1277
1273
1278
1274
BENCH_SCOPE (_timerConsistentInit);
0 commit comments