00001 /***************************************************************************
00002 vectorfunction.h - description
00003 -------------------
00004 begin : Thu Apr 20 2000
00005 copyright : (C) 2000 by Michael Peeters
00006 email : Michael.Peeters@vub.ac.be
00007 ***************************************************************************/
00008
00009 /***************************************************************************
00010 * *
00011 * This program is free software; you can redistribute it and/or modify *
00012 * it under the terms of the GNU General Public License as published by *
00013 * the Free Software Foundation; either version 2 of the License, or *
00014 * (at your option) any later version. *
00015 * *
00016 ***************************************************************************/
00017
00018 #ifndef VECTORFUNCTION_H
00019 #define VECTORFUNCTION_H
00020
00021 #include "numerictypes.h"
00022 #include "numerictraits.h"
00023 #include "numvector.h"
00024 #include "parameter.h"
00025 #include <stdexcept>
00026 #include <map>
00027 #include <string>
00028 #include <algorithm>
00029
00030
00031 namespace MODEL {
00032
00033 using namespace std;
00034
00042 // Previously template <integer dims, class NT = NumericTraits<number,dims> >
00043 template<integer dims, typename nelem=number, class NT = NumericTraits<nelem,dims> >
00044 class VectorFunction
00045 {
00046 public:
00048 typedef NT NT_outside;
00049 typedef typename NT::number numT;
00050 typedef typename NT::vect vect;
00051 typedef typename NT::vf vf;
00052 typedef typename NT::matrix matrix;
00053
00054 VectorFunction() {}
00055 virtual ~VectorFunction() {};
00056
00057 // Just to make sure no errors are made
00060 VectorFunction(const VectorFunction& vf) {}
00061 // const VectorFunction<dims,nelem> operator=(const VectorFunction<dims,nelem>& vf)
00062 // {if(this!=&vf){} return *this;}
00063
00065 virtual VectorFunction* clone () const =0;
00066
00069 vect operator()(const vect& u)
00070 { vect temp(0.); return function(temp,u); }
00071
00076 virtual const vect& function(vect& fu,const vect& u) = 0;
00077
00078 void define_parameter(const string& name, number&
00079 p){parlist[name]=&p;}
00080
00081 number& get_parameter(const string& name)
00082 {
00083 map<string,number*>::iterator end=parlist.end();
00084 map<string,number*>::iterator found=parlist.find(name);
00085
00086 if (found==end) throw std::logic_error("VectorFunction::Parameter not found");
00087
00088 return *(found->second);
00089 }
00090
00091 number& get_parameter(const string& name) const
00092 {
00093 map<string,number*>::iterator end=parlist.end();
00094 map<string,number*>::iterator found=parlist.find(name);
00095
00096 if (found==end) throw
00097 std::logic_error("VectorFunction::Parameter not found");
00098
00099 return *(found->second);
00100 }
00101
00102 public:
00103 map<string,number*>& get_parlist(void)
00104 {
00105 return parlist;
00106 }
00107
00108 const map<string,number*>& get_parlist(void) const
00109 {
00110 return parlist;
00111 }
00112
00113 private:
00114 map<string,number*> parlist;
00115 };
00116
00117 // Used To make older code happy */
00118 // typedef VectorFunction<MODEL::real,3> RealVectorFunction;
00119
00120 } // end namespace MODEL
00121 #endif
00122
00123 /*********************************************************************
00124 $Id: vectorfunction.h,v 1.2.2.1 2001/10/15 15:09:36 mpeeters Exp $
00125 **********************************************************************
00126
00127 $Log: vectorfunction.h,v $
00128 Revision 1.2.2.1 2001/10/15 15:09:36 mpeeters
00129 Finally removed multiline string literal.
00130
00131 Revision 1.2 2001/08/23 20:24:00 mpeeters
00132 Modified docs to provide correct version info.
00133
00134 Revision 1.1 2001/05/22 10:54:55 mpeeters
00135 Moved sources and headers for libModel to model/ subdirectory, in an attempt to rationalize the source tree. This should make things "netter".
00136
00137 Revision 1.3 2001/05/21 11:53:16 mpeeters
00138 Removed Makefile.in, which is automatically generated anyway.
00139
00140 Revision 1.2 2000/09/15 10:26:31 mpeeters
00141 Cleaned out header and added CVS tails to files, removed superfuous
00142 @author comments, inserted dates
00143
00144 *********************************************************************/
More Info? Michael Peeters. Also, check our research website: www.alna.vub.ac.be
Last update: June 2002.