@@ -331,7 +331,7 @@ int schurComplementMultiplierGRM2D(void* userData, double const* x, double* z)
331331
332332
333333GeneralRateModel2D::GeneralRateModel2D (UnitOpIdx unitOpIdx) : UnitOperationBase(unitOpIdx),
334- _dynReactionBulk ( nullptr ), _jacP(nullptr ), _jacPdisc(nullptr ), _jacPF(nullptr ), _jacFP(nullptr ), _jacInlet(),
334+ _jacP (nullptr ), _jacPdisc(nullptr ), _jacPF(nullptr ), _jacFP(nullptr ), _jacInlet(),
335335 _analyticJac(true ), _jacobianAdDirs(0 ), _factorizeJacobian(false ), _tempState(nullptr ),
336336 _initC(0 ), _singleRadiusInitC(true ), _initCp(0 ), _singleRadiusInitCp(true ), _initCs(0 ), _singleRadiusInitCs(true ), _initState(0 ), _initStateDot(0 )
337337{
@@ -341,8 +341,6 @@ GeneralRateModel2D::~GeneralRateModel2D() CADET_NOEXCEPT
341341{
342342 delete[] _tempState;
343343
344- delete _dynReactionBulk;
345-
346344 delete[] _jacPF;
347345 delete[] _jacFP;
348346
@@ -419,7 +417,6 @@ bool GeneralRateModel2D::configureModelDiscretization(IParameterProvider& paramP
419417 _binding = std::vector<IBindingModel*>(_disc.nParType , nullptr );
420418 bool bindingConfSuccess = true ;
421419 clearDynamicReactionModels ();
422- _dynReaction = std::vector<IDynamicReactionModel*>(_disc.nParType , nullptr );
423420 bool reactionConfSuccess = true ;
424421
425422 for (int parType = 0 ; parType < _disc.nParType ; parType++)
@@ -497,13 +494,6 @@ bool GeneralRateModel2D::configureModelDiscretization(IParameterProvider& paramP
497494 _singleBinding = !paramProvider.getInt (" REACTION_PARTYPE_DEPENDENT" );
498495 else
499496 _singleBinding = _disc.nParType == 1 ;
500-
501- _dynReaction[parType] = helper.createDynamicReactionModel (dynReactModelName);
502- if (!_dynReaction[parType])
503- throw InvalidParameterException (" Unknown dynamic reaction model " + dynReactModelName);
504-
505- MultiplexedScopeSelector scopeGuard (paramProvider, " reaction" , _dynReaction[parType]->usesParamProviderInDiscretizationConfig ());
506- reactionConfSuccess = reactionConfSuccess && _dynReaction[parType]->configureModelDiscretization (paramProvider, _disc.nComp , _disc.nBound + parType * _disc.nComp , _disc.boundOffset + parType * _disc.nComp ) && reactionConfSuccess;
507497 }
508498
509499 // Set particle geometry
@@ -639,8 +629,6 @@ bool GeneralRateModel2D::configureModelDiscretization(IParameterProvider& paramP
639629
640630 // ==== Construct and configure dynamic bulk reaction model
641631
642- _dynReaction.resize (_disc.nParType , nullptr );
643-
644632 _reaction.clearDynamicReactionModels ();
645633
646634 _reacParticle.clear ();
@@ -1419,7 +1407,7 @@ template <typename StateType, typename ResidualType, typename ParamType, bool wa
14191407int GeneralRateModel2D::residualBulk (double t, unsigned int secIdx, StateType const * yBase, double const * yDotBase, ResidualType* resBase, util::ThreadLocalStorage& threadLocalMem)
14201408{
14211409 _convDispOp.residual (*this , t, secIdx, yBase, yDotBase, resBase, wantJac, typename ParamSens<ParamType>::enabled ());
1422- if (!_dynReactionBulk || (_dynReactionBulk-> numReactionsLiquid () == 0 ) )
1410+ if (! _reaction. getDynReactionVector ( " liquid " )[ 0 ] )
14231411 return 0 ;
14241412
14251413 // Get offsets
@@ -1441,12 +1429,12 @@ int GeneralRateModel2D::residualBulk(double t, unsigned int secIdx, StateType co
14411429 if (!_reaction.getDynReactionVector (" liquid" )[i])
14421430 continue ;
14431431
1444- _dynReactionBulk ->residualFluxAdd (t, secIdx, colPos, _disc.nComp , y, res, -1.0 , tlmAlloc);
1432+ _reaction. getDynReactionVector ( " liquid " )[i] ->residualFluxAdd (t, secIdx, colPos, _disc.nComp , y, res, -1.0 , tlmAlloc);
14451433
14461434 if (wantJac)
14471435 {
14481436 // static_cast should be sufficient here, but this statement is also analyzed when wantJac = false
1449- _dynReactionBulk ->analyticJacobianAdd (t, secIdx, colPos, _disc.nComp , reinterpret_cast <double const *>(y), -1.0 , _convDispOp.jacobian ().row (colCell * idxr.strideColRadialCell ()), tlmAlloc);
1437+ _reaction. getDynReactionVector ( " liquid " )[i] ->analyticJacobianAdd (t, secIdx, colPos, _disc.nComp , reinterpret_cast <double const *>(y), -1.0 , _convDispOp.jacobian ().row (colCell * idxr.strideColRadialCell ()), tlmAlloc);
14501438 }
14511439 }
14521440 }
@@ -2434,7 +2422,7 @@ bool GeneralRateModel2D::setParameter(const ParameterId& pId, double value)
24342422 if (_convDispOp.setParameter (pId, value))
24352423 return true ;
24362424
2437- if (model::setParameter (pId, value, std::vector<IDynamicReactionModel*>{ _dynReactionBulk } , true ))
2425+ if (model::setParameter (pId, value, _reaction. getDynReactionVector ( " liquid " ) , true ))
24382426 return true ;
24392427 }
24402428
@@ -2454,7 +2442,7 @@ bool GeneralRateModel2D::setParameter(const ParameterId& pId, int value)
24542442
24552443 if (pId.unitOperation == _unitOpIdx)
24562444 {
2457- if (model::setParameter (pId, value, std::vector<IDynamicReactionModel*>{ _dynReactionBulk } , true ))
2445+ if (model::setParameter (pId, value, _reaction. getDynReactionVector ( " liquid " ) , true ))
24582446 return true ;
24592447 }
24602448
@@ -2468,7 +2456,7 @@ bool GeneralRateModel2D::setParameter(const ParameterId& pId, bool value)
24682456
24692457 if (pId.unitOperation == _unitOpIdx)
24702458 {
2471- if (model::setParameter (pId, value, std::vector<IDynamicReactionModel*>{ _dynReactionBulk } , true ))
2459+ if (model::setParameter (pId, value, _reaction. getDynReactionVector ( " liquid " ) , true ))
24722460 return true ;
24732461 }
24742462
@@ -2505,7 +2493,7 @@ void GeneralRateModel2D::setSensitiveParameterValue(const ParameterId& pId, doub
25052493 if (_convDispOp.setSensitiveParameterValue (_sensParams, pId, value))
25062494 return ;
25072495
2508- if (model::setSensitiveParameterValue (pId, value, _sensParams, std::vector<IDynamicReactionModel*>{ _dynReactionBulk } , true ))
2496+ if (model::setSensitiveParameterValue (pId, value, _sensParams, _reaction. getDynReactionVector ( " liquid " ) , true ))
25092497 return ;
25102498 }
25112499
@@ -2586,7 +2574,7 @@ bool GeneralRateModel2D::setSensitiveParameter(const ParameterId& pId, unsigned
25862574 return true ;
25872575 }
25882576
2589- if (model::setSensitiveParameter (pId, adDirection, adValue, _sensParams, std::vector<IDynamicReactionModel*> { _dynReactionBulk } , true ))
2577+ if (model::setSensitiveParameter (pId, adDirection, adValue, _sensParams, _reaction. getDynReactionVector ( " liquid " ) , true ))
25902578 {
25912579 LOG (Debug) << " Found parameter " << pId << " in DynamicBulkReactionModel: Dir " << adDirection << " is set to " << adValue;
25922580 return true ;
0 commit comments