Commit 2cfcd5dd authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

splitted pdesolver

parent 2b40b4cc
#include "PDESolver.hpp"
#include "EllipticPDESolver.hpp"
void DummyPDESolver::run(SampleSolution &solution) {}
void DummyPDESolver::computeQ(SampleSolution &solution) {
if (quantity == "GeneratorValue") solution.Q = assemble->GeneratorValue();
else Exit("Quantity of interest not implemented")
}
void DummyPDESolver::computeCost(SampleSolution &solution) {
if (costMeasure == "size") solution.Cost = solution.U.size();
// else if (costMeasure == "time") solution.Cost = solution.U.size(); // Todo
else Exit("Cost measure not implemented")
}
void DummyPDESolver::plotSolution(SampleSolution &solution) {}
void EllipticPDESolver::run(SampleSolution &solution) {
newton->operator()(*assemble, solution.U);
}
......@@ -66,28 +51,4 @@ void EllipticPDESolver::plotSolution(SampleSolution &solution) {
mpp::plot(kappa.IdString()) << kappa.U << mpp::endp;
delete pressureDisc;
}
void TransportPDESolver::run(SampleSolution &solution) {
assemble->SetTimeSeries(solution.U);
solution.U.GetMesh().PrintInfo();
assemble->GetTimeSeries().PrintInfo();
timeInt->Method(assemble, solution.U);
}
void TransportPDESolver::computeQ(SampleSolution &solution) {
if (quantity == "Energy") solution.Q = assemble->Energy(solution.U);
else if (quantity == "Mass") solution.Q = assemble->Mass(solution.U);
else if (quantity == "Error") solution.Q = assemble->Error(0, solution.U);
else if (quantity == "Inflow") solution.Q = assemble->InflowOutflow(solution.U).first;
else if (quantity == "Outflow") solution.Q = assemble->InflowOutflow(solution.U).second;
// else if (quantity == "L2Error") solution.Q = assemble->L2Error(solution.U);
// else if (quantity == "EnergyError") solution.Q = assemble->EnergyError(solution.U);
else Exit("Quantity of interest not implemented")
}
void TransportPDESolver::computeCost(SampleSolution &solution) {
}
void TransportPDESolver::plotSolution(SampleSolution &solution) {
}
}
\ No newline at end of file
#ifndef ELLIPTICPDESOLVER_HPP
#define ELLIPTICPDESOLVER_HPP
#include "PDESolver.hpp"
class EllipticPDESolver : public PDESolver {
private:
Newton *newton;
IStochasticEllipticAssemble *assemble;
protected:
void run(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void plotSolution(SampleSolution &solution) override;
public:
EllipticPDESolver(IStochasticEllipticAssemble *assemble, Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure),
newton(new Newton()), assemble(assemble) {
if (verbose > 0) {
PrintInfo();
newton->PrintInfo();
assemble->PrintInfo();
}
}
~EllipticPDESolver() {
delete assemble;
delete newton;
}
IAssemble *GetAssemble() const override { return assemble; }
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
std::string Name() const override { return "EllipticPDESolver"; }
};
#endif //ELLIPTICPDESOLVER_HPP
......@@ -87,13 +87,22 @@ private:
IStochasticDummyAssemble *assemble;
protected:
void run(SampleSolution &solution) override;;
void run(SampleSolution &solution) override {}
void computeQ(SampleSolution &solution) override;;
void computeQ(SampleSolution &solution) override {
if (quantity == "GeneratorValue") solution.Q = assemble->GeneratorValue();
else Exit("Quantity of interest not implemented")
}
void computeCost(SampleSolution &solution) override;;
void computeCost(SampleSolution &solution) override {
if (costMeasure == "size") solution.Cost = solution.U.size();
// else if (costMeasure == "time") solution.Cost = solution.U.size(); // Todo
else Exit("Cost measure not implemented")
}
void plotSolution(SampleSolution &solution) override;;
void plotSolution(SampleSolution &solution) override {
// plot meshes?
}
public:
DummyPDESolver(IStochasticDummyAssemble *assemble,
......@@ -118,98 +127,4 @@ public:
std::string Name() const override { return "DummyPDESolver"; }
};
class EllipticPDESolver : public PDESolver {
private:
Newton *newton;
IStochasticEllipticAssemble *assemble;
protected:
void run(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void plotSolution(SampleSolution &solution) override;
public:
EllipticPDESolver(IStochasticEllipticAssemble *assemble, Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure),
newton(new Newton()), assemble(assemble) {
if (verbose > 0) {
PrintInfo();
newton->PrintInfo();
assemble->PrintInfo();
}
}
~EllipticPDESolver() {
delete assemble;
delete newton;
}
IAssemble *GetAssemble() const override { return assemble; }
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
std::string Name() const override { return "EllipticPDESolver"; }
};
class TransportPDESolver : public PDESolver {
private:
TimeIntegrator *timeInt;
IStochasticLinearTransportAssemble *assemble;
protected:
void run(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void plotSolution(SampleSolution &solution) override;
public:
TransportPDESolver(IStochasticLinearTransportAssemble *assemble,
Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure), assemble(assemble),
timeInt(TimeIntegratorCreator(IMPLICIT_MIDPOINT).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
Create()) {
if (verbose)
PrintInfo();
}
~TransportPDESolver() {
delete assemble;
delete timeInt;
}
IAssemble *GetAssemble() const override {
return nullptr;
// return assemble;
}
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
std::string Name() const override { return "TransportPDESolver"; }
};
#endif //PDESOLVER_HPP
#include "PDESolverCreator.hpp"
#include "EllipticPDESolver.hpp"
#include "TransportPDESolver.hpp"
PDESolver *PDESolverCreator::Create(Meshes &meshes) {
......
#include "TransportPDESolver.hpp"
void TransportPDESolver::run(SampleSolution &solution) {
assemble->SetTimeSeries(solution.U);
solution.U.GetMesh().PrintInfo();
assemble->GetTimeSeries().PrintInfo();
timeInt->Method(assemble, solution.U);
}
void TransportPDESolver::computeQ(SampleSolution &solution) {
if (quantity == "Energy") solution.Q = assemble->Energy(solution.U);
else if (quantity == "Mass") solution.Q = assemble->Mass(solution.U);
else if (quantity == "Error") solution.Q = assemble->Error(0, solution.U);
else if (quantity == "Inflow") solution.Q = assemble->InflowOutflow(solution.U).first;
else if (quantity == "Outflow") solution.Q = assemble->InflowOutflow(solution.U).second;
// else if (quantity == "L2Error") solution.Q = assemble->L2Error(solution.U);
// else if (quantity == "EnergyError") solution.Q = assemble->EnergyError(solution.U);
else Exit("Quantity of interest not implemented")
}
void TransportPDESolver::computeCost(SampleSolution &solution) {
}
void TransportPDESolver::plotSolution(SampleSolution &solution) {
}
\ No newline at end of file
#ifndef TRANSPORTPDESOLVER_HPP
#define TRANSPORTPDESOLVER_HPP
#include "PDESolver.hpp"
class TransportPDESolver : public PDESolver {
private:
TimeIntegrator *timeInt;
IStochasticLinearTransportAssemble *assemble;
protected:
void run(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void plotSolution(SampleSolution &solution) override;
public:
TransportPDESolver(IStochasticLinearTransportAssemble *assemble,
Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure), assemble(assemble),
timeInt(TimeIntegratorCreator(IMPLICIT_MIDPOINT).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
Create()) {
if (verbose)
PrintInfo();
}
~TransportPDESolver() {
delete assemble;
delete timeInt;
}
IAssemble *GetAssemble() const override {
return nullptr;
// return assemble;
}
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
std::string Name() const override { return "TransportPDESolver"; }
};
#endif //TRANSPORTPDESOLVER_HPP
Markdown is supported
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