Commit 82af39c5 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

using verbose as quick hack to get rid of useless logging

parent 9d74096d
......@@ -25,183 +25,189 @@
class PDESolver {
protected:
int verbose = 1;
int verbose = 1;
int plotting = 0;
int plotting = 0;
Meshes &meshes;
Meshes &meshes;
std::string quantity;
std::string quantity;
std::string costMeasure;
std::string costMeasure;
virtual void run(SampleSolution &solution) = 0;
virtual void run(SampleSolution &solution) = 0;
virtual void computeQ(SampleSolution &solution) = 0;
virtual void computeQ(SampleSolution &solution) = 0;
virtual void computeCost(SampleSolution &solution) = 0;
virtual void computeCost(SampleSolution &solution) = 0;
virtual void plotSolution(SampleSolution &solution) = 0;
virtual void plotSolution(SampleSolution &solution) = 0;
public:
PDESolver(Meshes &meshes, const std::string &quantity,
const std::string &costMeasure) :
meshes(meshes), quantity(quantity), costMeasure(costMeasure) {
config.get("PDESolverVerbose", verbose);
config.get("PDESolverPlotting", plotting);
}
virtual ~PDESolver() {};
virtual void PrintInfo() const {
mout.PrintInfo(Name(), verbose,
PrintInfoEntry("Quantity", quantity),
PrintInfoEntry("Cost measure", costMeasure));
}
void Run(SampleSolution &solution) {
mout.StartBlock("PDE Solver");
vout(2) << solution.IdString() << endl;
run(solution);
computeQ(solution);
computeCost(solution);
plotSolution(solution);
vout(2) << "Q=" << solution.Q << " cost=" << solution.Cost << endl;
mout.EndBlock(verbose <= 1);
}
virtual IAssemble *GetAssemble() const = 0;
virtual IDiscretization *GetDisc() const = 0;
virtual IStochasticProblem *GetProblem() const = 0;
virtual void DrawSample(const SampleID &id) = 0;
virtual std::string Name() const = 0;
PDESolver(Meshes &meshes, const std::string &quantity,
const std::string &costMeasure) :
meshes(meshes), quantity(quantity), costMeasure(costMeasure) {
config.get("PDESolverVerbose", verbose);
config.get("PDESolverPlotting", plotting);
}
virtual ~PDESolver() {};
virtual void PrintInfo() const {
if (verbose > 0)
mout.PrintInfo(Name(), verbose,
PrintInfoEntry("Quantity", quantity),
PrintInfoEntry("Cost measure", costMeasure));
}
void Run(SampleSolution &solution) {
mout.StartBlock("PDE Solver");
vout(2) << solution.IdString() << endl;
run(solution);
computeQ(solution);
computeCost(solution);
plotSolution(solution);
vout(2) << "Q=" << solution.Q << " cost=" << solution.Cost << endl;
mout.EndBlock(verbose <= 1);
}
virtual IAssemble *GetAssemble() const = 0;
virtual IDiscretization *GetDisc() const = 0;
virtual IStochasticProblem *GetProblem() const = 0;
virtual void DrawSample(const SampleID &id) = 0;
virtual std::string Name() const = 0;
};
class DummyPDESolver : public PDESolver {
private:
IStochasticDummyAssemble *assemble;
IStochasticDummyAssemble *assemble;
protected:
void run(SampleSolution &solution) override;;
void run(SampleSolution &solution) override;;
void computeQ(SampleSolution &solution) override;;
void computeQ(SampleSolution &solution) override;;
void computeCost(SampleSolution &solution) override;;
void computeCost(SampleSolution &solution) override;;
void plotSolution(SampleSolution &solution) override;;
void plotSolution(SampleSolution &solution) override;;
public:
DummyPDESolver(IStochasticDummyAssemble *assemble,
Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure), assemble(assemble) {
PrintInfo();
// assemble->PrintInfo();
DummyPDESolver(IStochasticDummyAssemble *assemble,
Meshes &meshes,
const std::string &quantity = "L2",
const std::string &costMeasure = "size") :
PDESolver(meshes, quantity, costMeasure), assemble(assemble) {
if (verbose > 0) {
PrintInfo();
assemble->PrintInfo();
}
}
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); }
std::string Name() const override { return "DummyPDESolver"; }
std::string Name() const override { return "DummyPDESolver"; }
};
class EllipticPDESolver : public PDESolver {
private:
Newton *newton;
Newton *newton;
IStochasticEllipticAssemble *assemble;
IStochasticEllipticAssemble *assemble;
protected:
void run(SampleSolution &solution) override;
void run(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void plotSolution(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) {
PrintInfo();
newton->PrintInfo();
assemble->PrintInfo();
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;
}
~EllipticPDESolver() {
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); }
std::string Name() const override { return "EllipticPDESolver"; }
std::string Name() const override { return "EllipticPDESolver"; }
};
class TransportPDESolver : public PDESolver {
private:
TimeIntegrator *timeInt;
TimeIntegrator *timeInt;
IStochasticLinearTransportAssemble *assemble;
IStochasticLinearTransportAssemble *assemble;
protected:
void run(SampleSolution &solution) override;
void run(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeQ(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void computeCost(SampleSolution &solution) override;
void plotSolution(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"))).
Create()) {
PrintInfo();
}
~TransportPDESolver() {
delete assemble;
delete timeInt;
}
IAssemble *GetAssemble() const override {
return nullptr;
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"))).
Create()) {
if (verbose)
PrintInfo();
}
~TransportPDESolver() {
delete assemble;
delete timeInt;
}
IAssemble *GetAssemble() const override {
return nullptr;
// 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); }
std::string Name() const override { return "TransportPDESolver"; }
std::string Name() const override { return "TransportPDESolver"; }
};
#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