[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Using structures in OCT files

**From**: |
c. |

**Subject**: |
Re: Using structures in OCT files |

**Date**: |
Fri, 15 Apr 2011 10:49:08 +0200 |

On 14 Apr 2011, at 18:59, Andreas Stahel wrote:
>* Dear Octave users*
>* *
>* currently I am attempting to update a FEM package an with Octave 3.4*
>* I have a hard time to implement a feature in an OCT file*
>* On the Octave level I will have a structure Mesh of the type*
>* *
>* Mesh.nodes = [0.0 0.5; 0.2,0.2;0.1,2.0]*
>* Mesh. edge = [1 2; 2 3; 3 1]*
>* *
>* Then in an C++ file I need to access those structures*
>* in a command FEMEquation(Mesh, ...)*
>* *
>* With older version of Octave I used codes like below*
>* *
>* ===================*
>* DEFUN_DLD (FEMEquation, args, , "[...] = FEMEquation (...)\n ")*
>* {*
>* octave_value_list retval;*
>* using namespace std;*
>* octave_value_list argin;*
>* octave_value_list res;*
>* int nargout;*
>* *
>* Octave_map arg0 = args(0).map_value ();*
>* *
>* Octave_map::const_iterator p1 = arg0.seek ("nodes");*
>* const Matrix nodes = arg0.contents(p1)(0).matrix_value();*
>* p1 = arg0.seek ("edge");*
>* const ColumnVector edge = arg0.contents(p1)(0).column_vector_value();*
>* ......*
>* ====================*
>* *
>* Then I could use those matrices. Even with the help of section A.1.5 *
>* Structures in Oct-Files*
>* in the manual I could not figure out how to adapt to the new method.*
>* This failure is caused by my lack of knowledge of C++ and Octave programming.*
>* I would really appreciate some help or a good pointer to a similar example.*
>* *
Andreas,
You can have a look at the sourcecode of geopdes-base
<http://sourceforge.net/projects/geopdes/> <http://geopdes.sf.net>
which uses structures extensively.
In particular you might want to look at the function op_gradu_gradv.cc that
asssembles the discrete version of the Laplace operator.
Though the numerical method used in geopdes is more general than finite
elements, that function should be exactly the same as for FEM,
so this function should be easy for you to read.
HTH,
c.