Skip to content

Commit 02c7bf0

Browse files
[femutils] Apply matrix transformation then RHS transformation at the beginning of solve in AlephDoFLinearSystem.
1 parent 4cdb5dc commit 02c7bf0

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

femutils/AlephDoFLinearSystem.cc

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ class AlephDoFLinearSystemImpl
199199
private:
200200

201201
AlephParams* _createAlephParam() const;
202-
void _fillMatrix();
202+
void _applyMatrixTransformationAndFillAlephMatrix();
203203
void _fillRHSVector();
204+
void _applyRHSTransformationAndFillAlephRHS();
204205
void _setMatrixValue(DoF row, DoF column, Real value)
205206
{
206207
if (m_do_print_filling)
@@ -265,7 +266,6 @@ _fillRowColumnEliminationInfos()
265266

266267
auto& dof_elimination_info = getEliminationInfo();
267268
auto& dof_elimination_value = getEliminationValue();
268-
auto& rhs_variable = rhsVariable();
269269

270270
for (const auto& rc_value : m_values_map) {
271271
RowColumn rc = rc_value.first;
@@ -283,7 +283,7 @@ _fillRowColumnEliminationInfos()
283283
/*---------------------------------------------------------------------------*/
284284

285285
void AlephDoFLinearSystemImpl::
286-
_fillMatrix()
286+
_applyMatrixTransformationAndFillAlephMatrix()
287287
{
288288
_fillRowColumnEliminationInfos();
289289
OrderedRowColumnMap& rc_elimination_map = _rowColumnEliminationMap();
@@ -293,7 +293,6 @@ _fillMatrix()
293293

294294
auto& dof_elimination_info = getEliminationInfo();
295295
auto& dof_elimination_value = getEliminationValue();
296-
auto& rhs_variable = rhsVariable();
297296

298297
// Fill the matrix from the values of \a m_values_map
299298
// Skip (row,column) values which are part of an elimination.
@@ -322,14 +321,44 @@ _fillMatrix()
322321
_setMatrixValue(dof_row, dof_column, value);
323322
}
324323

324+
const bool do_print_filling = m_do_print_filling;
325+
326+
// Apply Row or Row+Column elimination on Matrix
327+
// Phase 2: set the diagonal value for elimination row to 1.0
328+
ENUMERATE_ (DoF, idof, dof_family->allItems()) {
329+
DoF dof = *idof;
330+
if (!dof.isOwn())
331+
continue;
332+
Byte elimination_info = dof_elimination_info[dof];
333+
if (elimination_info == ELIMINATE_ROW || elimination_info == ELIMINATE_ROW_COLUMN) {
334+
Real elimination_value = dof_elimination_value[dof];
335+
if (do_print_filling)
336+
info() << "EliminateMatrix info=" << static_cast<int>(elimination_info) << " row="
337+
<< std::setw(4) << dof.localId() << " value=" << elimination_value;
338+
_setMatrixValue(dof, dof, 1.0);
339+
}
340+
}
341+
}
342+
/*---------------------------------------------------------------------------*/
343+
/*---------------------------------------------------------------------------*/
344+
345+
void AlephDoFLinearSystemImpl::
346+
_applyRHSTransformationAndFillAlephRHS()
347+
{
348+
const bool do_print_filling = m_do_print_filling;
349+
325350
// Apply Row+Column elimination
326351
// Phase 1:
327352
// - subtract values of the RHS vector if Row+Column elimination
328-
_applyRowColumnEliminationToRHS(m_do_print_filling);
353+
_applyRowColumnEliminationToRHS(do_print_filling);
354+
355+
IItemFamily* dof_family = dofFamily();
356+
357+
auto& dof_elimination_info = getEliminationInfo();
358+
auto& dof_elimination_value = getEliminationValue();
359+
auto& rhs_variable = rhsVariable();
329360

330-
// Apply Row or Row+Column elimination
331-
// Phase 2: set the value of the RHS
332-
// Phase 2: fill the diagonal with 1.0
361+
// Apply Row or Row+Column elimination on RHS
333362
ENUMERATE_ (DoF, idof, dof_family->allItems()) {
334363
DoF dof = *idof;
335364
if (!dof.isOwn())
@@ -338,11 +367,13 @@ _fillMatrix()
338367
if (elimination_info == ELIMINATE_ROW || elimination_info == ELIMINATE_ROW_COLUMN) {
339368
Real elimination_value = dof_elimination_value[dof];
340369
rhs_variable[dof] = elimination_value;
341-
info() << "Eliminate info=" << static_cast<int>(elimination_info) << " row="
342-
<< std::setw(4) << dof.localId() << " value=" << elimination_value;
343-
_setMatrixValue(dof, dof, 1.0);
370+
if (do_print_filling)
371+
info() << "EliminateRHS info=" << static_cast<int>(elimination_info) << " row="
372+
<< std::setw(4) << dof.localId() << " value=" << elimination_value;
344373
}
345374
}
375+
376+
_fillRHSVector();
346377
}
347378

348379
/*---------------------------------------------------------------------------*/
@@ -468,15 +499,16 @@ solve()
468499
{
469500
UniqueArray<Real> aleph_result;
470501

471-
// _fillMatrix() may change the values of RHS vector
472-
// with row or row-column elimination so we have to fill the RHS vector
473-
// before the matrix.
474-
_fillMatrix();
475-
_fillRHSVector();
476-
477502
info() << "[AlephFem] Assemble matrix ptr=" << m_aleph_matrix;
503+
504+
// Matrix transformation
505+
_applyMatrixTransformationAndFillAlephMatrix();
478506
m_aleph_matrix->assemble();
507+
508+
// RHS Transformation
509+
_applyRHSTransformationAndFillAlephRHS();
479510
m_aleph_rhs_vector->assemble();
511+
480512
auto* aleph_solution_vector = m_aleph_solution_vector;
481513
IItemFamily* dof_family = dofFamily();
482514
DoFGroup own_dofs = dof_family->allItems().own();

0 commit comments

Comments
 (0)