Commit 4407388e authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

refactored assemble classes

parent 4c689d61
......@@ -228,20 +228,22 @@ void DGEllipticAssemble::AssembleTransfer(TransferMatrix &TM) const {
TM(c(), c.Child(k))[0] = 1;
}
void DGEllipticAssemble::plotU(const Vector &u, const string &name) {
Vector plot_u(u);
for (cell c = u.cells(); c != u.cells_end(); ++c) {
DGElement elem(*disc, u, c);
double U = 0;
double area = 0;
for (int q = 0; q < elem.nQ(); ++q) {
double w = elem.QWeight(q);
U += w * elem.Value(q, u);
area += w;
}
U *= (1 / area);
plot_u(c(), 0) = U;
}
plot->celldata(plot_u);
plot->vtk_celldata("u");
}
//void plotU(const Vector &u, const string &name) override;
//
//void DGEllipticAssemble::plotU(const Vector &u, const string &name) {
// Vector plot_u(u);
// for (cell c = u.cells(); c != u.cells_end(); ++c) {
// DGElement elem(*disc, u, c);
// double U = 0;
// double area = 0;
// for (int q = 0; q < elem.nQ(); ++q) {
// double w = elem.QWeight(q);
// U += w * elem.Value(q, u);
// area += w;
// }
// U *= (1 / area);
// plot_u(c(), 0) = U;
// }
// plot->celldata(plot_u);
// plot->vtk_celldata("u");
//}
......@@ -2,7 +2,7 @@
#define _DGLAPLACE_H_
#include "EllipticAssemble.h"
#include "discretization/DGDiscretization.h"
#include "discretization/DGDiscretization.hpp"
#include "discretization/DGUtils.h"
......@@ -13,7 +13,7 @@ public:
double penalty = 1.0;
int sign = 1;
DGEllipticAssemble(shared_ptr<Discretization> disc,
DGEllipticAssemble(shared_ptr<IDiscretizationT<>> disc,
shared_ptr<StochasticEllipticProblem> problem)
: EllipticAssemble(move(disc), move(problem)) {
this->disc = dynamic_pointer_cast<DGDiscretization>(disc);
......@@ -48,8 +48,6 @@ public:
void Jacobi(const cell &c, const Vector &u, Matrix &A) const override;
void AssembleTransfer(TransferMatrix &TM) const override;
void plotU(const Vector &u, const string &name) override;
};
#endif
#ifndef _DGASSEMBLE_H_
#define _DGASSEMBLE_H_
#include "discretization/DGDiscretization.h"
#include "discretization/DGDiscretization.hpp"
#include "discretization/DGUtils.h"
#include "problem/StochasticTransportProblem.hpp"
......
......@@ -368,26 +368,6 @@ void EllipticAssemble::setFlux(const Vector &u, Vector &flux) const {
}
}
void EllipticAssemble::plotU(const Vector &u, const string &name) {
plot->vertexdata(u);
plot->vtk_vertexdata(name);
}
void EllipticAssemble::plotFlux(const Vector &flux, const string &name) {
plot->celldata(flux, 3);
plot->vtk_cellvector(name);
}
void EllipticAssemble::plotPerm(const Vector &perm, const string &name) {
plot->celldata(perm);
plot->vtk_celldata(name);
}
void EllipticAssemble::PlotResults(const Vector &u) {
string nameU = sampleDir +"/u";
plotU(u, nameU);
}
void EllipticAssemble::AssembleTransfer(TransferMatrix &TM) const {
TM = 0;
......@@ -429,4 +409,31 @@ void EllipticAssemble::printSolutionInfo(const Vector &u) {
}
}
#include <utility>
//virtual void plotU(const Vector &u, const string &name);
//
//virtual void plotFlux(const Vector &flux, const string &name);
//
//virtual void plotPerm(const Vector &perm, const string &name);
//
//void PlotResults(const Vector &u);
//
//void EllipticAssemble::plotU(const Vector &u, const string &name) {
// plot->vertexdata(u);
// plot->vtk_vertexdata(name);
//}
//
//void EllipticAssemble::plotFlux(const Vector &flux, const string &name) {
// plot->celldata(flux, 3);
// plot->vtk_cellvector(name);
//}
//
//void EllipticAssemble::plotPerm(const Vector &perm, const string &name) {
// plot->celldata(perm);
// plot->vtk_celldata(name);
//}
//
//void EllipticAssemble::PlotResults(const Vector &u) {
// string nameU = sampleDir +"/u";
// plotU(u, nameU);
//}
......@@ -8,16 +8,13 @@
class EllipticAssemble : public Assemble {
public:
std::shared_ptr<Discretization> disc;
std::shared_ptr<IDiscretizationT<>> disc;
std::shared_ptr<StochasticEllipticProblem> problem;
EllipticAssemble(std::shared_ptr<Discretization> disc,
EllipticAssemble(std::shared_ptr<IDiscretizationT<>> disc,
std::shared_ptr<StochasticEllipticProblem> problem) :
disc(move(disc)), problem(move(problem)) {}
string sampleDir = "";
Plot *plot;
virtual ~EllipticAssemble() = default;
virtual Element *getElement(const cell &c, const Vector &u) const;
......@@ -84,14 +81,6 @@ public:
virtual void setFlux(const Vector &u, Vector &flux) const;
virtual void plotU(const Vector &u, const string &name);
virtual void plotFlux(const Vector &flux, const string &name);
virtual void plotPerm(const Vector &perm, const string &name);
void PlotResults(const Vector &u);
void AssembleTransfer(TransferMatrix &TM) const override;
void printSolutionInfo(const Vector &u);
......
......@@ -301,11 +301,6 @@ void HybridEllipticAssemble::setFlux(const Vector &u, Vector &flux) const {
}
}
void HybridEllipticAssemble::plotU(const Vector &u, const string &name) {
plot->celldata(u);
plot->vtk_celldata("u");
}
void HybridEllipticAssemble::SetNormalFlux(const Vector &u, Vector &flux) {
for (cell c = u.cells(); c != u.cells_end(); ++c) {
int N = c.Faces();
......@@ -375,3 +370,10 @@ void HybridEllipticAssemble::PrintFlux(Vector &flux) const {
}
}
}
//void plotU(const Vector &u, const string &name) override;
//
//void HybridEllipticAssemble::plotU(const Vector &u, const string &name) {
// plot->celldata(u);
// plot->vtk_celldata("u");
//}
\ No newline at end of file
......@@ -6,7 +6,7 @@
class HybridEllipticAssemble : public MixedEllipticAssemble {
public:
HybridEllipticAssemble(shared_ptr<Discretization> disc,
HybridEllipticAssemble(shared_ptr<IDiscretizationT<>> disc,
shared_ptr<StochasticEllipticProblem> problem)
: MixedEllipticAssemble(move(disc), move(problem)) {}
......@@ -38,8 +38,6 @@ public:
void setFlux(const Vector &u, Vector &flux) const override;
void plotU(const Vector &u, const string &name) override;
void SetNormalFlux(const Vector &u, Vector &flux);
VectorField EvaluateCellFlux(const Vector &flux, const cell &c) const;
......
......@@ -145,11 +145,6 @@ double MixedEllipticAssemble::DualPrimalError(const Discretization &discretizati
return sqrt(PPM->Sum(err));
}
void MixedEllipticAssemble::plotU(const Vector &u, const string &name) {
plot->celldata(u);
plot->vtk_celldata("u");
}
void MixedEllipticAssemble::AssembleTransfer(TransferMatrix &TM) const {
TM = 0;
const matrixgraph &cg = TM.CoarseMatrixGraph();
......@@ -165,3 +160,11 @@ void MixedEllipticAssemble::AssembleTransfer(TransferMatrix &TM) const {
}
}
}
//void plotU(const Vector &u, const string &name) override;
//
//void MixedEllipticAssemble::plotU(const Vector &u, const string &name) {
// plot->celldata(u);
// plot->vtk_celldata("u");
//}
\ No newline at end of file
......@@ -6,7 +6,7 @@
class MixedEllipticAssemble : public EllipticAssemble {
public:
MixedEllipticAssemble(shared_ptr<Discretization> disc,
MixedEllipticAssemble(shared_ptr<IDiscretizationT<>> disc,
shared_ptr<StochasticEllipticProblem> problem)
: EllipticAssemble(move(disc), move(problem)) {}
......@@ -39,8 +39,6 @@ public:
virtual double DualPrimalError(const Discretization &discretization,
const Vector &u_ref, const Vector &u) const;
void plotU(const Vector &u, const string &name) override;
void AssembleTransfer(TransferMatrix &TM) const override;
};
......
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