This is an automated email from the git hooks/post-receive script. logari81 pushed a commit to branch master in repository getfem.
The following commit(s) were added to refs/heads/master by this push: new b3d9703d Enable scripting interface to get and set internal model variables b3d9703d is described below commit b3d9703d1432d06918e94e25b718b83392d2339c Author: Konstantinos Poulios <logar...@gmail.com> AuthorDate: Tue Oct 17 14:43:51 2023 +0200 Enable scripting interface to get and set internal model variables --- interface/src/gf_model_get.cc | 11 +++++++---- interface/src/gf_model_set.cc | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/interface/src/gf_model_get.cc b/interface/src/gf_model_get.cc index 7f955eeb..d92408de 100644 --- a/interface/src/gf_model_get.cc +++ b/interface/src/gf_model_get.cc @@ -344,17 +344,20 @@ void gf_model_get(getfemint::mexargs_in& m_in, ); - /*@GET V = ('from variables') + /*@GET V = ('from variables'[, @bool with_internal]) Return the vector of all the degrees of freedom of the model consisting of the concatenation of the variables of the model (useful to solve your problem with you own solver). @*/ sub_command - ("from variables", 0, 0, 0, 1, + ("from variables", 0, 1, 0, 1, if (!md->is_complex()) { - std::vector<double> V(md->nb_dof()); - md->from_variables(V); + bool with_internal = in.remaining() && in.pop().to_bool(); + std::vector<double> V(md->nb_dof(with_internal)); + md->from_variables(V, with_internal); out.pop().from_dcvector(V); } else { + GMM_ASSERT1(!in.remaining(), + "Not supported argument for complex model"); std::vector<std::complex<double> > V(md->nb_dof()); md->from_variables(V); out.pop().from_dcvector(V); diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc index 2c90b654..0f4034ea 100644 --- a/interface/src/gf_model_set.cc +++ b/interface/src/gf_model_set.cc @@ -409,21 +409,24 @@ void gf_model_set(getfemint::mexargs_in& m_in, ); - /*@SET ('to variables', @vec V) + /*@SET ('to variables', @vec V[, @bool with_internal]) Set the value of the variables of the model with the vector `V`. Typically, the vector `V` results of the solve of the tangent linear system (useful to solve your problem with you own solver).@*/ sub_command - ("to variables", 1, 1, 0, 0, + ("to variables", 1, 2, 0, 0, if (!md->is_complex()) { darray st = in.pop().to_darray(-1); std::vector<double> V; V.assign(st.begin(), st.end()); - md->to_variables(V); + bool with_internal = in.remaining() && in.pop().to_bool(); + md->to_variables(V, with_internal); } else { carray st = in.pop().to_carray(-1); std::vector<std::complex<double> > V; V.assign(st.begin(), st.end()); + GMM_ASSERT1(!in.remaining(), + "Not supported argument for complex model"); md->to_variables(V); } );