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
reinit_fms.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): Christoph Winkelmann <christoph.winkelmann@epfl.ch>
6  Date: 2006-10-18
7 
8  Copyright (C) 2005,2006 EPFL
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 3.0 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 #ifndef __Reinit_Fms_H
30 #define __Reinit_Fms_H 1
31 
32 #include <feel/feel.hpp>
33 
34 #include <feel/feelpde/fmsheap.hpp>
36 
37 
38 namespace Feel
39 {
40 
41 template<typename FunctionSpaceType, typename IteratorRange, typename periodicity_type = NoPeriodicity>
42 class ReinitializerFMS
43 {
44 public:
45 
46 
50 
51  enum status_type { DONE=0, CLOSE=1, FAR=2 };
52 
53  typedef FunctionSpaceType functionspace_type;
54  typedef boost::shared_ptr<functionspace_type> functionspace_ptrtype;
55  typedef typename functionspace_type::element_type element_type;
56  typedef boost::shared_ptr<element_type> element_ptrtype;
57  typedef typename functionspace_type::value_type value_type;
58 
59  typedef typename functionspace_type::mesh_type mesh_type;
60  typedef typename mesh_type::element_type geoelement_type;
61  static const uint16_type Dim = geoelement_type::nDim;
62 
63  typedef typename boost::tuples::template element<1, IteratorRange>::type iterator_type;
64  typedef IteratorRange range_iterator;
65 
66  ReinitializerFMS( functionspace_ptrtype const& __functionspace,
67  IteratorRange const& r ,
68  periodicity_type __periodicity=NoPeriodicity());
69 
70 
71  // ReinitializerFMS( ReinitializerFMS const& __vfi )
72  // :
73  // M_functionspace( __vfi.M_functionspace ),
74  // M_range( __vfi.M_range ),
75  // M_neighbors( __vfi.M_neighbors ),
76  // M_coords( __vfi.M_coords )
77  // {
78  // Debug( 5065 ) << "ReinitializerFMS copy constructor\n";
79  // }
80 
81  virtual ~ReinitializerFMS() {}
82 
84 
88 
89  element_type operator() ( element_type const& phi) const;
91 
92 private:
93 
94  typedef typename functionspace_type::fe_type fe_type;
95 
96  typedef typename functionspace_type::gm_type gm_type;
97  typedef typename gm_type::template Context<vm::POINT, geoelement_type>
98  gm_context_type;
99  typedef typename fe_type::template Context<vm::POINT, fe_type, gm_type, geoelement_type> fecontext_type;
100 
101  typedef boost::shared_ptr<gm_context_type> gm_context_ptrtype;
102 
103  typedef decltype( vf::P() ) expression_type;
104  typedef fusion::map<fusion::pair<vf::detail::gmc<0>, gm_context_ptrtype> > map_gmc_type;
105  typedef typename expression_type::template tensor<map_gmc_type,fecontext_type> t_expr_type;
106 
107  typedef Feel::details::FmsPoint<value_type, Dim> point_type;
108  typedef std::map<size_type, std::set<size_type> > neighbors_type;
109 
110  void updatePeriodicPoint(typename Feel::details::FmsHeap<value_type>::heap_entry_type const& newAccepted,
111  element_type& __v,
112  std::vector<status_type>& status,
113  Feel::details::FmsHeap<value_type>& theHeap) const;
114 
115  void fmsHeapUpdate( size_type idDone,
116  element_type const& __v,
117  std::vector<status_type>& status,
118  Feel::details::FmsHeap<value_type>& theHeap ) const;
119 
120  value_type fmsDistN( std::vector<size_type> const& ids,
121  element_type const& __v ) const;
122 
123  value_type fmsDistRec( std::vector<size_type> & ids,
124  size_type idClose,
125  element_type const& __v,
126  value_type phiOld,
127  std::vector<status_type> const& status ) const;
128 
129  value_type closerOne( value_type a, value_type b ) const
130  {
131  return a*a < b*b ? a : b;
132  }
133 
134  functionspace_ptrtype const& M_functionspace;
135  range_iterator M_range;
136  periodicity_type M_periodicity;
137  neighbors_type M_neighbors;
138  std::vector<point_type> M_coords;
139  vf::node_type M_translation;
140 };
141 
142 // needed for instantiation (copied from levelset.hpp)
143 typedef Mesh< Simplex<2> > mesh_typeLS;
144 typedef boost::shared_ptr<mesh_typeLS> mesh_ptrtypeLS;
145 typedef bases<Lagrange<1, Scalar> > basisP1LS_type;
146 typedef FunctionSpace<mesh_typeLS, basisP1LS_type, Periodicity <NoPeriodicity> > spaceP1LS_type;
147 mesh_ptrtypeLS ___mesh_LS;
148 typedef decltype( elements( ___mesh_LS ) ) itRangeLS;
149 
150 typedef ReinitializerFMS< spaceP1LS_type, itRangeLS, Periodic<> > fms_2d_type;
151 typedef ReinitializerFMS< spaceP1LS_type, itRangeLS, NoPeriodicity > fms_2d_periodic_type;
152 
153 #if !defined( FEELPP_INSTANTIATE_FMS )
154 extern template class ReinitializerFMS< spaceP1LS_type, itRangeLS, Periodic<> > ;
155 extern template class ReinitializerFMS< spaceP1LS_type, itRangeLS, NoPeriodicity > ;
156 #endif
157 
158 // 3d
159 typedef Mesh< Simplex<3> > mesh_3d_typeLS;
160 typedef boost::shared_ptr<mesh_3d_typeLS> mesh_3d_ptrtypeLS;
161 typedef FunctionSpace<mesh_3d_typeLS, basisP1LS_type, Periodicity <NoPeriodicity> > spaceP1LS_3d_type;
162 mesh_3d_ptrtypeLS ___mesh_3d_LS;
163 typedef decltype( elements( ___mesh_3d_LS ) ) itRange_3d_LS;
164 
165 typedef ReinitializerFMS< spaceP1LS_3d_type, itRange_3d_LS, NoPeriodicity > fms_3d_type;
166 typedef ReinitializerFMS< spaceP1LS_3d_type, itRange_3d_LS, Periodic<> > fms_3d_periodic_type;
167 
168 #if !defined( FEELPP_INSTANTIATE_FMS )
169 extern template class ReinitializerFMS< spaceP1LS_3d_type, itRange_3d_LS, NoPeriodicity > ;
170 extern template class ReinitializerFMS< spaceP1LS_3d_type, itRange_3d_LS, Periodic<> > ;
171 #endif
172 
173 template<typename FunctionSpaceType, typename IteratorRange, typename periodicity_type = NoPeriodicity>
174 boost::shared_ptr<ReinitializerFMS< FunctionSpaceType, IteratorRange, periodicity_type>>
175 fms( boost::shared_ptr<FunctionSpaceType> const& Xh,
176  IteratorRange r,
177  periodicity_type p = NoPeriodicity() )
178 {
179  boost::shared_ptr<ReinitializerFMS< FunctionSpaceType, IteratorRange, periodicity_type>> ret( new ReinitializerFMS< FunctionSpaceType, IteratorRange, periodicity_type>( Xh, r ) );
180  return ret;
181 }
182 
183 } // namespace Feel
184 
185 #endif /* __Reinit_Fms_H */

Generated on Sun Oct 20 2013 08:25:04 for Feel++ by doxygen 1.8.4