DPsim
Loading...
Searching...
No Matches
DenseLUAdapter.h
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
11#include <bitset>
12#include <chrono>
13#include <iostream>
14#include <list>
15#include <memory>
16#include <unordered_map>
17#include <vector>
18
19#include <dpsim/Config.h>
20#include <dpsim/Definitions.h>
22
23namespace DPsim {
25 Eigen::PartialPivLU<Matrix> LUFactorized;
26 Matrix mReferenceMatrix;
27 Matrix mCorrectionInverse;
28 Matrix mCurrentMatrix;
29 Matrix mResidual;
30 Matrix mCorrection;
31 std::vector<std::pair<UInt, UInt>> mVariableEntries;
32 Bool mUseStaticPreconditioner = false;
33 Bool mStaticPreconditionerActive = false;
34 Bool mUseInverseForCorrections = false;
35 Bool mDetailedProfiling = false;
36 struct Timing {
37 std::chrono::nanoseconds total{};
38 std::size_t calls = 0;
39 };
40 Timing mInitialSolveTime, mResidualBuildTime, mCorrectionSolveTime,
41 mResidualUpdateTime, mFallbackFactorizationTime, mFallbackSolveTime;
42 std::size_t mSolveCalls = 0;
43 std::size_t mRefinementIterations = 0;
44 std::size_t mMaximumRefinementIterations = 0;
45 std::size_t mFallbackCount = 0;
46
47 void applyConfiguration() override;
48
49public:
52
54 ~DenseLUAdapter() override;
55
57 void preprocessing(SparseMatrix &systemMatrix,
58 std::vector<std::pair<UInt, UInt>>
59 &listVariableSystemMatrixEntries) override;
60
62 void factorize(SparseMatrix &systemMatrix) override;
63
65 void refactorize(SparseMatrix &systemMatrix) override;
66
68 void partialRefactorize(SparseMatrix &systemMatrix,
69 std::vector<std::pair<UInt, UInt>>
70 &listVariableSystemMatrixEntries) override;
71
73 Matrix solve(Matrix &rightSideVector) override;
74 void solveInto(Matrix &rightSideVector, Matrix &solution) override;
75 void setDetailedProfiling(Bool enabled) { mDetailedProfiling = enabled; }
76 void writeDetailedProfile(std::ostream &profile) const;
77 void writeDetailedDiagnostics(std::ostream &diagnostics) const;
78};
79} // namespace DPsim
DirectLinearSolver()=default
Constructor with logging.
void writeDetailedProfile(std::ostream &profile) const
void setDetailedProfiling(Bool enabled)
void factorize(SparseMatrix &systemMatrix) override
factorization function with partial pivoting
void partialRefactorize(SparseMatrix &systemMatrix, std::vector< std::pair< UInt, UInt > > &listVariableSystemMatrixEntries) override
partial refactorization withouth partial pivoting
void writeDetailedDiagnostics(std::ostream &diagnostics) const
void solveInto(Matrix &rightSideVector, Matrix &solution) override
~DenseLUAdapter() override
Destructor.
void preprocessing(SparseMatrix &systemMatrix, std::vector< std::pair< UInt, UInt > > &listVariableSystemMatrixEntries) override
preprocessing function pre-ordering and scaling the matrix
void refactorize(SparseMatrix &systemMatrix) override
refactorization without partial pivoting
Matrix solve(Matrix &rightSideVector) override
solution function for a right hand side
DirectLinearSolver()=default
Constructor.
CPS::Matrix Matrix
Definition Definitions.h:24
CPS::Bool Bool
Definition Definitions.h:21
CPS::SparseMatrixRow SparseMatrix
Definition Definitions.h:26