00001
00029 #ifndef AVI_CLASS
00030 #define AVI_CLASS
00031
00032 #include <vector>
00033 #include <list>
00034 #include <queue>
00035 #include <string>
00036 #include <sstream>
00037 #include <iostream>
00038
00039 #include <cstdio>
00040 #include <cassert>
00041 #include <cmath>
00042 #include <cstring>
00043
00044
00045 #include "AuxDefs.h"
00046 #include "ElementalOperation.h"
00047 #include "DiagonalMassForSW.h"
00048 #include "StressWork.h"
00049
00050 #include "util.h"
00051
00113 class AVI {
00114 public:
00115 AVI () {
00116 }
00117 ;
00118 virtual ~AVI () {
00119 }
00120 ;
00121 AVI (const AVI& NewAVI) {
00122 }
00123 ;
00124 virtual AVI * clone () const = 0;
00125
00126
00128 virtual double getTimeStep () const = 0;
00129
00131 virtual double getTimeStamp () const = 0;
00132
00136 virtual bool setTimeStamp (double timeval) = 0;
00137
00139 virtual double getNextTimeStamp () const = 0;
00140
00142 virtual void incTimeStamp () = 0;
00143
00149 virtual const std::vector<size_t>& getFields () const = 0;
00150
00157
00158 virtual size_t getFieldDof (size_t fieldnumber) const = 0;
00159
00161 virtual size_t getGlobalIndex (void) const = 0;
00162
00163 virtual const DResidue& getOperation () const = 0;
00164
00165 virtual const Element& getElement () const = 0;
00166
00167 virtual const ElementGeometry& getGeometry () const = 0;
00168
00172 virtual void computeLocalTvec (MatDouble& tnew) const = 0;
00173
00196
00197 virtual bool vbInit (
00198 const MatDouble& q,
00199 const MatDouble& v,
00200 const MatDouble& vb,
00201 const MatDouble& ti,
00202 const MatDouble& tnew,
00203 MatDouble& qnew,
00204 MatDouble& vbinit,
00205 MatDouble& forcefield,
00206 MatDouble& funcval,
00207 MatDouble& deltaV
00208 ) const = 0;
00209
00219 virtual bool
00220 getForceField (const MatDouble& argval, MatDouble& forcefield) const = 0;
00221
00251
00252
00253 virtual bool update (
00254 const MatDouble& q,
00255 const MatDouble& v,
00256 const MatDouble& vb,
00257 const MatDouble& ti,
00258 const MatDouble& tnew,
00259 MatDouble& qnew,
00260 MatDouble& vnew,
00261 MatDouble& vbnew,
00262 MatDouble& forcefield,
00263 MatDouble& funcval,
00264 MatDouble& deltaV
00265 ) const = 0;
00266
00292 virtual bool
00293 gather ( const LocalToGlobalMap& L2G,
00294 const VecDouble& Qval,
00295 const VecDouble& Vval,
00296 const VecDouble& Vbval,
00297 const VecDouble& Tval,
00298 MatDouble& q,
00299 MatDouble& v,
00300 MatDouble& vb,
00301 MatDouble& ti) const = 0;
00302
00331 virtual bool assemble (const LocalToGlobalMap& L2G,
00332 const MatDouble& qnew,
00333 const MatDouble& vnew,
00334 const MatDouble& vbnew,
00335 const MatDouble& tnew,
00336 VecDouble& Qval,
00337 VecDouble& Vval,
00338 VecDouble& Vbval,
00339 VecDouble& Tval,
00340 VecDouble& LUpdate) const = 0;
00341
00342 protected:
00343 virtual void setTimeStep (double epsilon = 1.0) = 0;
00344
00357
00358 virtual void
00359 computeDeltaV (const MatDouble& funcval, MatDouble& DeltaV) const = 0;
00360
00377 virtual bool getImposedValues (const GlobalElementIndex& ElementIndex,
00378 const LocalToGlobalMap& L2G, size_t field, size_t dof,
00379 double& qvalue, double& vvalue) const = 0;
00380
00381 public:
00383 virtual const std::string toString () const {
00384 std::ostringstream ss;
00385 ss << "AVI(id: " << getGlobalIndex() << ", " << getNextTimeStamp() << " )";
00386 return ss.str ();
00387 }
00388
00390 friend std::ostream& operator << (std::ostream& out, const AVI& avi) {
00391 out << avi.toString ();
00392 return out;
00393 }
00394 };
00395
00396
00401 struct AVIComparator {
00402 static const double EPS = 1e-12;
00403
00407 int compare (const AVI* left, const AVI* right) const {
00408 int result = 0;
00409 double tdiff = left->getNextTimeStamp() - right->getNextTimeStamp();
00410
00411 if (tdiff < 0) {
00412 result = -1;
00413 } else if (tdiff > 0) {
00414 result = 1;
00415 } else {
00416 result = left->getGlobalIndex() - right->getGlobalIndex();
00417 }
00418
00419 return result;
00420 }
00421
00425 bool operator () (const AVI* left, const AVI* right) const {
00426 return compare (left, right) < 0;
00427 }
00428 };
00429
00433 struct AVIReverseComparator: public AVIComparator {
00437 bool operator () (const AVI* left, const AVI* right) const {
00438 return compare (left, right) > 0;
00439 }
00440 };
00441
00442
00443 #endif