TimeStepper.hpp 1.34 KB
Newer Older
1 2 3 4 5 6 7
/*************************************************************************
*  Copyright (C) 2004 by Olivier Galizzi                                 *
*  olivier.galizzi@imag.fr                                               *
*                                                                        *
*  This program is free software; it is licensed under the terms of the  *
*  GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/
8

9
#pragma once
10 11

#include "Interaction.hpp"
12
#include "GlobalEngine.hpp"
13
#include "Scene.hpp"
14

15 16
namespace yade { // Cannot have #include directive inside.

17 18
class Body;

19 20
class TimeStepper: public GlobalEngine{
	public:
21
		virtual void computeTimeStep(Scene* ) { throw; };
22
		virtual bool isActivated() {return (active && (scene->iter % timeStepUpdateInterval == 0));};
23
		virtual void action() { computeTimeStep(scene);} ;
24
		void setActive(bool a, int nb=-1) {active = a; if (nb>0) {timeStepUpdateInterval = (unsigned int)nb;}}
25
		
26
	// clang-format off
27 28
		YADE_CLASS_BASE_DOC_ATTRS(
			TimeStepper,GlobalEngine,"Engine defining time-step (fundamental class)",
29 30
			((bool,active,true,,"is the engine active?"))
			((unsigned int,timeStepUpdateInterval,1,,"dt update interval")));
31
	// clang-format on
32 33
};

34
REGISTER_SERIALIZABLE(TimeStepper);
35

36
} // namespace yade
37