[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: |
Fri, 9 Apr 2021 05:19:02 -0400 (EDT) |
branch: devel-tetsuo-add_lumped_mass_python_interface_squash
commit a76e73d0c3033eac71e08e33427d18b1a1b18435
Author: Tetsuo Koyama <tkoyama010@gmail.com>
AuthorDate: Fri Apr 9 18:17:26 2021 +0900
Add lumped mass python interface
---
interface/src/gf_model_set.cc | 23 +++++++++++++++++++++++
interface/tests/python/demo_wave_equation.py | 11 +++++++++++
2 files changed, 34 insertions(+)
diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc
index 288572d..346c570 100644
--- a/interface/src/gf_model_set.cc
+++ b/interface/src/gf_model_set.cc
@@ -2816,6 +2816,29 @@ void gf_model_set(getfemint::mexargs_in& m_in,
);
+ /*@SET ind = ('add lumped mass brick for first order', @tmim mim, @str
varname[, @str dataexpr_rho[, @int region]])
+ Add lumped mass for first order term to the model relatively to the
variable `varname`.
+ If specified, the data `dataexpr_rho` is the
+ density (1 if omitted). `region` is an optional mesh region on
+ which the term is added. If it is not specified, it
+ is added on the whole mesh. Return the brick index in the model.@*/
+ sub_command
+ ("add lumped mass brick for first order", 2, 4, 0, 1,
+ getfem::mesh_im *mim = to_meshim_object(in.pop());
+ std::string varname = in.pop().to_string();
+ std::string dataname_rho;
+ if (in.remaining()) dataname_rho = in.pop().to_string();
+ size_type region = size_type(-1);
+ if (in.remaining()) region = in.pop().to_integer();
+ size_type ind
+ = getfem::add_lumped_mass_brick_for_first_order
+ (*md, *mim, varname, dataname_rho, region)
+ + config::base_index();
+ workspace().set_dependence(md, mim);
+ out.pop().from_integer(int(ind));
+ );
+
+
/*@SET ('shift variables for time integration')
Function used to shift the variables of a model to the data
corresponding of ther value on the previous time step for time
diff --git a/interface/tests/python/demo_wave_equation.py
b/interface/tests/python/demo_wave_equation.py
index 5a5e437..8d35ffc 100644
--- a/interface/tests/python/demo_wave_equation.py
+++ b/interface/tests/python/demo_wave_equation.py
@@ -57,10 +57,13 @@ V0 = 0.*U0
md=gf.Model('real');
md.add_fem_variable('u', mf);
md.add_fem_variable('u1', mf);
+md.add_fem_variable('u2', mf);
md.add_Laplacian_brick(mim, 'u');
md.add_Laplacian_brick(mim, 'u1');
+md.add_Laplacian_brick(mim, 'u2');
md.add_Dirichlet_condition_with_multipliers(mim, 'u', mf, 1);
md.add_Dirichlet_condition_with_multipliers(mim, 'u1', mf, 1);
+md.add_Dirichlet_condition_with_multipliers(mim, 'u2', mf, 1);
# md.add_Dirichlet_condition_with_penalization(mim, 'u', 1E9, 1);
# md.add_Dirichlet_condition_with_simplification('u', 1);
@@ -74,8 +77,10 @@ gamma = 0.5;
md.add_Newmark_scheme('u', beta, gamma)
md.add_Houbolt_scheme('u1')
+md.add_Newmark_scheme('u2', beta, gamma)
md.add_mass_brick(mim, 'Dot2_u')
md.add_mass_brick(mim, 'Dot2_u1')
+md.add_lumped_mass_brick_for_first_order(mim, 'Dot2_u2')
md.set_time_step(dt)
## Initial data.
@@ -84,6 +89,8 @@ md.set_variable('Previous_Dot_u', V0)
md.set_variable('Previous_u1', U0)
md.set_variable('Previous2_u1', U0)
md.set_variable('Previous3_u1', U0)
+md.set_variable('Previous_u2', U0)
+md.set_variable('Previous_Dot_u2', V0)
## Initialisation of the acceleration 'Previous_Dot2_u'
md.perform_init_time_derivative(dt/2.)
@@ -116,6 +123,10 @@ for t in np.arange(0.,T,dt):
V = md.variable('Dot_u1')
A = md.variable('Dot2_u1')
+ U = md.variable('u2')
+ V = md.variable('Dot_u2')
+ A = md.variable('Dot2_u2')
+
n += 1
md.shift_variables_for_time_integration()