Finite Element Embedded Library and Language in C++
All
Classes
Files
Functions
Variables
Typedefs
Pages
residualestimator_oct.hpp
1
/* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2
3
This file is part of the Feel library
4
5
Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6
Date: 2010-08-05
7
8
Copyright (C) 2010 Université Joseph Fourier (Grenoble I)
9
10
This library is free software; you can redistribute it and/or
11
modify it under the terms of the GNU Lesser General Public
12
License as published by the Free Software Foundation; either
13
version 2.1 of the License, or (at your option) any later version.
14
15
This library is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public
21
License along with this library; if not, write to the Free Software
22
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
*/
29
#include <octave/oct.h>
30
31
#include <residualestimator.hpp>
32
33
#define OCTNAME(name,dim, order) BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(name,dim),_),order)
34
35
#define RESIDUAL_ESTIMATOR( dim, order ) \
36
DEFUN_DLD (OCTNAME(residualestimator_,dim,order), args, nargout, "Residual Estimator for the Laplacian") \
37
{ \
38
int nargin = args.length (); \
39
if (nargin != 1) \
40
print_usage (); \
41
else \
42
{ \
43
NDArray A = args(0).array_value (); \
44
dim_vector dims = A.dims(); \
45
dim_vector ydims(1); \
46
ydims(0)=4; \
47
\
48
NDArray Y(ydims); \
49
{ \
50
static bool is_init = false; \
51
if ( !is_init ) \
52
{ \
53
if (!Feel::Environment::initialized() ) \
54
new Feel::Environment(); \
55
is_init = true; \
56
} \
57
boost::shared_ptr<ResidualEstimator<dim,order> > OCTNAME(app_,dim,order)( new ResidualEstimator<dim,order>( makeAbout() ) ); \
58
std::vector<double> x( dims(0) ); \
59
for( int j = 0; j < dims(0); ++j ) \
60
{ \
61
x[j] = A(j); \
62
} \
63
std::vector<double> y( 4 ); \
64
OCTNAME(app_,dim,order)->run( x.data(), dims(1), y.data(), 4 ); \
65
Y(0)=y[0]; \
66
Y(1)=y[1]; \
67
Y(2)=y[2]; \
68
Y(3)=y[3]; \
69
} \
70
if (! error_state) \
71
return octave_value (Y); \
72
} \
73
return octave_value_list (); \
74
}
75
76