Re: [Getfem-commits] please merge branch devel-tetsuo-add_lumped_mass_python_interface_squash

2021-04-09 Thread Tetsuo Koyama
Dear Kostas and Yves

@Kostas Thank you for your comment. It is a good point.
I am a fan of adding brick at the end of the methods.

add_isotropic_linearized_elasticity_pstrain_brick
add_isotropic_linearized_elasticity_pstrain_brick
add_lumped_mass_for_first_order_brick

If you don't mind I will fix the name of these methods in this branch.

Best regards Tetsuo

2021年4月10日(土) 4:24 Konstantinos Poulios :

> Dear Tetsuo and Yves
>
> @Tetsuo thanks for this interface functions. I would like to use this
> opportunity to discuss about the word "brick" in the naming of our
> functions adding PDE term matrices. Traditionally, "brick" was only used at
> the end of the function name. More recently, Yves started skipping "brick"
> from some of the newer terms, which I think is fine. Now we have a mix with
> names including "brick" and some without. Apart from that, there are 3
> functions that do not follow the old naming convention at all:
>
> add_isotropic_linearized_elasticity_brick_pstrain
> add_isotropic_linearized_elasticity_brick_pstrain
> add_lumped_mass_brick_for_first_order
>
> I would like to avoid this kind of inconsistencies in the naming so that
> all functions for adding a PDE matrix either have "brick" at the end of
> their name or that they do not include it at all.
>
> For Tetsuo's function I would suggest one of
> add_lumped_mass_matrix_for_first_order
> add_lumped_mass_for_first_order_brick
>
> Both in c++ and the interfaces.
>
> What do you think?
>
> Best regards
> Kostas
>
> On Fri, Apr 9, 2021 at 11:23 AM Tetsuo Koyama 
> wrote:
>
>> Dear GetFEM project
>>
>> I added the lumped mass for first order to the python interface.
>> Could you merge devel-tetsuo-add_lumped_mass_python_interface_squash ?
>>
>> BR Tetsuo
>>
>


Re: [Getfem-commits] please merge branch devel-tetsuo-add_lumped_mass_python_interface_squash

2021-04-09 Thread Konstantinos Poulios via Getfem-commits
Dear Tetsuo and Yves

@Tetsuo thanks for this interface functions. I would like to use this
opportunity to discuss about the word "brick" in the naming of our
functions adding PDE term matrices. Traditionally, "brick" was only used at
the end of the function name. More recently, Yves started skipping "brick"
from some of the newer terms, which I think is fine. Now we have a mix with
names including "brick" and some without. Apart from that, there are 3
functions that do not follow the old naming convention at all:

add_isotropic_linearized_elasticity_brick_pstrain
add_isotropic_linearized_elasticity_brick_pstrain
add_lumped_mass_brick_for_first_order

I would like to avoid this kind of inconsistencies in the naming so that
all functions for adding a PDE matrix either have "brick" at the end of
their name or that they do not include it at all.

For Tetsuo's function I would suggest one of
add_lumped_mass_matrix_for_first_order
add_lumped_mass_for_first_order_brick

Both in c++ and the interfaces.

What do you think?

Best regards
Kostas

On Fri, Apr 9, 2021 at 11:23 AM Tetsuo Koyama  wrote:

> Dear GetFEM project
>
> I added the lumped mass for first order to the python interface.
> Could you merge devel-tetsuo-add_lumped_mass_python_interface_squash ?
>
> BR Tetsuo
>


[Getfem-commits] please merge branch devel-tetsuo-add_lumped_mass_python_interface_squash

2021-04-09 Thread Tetsuo Koyama
Dear GetFEM project

I added the lumped mass for first order to the python interface.
Could you merge devel-tetsuo-add_lumped_mass_python_interface_squash ?

BR Tetsuo


[Getfem-commits] [getfem-commits] branch devel-tetsuo-add_lumped_mass_python_interface_squash created (now a76e73d)

2021-04-09 Thread Tetsuo Koyama
tkoyama010 pushed a change to branch 
devel-tetsuo-add_lumped_mass_python_interface_squash.

  at a76e73d  Add lumped mass python interface

This branch includes the following new commits:

 new a76e73d  Add lumped mass python interface




[Getfem-commits] (no subject)

2021-04-09 Thread Tetsuo Koyama
branch: devel-tetsuo-add_lumped_mass_python_interface_squash
commit a76e73d0c3033eac71e08e33427d18b1a1b18435
Author: Tetsuo Koyama 
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()