Skip to content

Commit c34f907

Browse files
committed
Reset Jacobian matrix to zero every residualImpl call with wantJac
1 parent 4f16999 commit c34f907

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/libcadet/model/ColumnModel1D.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,11 @@ int ColumnModel1D::residualImpl(double t, unsigned int secIdx, StateType const*
923923
{
924924
if (wantRes)
925925
{
926-
double* const resPtr = reinterpret_cast<double* const>(res);
927-
Eigen::Map<Eigen::VectorXd> resi(resPtr, numDofs());
926+
Eigen::Map<Eigen::Vector<ResidualType, Dynamic>> resi(res, numDofs());
928927
resi.setZero();
929928
}
929+
if (wantJac)
930+
_globalJac.coeffs().setZero();
930931

931932
LinearBufferAllocator tlmAlloc = threadLocalMem.get();
932933
Indexer idxr(_disc);

src/libcadet/model/ColumnModel2D.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,7 @@ int ColumnModel2D::residualImpl(double t, unsigned int secIdx, StateType const*
10811081
resi.setZero();
10821082
}
10831083
if (wantJac)
1084-
{
1085-
std::fill_n(_globalJac.valuePtr(), _globalJac.nonZeros(), 0.0);
1086-
}
1084+
_globalJac.coeffs().setZero();
10871085

10881086
#ifdef CADET_PARALLELIZE
10891087
tbb::parallel_for(std::size_t(0), static_cast<std::size_t>(_disc.axNPoints * _disc.radNPoints * _disc.nParType + 1), [&](std::size_t pblk)

0 commit comments

Comments
 (0)