octave-maintainers
[Top][All Lists]
Advanced

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

FEM pkg and classes


From: Marco Vassallo
Subject: FEM pkg and classes
Date: Fri, 28 Jun 2013 16:41:13 +0200

Hi all,
after the discussion we had at OctConf I'm trying to gain some insight about how classes works inside Octave. I'm using as a reference the examples provided with the presentation "what is octave" [1].
The class/classes that we want to create should allow us to write an m.file like:

    # Create mesh and define the problem 
    init_dolfin ();
 
    x = y = linspace (0, 1, 32) ;
    msho = msh2m_structured_mesh (x, y, 1, [ 1 1 2 2 ])
   
    #the functions that we call above have to be
    #implemented, they don't exist in Octave (at the moment)

    mshd = dolfin_mesh ();
 
    ffc ("Laplace.ufl");
    V  = FunctionSpace (mshd);
    sd = SubDomain (mesh, @(x, y) abs (x - 1.0) < eps);
    bc = DirichletBC (V, @(x, y) 0.0, sd);
 
    A  = BilinearForm (V, V, bc);
    L  = LinearForm (V, bc);
 
    u = A\L;
 
    uf = Function (V, u);
    dolfin_plot (uf, "Solution")
   

What it is not clear to me, among other things, is if it is better to create a class for every different type or if it is better to create a unique class with all the variables that we need.
1)
-------------------------------------------------------------------
class dolfin_mesh : public octave_base_value
{

 public:
  // Constructor
  dolfin_mesh( octave_scalar_map msho);

  //destructor
  ~dolfin_mesh(void) {  };

 private:
  dolfin::Mesh msh;
};
--------------------------------------------------------------------
class FunctionSpace : public octave_base_value
{

 public:
  // Constructor
  FunctionSpace (dolfin_mesh& mshd);

  //destructor
  ~FunctionSpace(void) {  };

 private:
  dolfin::FunctionSpace V;
};

and we obviously add the DLD function that we need
----------------------------------------------------------------------

2) All things together
---------------------------------------------------------------------
class fem : public octave_base_value
{

 public:
  // Constructor
  fem ();

  //destructor
  ~fem(void) {  };
  //method
  void set_msh   (dolfin::Mesh & _msh);
  void set_function_space   (dolfin::FunctionSpace & _V);
//
 private:
  dolfin::FunctionSpace V;
  dolfin::Mesh msh;
};

-------------------------------------------------------------------------

Thanks to all,

Marco

[1] http://inversethought.com/hg/what-is-octave/

reply via email to

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