This is an automated email from the git hooks/post-receive script. renard pushed a commit to branch master in repository getfem.
The following commit(s) were added to refs/heads/master by this push: new b91ee1de add of two scalar functions to GWFL : sqr_pos_part and sqr_neg_part b91ee1de is described below commit b91ee1def946a4295ea9ac2431c0ce35165c66c3 Author: Renard Yves <yves.ren...@insa-lyon.fr> AuthorDate: Wed Oct 11 12:51:12 2023 +0200 add of two scalar functions to GWFL : sqr_pos_part and sqr_neg_part --- doc/sphinx/source/userdoc/gasm_high.rst | 5 ++++- src/getfem_generic_assembly_functions_and_operators.cc | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/sphinx/source/userdoc/gasm_high.rst b/doc/sphinx/source/userdoc/gasm_high.rst index e556fa01..b4750e09 100644 --- a/doc/sphinx/source/userdoc/gasm_high.rst +++ b/doc/sphinx/source/userdoc/gasm_high.rst @@ -417,9 +417,12 @@ A certain number of predefined scalar functions can be used. The exhaustive list - ``Heaviside(t)`` (:math:`0 \mbox{ for } t < 0, 1 \mbox{ for } t \ge 0`) - ``sign(t)`` - ``abs(t)`` - - ``pos_part(t)`` (:math:`tH(t)`) - ``reg_pos_part(t, eps)`` (:math:`(t-eps/2-t^2/(2eps))H(t-eps) + t^2H(t)/(2eps)`) + - ``max(t, u)``, ``min(t, u)`` + - ``pos_part(t)`` (:math:`tH(t)`) + - ``sqr_pos_part(t)`` (:math:`(tH(t))^2`) - ``neg_part(t)`` (:math:`-tH(-t)`), ``max(t, u)``, ``min(t, u)`` + - ``sqr_neg_part(t)`` (:math:`(tH(-t))^2`) A scalar function can be applied to a scalar expression, but also to a tensor one. If is is applied to a tensor expression, is is applied componentwise and the result is a tensor with the same dimensions. For functions having two arguments (pow(t,u), min(t,u) ...) if two non-scalar arguments are passed, the dimension have to be the same. For instance "max([1;2],[0;3])" will return "[0;3]". diff --git a/src/getfem_generic_assembly_functions_and_operators.cc b/src/getfem_generic_assembly_functions_and_operators.cc index 1c889acf..0b877fed 100644 --- a/src/getfem_generic_assembly_functions_and_operators.cc +++ b/src/getfem_generic_assembly_functions_and_operators.cc @@ -77,6 +77,8 @@ namespace getfem { static scalar_type ga_Heaviside(scalar_type t) { return (t >= 0.) ? 1.: 0.; } static scalar_type ga_pos_part(scalar_type t) { return (t >= 0.) ? t : 0.; } + static scalar_type ga_sqr_pos_part(scalar_type t) + { return (t >= 0.) ? t*t : 0.; } static scalar_type ga_reg_pos_part(scalar_type t, scalar_type eps) { return (t >= eps) ? t-eps/2. : ((t <= 0) ? 0. : t*t/(2.*eps)); } static scalar_type ga_der_reg_pos_part(scalar_type t, scalar_type eps) @@ -88,6 +90,8 @@ namespace getfem { static scalar_type ga_half_sqr_pos_part(scalar_type t) { return (t >= 0.) ? 0.5*t*t : 0.; } static scalar_type ga_neg_part(scalar_type t) { return (t >= 0.) ? 0. : -t; } + static scalar_type ga_sqr_neg_part(scalar_type t) + { return (t >= 0.) ? 0. : t*t; } static scalar_type ga_half_sqr_neg_part(scalar_type t) { return (t >= 0.) ? 0. : 0.5*t*t; } static scalar_type ga_sinc(scalar_type t) {// cardinal sine function sin(t)/t @@ -507,10 +511,14 @@ namespace getfem { PREDEF_FUNCTIONS["abs"] = ga_predef_function(ga_abs, 1, "sign"); PREDEF_FUNCTIONS["pos_part"] = ga_predef_function(ga_pos_part, 1, "Heaviside"); + PREDEF_FUNCTIONS["sqr_pos_part"] + = ga_predef_function(ga_sqr_pos_part, 2, "2*pos_part(t)"); PREDEF_FUNCTIONS["half_sqr_pos_part"] = ga_predef_function(ga_half_sqr_pos_part, 1, "pos_part"); PREDEF_FUNCTIONS["neg_part"] = ga_predef_function(ga_neg_part, 1, "DER_PDFUNC_NEG_PART"); + PREDEF_FUNCTIONS["sqr_neg_part"] + = ga_predef_function(ga_sqr_neg_part, 2, "-2*neg_part(t)"); PREDEF_FUNCTIONS["half_sqr_neg_part"] = ga_predef_function(ga_half_sqr_neg_part, 2, "-neg_part(t)"); PREDEF_FUNCTIONS["reg_pos_part"]