00001 /*************************************************************************** 00002 switchprobe.h - description 00003 ------------------- 00004 begin : Thu 22 Feb 2001 00005 copyright : (C) 2001 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 SWPROBE_H 00019 #define SWPROBE_H 00020 00021 #include <vector> 00022 #include <string> 00023 #include <iostream> 00024 #include <fstream> 00025 #include "odesystem.h" 00026 #include "numerictraits.h" 00027 00028 namespace MODEL 00029 { 00030 00034 template<integer dims, typename nelem=number, class NT = NumericTraits<nelem,dims> > 00035 class SwitchProbe : public TickTock 00036 { 00037 public: 00038 typedef ODESystem<dims,nelem,NT> system; 00039 SwitchProbe(system& sys, integer var, number threshold) : 00040 TickTock(sys,sys.get_dt()),s(&sys), v(var),th(threshold) 00041 { 00042 reset(); 00043 } 00044 00045 void tick() 00046 { 00047 if(!switched) 00048 if (s->get_current()[v] >th) 00049 { 00050 switched=true; 00051 switcht=get_time(); 00052 } 00053 } 00054 00055 const bool check(void) 00056 { 00057 return switched; 00058 } 00059 00060 const number switch_time(void) 00061 { 00062 return switcht; 00063 } 00064 00065 00066 void reset() 00067 { 00068 switched=false; 00069 } 00070 00071 NO_COPY(SwitchProbe); 00072 00073 private: 00074 system* s; 00075 integer v; 00076 number th; 00077 00078 bool switched; 00079 number switcht; 00080 }; 00081 00082 } 00083 00084 #endif
More Info? Michael Peeters. Also, check our research website: www.alna.vub.ac.be
Last update: June 2002.