Commit 7593a9ac authored by Philipp Fensch's avatar Philipp Fensch
Browse files

Added LogTask and getTasks()

parent 393dd5e1
......@@ -6,14 +6,12 @@
#include <cusolverDn.h>
/**
*
* TODO:
* || Test & fix ||
* -initialize();
* -void setSystem(CPS::SystemTopology system);
* -CPS::Task::List getTasks();
* -class SolveTask : public CPS::Task
* -class SolveTask : public CPS::Task
* -class LogTask : public CPS::Task
*
* -CPS::Task::List getTasks();
*/
namespace DPsim {
......@@ -50,7 +48,6 @@ namespace DPsim {
void copySystemMatrixToDevice();
/// LU factorization
void LUfactorization();
public:
MnaSolverGpu(String name,
......@@ -59,9 +56,10 @@ namespace DPsim {
virtual ~MnaSolverGpu();
CPS::Task::List getTasks();
class SolveTask : public CPS::Task {
public:
SolveTask(MnaSolverGpu<VarType>& solver, Bool steadyStateInit) :
Task(solver.mName + ".Solve"), mSolver(solver), mSteadyStateInit(steadyStateInit) {
for (auto it : solver.mPowerComponents) {
......@@ -77,9 +75,23 @@ namespace DPsim {
void execute(Real time, Int timeStepCount);
private:
MnaSolverGpu<VarType>& mSolver;
Bool mSteadyStateInit;
private:
MnaSolverGpu<VarType>& mSolver;
Bool mSteadyStateInit;
};
class LogTask : public CPS::Task {
public:
LogTask(MnaSolverGpu<VarType>& solver) :
Task(solver.mName + ".Log"), mSolver(solver) {
mAttributeDependencies.push_back(solver.attribute("left_vector"));
mModifiedAttributes.push_back(Scheduler::external);
}
void execute(Real time, Int timeStepCount);
private:
MnaSolverGpu<VarType>& mSolver;
};
};
}
\ No newline at end of file
#include <dpsim/MNASolverGpu.h>
#include <dpsim/Definitions.h>
#include <dpsim/SequentialScheduler.h>
using namespace DPsim;
using namespace CPS;
namespace DPsim {
......@@ -106,6 +107,30 @@ void MnaSolverGpu<VarType>::LUfactorization() {
cudaDeviceSynchronize();
}
template <typename VarType>
Task::List MnaSolverGpu<VarType>::getTasks() {
Task::List l;
for (auto comp : this->mPowerComponents) {
for (auto task : comp->mnaTasks()) {
l.push_back(task);
}
}
for (auto node : this->mNodes) {
for (auto task : node->mnaTasks())
l.push_back(task);
}
// TODO signal components should be moved out of MNA solver
for (auto comp : this->mSignalComponents) {
for (auto task : comp->getTasks()) {
l.push_back(task);
}
}
l.push_back(std::make_shared<MnaSolverGpu<VarType>::SolveTask>(*this, false));
l.push_back(std::make_shared<MnaSolverGpu<VarType>::LogTask>(*this));
return l;
}
template <typename VarType>
void MnaSolverGpu<VarType>::SolveTask::execute(Real time, Int timeStepCount) {
// Reset source vector
......@@ -154,6 +179,11 @@ void MnaSolverGpu<VarType>::SolveTask::execute(Real time, Int timeStepCount) {
// Components' states will be updated by the post-step tasks
}
template <typename VarType>
void MnaSolverGpu<VarType>::LogTask::execute(Real time, Int timeStepCount) {
mSolver.log(time);
}
}
template class DPsim::MnaSolverGpu<Real>;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment