tension_spline.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_GEOMETRY_TENSION_SPLINE_HPP_
13 #define ECL_GEOMETRY_TENSION_SPLINE_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include "tension_function.hpp"
20 #include <ecl/config/macros.hpp>
21 #include <ecl/concepts/macros.hpp>
22 #include <ecl/concepts/streams.hpp>
23 #include <ecl/concepts/containers.hpp>
24 #include <ecl/containers/array.hpp>
25 #include <ecl/exceptions/standard_exception.hpp>
26 #include <ecl/utilities/blueprints.hpp>
27 #include "macros.hpp"
28 
29 /*****************************************************************************
30 ** Namespaces
31 *****************************************************************************/
32 
33 namespace ecl {
34 
35 /*****************************************************************************
36 ** Forward Declarations
37 *****************************************************************************/
38 
39 class TensionSpline;
40 
41 namespace blueprints {
42 
43 class C2TensionSpline;
44 
45 } // namespace blueprints
46 
47 /*****************************************************************************
48 ** BluePrintFactory
49 *****************************************************************************/
58 template<>
59 class ECL_PUBLIC BluePrintFactory< TensionSpline > {
60 public:
74  static blueprints::C2TensionSpline Natural(const Array<double>& x_set, const Array<double>& y_set,
75  const double &tau) ecl_assert_throw_decl(StandardException);
76 
77  virtual ~BluePrintFactory() {};
78 };
79 
80 /*****************************************************************************
81 ** Interface [TensionSpline]
82 *****************************************************************************/
95 class ecl_geometry_PUBLIC TensionSpline : public BluePrintFactory< TensionSpline > {
96  public:
97  /******************************************
98  ** Typedefs
99  *******************************************/
100  typedef BluePrintFactory< TensionSpline > Factory;
102  /******************************************
103  ** Constructors
104  *******************************************/
111  TensionSpline () {};
112  virtual ~TensionSpline() {};
139  template<typename Derived>
140  TensionSpline(const BluePrint< Derived > &blueprint) {
141  blueprint.implementApply(*this);
142  }
143 
144  /******************************************
145  ** Access
146  *******************************************/
147  friend class blueprints::C2TensionSpline;
148 
158  double operator()(const double &x) const ecl_assert_throw_decl(StandardException);
169  double derivative(const double &x) const ecl_assert_throw_decl(StandardException);
178  double dderivative(const double &x) const ecl_assert_throw_decl(StandardException);
179 
187  const Array<double>& domain() const { return discretised_domain; }
188 
189  /******************************************
190  ** Streaming
191  *******************************************/
204  template <typename OutputStream>
205  friend OutputStream& operator << (OutputStream &ostream, const TensionSpline &tension_spline);
206 
207  private:
208  Array<double> discretised_domain; // N+1 x_i's
209  Array<TensionFunction> functions; // N tension_functions
210  double tension;
211 };
212 
213 /*****************************************************************************
214 ** Interface [Minimum/Maximum][TensionSpline]
215 *****************************************************************************/
216 
217 /*****************************************************************************
218 ** Implementation [TensionSpline][Streaming]
219 *****************************************************************************/
220 
221 template <typename OutputStream>
222 OutputStream& operator << (OutputStream &ostream, const TensionSpline &tension_spline) {
223 
225 
226  for ( unsigned int i = 0; i < tension_spline.functions.size(); ++i ) {
227  ostream << tension_spline.functions[i] << "\n";
228  }
229  ostream.flush();
230  return ostream;
231 }
232 
233 /*****************************************************************************
234 ** BluePrints
235 *****************************************************************************/
236 
237 namespace blueprints {
238 
239 /*****************************************************************************
240 ** Interface [C2TensionSpline]
241 *****************************************************************************/
242 
252 class ecl_geometry_PUBLIC C2TensionSpline : public ecl::BluePrint<C2TensionSpline> {
253  public:
257  typedef ecl::TensionSpline base_type;
263  C2TensionSpline() {};
264  ~C2TensionSpline() {};
265 
279  C2TensionSpline(const ecl::Array<double>& x_set, const ecl::Array<double>& y_set, const double &tau) ecl_assert_throw_decl(ecl::StandardException);
280 
288  base_type instantiate();
289 
297  void apply(base_type& spline) const;
298 
299  private:
300  ecl::Array<double> x_data;
301  ecl::Array<double> y_data;
302  ecl::Array<double> yddot_data;
303  double tension;
304 };
305 
306 } // namespace blueprints
307 } // namespace ecl
308 
309 #endif /* ECL_GEOMETRY_TENSION_SPLINE_HPP_ */
Storage container for a tension spline interpolation.
Defines validating functionality for the streams concept.
OutputStream & operator<<(OutputStream &ostream, const Void void_object)
Output stream operator for Void objects.
Definition: void.hpp:76
Standard exception type, provides code location and error string.
#define ecl_geometry_PUBLIC
#define ECL_PUBLIC
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.
#define ecl_compile_time_concept_check(Model)
Compile time concept checking assertion.
This is a parent template for blueprints using crtp.
Array< TensionFunction > functions


xbot_node
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:28:13