[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Tetsuo Koyama |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Sat, 25 May 2019 04:32:48 -0400 (EDT) |
branch: devel-tetsuo-houbolt
commit eacdc60869472c2d88cfeeb50f9311ab8ed92b0d
Author: Tetsuo Koyama <address@hidden>
Date: Sat May 25 15:39:31 2019 +0900
Add Houbolt method tests
---
tests/heat_equation.cc | 29 +++++++++++++++++++++++++----
tests/heat_equation.param | 3 +++
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/tests/heat_equation.cc b/tests/heat_equation.cc
index 4943475..c2c78be 100644
--- a/tests/heat_equation.cc
+++ b/tests/heat_equation.cc
@@ -103,6 +103,7 @@ struct heat_equation_problem {
plain_vector U, V;
scalar_type dt, T, theta;
+ size_type scheme;
std::string datafilename;
bgeot::md_param PARAM;
@@ -150,6 +151,7 @@ void heat_equation_problem::init(void) {
scalar_type FT = PARAM.real_value("FT", "parameter for exact solution");
dt = PARAM.real_value("DT", "Time step");
T = PARAM.real_value("T", "final time");
+ scheme = PARAM.int_value("SCHEME", "Time integration scheme");
theta = PARAM.real_value("THETA", "Theta method parameter");
sol_c = PARAM.real_value("C", "Diffusion coefficient");
residual = PARAM.real_value("RESIDUAL");
@@ -243,7 +245,16 @@ bool heat_equation_problem::solve(void) {
DIRICHLET_BOUNDARY_NUM, "DirichletData");
// transient part.
- getfem::add_theta_method_for_first_order(model, "u", theta);
+ switch (scheme) {
+ case 1 : // Theta-method
+ getfem::add_theta_method_for_first_order(model, "u", theta);
+ break;
+ case 2 : // Houbolt-method
+ getfem::add_Houbolt_scheme(model, "u");
+ break;
+ default : GMM_ASSERT1(false, "Unvalid time integration scheme");
+ }
+
getfem::add_mass_brick(model, mim, "Dot_u");
gmm::iteration iter(residual, 0, 40000);
@@ -261,9 +272,19 @@ bool heat_equation_problem::solve(void) {
getfem::interpolation_function(mf_u, V, sol_dot);
}
- gmm::copy(U, model.set_real_variable("Previous_u"));
- if (!with_automatic_init)
- gmm::copy(V, model.set_real_variable("Previous_Dot_u"));
+ switch (scheme) {
+ case 1 : // Theta-method
+ gmm::copy(U, model.set_real_variable("Previous_u"));
+ if (!with_automatic_init)
+ gmm::copy(V, model.set_real_variable("Previous_Dot_u"));
+ break;
+ case 2 : // Houbolt-method
+ gmm::copy(U, model.set_real_variable("Previous_u"));
+ gmm::copy(U, model.set_real_variable("Previous2_u"));
+ gmm::copy(U, model.set_real_variable("Previous3_u"));
+ break;
+ default : GMM_ASSERT1(false, "Unvalid time integration scheme");
+ }
if (with_automatic_init) {
diff --git a/tests/heat_equation.param b/tests/heat_equation.param
index 3cafdd9..5dbc90c 100644
--- a/tests/heat_equation.param
+++ b/tests/heat_equation.param
@@ -36,6 +36,9 @@ T = 1/(C*FT*FT*N*2); % Final time
DT = T/50; % Time step
THETA = 0.5; % Theta method parameter
+SCHEME = 2; % Time integration scheme
+ % 1 = Theta-method
+ % 2 = Houbolt
if (N == 1)
MESH_TYPE = 'GT_PK(1,1)'; % segments