tension_spline.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_GEOMETRY_TENSION_SPLINE_HPP_
00013 #define ECL_GEOMETRY_TENSION_SPLINE_HPP_
00014 
00015 /*****************************************************************************
00016 ** Includes
00017 *****************************************************************************/
00018 
00019 #include "tension_function.hpp"
00020 #include <ecl/config/macros.hpp>
00021 #include <ecl/concepts/macros.hpp>
00022 #include <ecl/concepts/streams.hpp>
00023 #include <ecl/concepts/containers.hpp>
00024 #include <ecl/containers/array.hpp>
00025 #include <ecl/exceptions/standard_exception.hpp>
00026 #include <ecl/utilities/blueprints.hpp>
00027 #include "macros.hpp"
00028 
00029 /*****************************************************************************
00030 ** Namespaces
00031 *****************************************************************************/
00032 
00033 namespace ecl {
00034 
00035 /*****************************************************************************
00036 ** Forward Declarations
00037 *****************************************************************************/
00038 
00039 class TensionSpline;
00040 
00041 namespace blueprints {
00042 
00043 class C2TensionSpline;
00044 
00045 } // namespace blueprints
00046 
00047 /*****************************************************************************
00048 ** BluePrintFactory
00049 *****************************************************************************/
00058 template<>
00059 class ECL_PUBLIC BluePrintFactory< TensionSpline > {
00060 public:
00074         static blueprints::C2TensionSpline Natural(const Array<double>& x_set, const Array<double>& y_set,
00075                         const double &tau) ecl_assert_throw_decl(StandardException);
00076 
00077         virtual ~BluePrintFactory() {};
00078 };
00079 
00080 /*****************************************************************************
00081 ** Interface [TensionSpline]
00082 *****************************************************************************/
00095 class ecl_geometry_PUBLIC TensionSpline : public BluePrintFactory< TensionSpline > {
00096     public:
00097         /******************************************
00098         ** Typedefs
00099         *******************************************/
00100         typedef BluePrintFactory< TensionSpline > Factory; 
00102         /******************************************
00103         ** Constructors
00104         *******************************************/
00111         TensionSpline () {};
00112         virtual ~TensionSpline() {};
00139         template<typename Derived>
00140         TensionSpline(const BluePrint< Derived > &blueprint) {
00141             blueprint.implementApply(*this);
00142         }
00143 
00144         /******************************************
00145         ** Access
00146         *******************************************/
00147         friend class blueprints::C2TensionSpline;
00148 
00158         double operator()(const double &x) const ecl_assert_throw_decl(StandardException);
00169         double derivative(const double &x) const ecl_assert_throw_decl(StandardException);
00178         double dderivative(const double &x) const ecl_assert_throw_decl(StandardException);
00179 
00187         const Array<double>& domain() const { return discretised_domain; }
00188 
00189         /******************************************
00190         ** Streaming
00191         *******************************************/
00204         template <typename OutputStream>
00205         friend OutputStream& operator << (OutputStream &ostream, const TensionSpline &tension_spline);
00206 
00207     private:
00208         Array<double> discretised_domain;           // N+1 x_i's
00209         Array<TensionFunction> functions;   // N tension_functions
00210         double tension;
00211 };
00212 
00213 /*****************************************************************************
00214 ** Interface [Minimum/Maximum][TensionSpline]
00215 *****************************************************************************/
00216 
00217 /*****************************************************************************
00218 ** Implementation [TensionSpline][Streaming]
00219 *****************************************************************************/
00220 
00221 template <typename OutputStream>
00222 OutputStream& operator << (OutputStream &ostream, const TensionSpline &tension_spline) {
00223 
00224         ecl_compile_time_concept_check(ecl::StreamConcept<OutputStream>);
00225 
00226     for ( unsigned int i = 0; i < tension_spline.functions.size(); ++i ) {
00227         ostream << tension_spline.functions[i] << "\n";
00228     }
00229     ostream.flush();
00230     return ostream;
00231 }
00232 
00233 /*****************************************************************************
00234 ** BluePrints
00235 *****************************************************************************/
00236 
00237 namespace blueprints {
00238 
00239 /*****************************************************************************
00240 ** Interface [C2TensionSpline]
00241 *****************************************************************************/
00242 
00252 class ecl_geometry_PUBLIC C2TensionSpline : public ecl::BluePrint<C2TensionSpline> {
00253     public:
00257         typedef ecl::TensionSpline base_type;
00263         C2TensionSpline() {};
00264         ~C2TensionSpline() {};
00265 
00279         C2TensionSpline(const ecl::Array<double>& x_set, const ecl::Array<double>& y_set, const double &tau) ecl_assert_throw_decl(ecl::StandardException);
00280 
00288         base_type instantiate();
00289 
00297         void apply(base_type& spline) const;
00298 
00299     private:
00300         ecl::Array<double> x_data;
00301         ecl::Array<double> y_data;
00302         ecl::Array<double> yddot_data;
00303         double tension;
00304 };
00305 
00306 } // namespace blueprints
00307 } // namespace ecl
00308 
00309 #endif /* ECL_GEOMETRY_TENSION_SPLINE_HPP_ */


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:46