20#include <unordered_map>
23template <
typename VarType>
42 std::shared_ptr<DirectLinearSolver> directLinearSolver;
46 std::vector<std::pair<UInt, UInt>> listVariableEntries;
48 std::vector<UInt> tearColumns;
50 std::vector<const Matrix *> rightVectorStamps;
58 Real mSystemFrequency;
63 std::shared_ptr<DataLogger> mLeftVectorLog;
65 std::shared_ptr<DataLogger> mRightVectorLog;
67 std::vector<Subnet> mSubnets;
68 std::unordered_map<typename CPS::SimNode<VarType>::Ptr, Subnet *>
78 Matrix mSystemInverseTearTopology;
89 std::atomic<bool> mTearSchurNeedsRebuild{
false};
99 void initSubnets(
const std::vector<CPS::SystemTopology> &subnets);
100 void collectVirtualNodes(
int net);
101 void assignMatrixNodeIndices(
int net);
102 void setSubnetSize(
int net,
UInt nodes);
104 void setLogColumns();
106 void createMatrices();
107 void createTearMatrices(
UInt totalSize);
109 void initComponents();
112 void applyTearComponentStamp(
UInt compIdx);
114 void log(
Real time,
Int timeStepCount)
override;
132 :
Task(solver.
mName +
".SubnetSolve_" +
std::to_string(net)),
133 mSolver(solver), mSubnet(solver.mSubnets[net]) {
134 for (
auto it : mSubnet.components) {
135 if (it->getRightVector()->get().size() != 0) {
136 mAttributeDependencies.push_back(it->getRightVector());
142 void execute(
Real time,
Int timeStepCount);
143 void recomputeSubnetMatrix(
Real time);
145 Bool hasVariableComponentChanged();
156 :
Task(solver.
mName +
".PreSolve"), mSolver(solver) {
161 void execute(
Real time,
Int timeStepCount);
170 :
Task(solver.
mName +
".Solve_" +
std::to_string(net)), mSolver(solver),
171 mSubnet(solver.mSubnets[net]) {
176 void execute(
Real time,
Int timeStepCount);
186 :
Task(solver.
mName +
".PostSolve"), mSolver(solver) {
187 for (
auto &net : solver.mSubnets) {
188 mAttributeDependencies.push_back(net.leftVector);
189 for (UInt node = 0; node < net.mRealNetNodeNum; ++node) {
190 mModifiedAttributes.push_back(net.nodes[node]->attribute(
"v"));
205 :
Task(solver.
mName +
".Log"), mSolver(solver) {
206 for (
auto &net : solver.mSubnets) {
207 mAttributeDependencies.push_back(net.leftVector);
212 void execute(
Real time,
Int timeStepCount);
AttributePointer< Attribute< T > > Ptr
Base class of objects having attributes to access member variables.
spdlog::level::level_enum Level
Tasks to be defined by every component.
std::vector< AttributeBase::Ptr > mModifiedAttributes
std::vector< AttributeBase::Ptr > mAttributeDependencies
LogTask(DiakopticsSolver< VarType > &solver)
void execute(Real time, Int timeStepCount)
PostSolveTask(DiakopticsSolver< VarType > &solver)
PreSolveTask(DiakopticsSolver< VarType > &solver)
SolveTask(DiakopticsSolver< VarType > &solver, UInt net)
SubnetSolveTask(DiakopticsSolver< VarType > &solver, UInt net)
CPS::Task::List getTasks() override
Get tasks for scheduler.
const CPS::Attribute< Matrix >::Ptr mOrigLeftSideVector
Solutions of the split systems.
DiakopticsSolver(String name, CPS::SystemTopology system, CPS::IdentifiedObject::List tearComponents, Real timeStep, CPS::Logger::Level logLevel)
const CPS::Attribute< Matrix >::Ptr mMappedTearCurrents
Currents through the removed network (as "seen" from the other subnets)
static CPS::AttributeBase::Ptr external
Solver(String name, CPS::Logger::Level logLevel)
Eigen::PartialPivLU< Matrix > LUFactorized
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
CPS::SparseMatrixRow SparseMatrix