Commit 5b1d3bfa authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

new assemble idea

parent 002a6ac4
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#include "discretization/DGDiscretization.hpp" #include "discretization/DGDiscretization.hpp"
#include "elements/Elements.h" #include "elements/Elements.h"
#include "IEllipticAssemble.hpp" #include "IStochasticEllipticAssemble.hpp"
class DGEllipticAssemble : public IEllipticAssemble { class DGEllipticAssemble : public IStochasticEllipticAssemble {
public: public:
DGDiscretization *disc; DGDiscretization *disc;
...@@ -13,7 +13,7 @@ public: ...@@ -13,7 +13,7 @@ public:
int sign = 1; int sign = 1;
DGEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem) DGEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem)
: IEllipticAssemble(problem), disc(dynamic_cast<DGDiscretization *> (disc)) { : IStochasticEllipticAssemble(problem), disc(dynamic_cast<DGDiscretization *> (disc)) {
this->disc = dynamic_cast<DGDiscretizationT<> *>(disc); this->disc = dynamic_cast<DGDiscretizationT<> *>(disc);
config.get("penalty", penalty); config.get("penalty", penalty);
config.get("sign", sign); config.get("sign", sign);
......
...@@ -545,3 +545,4 @@ void HybridEllipticAssemble::AssembleTransfer(TransferMatrix &TM) const { ...@@ -545,3 +545,4 @@ void HybridEllipticAssemble::AssembleTransfer(TransferMatrix &TM) const {
} }
} }
} }
...@@ -10,6 +10,14 @@ public: ...@@ -10,6 +10,14 @@ public:
HybridEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem) HybridEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem)
: MixedEllipticAssemble(disc, problem) {} : MixedEllipticAssemble(disc, problem) {}
virtual void DrawSample(SampleID id) override {
problem->DrawSample(id);
};
virtual IDiscretization *GetDiscretization() override {
return disc;
}
const char *Name() const override; const char *Name() const override;
void Initialize(Vector &u) const override; void Initialize(Vector &u) const override;
......
#ifndef ISTOCHASTICASSEMBLE_HPP
#define ISTOCHASTICASSEMBLE_HPP
#include "Assemble.h"
#include "problem/StochasticProblem.hpp"
// Todo Refactor TAssemble and use ITimeAssemble
class IStochasticAssemble : public IAssemble {
protected:
int verbose = 1;
public:
IStochasticAssemble() {
config.get("AssembleVerbose", verbose);
}
const char *Name() const override = 0;
void Initialize(Vector &u) const override = 0;
double Energy(const Vector &u) const override = 0;
void Residual(const cell &c, const Vector &u, Vector &r) const override = 0;
void Jacobi(const cell &c, const Vector &u, Matrix &A) const override = 0;
virtual void DrawSample(SampleID id) = 0;
virtual IDiscretization *GetDiscretization() = 0;
virtual IStochasticProblem *GetStochasticProblem() = 0;
void PrintInfo() const override = 0;
};
#endif //ISTOCHASTICASSEMBLE_HPP
#ifndef IELLIPTICASSEMBLE_HPP #ifndef ISTOCHASTICELLIPTICASSEMBLE_HPP
#define IELLIPTICASSEMBLE_HPP #define ISTOCHASTICELLIPTICASSEMBLE_HPP
#include "Assemble.h" #include "assemble/IStochasticAssemble.hpp"
#include "problem/StochasticEllipticProblem.hpp" #include "problem/StochasticEllipticProblem.hpp"
typedef std::pair<double, double> FluxPair; typedef std::pair<double, double> FluxPair;
class IEllipticAssemble : public IAssemble { class IStochasticEllipticAssemble : public IStochasticAssemble {
protected:
int verbose = 1;
public: public:
IStochasticEllipticProblem *problem; IStochasticEllipticProblem *problem;
explicit IEllipticAssemble(IStochasticEllipticProblem *problem) : problem(problem) { explicit IStochasticEllipticAssemble(IStochasticEllipticProblem *problem) :
config.get("EllipticVerbose", verbose); IStochasticAssemble(), problem(problem) {
};
void DrawSample(SampleID id) override {
problem->DrawSample(id);
}
IStochasticProblem *GetStochasticProblem() override {
return problem;
}; };
virtual ~IEllipticAssemble() = default;; virtual ~IStochasticEllipticAssemble() = default;;
const char *Name() const override = 0; const char *Name() const override = 0;
...@@ -32,6 +37,7 @@ public: ...@@ -32,6 +37,7 @@ public:
virtual double EnergyError(const Vector &u) const = 0; virtual double EnergyError(const Vector &u) const = 0;
// Todo make class out of it SpacialMeasures see EmpiricalMeasures
virtual double L2(const Vector &u) const = 0; virtual double L2(const Vector &u) const = 0;
virtual double H1(const Vector &u) const = 0; virtual double H1(const Vector &u) const = 0;
...@@ -104,4 +110,4 @@ public: ...@@ -104,4 +110,4 @@ public:
} }
}; };
#endif //IELLIPTICASSEMBLE_HPP #endif //ISTOCHASTICELLIPTICASSEMBLE_HPP
...@@ -3,14 +3,18 @@ ...@@ -3,14 +3,18 @@
#include "discretization/LagrangeDiscretization.hpp" #include "discretization/LagrangeDiscretization.hpp"
#include "elements/Elements.h" #include "elements/Elements.h"
#include "IEllipticAssemble.hpp" #include "IStochasticEllipticAssemble.hpp"
class LagrangeEllipticAssemble : public IEllipticAssemble { class LagrangeEllipticAssemble : public IStochasticEllipticAssemble {
public: public:
IDiscretization *disc; IDiscretization *disc;
LagrangeEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem) LagrangeEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem)
: IEllipticAssemble(problem), disc(disc) {} : IStochasticEllipticAssemble(problem), disc(disc) {}
IDiscretization *GetDiscretization() override {
return disc;
};
const char *Name() const override; const char *Name() const override;
......
...@@ -4,15 +4,20 @@ ...@@ -4,15 +4,20 @@
#include "discretization/RTLagrangeDiscretization.hpp" #include "discretization/RTLagrangeDiscretization.hpp"
#include "discretization/LagrangeDiscretization.hpp" #include "discretization/LagrangeDiscretization.hpp"
#include "elements/Elements.h" #include "elements/Elements.h"
#include "IEllipticAssemble.hpp" #include "IStochasticEllipticAssemble.hpp"
class MixedEllipticAssemble : public IEllipticAssemble { class MixedEllipticAssemble : public IStochasticEllipticAssemble {
public: protected:
IDiscretization *disc; IDiscretization *disc;
public:
MixedEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem) : MixedEllipticAssemble(IDiscretization *disc, IStochasticEllipticProblem *problem) :
IEllipticAssemble(problem), disc(disc) {}; IStochasticEllipticAssemble(problem), disc(disc) {};
IDiscretization *GetDiscretization() override {
return disc;
};
const char *Name() const override; const char *Name() const override;
...@@ -53,44 +58,6 @@ public: ...@@ -53,44 +58,6 @@ public:
virtual void SetFlux(const Vector &u, Vector &flux) override; virtual void SetFlux(const Vector &u, Vector &flux) override;
void AssembleTransfer(TransferMatrix &TM) const override; void AssembleTransfer(TransferMatrix &TM) const override;
//protected:
// Element *createElement(const cell &c, const Vector &u) const override {
// return new RT0_LagrangeElementT<>(*disc, u, c);
// }
//
// FaceElement *createFaceElement(const cell &c, const Vector &u,
// int face) const override {
// return new RT0FaceElement(*disc, u, c, face);
// }
//
// Scalar getValue(const cell &c, const Vector &u, Element *elem, int q) const override {
// return u(c(), 0);
// }
//
// Scalar getFaceValue(const cell &c, const Vector &u, FaceElement *faceElem,
// int q, int face) const override {
// return u(c(), 0);
// }
//
// VectorField getFlux(const cell &c, const Vector &u,
// Element *elem, int q) const override {
// auto rt0Elem = dynamic_cast<RT0_LagrangeElementT<> *>(elem);
// return rt0Elem->VelocityField(q, u);
// }
//
// VectorField getFaceFlux(const cell &c, const Vector &u,
// FaceElement *faceElem, int q,
// int face) const override {
// auto rt0FaceElem = dynamic_cast<RT0FaceElement *>(faceElem);
// return rt0FaceElem->VectorValue(q, u, face);
// }
//
// VectorField getGradient(const cell &c, const Vector &u,
// Element *elem, int q) const override {
// Tensor IK = problem->InversePermeability(c.Subdomain(), elem->QPoint(q));
// return IK * getFlux(c, u, elem, q);
// }
}; };
#endif #endif
...@@ -102,26 +102,26 @@ IStochasticProblem *MainProgram::createStochasticProblem() { ...@@ -102,26 +102,26 @@ IStochasticProblem *MainProgram::createStochasticProblem() {
return new StochasticLaplace1D(*meshes); return new StochasticLaplace1D(*meshes);
if (problemName == "StochasticLaplace2D") if (problemName == "StochasticLaplace2D")
return new StochasticLaplace2D(*meshes); return new StochasticLaplace2D(*meshes);
if (problemName == "StochasticPollution1D") // if (problemName == "StochasticPollution1D")
return new StochasticPollution1D(*meshes); // return new StochasticPollution1D(*meshes);
if (problemName == "StochasticPollutionCosHat1D") // if (problemName == "StochasticPollutionCosHat1D")
return new StochasticPollutionCosHat1D(*meshes); // return new StochasticPollutionCosHat1D(*meshes);
if (problemName == "StochasticPollution2D") // if (problemName == "StochasticPollution2D")
return new StochasticPollution2D(*meshes); // return new StochasticPollution2D(*meshes);
if (problemName == "StochasticPollutionCosHat2D") // if (problemName == "StochasticPollutionCosHat2D")
return new StochasticPollutionCosHat2D(*meshes); // return new StochasticPollutionCosHat2D(*meshes);
if (problemName == "StochasticPollutionMollifiedBar2D") // if (problemName == "StochasticPollutionMollifiedBar2D")
return new StochasticPollutionMollifiedBar2D(*meshes); // return new StochasticPollutionMollifiedBar2D(*meshes);
if (problemName == "StochasticInitialConditions2D") // if (problemName == "StochasticInitialConditions2D")
return nullptr; // return nullptr;
Exit("\nProblem field not found in " + problemName + "\n") Exit("\nProblem field not found in " + problemName + "\n")
} }
IAssemble *MainProgram::createAssemble() { IStochasticAssemble * MainProgram::createAssemble() {
IStochasticEllipticProblem *ellipticProblem = IStochasticEllipticProblem *ellipticProblem =
dynamic_cast<IStochasticEllipticProblem * >(problem); dynamic_cast<IStochasticEllipticProblem * >(problem);
IStochasticTransportProblem *transportProblem = // IStochasticTransportProblem *transportProblem =
dynamic_cast<IStochasticTransportProblem * >(problem); // dynamic_cast<IStochasticTransportProblem * >(problem);
if (ellipticProblem != nullptr) { if (ellipticProblem != nullptr) {
if (modelName == "LagrangeFEM") if (modelName == "LagrangeFEM")
...@@ -134,12 +134,12 @@ IAssemble *MainProgram::createAssemble() { ...@@ -134,12 +134,12 @@ IAssemble *MainProgram::createAssemble() {
// return new DGEllipticAssemble(disc, ellipticProblem); // return new DGEllipticAssemble(disc, ellipticProblem);
} }
if (transportProblem != nullptr) { //// if (transportProblem != nullptr) {
if (modelName == "DGTransport") //// if (modelName == "DGTransport")
return new DGTransportAssemble(disc, transportProblem, nullptr); //// return new DGTransportAssemble(disc, transportProblem, nullptr);
if (modelName == "PGTransport") //// if (modelName == "PGTransport")
return nullptr; // Todo open research question //// return nullptr; // Todo open research question
} // }
Exit(("\nAssembling for Problem=" + problemName + " with Model=" + Exit(("\nAssembling for Problem=" + problemName + " with Model=" +
modelName + " not implemented\n")) modelName + " not implemented\n"))
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
Meshes *meshes; Meshes *meshes;
IDiscretization *disc; IDiscretization *disc;
IStochasticProblem *problem; IStochasticProblem *problem;
IAssemble *assemble; IStochasticAssemble *assemble;
MultilevelMonteCarlo *mlmc; MultilevelMonteCarlo *mlmc;
MainProgram() { MainProgram() {
...@@ -83,7 +83,7 @@ private: ...@@ -83,7 +83,7 @@ private:
IStochasticProblem *createStochasticProblem(); IStochasticProblem *createStochasticProblem();
IAssemble *createAssemble(); IStochasticAssemble * createAssemble();
}; };
#endif //MLMC_MLMCMAIN_H #endif //MLMC_MLMCMAIN_H
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