00001
00002
00003 #ifndef MOTION_COUPLED_SOLVER_H
00004 #define MOTION_COUPLED_SOLVER_H
00005
00012 #include "MotionSolver.h"
00013
00014 template <class DataType, int dim>
00015 class MotionCoupledSolver : public MotionSolver<DataType,dim> {
00016 typedef MotionSolver<DataType,dim> base;
00017 public:
00018 MotionCoupledSolver() : base(), CouplingStrategy(0), SAL(0.5) {}
00019
00020
00021
00022
00023 virtual void SendBoundaryData() = 0;
00024 virtual void PostReceiveBoundaryData() = 0;
00025 virtual void WaitReceiveBoundaryData() = 0;
00026 virtual void sendBoundaryReceivePressure() = 0;
00027
00028
00029 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00030 base::register_at(Ctrl,prefix);
00031 RegisterAt(base::LocCtrl,"CouplingStrategy",CouplingStrategy);
00032 }
00033 virtual void register_at(ControlDevice& Ctrl) { register_at(Ctrl,""); }
00034
00035 virtual void Initialize(double& t, double& dt) {
00036 base::Initialize(t,dt);
00037 #ifndef MOTION_ONLY
00038 SendBoundaryData();
00039 PostReceiveBoundaryData();
00040 WaitReceiveBoundaryData();
00041 #endif
00042 }
00043
00044 virtual void Advance(double& t, double& dt) {
00045 #ifdef MOTION_ONLY
00046 dt = dt*SAL;
00047 ( base::log() << " ^^^ Iteration " << base::NSteps()
00048 << " ^^^ t = " << t << " dt = " << dt << std::endl).flush();
00049 ( std::cout << " ^^^ Iteration " << base::NSteps()
00050 << " ^^^ t = " << t << " dt = " << dt << std::endl).flush();
00051 base::Advance(t,dt);
00052 #else
00053 SendBoundaryData();
00054 PostReceiveBoundaryData();
00055 if (CouplingStrategy<=0) WaitReceiveBoundaryData();
00056 base::Advance(t,dt);
00057 if (CouplingStrategy>0) WaitReceiveBoundaryData();
00058 #endif
00059
00060 }
00061
00062 virtual void Restart(double& t, double& dt) {
00063 base::Restart(t,dt);
00064 #ifndef MOTION_ONLY
00065 SendBoundaryData();
00066 PostReceiveBoundaryData();
00067 WaitReceiveBoundaryData();
00068 #endif
00069 }
00070
00071 inline int NumNodes() { return base::num_vertices; }
00072 inline int NumElements() { return base::num_connections; }
00073 inline DataType* Pressures() { return base::pressures; }
00074 inline const int* NodeIDs() const { return base::nodeids; }
00075 inline const int* Connections() const { return (int *)base::connections; }
00076 inline const DataType* Coordinates() const { return (DataType *)base::vertices; }
00077 inline const DataType* Velocities() const { return (DataType *)base::velocities; }
00078
00079 protected:
00080 int CouplingStrategy;
00081 DataType SAL;
00082 };
00083
00084 #endif