BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
boundary_operator.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_boundary_operator_hpp
22 #define bempp_boundary_operator_hpp
23 
24 #include "../common/common.hpp"
25 #include "../common/shared_ptr.hpp"
26 #include "transposition_mode.hpp"
27 
28 #include <boost/mpl/set.hpp>
29 #include <boost/mpl/has_key.hpp>
30 #include <boost/utility/enable_if.hpp>
31 #include <boost/weak_ptr.hpp>
32 #include <string>
33 
34 namespace Bempp
35 {
36 
38 template <typename BasisFunctionType> class Space;
39 template <typename ResultType> class DiscreteBoundaryOperator;
40 template <typename BasisFunctionType, typename ResultType> class AbstractBoundaryOperator;
41 template <typename BasisFunctionType, typename ResultType> class Context;
42 template <typename BasisFunctionType, typename ResultType> class GridFunction;
62 template <typename BasisFunctionType, typename ResultType>
64 {
65 public:
68 
82  BoundaryOperator(const shared_ptr<const Context<
83  BasisFunctionType, ResultType> >& context,
84  const shared_ptr<const AbstractBoundaryOperator<
85  BasisFunctionType, ResultType> >& abstractOp);
86 
101  void initialize(const shared_ptr<const Context<
102  BasisFunctionType, ResultType> >& context,
103  const shared_ptr<const AbstractBoundaryOperator<
104  BasisFunctionType, ResultType> >& abstractOp);
105 
110  void uninitialize();
111 
114  bool isInitialized() const;
115 
118  shared_ptr<const AbstractBoundaryOperator<BasisFunctionType, ResultType> >
119  abstractOperator() const;
120 
122  shared_ptr<const Context<BasisFunctionType, ResultType> > context() const;
123 
129  shared_ptr<const DiscreteBoundaryOperator<ResultType> > weakForm() const;
130 
136  shared_ptr<const Space<BasisFunctionType> > domain() const;
137 
143  shared_ptr<const Space<BasisFunctionType> > range() const;
144 
150  shared_ptr<const Space<BasisFunctionType> > dualToRange() const;
151 
153  std::string label() const;
154 
170  bool isWeakFormHeld() const;
171 
176  void holdWeakForm(bool value);
177 
189  void apply(const TranspositionMode trans,
192  ResultType alpha, ResultType beta) const;
193 
194 private:
196  shared_ptr<const Context<BasisFunctionType, ResultType> > m_context;
197  shared_ptr<const AbstractBoundaryOperator<BasisFunctionType, ResultType> >
198  m_abstractOp;
199  bool m_holdWeakForm;
200  typedef shared_ptr<const DiscreteBoundaryOperator<ResultType> >
201  ConstWeakFormContainer;
202  mutable shared_ptr<ConstWeakFormContainer> m_weakFormContainer;
203  typedef boost::weak_ptr<const DiscreteBoundaryOperator<ResultType> >
204  WeakConstWeakFormContainer;
205  mutable shared_ptr<WeakConstWeakFormContainer> m_weakWeakFormContainer;
207 };
208 
211 template <typename BasisFunctionType, typename ResultType>
214 
219 template <typename BasisFunctionType, typename ResultType>
222 
227 template <typename BasisFunctionType, typename ResultType>
231 
236 template <typename BasisFunctionType, typename ResultType>
240 
241 // This type machinery is needed to disambiguate between this operator and
242 // the one taking a BoundaryOperator and a GridFunction
248 template <typename BasisFunctionType, typename ResultType, typename ScalarType>
249 typename boost::enable_if<
250  typename boost::mpl::has_key<
251  boost::mpl::set<float, double, std::complex<float>, std::complex<double> >,
252  ScalarType>,
254 operator*(
256  const ScalarType& scalar);
257 
263 template <typename BasisFunctionType, typename ResultType, typename ScalarType>
265  const ScalarType& scalar,
267 
273 template <typename BasisFunctionType, typename ResultType, typename ScalarType>
276  const ScalarType& scalar);
277 
289 template <typename BasisFunctionType, typename ResultType>
293 
299 template <typename BasisFunctionType, typename ResultType>
303 
315 template <typename BasisFunctionType, typename ResultType>
318 
329 template <typename BasisFunctionType, typename ResultType>
332  const shared_ptr<const Space<BasisFunctionType> >& range);
333 
341 template <typename BasisFunctionType, typename ResultType>
344  std::string message = "");
345 
349 template <typename BasisFunctionType, typename ResultType>
350 const BoundaryOperator<BasisFunctionType, ResultType>& throwIfUninitialized(
352  std::string message = "");
353 
354 } // namespace Bempp
355 
356 #endif
Function space.
Definition: assembled_potential_operator.hpp:35
void initialize(const shared_ptr< const Context< BasisFunctionType, ResultType > > &context, const shared_ptr< const AbstractBoundaryOperator< BasisFunctionType, ResultType > > &abstractOp)
Initialize or reinitialize a BoundaryOperator.
Definition: boundary_operator.cpp:54
Assembly context.
Definition: context.hpp:30
void apply(const TranspositionMode trans, const GridFunction< BasisFunctionType, ResultType > &x_in, GridFunction< BasisFunctionType, ResultType > &y_inout, ResultType alpha, ResultType beta) const
Act on a GridFunction.
Definition: boundary_operator.cpp:181
TranspositionMode
Enumeration determining how a discrete boundary operator is transformed before being applied...
Definition: transposition_mode.hpp:37
shared_ptr< const Space< BasisFunctionType > > range() const
Return a shared pointer to the range of the encapsulated abstract boundary operator.
Definition: boundary_operator.cpp:136
void holdWeakForm(bool value)
Specify whether the BoundaryOperator should prevent its weak form from being destroyed.
Definition: boundary_operator.cpp:170
Operator acting on functions defined on a surface.
Definition: boundary_operator.hpp:63
Abstract (non-discretized) boundary operator.
Definition: abstract_boundary_operator.hpp:90
shared_ptr< const Context< BasisFunctionType, ResultType > > context() const
Return a shared pointer to the stored Context object.
Definition: boundary_operator.cpp:96
Function defined on a grid.
Definition: assembled_potential_operator.hpp:34
void uninitialize()
Uninitialize the BoundaryOperator.
Definition: boundary_operator.cpp:73
shared_ptr< const AbstractBoundaryOperator< BasisFunctionType, ResultType > > abstractOperator() const
Return a shared pointer to the encapsulated abstract boundary operator.
Definition: boundary_operator.cpp:89
bool isWeakFormHeld() const
Return true if the BoundaryOperator should prevent its weak form from being destroyed.
Definition: boundary_operator.cpp:163
BoundaryOperator()
Construct an uninitialized BoundaryOperator.
Definition: boundary_operator.cpp:37
shared_ptr< const DiscreteBoundaryOperator< ResultType > > weakForm() const
Return a shared pointer to the weak form of the encapsulated abstract boundary operator.
Definition: boundary_operator.cpp:103
shared_ptr< const Space< BasisFunctionType > > domain() const
Return a shared pointer to the domain of the encapsulated abstract boundary operator.
Definition: boundary_operator.cpp:127
std::string label() const
Return the label of this BoundaryOperator.
Definition: boundary_operator.cpp:154
shared_ptr< const Space< BasisFunctionType > > dualToRange() const
Return a shared pointer to the space dual to the range of the encapsulated abstract boundary operator...
Definition: boundary_operator.cpp:145
bool isInitialized() const
Return true if the BoundaryOperator has been initialized, false otherwise.
Definition: boundary_operator.cpp:82