getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5183 - in /trunk/getfem: doc/sphinx/source/project/ in


From: Yves . Renard
Subject: [Getfem-commits] r5183 - in /trunk/getfem: doc/sphinx/source/project/ interface/src/ interface/src/scilab/sci_gateway/c/
Date: Sun, 13 Dec 2015 19:25:52 -0000

Author: renard
Date: Sun Dec 13 20:25:51 2015
New Revision: 5183

URL: http://svn.gna.org/viewcvs/getfem?rev=5183&view=rev
Log:
minor corrections

Modified:
    trunk/getfem/doc/sphinx/source/project/libdesc_interface.rst
    trunk/getfem/interface/src/getfemint_workspace.cc
    trunk/getfem/interface/src/getfemint_workspace.h
    trunk/getfem/interface/src/gf_mesh_fem_get.cc
    trunk/getfem/interface/src/gf_mesh_im_data_get.cc
    trunk/getfem/interface/src/gf_mesh_im_get.cc
    trunk/getfem/interface/src/gf_slice_get.cc
    trunk/getfem/interface/src/scilab/sci_gateway/c/builder_gateway_c.sce.in

Modified: trunk/getfem/doc/sphinx/source/project/libdesc_interface.rst
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/doc/sphinx/source/project/libdesc_interface.rst?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/doc/sphinx/source/project/libdesc_interface.rst        
(original)
+++ trunk/getfem/doc/sphinx/source/project/libdesc_interface.rst        Sun Dec 
13 20:25:51 2015
@@ -10,8 +10,7 @@
 Interface with scripts languages (Python, Scilab and Matlab)
 ------------------------------------------------------------
 
-A simplified interface of |gf| is provided, so that it is possible to use 
getfem
-in other languages.
+A simplified (but rather complete) interface of |gf| is provided, so that it 
is possible to use getfem in some script languages.
 
 Description
 ^^^^^^^^^^^
@@ -24,8 +23,8 @@
 This interface is not something that is generated automatically from c++ 
sources
 (as that could be the case with tools such as swig). It is something that has
 been designed as a simplified and consistent interface to getfem. Adding a new
-language should be quite easy (assuming the language provides some structures 
for
-dense arrays manipulations).
+language should be quite easy (assuming the language provides some structures
+for dense arrays manipulations).
 
 Files
 ^^^^^
@@ -55,27 +54,22 @@
   how to send and receive arrays, and object handles, from 
   ``getfem_interface_main()``. This file provide such functionnality.
 
-* :file:`getfemint_object.h`.
-
-  Not all getfem objects are exported, only a selected subset, mostly |m|, 
|mim|, 
-  |mf|, |sl|, |br|, etc. They are all wrapped in a common interface, which is 
-  ``getfemint::getfem_object``.
-
-* :file:`getfemint_mesh.h`, :file:`getfemint_mesh_fem.h`, etc.
-
-  All the wrapped |gf| objects. Some of them are quite complicated 
+* :file:`getfemint_gsparse.h`, :file:`getfemint_precond.h`, etc.
+
+  Files specific to an interfaced object if needed. 
   (getfemint_gsparse which export some kind of mutable sparse matrix that can 
   switch between different storage types, and real of complex elements).
 
 * :file:`gf_workspace.cc`, :file:`gf_delete.cc`.
 
-  Memory management for getfem objects. There is a layer in 
-  ``getfemint::getfem_object`` which handles the dependency between for 
example a 
-  ``getfemint_mesh`` and a ``getfemint_mesh_fem``. It makes sure that no 
object 
-  will be destroyed while there is still another getfem_object using it. The 
goal 
+  Memory management for getfem objects. There is a layer which handles the
+  dependency between for example a ``mesh`` and a ``mesh_fem``.
+  It makes sure that no object 
+  will be destroyed while there is still another getfem_object using it.
+  The goal 
   is to make sure that under no circumstances the user is able to crash getfem 
-  (and the host program, matlab, scilab or python) by passing incorrect 
argument to the 
-  getfem interface.
+  (and the host program, matlab, scilab or python) by passing incorrect
+  argument to the getfem interface.
 
   It also provides a kind of workspace stack, which was designed to simplify 
   handling and cleaning of many getfem objects in matlab (since matlab does 
not 
@@ -84,8 +78,9 @@
 * :file:`getfemint.h`, :file:`getfemint.cc`.
 
   Define the ``mexarg_in``, ``mexarg_out`` classes, which are used to parse 
the 
-  list of input and output arguments to the getfem interface functions. The 
name 
-  is not adequate anymore since any reference to "mex" has been moved into 
+  list of input and output arguments to the getfem interface functions.
+  The name  is not adequate anymore since any reference to "mex"
+  has been moved into 
   :file:`gfm_mex.c`.
 
 * :file:`gf_mesh.cc`, :file:`gf_mesh_get.cc`, :file:`gf_mesh_set.cc`,
@@ -297,8 +292,18 @@
 
 In order to add a new object to the interface, you have to build the new 
corresponding sources :file:`gf_obj.cc`, :file:`gf_obj_get.cc` and 
:file:`gf_obj_set.cc`. Of course you can take the existing ones as a model.
 
-A structure name `getfemint_object_name` has to be defined (see 
getfemint_mesh.h for instance).
-Moreover, for the management of the object, you have to declare the class in 
:file:`getfemint.cc` and :file:`getfemint.h` and add the methods `is_object()`, 
`to_const_object()`, `to_object()` and `to_getfemint_object()`. 
+For the management of the object, you have to declare the class at the 
begining of :file:`getfemint.h` (respecting the alphabetic order), and declare 
three functions::
+
+  bool is_"name"_object(const mexarg_in &p);
+  id_type store_"name"_object(const std::shared_ptr<object_class> &shp);
+  object_class *to_"name"_object(const mexarg_in &p);
+
+where "name" is the name of the object in the interface and ``object_class`` 
is the class name in getfem (for instance  ``getfem::mesh`` for the mesh 
object). Alternatively, for the object that are manipulated by a shared pointer 
in |gf|, the third function can return a shared pointer. 
+
+IMPORTANT : I order to be interfaced, a |gf| object has to derive from 
``dal::static_stored_object``. However, if it is not the case, a wrapper class 
can be defined such as the one for ``bgeot::base_poly`` (see the end of 
:file:`getfemint.h`).
+
+The previous three functions have to be implemented at the end of 
:file:`getfemint.cc`.It is possible to use one of the two macros defined in 
:file:`getfemint.cc`. The firs macro is for a standard object and the second 
one for an object which is manipulated in |gf| with a shared pointer.
+
 
 You have also to add the call of the interface function in 
:file:`getfem_interface.cc` and modifiy the file :file:`bin/extract_doc` and 
run the configure file.
 

Modified: trunk/getfem/interface/src/getfemint_workspace.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/getfemint_workspace.cc?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/getfemint_workspace.cc   (original)
+++ trunk/getfem/interface/src/getfemint_workspace.cc   Sun Dec 13 20:25:51 2015
@@ -78,6 +78,15 @@
     for (auto it = u.begin(); it != u.end(); ++it)
       if (it->get() == p.get()) return;
     u.push_back(p);
+  }
+
+  dal::pstatic_stored_object workspace_stack::hidden_object(id_type user,
+                                                           const void *p) {
+    if (!(valid_objects.is_in(user))) THROW_ERROR("Invalid object\n");
+    auto &u = obj[user].dependent_on;
+    for (auto it = u.begin(); it != u.end(); ++it)
+      if (it->get() == p) return *it;
+    return dal::pstatic_stored_object();
   }
 
   void workspace_stack::set_dependence(id_type user, id_type used) {

Modified: trunk/getfem/interface/src/getfemint_workspace.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/getfemint_workspace.h?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/getfemint_workspace.h    (original)
+++ trunk/getfem/interface/src/getfemint_workspace.h    Sun Dec 13 20:25:51 2015
@@ -99,6 +99,8 @@
     { sup_dependence( object(user), object(used)); }
     void add_hidden_object(id_type user, const dal::pstatic_stored_object &p);
 
+    dal::pstatic_stored_object hidden_object(id_type user, const void *p);
+
     /** At least mark the objet for future deletion (object becomes anonymous)
        and if possible, destroy the object (and all the objects which use
        this one if they are all anonymous).

Modified: trunk/getfem/interface/src/gf_mesh_fem_get.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_mesh_fem_get.cc?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_mesh_fem_get.cc       (original)
+++ trunk/getfem/interface/src/gf_mesh_fem_get.cc       Sun Dec 13 20:25:51 2015
@@ -673,7 +673,15 @@
     sub_command
       ("linked mesh", 0, 0, 0, 1,
        id_type id =  workspace().object((const void *)(&mf->linked_mesh()));
-       if (id == id_type(-1)) THROW_INTERNAL_ERROR;
+       if (id == id_type(-1)) {
+        auto pst = workspace().hidden_object(workspace().object(mf),
+                                             &mf->linked_mesh());
+        if (!pst.get()) THROW_INTERNAL_ERROR;
+        std::shared_ptr<getfem::mesh> pm = 
+          std::const_pointer_cast<getfem::mesh>
+          (std::dynamic_pointer_cast<const getfem::mesh>(pst));
+        id = store_mesh_object(pm);
+       }
        out.pop().from_object_id(id, MESH_CLASS_ID);
        );
 

Modified: trunk/getfem/interface/src/gf_mesh_im_data_get.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_mesh_im_data_get.cc?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_mesh_im_data_get.cc   (original)
+++ trunk/getfem/interface/src/gf_mesh_im_data_get.cc   Sun Dec 13 20:25:51 2015
@@ -132,7 +132,16 @@
     sub_command
       ("linked mesh", 0, 0, 0, 1,
        id_type id = workspace().object(&mimd->linked_mesh_im().linked_mesh());
-       if (id == id_type(-1)) THROW_INTERNAL_ERROR;
+       if (id == id_type(-1)) {
+        auto pst = workspace().hidden_object
+          (workspace().object(&mimd->linked_mesh_im()),
+           &mimd->linked_mesh_im().linked_mesh());
+        if (!pst.get()) THROW_INTERNAL_ERROR;
+        std::shared_ptr<getfem::mesh> pm = 
+          std::const_pointer_cast<getfem::mesh>
+          (std::dynamic_pointer_cast<const getfem::mesh>(pst));
+        id = store_mesh_object(pm);
+       }
        out.pop().from_object_id(id, MESH_CLASS_ID);
        );
 

Modified: trunk/getfem/interface/src/gf_mesh_im_get.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_mesh_im_get.cc?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_mesh_im_get.cc        (original)
+++ trunk/getfem/interface/src/gf_mesh_im_get.cc        Sun Dec 13 20:25:51 2015
@@ -272,7 +272,15 @@
     sub_command
       ("linked mesh", 0, 0, 0, 1,
        id_type id = workspace().object((const void *)(&mim->linked_mesh()));
-       if (id == id_type(-1)) THROW_INTERNAL_ERROR;
+       if (id == id_type(-1)) {
+        auto pst = workspace().hidden_object(workspace().object(mim),
+                                             &mim->linked_mesh());
+        if (!pst.get()) THROW_INTERNAL_ERROR;
+        std::shared_ptr<getfem::mesh> pm = 
+          std::const_pointer_cast<getfem::mesh>
+          (std::dynamic_pointer_cast<const getfem::mesh>(pst));
+        id = store_mesh_object(pm);
+       }
        out.pop().from_object_id(id, MESH_CLASS_ID);
        );
 

Modified: trunk/getfem/interface/src/gf_slice_get.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_slice_get.cc?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_slice_get.cc  (original)
+++ trunk/getfem/interface/src/gf_slice_get.cc  Sun Dec 13 20:25:51 2015
@@ -335,7 +335,15 @@
     sub_command
       ("linked mesh", 0, 0, 0, 1,
        id_type id = workspace().object((const void *)(&(sl->linked_mesh())));
-       if (id == id_type(-1)) THROW_INTERNAL_ERROR;
+       if (id == id_type(-1)) {
+        auto pst = workspace().hidden_object(workspace().object(sl),
+                                             &sl->linked_mesh());
+        if (!pst.get()) THROW_INTERNAL_ERROR;
+        std::shared_ptr<getfem::mesh> pm = 
+          std::const_pointer_cast<getfem::mesh>
+          (std::dynamic_pointer_cast<const getfem::mesh>(pst));
+        id = store_mesh_object(pm);
+       }
        out.pop().from_object_id(id, MESH_CLASS_ID);
        );
 

Modified: 
trunk/getfem/interface/src/scilab/sci_gateway/c/builder_gateway_c.sce.in
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/scilab/sci_gateway/c/builder_gateway_c.sce.in?rev=5183&r1=5182&r2=5183&view=diff
==============================================================================
--- trunk/getfem/interface/src/scilab/sci_gateway/c/builder_gateway_c.sce.in    
(original)
+++ trunk/getfem/interface/src/scilab/sci_gateway/c/builder_gateway_c.sce.in    
Sun Dec 13 20:25:51 2015
@@ -11,7 +11,6 @@
 
 Table = ['gf_workspace',               'sci_gf_scilab'; ...
          'gf_delete',                  'sci_gf_scilab'; ...
-         'gf_undelete',                'sci_gf_scilab'; ...
          'gf_eltm',                    'sci_gf_scilab'; ...
          'gf_geotrans',                'sci_gf_scilab'; ...
          'gf_geotrans_get',            'sci_gf_scilab'; ...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]