File: DummyFlowEngine.cpp

package info (click to toggle)
yade 2026.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,448 kB
  • sloc: cpp: 97,645; python: 52,173; sh: 677; makefile: 162
file content (64 lines) | stat: -rw-r--r-- 2,513 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

/*************************************************************************
*  Copyright (C) 2014 by Bruno Chareyre <bruno.chareyre@grenoble-inp.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. *
*************************************************************************/

// This is an example of how to derive a new FlowEngine with additional data and possibly completely new behaviour.
// Every functions of the base engine can be overloaded, and new functions can be added

//keep this #ifdef as long as you don't really want to release a final version publicly, it will save compilation time for everyone else
//when you want it compiled, you can pass -DDUMMYFLOW to cmake, or just uncomment the following line
// #define DUMMYFLOW
#ifdef DUMMYFLOW

#include "FlowEngine_DummyFlowEngineT.hpp"

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

/// We can add data to the Info types by inheritance
class DummyCellInfo : public FlowCellInfo_DummyFlowEngineT {
public:
	Real anotherVariable;
	void anotherFunction() {};
};

class DummyVertexInfo : public FlowVertexInfo_DummyFlowEngineT {
public:
	//same here if needed
};

typedef TemplateFlowEngine_DummyFlowEngineT<DummyCellInfo, DummyVertexInfo> DummyFlowEngineT;
REGISTER_SERIALIZABLE(DummyFlowEngineT);
YADE_PLUGIN((DummyFlowEngineT));

class DummyFlowEngine : public DummyFlowEngineT {
public:
	//We can overload every functions of the base engine to make it behave differently
	//if we overload action() like this, this engine is doing nothing in a standard timestep, it can still have useful functions
	virtual void action() {};

	//If a new function is specific to the derived engine, put it here, else go to the base TemplateFlowEngine
	//if it is useful for everyone
	void fancyFunction(Real what);

	// clang-format off
	YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(DummyFlowEngine,DummyFlowEngineT,"documentation here",
	((Real, myNewAttribute, 0,,"useless example"))
	,/*DummyFlowEngineT()*/,
	,
	.def("fancyFunction",&DummyFlowEngine::fancyFunction,(boost::python::arg("what")=0),"test function")
	)
	// clang-format on
	DECLARE_LOGGER;
};
REGISTER_SERIALIZABLE(DummyFlowEngine);
YADE_PLUGIN((DummyFlowEngine));

void DummyFlowEngine::fancyFunction(Real what) { std::cerr << "yes, I'm a new function" << std::endl; }

} // namespace yade

#endif //DummyFLOW