Marine systems simulation
FishPopulation.h
1#ifndef FISH_POPULATION_H
2#define FISH_POPULATION_H
3
4//#define CNetStructure_DO_PROFILE
5
6// Includes
7#include <string>
8#include <math.h>
9
10#include "SimObject.h"
11#include "CEnvironment.h"
12#include "IBasicBottom.h"
13#include "ICurrentVel.h"
14#include "sfh/timers/ProfilerWallclock.h"
15#include "sfh/math/math.h"
16
17#include "IndividualFish.h"
18#include "particles/PelletField.h"
19#include "fish/FishParameters.h"
20#include "environment/ArtificialLightSource.h"
21#include "fish/Z_Tree.h"
22#include <CIntegratorOptions.h>
23#include <CFhSimMgr.h>
24#include "fish/FishCage.h"
25#include <CPrintDuringExec.h>
26
27#include <CNCField.h> // BS_Temporary
28
29
30#ifdef FH_VISUALIZATION
31#include "CFhCamera.h"
32#endif
33
74//Class definition
75class FishPopulation : public SimObject
76{
77public:
79 FishPopulation(std::string simObjectName, ISimObjectCreator *creator);
81 virtual ~FishPopulation();
82 virtual void OdeFcn(const double T, const double *const X, double *const XDot, const bool isMajorTimeStep);
83 virtual void InitialConditionSetup(const double T, const double *const currentIC, double *const updatedIC, ISimObjectCreator *const creator);
84 virtual void FinalSetup(const double T, const double *const X, ISimObjectCreator *const creator);
85 //const double *outBehaviouralState(const double T, const double *const X, int iFish);
86 void PreOdeFcn(const double T, const double *const X, IStateUpdater* updater);
87
88 //============================================================ Herman_dev
89 bool GetRayIntersection(const Eigen::Vector3d& rayOrigin, const Eigen::Vector3d& rayVector, double& outDistance);
90 //============================================================ Herman_dev
91
92 const virtual double* DragForceNet(const double T, const double *const X); // Output function for drag force on the net
93 const virtual double* DragForceSkirt(const double T, const double *const X); // Output function for drag force on the skirt
94 const virtual double* DragForceDepth(const double T, const double *const X); // Output function for drag force on the net above a given depth
95 const virtual double* TopOutForceNet(const double T, const double* const X, int iTop); // Output function for top connection force on the net
96 const virtual double* BotOutPosition(const double T, const double* const X); // Output function for bottom positions
97 const virtual double* RingOutPosition(const double T, const double* const X); // Output function for ring positions
98 const virtual double* NetOutPosition(const double T, const double* const X); // Output function for net positions (single)
99 const virtual double* NetOutPositionMat(const double T, const double* const X, int iIndex); // Output function for net positions (multiple)
100 const virtual double* IngestionNumber(const double T, const double* const X); // Output function for number of ingestion
101 const virtual double* ObstacleOutPosition(const double T, const double* const X); // Output function for obstacle positions
102 const virtual double* ObstacleOutNormal(const double T, const double* const X); // Output function for obstacle normal
103 const virtual double* ObstacleOutDistance(const double T, const double* const X); // Output function for obstacle distance
104 const virtual double* ObstacleOutGuidance(const double T, const double* const X); // Output function for obstacle center
105 const virtual double* ObstacleOutEtaReference(const double T, const double* const X); // Output function for obstacle EtaReference
106 const virtual double* ObstacleOutVelocity(const double T, const double* const X); // Output function for obstacle velocities
107 const virtual double* ObstacleOutVertical(const double T, const double* const X); // Output function for obstacle vertical vector
108 const virtual double* TopBodyForce(const double T, const double *const X); // Output function for top body force
109 const virtual double* PortOutForceNet(const double T, const double* const X, int iCon); // Output function for port connection force on the net
110 const virtual double* PortOutPositionNet(const double T, const double* const X, int iCon); // Output function for port connection position on the net
111 const virtual double* PortOutVelocityNet(const double T, const double* const X, int iCon); // Output function for port connection velocity on the net
112 const virtual double* PortOutCageVolume(const double T, const double* const X); // Output function for cage volume
113 const virtual double* PortOutCD(const double T, const double* const X, int iCon); // Output function for drag coefficient
114 const virtual double* BotOutVelocity(const double T, const double* const X); // Output function for bottom velocities
115 const virtual double* CageTopCentre(const double T, const double* const X); // Output function for cage top centre
116 const virtual double* FishDensity(const double T, const double* const X); // Output function for fish density
117 const virtual double* FishSpeed(const double T, const double* const X); // Output function for fish swimming speed
118 const virtual double* FishSpeedRel(const double T, const double* const X); // Output function for fish swimming speed relative to flow
119 const virtual double* RingOutForce(const double T, const double* const X, int iIndex); // Output function for connection forces to external bottom ring
120 const virtual double* NetTrackOutPosition(const double T, const double* const X); // Output function for net track positions (6DOF x 2)
121 const virtual double* ChainOutForce(const double T, const double* const X, int iIndex); // Output function for connection forces to external chain
122 const virtual double* OutCageWakePos(const double T, const double* const X); // Output function for cage wake position
123
124 // BS_Temporary =========================
125 CNCField* m_ncField;
126 double m_ncInput[3];
127 double m_ncOutput[3];
128 const virtual double* NetCDFOutput(const double T, const double* const X);
129 // BS_Temporary =========================
130
131 //EIGEN_MAKE_ALIGNED_OPERATOR_NEW
132#ifdef FH_VISUALIZATION
134 virtual void RenderInit(Ogre::Root *const ogreRoot, ISimObjectCreator *const creator);
136 virtual void RenderUpdate(const double T, const double *const X);
137#endif
138
139protected:
140 // Fhsim logger
141 CPrintDuringExec* m_logger;
142
143 //std::mt19937& RNG(){return m_rng;}
144
145 // States
146 int m_baseStateIndex;
147 int m_totalNumberOfPelletsEaten;
148
149 FishResources m_resources;
150
151 std::mt19937 m_rng;
152
153 //double m_prevTextOutputTime;
154 std::vector<Fish::IndividualFish> m_individuals;
155 std::vector<Fish::IndividualFish> temp_individuals;
156 //ISimObjectCreator* m_creator;
157
158 //double* m_fishStatuses;
159 bool m_useTemperatureAndLight;
160 double m_fractionOfWaveVelAddedToMovementAsBias;
161 //long m_numPelletsForTimeStep;
162
163 long m_totalIngestionAttempts, m_successfulIngestionAttempts;
164 std::vector<int> m_ingestionList;
165
166 //============================================================================ biao_dev
167 double m_DisOutTimeInt;
168 std::string m_DisOutFile;
169 int m_DisOutNum;
170 double m_DisOutStart;
171 double m_DisOutStop;
172
173 double m_IngestionNumber[2];
174
175 int m_ObstacleNum;
176 double m_ObstacleCirRate;
177 double m_ObstacleCirVel;
178 double m_ObstacleVerVel[2];
179 double m_ObstacleDisTK;
180 double m_ObstacleDepTK;
181 double m_ObstacleDepGR;
182 double m_ObstacleRefDT;
183 ISignalPort* m_ObstacleInPos;
184 ISignalPort* m_ObstacleInVel;
185 double m_ObstacleOutP[3];
186 double m_ObstacleOutN[3];
187 double m_ObstacleOutD;
188 double m_ObstacleOutG[3];
189 double m_ObstacleOutV[3];
190 double m_ObstacleOutVV[3];
191 double m_ObstacleOutGR[4];
192
193 int m_FishObstNum;
194 Fish::vec3 m_FishObstVel;
195
196 double m_UpdateStepSize;
197 int m_UpdateNum;
198
199 double m_FishInitialPos[4];
200
201 std::vector<int> m_FishID;
202
203 double m_SchoolVar[2];
204 Fish::vec3 m_SchoolVarP;
205 Fish::vec3 m_SchoolVarN;
206
207 bool m_BoolFishInVel;
208 ISignalPort* m_FishInVelN;
209 ISignalPort* m_FishInVelE;
210 ISignalPort* m_FishInVelD;
211 ISignalPort* m_FishInVelC;
212
213 bool m_BoolFishInWave;
214 ISignalPort* m_FishInWaveHm;
215 ISignalPort* m_FishInWaveTm;
216
217 double m_OutFishDensityGrid;
218 int m_OutDataNum[4];
219 double* m_OutFishDensityData;
220 double m_OutFishDensity[4];
221 double m_OutFishSpeed[3];
222 double m_OutFishSpeedRel[3];
223 double m_MeanWeight;
224
225 double m_debStaTime;
226
227 bool m_OutCageNode;
228 double* m_OutCageNodePos;
229 const virtual double* PortOutCageNodePos(const double T, const double* const X, int index);
230
231 double m_CageWakePos[3];
232 //============================================================================ biao_dev
233
234 //============================================================================ herman_dev
235 double m_prev_time = 0.0;
236 //============================================================================ herman_dev
237
238
239
240#ifdef FH_VISUALIZATION
241 bool m_advancedFishAnim;
242 Ogre::SceneNode* m_childNode;
243 Ogre::ManualObject* m_fishRenderObj;
244 CFhCamera* m_FhCamera;
245 double m_FishColor[3];
246
247 //============================================================================ biao_dev
248 double m_ParticleGridOrigin[3];
249 double m_ParticleGridDim[3];
250 double m_ParticleGridSize[3];
251 int m_ParticleGridNum[3];
252 int m_ParticleNum;
253
254 Ogre::ParticleSystem* m_ParticleSystem;
255 Ogre::SceneNode* m_ParticleNode;
256 Ogre::ParticleEmitter* m_ParticleEmitter;
257 double m_ParticleSize[2];
258 double m_ParticleMultiplier;
259 double m_ParticleSpeedMultiplier;
260 double m_ParticleFadeRate;
261 int m_ParticleQuota;
262 double m_ParticleAngleSpread;
263 double m_ParticleColor[3];
264 double m_ParticleTimeToLive;
265 int m_ParticleSetTime;
266 double m_ParticleFlowReduction;
267
268 // ==================== Wake effect (BiaoSu)
269 bool m_wakeEffect;
270 int m_wakeObjNum;
271 ISignalPort** m_wakeObjPort;
272 ISignalPort* m_wakeDirPort;
273 ISignalPort* m_wakeRatioPort;
274 ISignalPort* m_wakeValuePort;
275 double m_wakeObjRadius[3];
276 double m_wakeObjDepth[3];
277 double m_wakeMaxVisValue;
278 bool m_wakeVisReduction;
279 double m_wakeObjPower;
280 double GetWakeRatio(const double T, const double* const X, const double adPos[3]);
281 // ==================== Wake effect (BiaoSu)
282 //============================================================================ biao_dev
283#endif
284};
285
286
287#endif
Definition: CNCField.h:8
Definition: FishPopulation.h:76
FishPopulation(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
virtual ~FishPopulation()
The destructor deletes dynamically allocated memory.
Definition: IndividualFish.h:30