Mercurial > fem-fenics-eugenio
comparison src/plot_mesh.cc @ 253:5e9b5bbdc56b
Support both DOLFIN 1.3.0 and 1.4.0
* src/dolfin_compat.h: use a macro to set the correct shared_ptr (std or boost)
author | Eugenio Gianniti <eugenio.gianniti@mail.polimi.it> |
---|---|
date | Tue, 29 Jul 2014 18:05:56 +0200 |
parents | 66071811eef8 |
children |
comparison
equal
deleted
inserted
replaced
252:7f33554e439a | 253:5e9b5bbdc56b |
---|---|
17 | 17 |
18 #include "function.h" | 18 #include "function.h" |
19 #include "mesh.h" | 19 #include "mesh.h" |
20 #include "Plot_2d.h" | 20 #include "Plot_2d.h" |
21 #include "Plot_3d.h" | 21 #include "Plot_3d.h" |
22 #include "dolfin_compat.h" | |
22 | 23 |
23 DEFUN_DLD (plot, args, , "-*- texinfo -*-\n\ | 24 DEFUN_DLD (plot, args, , "-*- texinfo -*-\n\ |
24 @deftypefn {Function File} \ | 25 @deftypefn {Function File} \ |
25 plot (@var{Mesh}, @var{Nodal_Values}(OPTIONAL))\n\ | 26 plot (@var{Mesh}, @var{Nodal_Values}(OPTIONAL))\n\ |
26 Plot a Mesh. \n\ | 27 Plot a Mesh. \n\ |
50 | 51 |
51 if (nargin == 1) | 52 if (nargin == 1) |
52 { | 53 { |
53 if (!error_state) | 54 if (!error_state) |
54 { | 55 { |
55 const boost::shared_ptr<const dolfin::Mesh> | 56 const SHARED_PTR <const dolfin::Mesh> |
56 & mshd = msho.get_pmsh (); | 57 & mshd = msho.get_pmsh (); |
57 dolfin::plot (*mshd); | 58 dolfin::plot (*mshd); |
58 dolfin::interactive (); | 59 dolfin::interactive (); |
59 retval = 0; | 60 retval = 0; |
60 } | 61 } |
65 Array <double> myu = args(1).array_value (); | 66 Array <double> myu = args(1).array_value (); |
66 | 67 |
67 if (!error_state) | 68 if (!error_state) |
68 { | 69 { |
69 const dolfin::Mesh & mshd = msho.get_msh (); | 70 const dolfin::Mesh & mshd = msho.get_msh (); |
70 boost::shared_ptr <const dolfin::FunctionSpace> V; | 71 SHARED_PTR <const dolfin::FunctionSpace> V; |
71 uint D = mshd.topology ().dim (); | 72 uint D = mshd.topology ().dim (); |
72 if (D == 2) | 73 if (D == 2) |
73 { | 74 { |
74 boost::shared_ptr <const dolfin::FunctionSpace> | 75 SHARED_PTR <const dolfin::FunctionSpace> |
75 Vt (new Plot_2d::FunctionSpace (mshd)); | 76 Vt (new Plot_2d::FunctionSpace (mshd)); |
76 V = Vt; | 77 V = Vt; |
77 } | 78 } |
78 | 79 |
79 else if(D == 3) | 80 else if(D == 3) |
80 { | 81 { |
81 boost::shared_ptr <const dolfin::FunctionSpace> | 82 SHARED_PTR <const dolfin::FunctionSpace> |
82 Vt (new Plot_3d::FunctionSpace (mshd)); | 83 Vt (new Plot_3d::FunctionSpace (mshd)); |
83 V = Vt; | 84 V = Vt; |
84 } | 85 } |
85 | 86 |
86 else | 87 else |
90 if (V->dim () != myu.length ()) | 91 if (V->dim () != myu.length ()) |
91 error ("Plot: The size of the functional space\ | 92 error ("Plot: The size of the functional space\ |
92 and the size of the vector must agree"); | 93 and the size of the vector must agree"); |
93 else | 94 else |
94 { | 95 { |
96 #ifdef LATEST_DOLFIN | |
97 dolfin::Vector du (MPI_COMM_WORLD, myu.length ()); | |
98 #else | |
95 dolfin::Vector du(myu.length ()); | 99 dolfin::Vector du(myu.length ()); |
100 #endif | |
96 for (std::size_t i = 0; i < myu.length (); ++i) | 101 for (std::size_t i = 0; i < myu.length (); ++i) |
97 du.setitem (i, myu(i)); | 102 du.setitem (i, myu(i)); |
98 | 103 |
99 boost::shared_ptr<dolfin::Vector> | 104 SHARED_PTR <dolfin::Vector> |
100 uu (new dolfin::Vector(du)); | 105 uu (new dolfin::Vector(du)); |
101 | 106 |
102 boost::shared_ptr <const dolfin::Function> | 107 SHARED_PTR <const dolfin::Function> |
103 u (new dolfin::Function(V, uu)); | 108 u (new dolfin::Function(V, uu)); |
104 | 109 |
105 dolfin::plot (*u); | 110 dolfin::plot (*u); |
106 dolfin::interactive (); | 111 dolfin::interactive (); |
107 | 112 |