Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
refentity.hpp
Go to the documentation of this file.
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: 2005-08-10
7 
8  Copyright (C) 2005,2006 EPFL
9  Copyright (C) 2007,2008 Université Joseph Fourier Grenoble 1
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef __RefEntity_H
31 #define __RefEntity_H 1
32 
33 #include <stdexcept>
34 #include <boost/numeric/ublas/matrix.hpp>
35 #include <boost/numeric/ublas/io.hpp>
36 
37 #include <feel/feelcore/traits.hpp>
38 #include <feel/feelalg/glas.hpp>
39 #include <feel/feelalg/lu.hpp>
42 
43 namespace Feel
44 {
45 template<size_type ShapeE, typename T = double>
46 class Entity
47 {
48 };
49 
57 template<typename Geo, uint16_type Dim = 1, uint16_type Order = 1, uint16_type RDim = Dim, typename T = double>
58 class Reference
59 {};
60 
61 template<typename Geo, uint16_type Dim, uint16_type Order, uint16_type RDim, typename T>
62 std::ostream&
63 operator<<( std::ostream& os,
65 {
66  typedef Reference<Geo, Dim, Order, RDim, T> ref_type;
67  os << " Dimension: " << ref_type::nDim << "\n"
68  << " Order: " << ref_type::nOrder << "\n"
69  << "Real dimension: " << ref_type::nRealDim << "\n";
70  os << " Vertices: " << ref.vertices() << "\n";
71  os << " Normals: " << ref.normals() << "\n";
72  return os;
73 }
74 template<typename RefEntity>
75 void toPython( RefEntity const& e, std::string str = "simplex" )
76 {
77  typedef typename RefEntity::value_type value_type;
78  typedef typename RefEntity::node_type node_type;
79  std::ostringstream ostr;
80  ostr << str
81  << "_" << RefEntity::nDim
82  << "_" << RefEntity::nOrder
83  << "_" << RefEntity::nRealDim
84  << ".py";
85  std::ofstream ofs( ostr.str().c_str() );
86 
87  ofs << "from pyx import *\n";
88  ofs << "p=path.path(";
89 
90  for ( int i = 0; i < RefEntity::numEdges; ++i )
91  {
92  for ( int j = 0; j < 2; ++j )
93  {
94  node_type x( 2 );
95 
96  if ( RefEntity::nRealDim == 1 )
97  {
98  x( 0 ) = e.edgeVertex( i,j )( 0 );
99  x( 1 ) = value_type( 0 );
100  }
101 
102  if ( RefEntity::nRealDim == 2 )
103  {
104  x = e.edgeVertex( i, j );
105  }
106 
107  if ( RefEntity::nRealDim == 3 )
108  {
109  x( 0 ) = e.edgeVertex( i, j )( 0 )+e.edgeVertex( i, j )( 1 )*std::cos( M_PI/4 );
110  x( 1 ) = e.edgeVertex( i, j )( 2 )+e.edgeVertex( i, j )( 1 )*std::sin( M_PI/4 );
111  }
112 
113  if ( j == 0 )
114  ofs << "path.moveto(" << double( x( 0 ) )<< "," << double( x( 1 ) ) << "),\n";
115 
116  else if ( j == 1 )
117  ofs << "path.lineto(" << double( x( 0 ) )<< "," << double( x( 1 ) ) << "),\n";
118  }
119  }
120 
121  ofs << "path.closepath() )\n";
122  ofs << "c = canvas.canvas()\n"
123  << "c.stroke(p, [style.linewidth.Thin])\n";
124 
125  for ( int i = 0; i < RefEntity::numPoints; ++i )
126  {
127  node_type x( 2 );
128 
129  if ( RefEntity::nRealDim == 1 )
130  {
131  x( 0 ) = e.point( i )( 0 );
132  x( 1 ) = value_type( 0 );
133  }
134 
135  if ( RefEntity::nRealDim == 2 )
136  {
137  x = e.point( i );
138  }
139 
140  if ( RefEntity::nRealDim == 3 )
141  {
142  x( 0 ) = e.point( i )( 0 )+e.point( i )( 1 )*std::cos( M_PI/4 );
143  x( 1 ) = e.point( i )( 2 )+e.point( i )( 1 )*std::sin( M_PI/4 );
144  }
145 
146  ofs << "c.fill ( path.circle(" << double( x( 0 ) ) << "," << double( x( 1 ) )<< ", 0.05 ),[deco.filled([color.grey.black])])\n";
147  ofs << "c.text(" << double( x( 0 ) ) << "," << double( x( 1 ) ) << ", \"" << i << "\")\n";
148  }
149 
150  ofs << "c.writePDFfile(\"" << str << "_" << RefEntity::nDim
151  << "_" << RefEntity::nOrder
152  << "_" << RefEntity::nRealDim
153  << "\", paperformat=\"a4\")\n";
154 }
155 
156 } // Feel
157 
160 #endif /* __RefEntity_H */
Reference convex.
Definition: refentity.hpp:58

Generated on Sun Dec 22 2013 13:11:12 for Feel++ by doxygen 1.8.5