tension_function.cpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Includes
00011 *****************************************************************************/
00012 
00013 #include <iostream>
00014 #include <string>
00015 #include <gtest/gtest.h>
00016 #include <ecl/formatters/floats.hpp>
00017 #include <ecl/formatters/strings.hpp>
00018 #include "../../include/ecl/geometry/tension_function.hpp"
00019 
00020 /*****************************************************************************
00021 ** Using
00022 *****************************************************************************/
00023 
00024 using std::string;
00025 using ecl::RightAlign;
00026 using ecl::Format;
00027 using ecl::TensionFunction;
00028 
00029 /*****************************************************************************
00030 ** Tests
00031 *****************************************************************************/
00032 
00033 TEST(TensionFunction,allEggsInOneBasket) {
00034         // Haven't got around to running this properly through gtests yet.
00035         SUCCEED();
00036 }
00037 /*****************************************************************************
00038 ** Main program
00039 *****************************************************************************/
00040 
00041 int main(int argc, char **argv) {
00042 
00043         Format<string> string_format; string_format.width(8); string_format.align(RightAlign);
00044     Format<double> format; format.width(8); format.precision(2); format.align(RightAlign);
00045 
00046     std::cout << std::endl;
00047     std::cout << "***********************************************************" << std::endl;
00048     std::cout << "                    Constructors" << std::endl;
00049     std::cout << "***********************************************************" << std::endl;
00050     std::cout << std::endl;
00051 
00052     TensionFunction function;
00053     function = TensionFunction::Interpolation(2.0,1.0,2.0,3.0,2.0,3.0);
00054 
00055     std::cout << "f(tau,x) =" << std::endl;
00056     std::cout << function << std::endl;
00057 
00058     std::cout << string_format("t=0.01");
00059     std::cout << string_format("t=1");
00060     std::cout << string_format("t=2");
00061     std::cout << string_format("t=3");
00062     std::cout << string_format("t=4");
00063     std::cout << string_format("t=10") << std::endl;
00064     for ( int i = 0; i <= 50; ++i ) {
00065         std::cout << format(function(0.01,2.0 + 0.02*i));
00066         for ( int j = 1; j < 5; j+=1 ) {
00067             std::cout << format(function(1.0*j,2.0 + 0.02*i));
00068         }
00069         std::cout << format(function(10.0,2.0 + 0.02*i));
00070         std::cout << std::endl;
00071     }
00072 
00073     std::cout << std::endl;
00074     std::cout << "***********************************************************" << std::endl;
00075     std::cout << "                    Derivatives" << std::endl;
00076     std::cout << "***********************************************************" << std::endl;
00077     std::cout << std::endl;
00078 
00079     std::cout << string_format("t=0.01");
00080     std::cout << string_format("t=1");
00081     std::cout << string_format("t=2");
00082     std::cout << string_format("t=3");
00083     std::cout << string_format("t=4");
00084     std::cout << string_format("t=10") << std::endl;
00085     for ( int i = 0; i <= 50; ++i ) {
00086         std::cout << format(function.derivative(0.01,2.0 + 0.02*i));
00087         for ( int j = 1; j < 5; j+=1 ) {
00088             std::cout << format(function.derivative(1.0*j,2.0 + 0.02*i));
00089         }
00090         std::cout << format(function.derivative(10.0,2.0 + 0.02*i));
00091         std::cout << std::endl;
00092     }
00093 
00094 
00095     std::cout << std::endl;
00096     std::cout << "***********************************************************" << std::endl;
00097     std::cout << "                  2nd Derivatives" << std::endl;
00098     std::cout << "***********************************************************" << std::endl;
00099     std::cout << std::endl;
00100 
00101     std::cout << string_format("t=0.01");
00102     std::cout << string_format("t=1");
00103     std::cout << string_format("t=2");
00104     std::cout << string_format("t=3");
00105     std::cout << string_format("t=4");
00106     std::cout << string_format("t=10") << std::endl;
00107     for ( int i = 0; i <= 50; ++i ) {
00108         std::cout << format(function.dderivative(0.01,2.0 + 0.02*i));
00109         for ( int j = 1; j < 5; j+=1 ) {
00110             std::cout << format(function.dderivative(1.0*j,2.0 + 0.02*i));
00111         }
00112         std::cout << format(function.dderivative(10.0,2.0 + 0.02*i));
00113         std::cout << std::endl;
00114     }
00115 
00116 
00117     std::cout << std::endl;
00118     std::cout << "***********************************************************" << std::endl;
00119     std::cout << "                      Passed" << std::endl;
00120     std::cout << "***********************************************************" << std::endl;
00121     std::cout << std::endl;
00122 
00123     testing::InitGoogleTest(&argc,argv);
00124     return RUN_ALL_TESTS();
00125 }
00126 
00127 


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Sun Oct 5 2014 23:36:08