@@ -145,10 +145,8 @@ SparseMatrix::SparseMatrix (SparseSolver eqSolver, int nt)
145
145
nrow = ncol = 0 ;
146
146
solver = eqSolver ;
147
147
numThreads = nt ;
148
- #ifdef HAS_UMFPACK
149
- umfSymbolic = nullptr ;
150
- #endif
151
148
slu = nullptr ;
149
+ umfSymbolic = nullptr ;
152
150
}
153
151
154
152
@@ -161,9 +159,7 @@ SparseMatrix::SparseMatrix (size_t m, size_t n)
161
159
solver = NONE ;
162
160
numThreads = 0 ;
163
161
slu = nullptr ;
164
- #ifdef HAS_UMFPACK
165
162
umfSymbolic = nullptr ;
166
- #endif
167
163
}
168
164
169
165
@@ -177,9 +173,7 @@ SparseMatrix::SparseMatrix (const SparseMatrix& B)
177
173
solver = B .solver ;
178
174
numThreads = B .numThreads ;
179
175
slu = nullptr ; // The SuperLU data (if any) is not copied
180
- #ifdef HAS_UMFPACK
181
- umfSymbolic = nullptr ;
182
- #endif
176
+ umfSymbolic = nullptr ; // The UMFPACK data (if any) is not copied
183
177
}
184
178
185
179
@@ -210,6 +204,7 @@ bool SparseMatrix::lockPattern (bool doLock)
210
204
void SparseMatrix ::resize (size_t r , size_t c , bool forceEditable )
211
205
{
212
206
factored = false;
207
+ if (c == 0 ) c = r ;
213
208
if (r == nrow && c == ncol && !forceEditable )
214
209
{
215
210
// Clear the matrix content but retain its sparsity pattern
@@ -227,15 +222,14 @@ void SparseMatrix::resize (size_t r, size_t c, bool forceEditable)
227
222
A .clear ();
228
223
229
224
nrow = r ;
230
- ncol = c > 0 ? c : r ;
225
+ ncol = c ;
231
226
232
227
delete slu ;
233
228
slu = nullptr ;
234
229
#ifdef HAS_UMFPACK
235
- if (umfSymbolic ) {
230
+ if (umfSymbolic )
236
231
umfpack_di_free_symbolic (& umfSymbolic );
237
- umfSymbolic = nullptr ;
238
- }
232
+ umfSymbolic = nullptr ;
239
233
#endif
240
234
}
241
235
@@ -477,8 +471,8 @@ bool SparseMatrix::augment (const SystemMatrix& B, size_t r0, size_t c0)
477
471
478
472
for (const ValueMap ::value_type & val : Bptr -> elem )
479
473
{
480
- elem [std :: make_pair ( r0 + val .first .first ,c0 + val .first .second ) ] += val .second ;
481
- elem [std :: make_pair ( c0 + val .first .second ,r0 + val .first .first ) ] += val .second ;
474
+ elem [{ r0 + val .first .first , c0 + val .first .second } ] += val .second ;
475
+ elem [{ c0 + val .first .second , r0 + val .first .first } ] += val .second ;
482
476
}
483
477
484
478
return true;
@@ -736,12 +730,14 @@ static void assemSparse (const RealArray& V, SparseMatrix& SM, size_t col,
736
730
}
737
731
738
732
739
- void SparseMatrix ::initAssembly (const SAM & sam , bool delayLocking )
733
+ void SparseMatrix ::initAssembly (const SAM & sam , char preAssembly )
740
734
{
741
735
this -> resize (sam .neq ,sam .neq );
736
+ if (preAssembly == 'f' )
737
+ this -> preAssemble (sam ,false);
742
738
#ifdef USE_OPENMP
743
- if (omp_get_max_threads () > 1 )
744
- this -> preAssemble (sam ,delayLocking );
739
+ else if (omp_get_max_threads () > 1 )
740
+ this -> preAssemble (sam ,preAssembly == 'd' );
745
741
#endif
746
742
}
747
743
@@ -758,7 +754,7 @@ void SparseMatrix::preAssemble (const SAM& sam, bool delayLocking)
758
754
759
755
// If we are not locking the sparsity pattern yet, the index pair map over
760
756
// the non-zero matrix elements needs to be initialized before the assembly.
761
- // This is used when SAM::getDofCouplings does not return all connectivities
757
+ // This is used when SAM::getDofCouplings() does not return all connectivities
762
758
if (delayLocking ) // that will exist in the final matrix.
763
759
for (size_t i = 0 ; i < dofc .size (); i ++ )
764
760
for (int j : dofc [i ])
0 commit comments