Commit 4e34df55 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

NavierStokes base problems changed

parent 006ad304
...@@ -19,7 +19,8 @@ NavierStokesPhase_TaylorHood::NavierStokesPhase_TaylorHood(const std::string &na ...@@ -19,7 +19,8 @@ NavierStokesPhase_TaylorHood::NavierStokesPhase_TaylorHood(const std::string &na
Parameters::get(name + "->epsilon", epsilon); Parameters::get(name + "->epsilon", epsilon);
Parameters::get(name + "->alpha", alpha); Parameters::get(name + "->alpha", alpha);
}; }
NavierStokesPhase_TaylorHood::~NavierStokesPhase_TaylorHood() NavierStokesPhase_TaylorHood::~NavierStokesPhase_TaylorHood()
{ {
...@@ -27,6 +28,7 @@ NavierStokesPhase_TaylorHood::~NavierStokesPhase_TaylorHood() ...@@ -27,6 +28,7 @@ NavierStokesPhase_TaylorHood::~NavierStokesPhase_TaylorHood()
delete fileWriterPhase; delete fileWriterPhase;
} }
void NavierStokesPhase_TaylorHood::initData() void NavierStokesPhase_TaylorHood::initData()
{ {
super::initData(); super::initData();
...@@ -52,8 +54,15 @@ void NavierStokesPhase_TaylorHood::transferInitialSolution(AdaptInfo *adaptInfo) ...@@ -52,8 +54,15 @@ void NavierStokesPhase_TaylorHood::transferInitialSolution(AdaptInfo *adaptInfo)
void NavierStokesPhase_TaylorHood::closeTimestep(AdaptInfo *adaptInfo) void NavierStokesPhase_TaylorHood::closeTimestep(AdaptInfo *adaptInfo)
{ {
super::closeTimestep(adaptInfo); super::closeTimestep(adaptInfo);
phaseOld->interpol(phase); phaseOld->interpol(phase);
writeFiles(adaptInfo, false);
}
void NavierStokesPhase_TaylorHood::writeFiles(AdaptInfo *adaptInfo, bool force)
{ FUNCNAME("NavierStokesPhase_TaylorHood::closeTimestep()");
super::writeFiles(adaptInfo, force);
fileWriterPhase->writeFiles(adaptInfo, false); fileWriterPhase->writeFiles(adaptInfo, false);
} }
...@@ -76,7 +85,7 @@ void NavierStokesPhase_TaylorHood::fillOperators() ...@@ -76,7 +85,7 @@ void NavierStokesPhase_TaylorHood::fillOperators()
/// < (1/tau)*u_i^old , psi > /// < (1/tau)*u_i^old , psi >
Operator *opTimeOld = new Operator(prob->getFeSpace(i), prob->getFeSpace(i)); Operator *opTimeOld = new Operator(prob->getFeSpace(i), prob->getFeSpace(i));
opTimeOld->addTerm(new Phase_ZOT(phaseOld, density)); opTimeOld->addTerm(new Phase_ZOT(phaseOld, density));
opTimeOld->setUhOld(prob->getSolution()->getDOFVector(i)); opTimeOld->setUhOld(getOldSolution(i));
prob->addVectorOperator(*opTimeOld, i, getInvTau()); prob->addVectorOperator(*opTimeOld, i, getInvTau());
/// < u^old*grad(u_i^old) , psi > /// < u^old*grad(u_i^old) , psi >
...@@ -148,7 +157,7 @@ void NavierStokesPhase_TaylorHood::addLaplaceTerm(int i) ...@@ -148,7 +157,7 @@ void NavierStokesPhase_TaylorHood::addLaplaceTerm(int i)
if (laplaceType == 1) { if (laplaceType == 1) {
for (unsigned j = 0; j < dow; ++j) { for (unsigned j = 0; j < dow; ++j) {
Operator *opLaplaceUi1 = new Operator(prob->getFeSpace(i), prob->getFeSpace(j)); Operator *opLaplaceUi1 = new Operator(prob->getFeSpace(i), prob->getFeSpace(j));
opLaplaceUi1->addTerm(new MatrixIJPhase_SOT(phase, 1-i, 1-j, viscosity)); opLaplaceUi1->addTerm(new MatrixIJPhase_SOT(phase, j, i, viscosity));
prob->addMatrixOperator(*opLaplaceUi1, i, j, &theta); prob->addMatrixOperator(*opLaplaceUi1, i, j, &theta);
opLaplaceUi1->setUhOld(prob->getSolution()->getDOFVector(j)); opLaplaceUi1->setUhOld(prob->getSolution()->getDOFVector(j));
......
...@@ -29,6 +29,8 @@ public: // methods ...@@ -29,6 +29,8 @@ public: // methods
virtual void transferInitialSolution(AdaptInfo *adaptInfo); virtual void transferInitialSolution(AdaptInfo *adaptInfo);
virtual void closeTimestep(AdaptInfo *adaptInfo); virtual void closeTimestep(AdaptInfo *adaptInfo);
virtual void writeFiles(AdaptInfo *adaptInfo, bool force = false);
// === getting/setting methods === // === getting/setting methods ===
DOFVector<double> *getPhase() DOFVector<double> *getPhase()
...@@ -51,6 +53,11 @@ public: // methods ...@@ -51,6 +53,11 @@ public: // methods
return epsilon; return epsilon;
} }
DOFVector<WorldVector<double> >* getVelocity()
{
return velocity;
}
void setPhase(DOFVector<double>* phase_) void setPhase(DOFVector<double>* phase_)
{ {
phase = phase_; phase = phase_;
......
...@@ -16,7 +16,10 @@ NavierStokes_TaylorHood::NavierStokes_TaylorHood(const std::string &name_) : ...@@ -16,7 +16,10 @@ NavierStokes_TaylorHood::NavierStokes_TaylorHood(const std::string &name_) :
theta(0.5), theta(0.5),
theta1(0.5), theta1(0.5),
minusTheta1(-0.5), minusTheta1(-0.5),
velocity(NULL) velocity(NULL),
fileWriter(NULL),
initialX(NULL),
initialY(NULL)
{ {
// force the homogeniouse dirichlet BC if combination of dirichlet and neumann BC // force the homogeniouse dirichlet BC if combination of dirichlet and neumann BC
// are set and AMDiS can not handle this combination automatically // are set and AMDiS can not handle this combination automatically
...@@ -50,6 +53,10 @@ NavierStokes_TaylorHood::NavierStokes_TaylorHood(const std::string &name_) : ...@@ -50,6 +53,10 @@ NavierStokes_TaylorHood::NavierStokes_TaylorHood(const std::string &name_) :
Initfile::get("mesh->scale",dimension); Initfile::get("mesh->scale",dimension);
} else } else
dimension.set(1.0); dimension.set(1.0);
for (size_t i = 0; i < dow; i++)
oldSolution[i] = NULL;
} }
...@@ -60,8 +67,18 @@ NavierStokes_TaylorHood::~NavierStokes_TaylorHood() ...@@ -60,8 +67,18 @@ NavierStokes_TaylorHood::~NavierStokes_TaylorHood()
delete initialX; delete initialX;
delete initialY; delete initialY;
} }
if (velocity != NULL)
if (velocity != NULL) {
delete velocity; delete velocity;
velocity = NULL;
}
for (size_t i = 0; i < dow; i++) {
if (oldSolution[i] != NULL)
delete oldSolution[i];
oldSolution[i] = NULL;
}
delete fileWriter; delete fileWriter;
} }
...@@ -71,6 +88,10 @@ void NavierStokes_TaylorHood::initData() ...@@ -71,6 +88,10 @@ void NavierStokes_TaylorHood::initData()
if (velocity == NULL) if (velocity == NULL)
velocity = new DOFVector<WorldVector<double> >(getFeSpace(0), "velocity"); velocity = new DOFVector<WorldVector<double> >(getFeSpace(0), "velocity");
for (size_t i = 0; i < dow; i++)
oldSolution[i] = new DOFVector<double>(getFeSpace(i), "old(v_"+Helpers::toString(i)+")");
fileWriter = new FileVectorWriter(name + "->velocity->output", getFeSpace()->getMesh(), velocity); fileWriter = new FileVectorWriter(name + "->velocity->output", getFeSpace()->getMesh(), velocity);
super::initData(); super::initData();
...@@ -111,7 +132,6 @@ void NavierStokes_TaylorHood::solveInitialProblem(AdaptInfo *adaptInfo) ...@@ -111,7 +132,6 @@ void NavierStokes_TaylorHood::solveInitialProblem(AdaptInfo *adaptInfo)
prob->getSolution()->getDOFVector(i)->interpol(initialFcts[i]); prob->getSolution()->getDOFVector(i)->interpol(initialFcts[i]);
prob->setExactSolutionFct(initialFcts[i], i); prob->setExactSolutionFct(initialFcts[i], i);
} }
} }
...@@ -123,6 +143,9 @@ void NavierStokes_TaylorHood::transferInitialSolution(AdaptInfo *adaptInfo) ...@@ -123,6 +143,9 @@ void NavierStokes_TaylorHood::transferInitialSolution(AdaptInfo *adaptInfo)
for (int i = 0; i < dow; i++) for (int i = 0; i < dow; i++)
prob->setExactSolution(prob->getSolution()->getDOFVector(i), i); prob->setExactSolution(prob->getSolution()->getDOFVector(i), i);
for (size_t i = 0; i < dow; i++)
oldSolution[i]->copy(*prob->getSolution()->getDOFVector(i));
fileWriter->writeFiles(adaptInfo, false); fileWriter->writeFiles(adaptInfo, false);
writeFiles(adaptInfo, false); writeFiles(adaptInfo, false);
...@@ -211,7 +234,7 @@ void NavierStokes_TaylorHood::addLaplaceTerm(int i) ...@@ -211,7 +234,7 @@ void NavierStokes_TaylorHood::addLaplaceTerm(int i)
if (laplaceType == 1) { if (laplaceType == 1) {
for (unsigned j = 0; j < dow; ++j) { for (unsigned j = 0; j < dow; ++j) {
Operator *opLaplaceUi1 = new Operator(getFeSpace(i), getFeSpace(j)); Operator *opLaplaceUi1 = new Operator(getFeSpace(i), getFeSpace(j));
opLaplaceUi1->addTerm(new MatrixIJ_SOT(1-i, 1-j, viscosity)); opLaplaceUi1->addTerm(new MatrixIJ_SOT(j, i, viscosity));
prob->addMatrixOperator(*opLaplaceUi1, i, j, &theta, &theta); prob->addMatrixOperator(*opLaplaceUi1, i, j, &theta, &theta);
if (abs(minusTheta1) > DBL_TOL) { if (abs(minusTheta1) > DBL_TOL) {
...@@ -244,6 +267,14 @@ void NavierStokes_TaylorHood::closeTimestep(AdaptInfo *adaptInfo) ...@@ -244,6 +267,14 @@ void NavierStokes_TaylorHood::closeTimestep(AdaptInfo *adaptInfo)
{ FUNCNAME("NavierStokes_TaylorHood::closeTimestep()"); { FUNCNAME("NavierStokes_TaylorHood::closeTimestep()");
calcVelocity(); calcVelocity();
for (size_t i = 0; i < dow; i++)
oldSolution[i]->copy(*prob->getSolution()->getDOFVector(i));
}
void NavierStokes_TaylorHood::writeFiles(AdaptInfo *adaptInfo, bool force)
{ FUNCNAME("NavierStokesPhase_TaylorHood::closeTimestep()");
super::writeFiles(adaptInfo, force);
fileWriter->writeFiles(adaptInfo, false); fileWriter->writeFiles(adaptInfo, false);
writeFiles(adaptInfo, false);
} }
...@@ -43,6 +43,8 @@ public: // methods ...@@ -43,6 +43,8 @@ public: // methods
virtual void transferInitialSolution(AdaptInfo *adaptInfo); virtual void transferInitialSolution(AdaptInfo *adaptInfo);
virtual void closeTimestep(AdaptInfo *adaptInfo); virtual void closeTimestep(AdaptInfo *adaptInfo);
virtual void writeFiles(AdaptInfo *adaptInfo, bool force = false);
// === getting/setting methods === // === getting/setting methods ===
...@@ -51,10 +53,15 @@ public: // methods ...@@ -51,10 +53,15 @@ public: // methods
DOFVector<WorldVector<double> >* getVelocity() DOFVector<WorldVector<double> >* getVelocity()
{ {
if (velocity == NULL) TEST_EXIT_DBG(velocity != NULL)("velocity is NULL!");
velocity = new DOFVector<WorldVector<double> >(getFeSpace(0), "velocity");
return velocity; return velocity;
} }
DOFVector<double> *getOldSolution(int i)
{
TEST_EXIT_DBG(oldSolution[i] != NULL)("Für die angegebene Komponente ist keine OldSolution erstellt!");
return oldSolution[i];
}
// protected: // methods // protected: // methods
...@@ -99,5 +106,6 @@ protected: // variables ...@@ -99,5 +106,6 @@ protected: // variables
WorldVector<double> dimension; WorldVector<double> dimension;
FileVectorWriter *fileWriter; FileVectorWriter *fileWriter;
std::vector<DOFVector<double>*> oldSolution;
}; };
#endif // NAVIER_STOKES_TAYLOR_HOOD_H #endif // NAVIER_STOKES_TAYLOR_HOOD_H
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