Skip to content
Snippets Groups Projects
Commit 905dafa9 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Solve velocity problem w/ corresponding Dirichlet

parent 189de4d7
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ class neumannCondition: ...@@ -13,7 +13,7 @@ class neumannCondition:
class dirichletCondition: class dirichletCondition:
def __call__(self, x): def __call__(self, x):
return x * .005 return .005
Functions = { Functions = {
'neumannCondition' : neumannCondition(), 'neumannCondition' : neumannCondition(),
......
...@@ -56,23 +56,20 @@ class ImplicitEuler ...@@ -56,23 +56,20 @@ class ImplicitEuler
problem_A = this->A; problem_A = this->A;
problem_A *= this->tau; problem_A *= this->tau;
// Treat as Delta u_n for now // Use the old velocity as an initial iterate if possible
problem_iterate = this->u_old; if (u_old_old_ptr) {
if (u_old_old_ptr) problem_iterate = this->u_old;
problem_iterate -= *u_old_old_ptr; problem_iterate -= *u_old_old_ptr;
problem_iterate /= this->tau;
} else
problem_iterate = 0.0;
for (size_t i = 0; i < this->dirichletNodes.size(); ++i) for (size_t i = 0; i < this->dirichletNodes.size(); ++i)
if (this->dirichletNodes[i].count() == dim) { if (this->dirichletNodes[i].count() == dim) {
double val; problem_iterate[i] = 0;
this->dirichletFunction.evaluate(this->time, val); this->dirichletFunction.evaluate(this->time, problem_iterate[i][0]);
problem_iterate[i] = 0; // Everything prescribed
problem_iterate[i][0] =
val - this->u_old[i][0]; // Time-dependent X direction
} else if (this->dirichletNodes[i][1]) } else if (this->dirichletNodes[i][1])
problem_iterate[i][1] = 0; // Y direction described problem_iterate[i][1] = 0; // Y direction prescribed
// Make it a velocity
problem_iterate /= this->tau;
} }
void virtual extractSolution(VectorType const &problem_iterate, void virtual extractSolution(VectorType const &problem_iterate,
...@@ -112,25 +109,17 @@ class ImplicitTwoStep ...@@ -112,25 +109,17 @@ class ImplicitTwoStep
problem_A = this->A; problem_A = this->A;
problem_A *= 2.0 / 3.0 * this->tau; problem_A *= 2.0 / 3.0 * this->tau;
// The finite difference makes a good start (treat it as such for now) // Use the old velocity as an initial iterate
problem_iterate = this->u_old; problem_iterate = this->u_old;
problem_iterate -= *u_old_old_ptr; problem_iterate -= *u_old_old_ptr;
problem_iterate /= this->tau;
for (size_t i = 0; i < this->dirichletNodes.size(); ++i) for (size_t i = 0; i < this->dirichletNodes.size(); ++i)
if (this->dirichletNodes[i].count() == dim) { if (this->dirichletNodes[i].count() == dim) {
double val;
this->dirichletFunction.evaluate(this->time, val);
problem_iterate[i] = 0; problem_iterate[i] = 0;
problem_iterate[i].axpy(-2, this->u_old[i]); this->dirichletFunction.evaluate(this->time, problem_iterate[i][0]);
problem_iterate[i].axpy(.5, (*u_old_old_ptr)[i]);
problem_iterate[i][0] =
1.5 * val - 2 * this->u_old[i][0] + .5 * (*u_old_old_ptr)[i][0];
} else if (this->dirichletNodes[i][1]) } else if (this->dirichletNodes[i][1])
// Y direction described problem_iterate[i][1] = 0; // Y direction prescribed
problem_iterate[i][1] =
-2 * this->u_old[i][1] + .5 * (*u_old_old_ptr)[i][1];
// Now treat it as a velocity
problem_iterate /= this->tau;
} }
void virtual extractSolution(VectorType const &problem_iterate, void virtual extractSolution(VectorType const &problem_iterate,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment