Commit cf722a00 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

removing matrix graph and other stuff

parent de784987
#include "PDESolver.hpp"
MatrixGraphs *PDESolver::CreateSolutionMatrixGraphs() {
createOtherMatrixGraphs();
auto disc = this->GetDisc();
auto discType = typeid(*disc).name();
if (discType == typeid(LagrangeDiscretization).name())
return new MatrixGraphs(meshes, *disc);
if (discType == typeid(RTLagrangeDiscretization).name()) {
auto assemble = this->GetAssemble();
auto assembleType = typeid(*assemble).name();
if (assembleType == typeid(HybridEllipticAssemble).name())
return new MatrixGraphs(meshes, new FaceDoF(1));
if (assembleType == typeid(MixedEllipticAssemble).name())
return new MatrixGraphs(meshes, *disc);
}
if (discType == typeid(DGDiscretization).name())
return new CellMatrixGraphs(meshes, *disc);
if (discType == typeid(EGDiscretization).name())
return new CellVertexMatrixGraphs(meshes, *disc);
Exit(string(discType) +" not found")
}
void PDESolver::PrintInfo() const {
mout.PrintInfo("PDESolver", verbose,
PrintInfoEntry("Quantity", quantity),
PrintInfoEntry("Cost measure", costMeasure));
}
void DummyPDESolver::run(SampleSolution &solution) {}
void DummyPDESolver::computeQ(SampleSolution &solution) {
......@@ -44,7 +17,7 @@ void DummyPDESolver::computeCost(SampleSolution &solution) {
void DummyPDESolver::plotSolution(SampleSolution &solution) {}
void EllipticPDESolver::run(SampleSolution &solution) {
NewtonMethod(assemble, solution.U);
newton->operator()(*assemble, solution.U);
}
void EllipticPDESolver::computeQ(SampleSolution &solution) {
......@@ -73,29 +46,24 @@ void EllipticPDESolver::computeCost(SampleSolution &solution) {
void EllipticPDESolver::plotSolution(SampleSolution &solution) {
if (!plotting) return;
SampleSolution solutionPressure(pressureMGraphs, solution.id, "Pressure");
SampleSolution solutionCellFlux(fluxMGraphs, solution.id, "Flux");
if (typeid(*assemble).name() == typeid(HybridEllipticAssemble).name()) {
LagrangeDiscretization pressureDisc(meshes, 0, 1);
SampleSolution solutionPressure(&pressureDisc, solution.id, "Pressure");
assemble->SetPressure(solution.U, solutionPressure.U);
plotMap.VtkPlot(solutionPressure);
} else {
LagrangeDiscretization pressureDisc(meshes, 1, 1);
SampleSolution solutionPressure(&pressureDisc, solution.id, "Pressure");
assemble->SetPressure(solution.U, solutionPressure.U);
plotMap.VtkPlot(solutionPressure);
}
assemble->SetPressure(solution.U, solutionPressure.U);
LagrangeDiscretization fluxDisc(meshes, 0, SpaceDimension);
SampleSolution solutionCellFlux(&fluxDisc, solution.id, "Flux");
assemble->SetFlux(solution.U, solutionCellFlux.U);
plotMap.VtkPlot(solutionPressure);
plotMap.VtkPlot(solutionCellFlux);
}
void EllipticPDESolver::createOtherMatrixGraphs() {
if (plotting) {
fluxMGraphs = new MatrixGraphs(meshes, new LagrangeDoF(0, SpaceDimension));
if (typeid(*assemble).name() == typeid(HybridEllipticAssemble).name())
pressureMGraphs = new MatrixGraphs(meshes, new LagrangeDoF(0, 1));
else
pressureMGraphs = new MatrixGraphs(meshes, new LagrangeDoF(1, 1));
} else {
fluxMGraphs = nullptr;
pressureMGraphs = nullptr;
}
}
void TransportPDESolver::run(SampleSolution &solution) {
auto timeSeries = assemble->GetTimeSeries(solution.U);
timeInt->Method(assemble, solution.U);
......
......@@ -16,9 +16,8 @@
#include "basics/PlotMap.hpp"
// Mpp imports
#include "dof/BasicDoFs.hpp"
#include "Newton.hpp"
#include "TimeIntegrator.hpp"
#include "Newton.hpp"
#include "GMRES.hpp"
// Standard library
......@@ -39,8 +38,6 @@ protected:
std::string costMeasure;
MatrixGraphs *solMGraphs;
virtual void run(SampleSolution &solution) = 0;
virtual void computeQ(SampleSolution &solution) = 0;
......@@ -54,8 +51,6 @@ protected:
plotMap.UpdateMap(solution);
}
virtual void createOtherMatrixGraphs() {}
public:
PDESolver(Meshes &meshes, const std::string &quantity,
const std::string &costMeasure) :
......@@ -64,12 +59,10 @@ public:
config.get("PDESolverPlotting", plotting);
}
virtual ~PDESolver() {
if (!solMGraphs) delete solMGraphs;
};
MatrixGraphs *MGraphs() {
return solMGraphs;
virtual void PrintInfo() const {
mout.PrintInfo("PDESolver", verbose,
PrintInfoEntry("Quantity", quantity),
PrintInfoEntry("Cost measure", costMeasure));
}
void Run(SampleSolution &solution) {
......@@ -84,8 +77,6 @@ public:
mout.EndBlock(verbose == 0);
}
MatrixGraphs *CreateSolutionMatrixGraphs();
virtual IAssemble *GetAssemble() const = 0;
virtual IDiscretization *GetDisc() const = 0;
......@@ -93,8 +84,6 @@ public:
virtual IStochasticProblem *GetProblem() const = 0;
virtual void DrawSample(const SampleID &id) = 0;
virtual void PrintInfo() const;
};
class DummyPDESolver : public PDESolver {
......@@ -116,36 +105,22 @@ public:
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure), assemble(assemble) {
solMGraphs = CreateSolutionMatrixGraphs();
PrintInfo();
// assemble->PrintInfo();
}
~DummyPDESolver() {
if (!solMGraphs) delete solMGraphs;
}
IAssemble *GetAssemble() const override {
return assemble;
}
IAssemble *GetAssemble() const override { return assemble; }
IDiscretization *GetDisc() const override {
return assemble->GetDisc();
}
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override {
return assemble->GetProblem();
}
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override {
assemble->DrawSample(id);
}
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
};
class EllipticPDESolver : public PDESolver {
private:
MatrixGraphs *fluxMGraphs;
MatrixGraphs *pressureMGraphs;
Newton *newton;
IStochasticEllipticAssemble *assemble;
......@@ -158,41 +133,29 @@ protected:
void plotSolution(SampleSolution &solution) override;
// void setUpPlot(SampleSolution &solution) override {}
void createOtherMatrixGraphs() override;
public:
EllipticPDESolver(IStochasticEllipticAssemble *assemble, Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure), assemble(assemble) {
solMGraphs = CreateSolutionMatrixGraphs();
PDESolver(meshes, quantity, costMeasure),
newton(new Newton()), assemble(assemble) {
PrintInfo();
newton->PrintInfo();
assemble->PrintInfo();
}
~EllipticPDESolver() {
if (!assemble) delete assemble;
if (!solMGraphs) delete solMGraphs;
if (!fluxMGraphs) delete fluxMGraphs;
if (!pressureMGraphs) delete pressureMGraphs;
delete assemble;
delete newton;
}
IAssemble *GetAssemble() const override {
return assemble;
}
IAssemble *GetAssemble() const override { return assemble; }
IDiscretization *GetDisc() const override {
return assemble->GetDisc();
}
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override {
return assemble->GetProblem();
}
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override {
assemble->DrawSample(id);
}
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
};
class TransportPDESolver : public PDESolver {
......@@ -222,13 +185,11 @@ public:
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
WithLinearSolver(new GMRES(GetPC("PointBlockJacobi_dG"))).
Create()) {
solMGraphs = CreateSolutionMatrixGraphs();
PrintInfo();
}
~TransportPDESolver() {
if (!assemble) delete assemble;
if (!solMGraphs) delete solMGraphs;
delete assemble;
delete timeInt;
}
......@@ -237,17 +198,11 @@ public:
// return assemble;
}
IDiscretization *GetDisc() const override {
return assemble->GetDisc();
}
IDiscretization *GetDisc() const override { return assemble->GetDisc(); }
IStochasticProblem *GetProblem() const override {
return assemble->GetProblem();
}
IStochasticProblem *GetProblem() const override { return assemble->GetProblem(); }
void DrawSample(const SampleID &id) override {
assemble->DrawSample(id);
}
void DrawSample(const SampleID &id) override { assemble->DrawSample(id); }
};
#endif //PDESOLVER_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