MAST
plot.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 // MAST includes
21 #include "utility/plot.h"
22 
23 #if MAST_ENABLE_GNUPLOT == 1
24 
25 void
26 MAST::plot_elem(Gnuplot& gp,
27  const libMesh::Elem& elem) {
28 
29  // currently only for 2D.
30  libmesh_assert_equal_to(elem.dim(), 2);
31 
32  unsigned int
33  n_nodes = elem.n_nodes();
34 
35  std::vector<std::tuple<Real, Real>>
36  xy(n_nodes+1);
37 
38  for (unsigned int i=0; i<=n_nodes; i++) {
39  std::get<0>(xy[i]) = (*elem.node_ptr(i%n_nodes))(0);
40  std::get<1>(xy[i]) = (*elem.node_ptr(i%n_nodes))(1);
41  }
42 
43  gp << "plot '-' with lines \n";
44  gp.send1d(xy);
45 }
46 
47 
48 void
49 MAST::plot_node(Gnuplot& gp, const libMesh::Node& node) {
50 
51  std::vector<std::tuple<Real, Real>>
52  xy(1);
53 
54  std::get<0>(xy[0]) = node(0);
55  std::get<1>(xy[0]) = node(1);
56 
57  gp << "plot '-' with points \n";
58  gp.send1d(xy);
59 }
60 
61 #endif