Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfEngine.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of mdcore.
3 * Coypright (c) 2010 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4 * Coypright (c) 2017 Andy Somogyi (somogyie at indiana dot edu)
5 * Copyright (c) 2022-2024 T.J. Sego
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ******************************************************************************/
21
26
27#ifndef _MDCORE_INCLUDE_TFENGINE_H_
28#define _MDCORE_INCLUDE_TFENGINE_H_
29
30#include "tf_platform.h"
31#include <pthread.h>
32#include "tfSpace.h"
33#include "tf_cycle.h"
35#include <tfSubEngine.h>
36#include <mutex>
37#include <thread>
38#include <set>
39
40
41#define engine_bonds_chunk 100
42#define engine_angles_chunk 100
43#define engine_rigids_chunk 50
44#define engine_dihedrals_chunk 100
45#define engine_exclusions_chunk 100
46#define engine_readbuff 16384
47#define engine_maxgpu 10
48#define engine_pshake_steps 20
49#define engine_maxKcutoff 2
50
51#define engine_split_MPI 1
52#define engine_split_GPU 2
53
54#define engine_bonded_maxnrthreads 16
55#define engine_bonded_nrthreads ((omp_get_num_threads()<engine_bonded_maxnrthreads)?omp_get_num_threads():engine_bonded_maxnrthreads)
56
57#ifdef MDCORE_MAXNRTYPES
58#define engine_maxnrtypes MDCORE_MAXNRTYPES
59#else
60#define engine_maxnrtypes 128
61#endif
62
63
64namespace TissueForge {
65
66
67 /* some constants */
68 enum EngineFlags {
69 engine_flag_none = 0,
70 engine_flag_static = 1 << 0,
71 engine_flag_localparts = 1 << 1,
72 engine_flag_cuda = 1 << 2,
73 engine_flag_explepot = 1 << 3,
74 engine_flag_verlet = 1 << 4,
75 engine_flag_verlet_pairwise = 1 << 5,
76 engine_flag_affinity = 1 << 6,
77 engine_flag_prefetch = 1 << 7,
78 engine_flag_verlet_pseudo = 1 << 8,
79 engine_flag_shake = 1 << 9,
80 engine_flag_mpi = 1 << 10,
81 engine_flag_parbonded = 1 << 11,
82 engine_flag_async = 1 << 12,
83 engine_flag_sets = 1 << 13,
84 engine_flag_nullpart = 1 << 14,
85 engine_flag_initialized = 1 << 15,
86 engine_flag_velocity_clamp = 1 << 16,
87 };
88
89 enum EngineIntegrator {
90 FORWARD_EULER,
91 RUNGE_KUTTA_4
92 };
93
95 enum {
96 engine_timer_step = 0,
97 engine_timer_kinetic,
98 engine_timer_prepare,
99 engine_timer_verlet,
100 engine_timer_exchange1,
101 engine_timer_nonbond,
102 engine_timer_bonded,
103 engine_timer_bonded_sort,
104 engine_timer_bonds,
105 engine_timer_angles,
106 engine_timer_dihedrals,
107 engine_timer_exclusions,
108 engine_timer_advance,
109 engine_timer_rigid,
110 engine_timer_exchange2,
111 engine_timer_shuffle,
112 engine_timer_cuda_load,
113 engine_timer_cuda_unload,
114 engine_timer_cuda_dopairs,
115 engine_timer_render,
116 engine_timer_image_data,
117 engine_timer_render_total,
118 engine_timer_total,
119 engine_timer_last
120 };
121
122
124 enum {
125 ENGINE_TIMER_STEP = 1 << 0,
126 ENGINE_TIMER_PREPARE = 1 << 1,
127 ENGINE_TIMER_VERLET = 1 << 2,
128 ENGINE_TIMER_EXCHANGE1 = 1 << 3,
129 ENGINE_TIMER_NONBOND = 1 << 4,
130 ENGINE_TIMER_BONDED = 1 << 5,
131 ENGINE_TIMER_BONDED_SORT = 1 << 6,
132 ENGINE_TIMER_BONDS = 1 << 7,
133 ENGINE_TIMER_ANGLES = 1 << 8,
134 ENGINE_TIMER_DIHEDRALS = 1 << 9,
135 ENGINE_TIMER_EXCLUSIONS = 1 << 10,
136 ENGINE_TIMER_ADVANCE = 1 << 11,
137 ENGINE_TIMER_RIGID = 1 << 12,
138 ENGINE_TIMER_EXCHANGE2 = 1 << 13,
139 ENGINE_TIMER_SHUFFLE = 1 << 14,
140 ENGINE_TIMER_CUDA_LOAD = 1 << 15,
141 ENGINE_TIMER_CUDA_UNLOAD = 1 << 16,
142 ENGINE_TIMER_CUDA_DOPAIRS = 1 << 17,
143 ENGINE_TIMER_RENDER = 1 << 18,
144 ENGINE_TIMER_LAST = 1 << 19
145 };
146
147 enum {
148 // forces that set the persistent_force should
149 // update values now. Otherwise, the integrator is
150 // probably in a multi-step and should use the saved
151 // value
152 INTEGRATOR_UPDATE_PERSISTENTFORCE = 1 << 0,
153
154 // intermediate flux values are being calculated between time steps
155 INTEGRATOR_FLUX_SUBSTEP = 1 << 1
156 };
157
158
159 struct CustomForce;
160
164 typedef struct CAPI_EXPORT engine {
165
167 unsigned int flags = 0;
168
172 unsigned int integrator_flags;
173
174 #ifdef HAVE_CUDA
176 unsigned int flags_cuda;
177 #endif
178
180 struct space s;
181
183 long time;
184 FPTYPE dt;
185
186 FPTYPE temperature;
187
188 // Boltzmann constant
189 FPTYPE K;
190
193 static const int max_type;
194 static int nr_types;
195
197 static struct ParticleType *types;
198
200 struct Potential **p, **p_cluster;
201
206 struct Force **forces;
207
212 struct Fluxes **fluxes;
213
214 int nr_fluxsteps = 1;
215 int step_flux = 0;
216 FPTYPE dt_flux;
217
219 pthread_mutex_t barrier_mutex;
220 pthread_cond_t barrier_cond;
221 pthread_cond_t done_cond;
222 int barrier_count;
223
226
229
231 struct queue *queues;
232 int nr_queues;
233
236 int nr_nodes;
237
239 struct engine_comm *send, *recv;
240
242 std::set<unsigned int> pids_avail;
243
245 struct Bond *bonds;
246
251
257
262
263 // mutex for anything that modifies the *number* of bonds.
264 std::mutex bonds_mutex;
265
268
270 int nr_exclusions, exclusions_size;
271
273 struct rigid *rigids;
274
277
279 int nr_rigids, rigids_size, nr_constr, rigids_local, rigids_semilocal;
280
282 FPTYPE tol_rigid;
283
285 struct Angle *angles;
286
291
297
300
303
308
314
317
319 #ifdef WITH_MPI
320 MPI_Comm comm;
321 pthread_mutex_t xchg_mutex;
322 pthread_cond_t xchg_cond;
323 short int xchg_started, xchg_running;
324 pthread_t thread_exchg;
325 pthread_mutex_t xchg2_mutex;
326 pthread_cond_t xchg2_cond;
327 short int xchg2_started, xchg2_running;
328 pthread_t thread_exchg2;
329 #endif
330
332 #ifdef HAVE_CUDA
333 void *sortlists_cuda[ engine_maxgpu ];
334 int nr_pots_cuda, nr_pots_cluster_cuda, *pind_cuda[ engine_maxgpu ], *pind_cluster_cuda[ engine_maxgpu ], *offsets_cuda[ engine_maxgpu ];
335 int nr_devices, devices[ engine_maxgpu ], nr_queues_cuda;
336 float *forces_cuda[ engine_maxgpu ];
337 void *parts_pos_cuda[engine_maxgpu];
338 void *parts_vel_cuda[engine_maxgpu];
339 void *parts_datai_cuda[engine_maxgpu];
340 void *part_states_cuda[engine_maxgpu];
341 int *part_species_flags_cuda[engine_maxgpu];
342 void *parts_pos_cuda_local;
343 void *parts_vel_cuda_local;
344 void *parts_datai_cuda_local;
345 void *part_states_cuda_local;
346 int *part_species_flags_cuda_local;
347 int *cells_cuda_local[ engine_maxgpu];
348 int cells_cuda_nr[ engine_maxgpu ];
349 int *counts_cuda[ engine_maxgpu ], *counts_cuda_local[ engine_maxgpu ];
350 int *ind_cuda[ engine_maxgpu ], *ind_cuda_local[ engine_maxgpu ];
351 struct task_cuda *tasks_cuda[ engine_maxgpu ];
352 int *taboo_cuda[ engine_maxgpu ];
353 int nrtasks_cuda[ engine_maxgpu ];
354 void *streams[ engine_maxgpu ];
355 int nr_blocks[engine_maxgpu], nr_threads[engine_maxgpu];
356 int nr_fluxes_cuda, *fxind_cuda[engine_maxgpu];
357 void **fluxes_cuda[engine_maxgpu];
358 float *fluxes_next_cuda[engine_maxgpu];
359 bool bonds_cuda = false;
360 bool angles_cuda = false;
361 #endif
362
364 ticks timers[engine_timer_last];
365
368 int nr_sets;
369
370 FPTYPE wall_time;
371
372 // bitmask of timers to show in performance counter output.
373 uint32_t timers_mask;
374
375 long timer_output_period;
376
382 std::vector<CustomForce*> custom_forces;
383
396
400 FPTYPE computed_volume;
401
402 EngineIntegrator integrator;
403
404 BoundaryConditions boundary_conditions;
405
410 std::vector<SubEngine*> subengines;
411
412
417 int _init_cells[3];
419
420
424 typedef struct engine_set {
425
426 /* Counts of the different interaction types. */
427 int nr_bonds, nr_angles, nr_dihedrals, nr_exclusions, weight;
428
429 /* Lists of ID of the relevant bonded types. */
430 struct Bond *bonds;
431 struct Angle *angles;
432 struct Dihedral *dihedrals;
433 struct exclusion *exclusions;
434
435 /* Nr of sets with which this set conflicts. */
436 int nr_confl;
437
438 /* IDs of the sets with which this set conflicts. */
439 int *confl;
440
442
443
447 typedef struct engine_comm {
448
449 /* Size and count of the cellids. */
450 int count, size;
451
452 int *cellid;
453
455
456
457 /* associated functions */
458
470 CAPI_FUNC(HRESULT) engine_addpot(struct engine *e, struct Potential *p, int i, int j);
471
480 CAPI_FUNC(HRESULT) engine_addfluxes(struct engine *e, struct Fluxes *f, int i, int j);
481
489 Fluxes *engine_getfluxes(struct engine *e, int i, int j);
490
494 CAPI_FUNC(HRESULT) engine_add_singlebody_force(struct engine *e, struct Force *p, int typeId);
495
499 CAPI_FUNC(int) engine_angle_alloc(struct engine *e, Angle **out);
500
506 CAPI_FUNC(HRESULT) engine_angle_eval(struct engine *e);
507
517 CAPI_FUNC(HRESULT) engine_barrier(struct engine *e);
518
524 CAPI_FUNC(HRESULT) engine_bond_eval(struct engine *e);
525
535 CAPI_FUNC(HRESULT) engine_bonded_eval(struct engine *e);
536
547
553 CAPI_FUNC(HRESULT) engine_bonded_sets(struct engine *e, int max_sets);
554
558 CAPI_FUNC(int) engine_dihedral_alloc(struct engine *e, Dihedral **out);
559
565 CAPI_FUNC(HRESULT) engine_dihedral_eval(struct engine *e);
566
574 CAPI_FUNC(HRESULT) engine_exclusion_add(struct engine *e, int i, int j);
575
581 CAPI_FUNC(HRESULT) engine_exclusion_eval(struct engine *e);
582
589
595 CAPI_FUNC(HRESULT) engine_finalize(struct engine *e);
596
602 CAPI_FUNC(HRESULT) engine_flush_ghosts(struct engine *e);
603
609 CAPI_FUNC(HRESULT) engine_flush(struct engine *e);
610
619 CAPI_FUNC(int) engine_gettype(struct engine *e, char *name);
620
629 CAPI_FUNC(int) engine_gettype2(struct engine *e, char *name2);
630
635 int engine_bond_alloc (struct engine *e, struct Bond **result);
636
640 CAPI_FUNC(struct ParticleType*) engine_type(int id);
641
662 struct engine *e,
663 struct Particle *p,
664 FPTYPE *x,
665 struct Particle **result
666 );
667
676 CAPI_FUNC(HRESULT) engine_addparts(struct engine *e, int nr_parts, struct Particle **parts, FPTYPE **x);
677
692 CAPI_FUNC(int) engine_addtype(
693 struct engine *e,
694 FPTYPE mass,
695 FPTYPE charge,
696 const char *name,
697 const char *name2
698 );
699
718 struct engine *e,
719 const FPTYPE *origin,
720 const FPTYPE *dim,
721 int *cells,
722 FPTYPE cutoff,
723 BoundaryConditionsArgsContainer *boundaryConditions,
724 int max_type,
725 unsigned int flags,
726 unsigned int nr_fluxsteps
727 );
728
732 CAPI_FUNC(HRESULT) engine_reset(struct engine *e);
733
751 struct engine *e,
752 FPTYPE *x,
753 FPTYPE *v,
754 int *type,
755 int *pid,
756 int *vid, FPTYPE *q,
757 unsigned int *flags,
758 int N
759 );
760
778 struct engine *e,
779 FPTYPE *x,
780 FPTYPE *v,
781 int *type,
782 int *pid,
783 int *vid,
784 FPTYPE *charge, unsigned int *flags, int N
785 );
786
796 CAPI_FUNC(HRESULT) engine_nonbond_eval(struct engine *e);
797
807 CAPI_FUNC(HRESULT) engine_fluxonly_eval(struct engine* e);
808
819 CAPI_FUNC(HRESULT) engine_rigid_add(struct engine *e, int pid, int pjd, FPTYPE d);
820
829 CAPI_FUNC(HRESULT) engine_rigid_eval(struct engine *e);
830
836 CAPI_FUNC(HRESULT) engine_rigid_sort(struct engine *e);
837
843 CAPI_FUNC(HRESULT) engine_rigid_unsort(struct engine *e);
844
850 CAPI_FUNC(HRESULT) engine_shuffle(struct engine *e);
851
859 CAPI_FUNC(HRESULT) engine_split_bisect(struct engine *e, int N, int particle_flags);
860
870 CAPI_FUNC(HRESULT) engine_split(struct engine *e);
871
881 CAPI_FUNC(HRESULT) engine_start(struct engine *e, int nr_runners, int nr_queues);
882
895 CAPI_FUNC(HRESULT) engine_step(struct engine *e);
896
902 CAPI_FUNC(HRESULT) engine_timers_reset(struct engine *e);
903
922 CAPI_FUNC(int) engine_unload_marked(
923 struct engine *e,
924 FPTYPE *x,
925 FPTYPE *v,
926 int *type,
927 int *pid,
928 int *vid,
929 FPTYPE *q,
930 unsigned int *flags,
931 FPTYPE *epot,
932 int N
933 );
934
953 CAPI_FUNC(int) engine_unload_strays(
954 struct engine *e,
955 FPTYPE *x,
956 FPTYPE *v,
957 int *type,
958 int *pid,
959 int *vid,
960 FPTYPE *q,
961 unsigned int *flags,
962 FPTYPE *epot,
963 int N
964 );
965
984 CAPI_FUNC(int) engine_unload(
985 struct engine *e,
986 FPTYPE *x,
987 FPTYPE *v,
988 int *type,
989 int *pid,
990 int *vid,
991 FPTYPE *charge,
992 unsigned int *flags,
993 FPTYPE *epot,
994 int N
995 );
996
1002 CAPI_FUNC(HRESULT) engine_verlet_update(struct engine *e);
1003
1007 CAPI_FUNC(int) engine_next_partid(struct engine *e);
1008
1012 CAPI_FUNC(HRESULT) engine_next_partids(struct engine *e, int nr_ids, int *ids);
1013
1018
1023
1032 CAPI_FUNC(HRESULT) engine_del_particle(struct engine *e, int pid);
1033
1034 // keep track of how frequently step is called, get average
1035 // steps per second, averaged over past 10 steps.
1036 CAPI_FUNC(FPTYPE) engine_steps_per_second();
1037
1038
1039 CAPI_FUNC(void) engine_dump();
1040
1041 #define ENGINE_DUMP(msg) {std::cout<<msg<<std::endl; engine_dump();}
1042
1043 CAPI_FUNC(FPTYPE) engine_kinetic_energy(struct engine *e);
1044
1045 CAPI_FUNC(FPTYPE) engine_temperature(struct engine *e);
1046
1047 #ifdef WITH_MPI
1048
1066 CAPI_FUNC(HRESULT) engine_init_mpi(
1067 struct engine *e,
1068 const FPTYPE *origin,
1069 const FPTYPE *dim,
1070 FPTYPE *L,
1071 FPTYPE cutoff,
1072 unsigned int period,
1073 int max_type,
1074 unsigned int flags,
1075 MPI_Comm comm,
1076 int rank
1077 );
1078
1085 CAPI_FUNC(HRESULT) engine_exchange(struct engine *e);
1086
1099 CAPI_FUNC(HRESULT) engine_exchange_async(struct engine *e);
1100
1114 CAPI_FUNC(HRESULT) engine_exchange_async_run(struct engine *e);
1115
1122 CAPI_FUNC(HRESULT) engine_exchange_incomming(struct engine *e);
1123
1129 CAPI_FUNC(HRESULT) engine_exchange_rigid(struct engine *e);
1130
1143 CAPI_FUNC(HRESULT) engine_exchange_rigid_async(struct engine *e);
1144
1150 CAPI_FUNC(HRESULT) engine_exchange_rigid_async_run(struct engine *e);
1151
1157 CAPI_FUNC(HRESULT) engine_exchange_rigid_wait(struct engine *e);
1158
1164 CAPI_FUNC(HRESULT) engine_exchange_wait(struct engine *e);
1165 #endif
1166
1167 #if defined(HAVE_CUDA)
1168
1169
1170 namespace cuda {
1171
1172
1178 CAPI_FUNC(HRESULT) engine_nonbond_cuda(struct engine *e);
1179
1185 CAPI_FUNC(HRESULT) engine_cuda_load(struct engine *e);
1186
1192 CAPI_FUNC(HRESULT) engine_cuda_load_parts(struct engine *e);
1193
1199 CAPI_FUNC(HRESULT) engine_cuda_unload_parts(struct engine *e);
1200
1206 CAPI_FUNC(HRESULT) engine_cuda_load_pots(struct engine *e);
1207
1213 CAPI_FUNC(HRESULT) engine_cuda_unload_pots(struct engine *e);
1214
1220 CAPI_FUNC(HRESULT) engine_cuda_refresh_particles(struct engine *e);
1221
1227 CAPI_FUNC(HRESULT) engine_cuda_allocate_particle_states(struct engine *e);
1228
1234 CAPI_FUNC(HRESULT) engine_cuda_finalize_particle_states(struct engine *e);
1235
1241 CAPI_FUNC(HRESULT) engine_cuda_refresh_particle_states(struct engine *e);
1242
1250 CAPI_FUNC(HRESULT) engine_cuda_refresh_pots(struct engine *e);
1251
1257 CAPI_FUNC(HRESULT) engine_cuda_load_fluxes(struct engine *e);
1258
1264 CAPI_FUNC(HRESULT) engine_cuda_unload_fluxes(struct engine *e);
1265
1271 CAPI_FUNC(HRESULT) engine_cuda_refresh_fluxes(struct engine *e);
1272
1278 CAPI_FUNC(HRESULT) engine_cuda_boundary_conditions_refresh(struct engine *e);
1279
1285 CAPI_FUNC(HRESULT) engine_cuda_queues_finalize(struct engine *e);
1286
1292 CAPI_FUNC(HRESULT) engine_cuda_finalize(struct engine *e);
1293
1301 CAPI_FUNC(HRESULT) engine_cuda_refresh(struct engine *e);
1302
1309 CAPI_FUNC(HRESULT) engine_cuda_setthreads(struct engine *e, int id, int nr_threads);
1310
1317 CAPI_FUNC(HRESULT) engine_cuda_setblocks(struct engine *e, int id, int nr_blocks);
1318
1324 CAPI_FUNC(HRESULT) engine_cuda_setdevice(struct engine *e, int id);
1325
1331 CAPI_FUNC(HRESULT) engine_cuda_setdevices(struct engine *e, int nr_devices, int *ids);
1332
1336 CAPI_FUNC(HRESULT) engine_cuda_cleardevices(struct engine *e);
1337
1345 CAPI_FUNC(HRESULT) engine_split_gpu(struct engine *e, int N, int flags);
1346
1357 CAPI_FUNC(HRESULT) engine_toCUDA(struct engine *e);
1358
1364 CAPI_FUNC(HRESULT) engine_fromCUDA(struct engine *e);
1365
1366 }
1367
1368 #endif
1369
1370 #ifdef WITH_METIS
1371 CAPI_FUNC(int) engine_split_METIS(struct engine *e, int N, int flags);
1372 #endif
1373
1374 FVector3 engine_origin();
1375 FVector3 engine_dimensions();
1376 FVector3 engine_center();
1377
1383 // CAPI_DATA(engine) _Engine;
1384 extern CAPI_EXPORT engine _Engine;
1385
1386 CPPAPI_FUNC(struct engine*) engine_get();
1387
1388};
1389
1390
1391// inline definitions...
1392
1393#include "tfParticle.h"
1394
1395
1396namespace TissueForge {
1397
1398
1399 inline Particle *Particle::particle(int i) {
1400 return _Engine.s.partlist[this->parts[i]];
1401 };
1402
1403 inline FVector3 Particle::global_position() {
1404 FVector3 position;
1405 space_getpos(&_Engine.s, this->id, position.data());
1406 return position;
1407 }
1408
1409 inline void Particle::set_global_position(const FVector3& pos) {
1410 FPTYPE x[] = {pos.x(), pos.y(), pos.z()};
1411 space_setpos(&_Engine.s, this->id, x);
1412 }
1413
1415 return _Engine.s.partlist[this->id];
1416 };
1417
1419 return &_Engine.types[this->getTypeId()];
1420 }
1421
1422 inline Particle *Particle_FromId(int id) {
1423 return _Engine.s.partlist[id];
1424 }
1425
1430 return _Engine.s.partlist[this->parts.parts[i]];
1431 }
1432
1433};
1434
1435#endif // _MDCORE_INCLUDE_TFENGINE_H_
T & x()
Definition tfVector3.h:60
T & z()
Definition tfVector3.h:66
T & y()
Definition tfVector3.h:63
Tissue Forge GPU acceleration on CUDA-supporting devices.
Definition tfAngleConfig.h:26
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
int engine_dihedral_alloc(struct engine *e, Dihedral **out)
HRESULT engine_addfluxes(struct engine *e, struct Fluxes *f, int i, int j)
Add fluxes to a particle of particle types.
HRESULT engine_addpart(struct engine *e, struct Particle *p, FPTYPE *x, struct Particle **result)
Add a #part to a space at the given coordinates. The given particle p is only used for the attributes...
HRESULT engine_angle_eval(struct engine *e)
Compute the angled interactions stored in this engine.
struct TissueForge::engine engine
HRESULT engine_rigid_eval(struct engine *e)
Resolve the constraints.
HRESULT engine_init(struct engine *e, const FPTYPE *origin, const FPTYPE *dim, int *cells, FPTYPE cutoff, BoundaryConditionsArgsContainer *boundaryConditions, int max_type, unsigned int flags, unsigned int nr_fluxsteps)
Initialize an engine with the given data.
HRESULT engine_timers_reset(struct engine *e)
Set all the engine timers to 0.
HRESULT engine_shuffle(struct engine *e)
Re-shuffle the particles in the engine.
int engine_bond_alloc(struct engine *e, struct Bond **result)
HRESULT engine_bonded_sets(struct engine *e, int max_sets)
Assemble non-conflicting sets of bonded interactions.
HRESULT engine_barrier(struct engine *e)
Barrier routine to hold the runners back.
HRESULT engine_load_ghosts(struct engine *e, FPTYPE *x, FPTYPE *v, int *type, int *pid, int *vid, FPTYPE *q, unsigned int *flags, int N)
Load a set of particle data as ghosts.
HRESULT engine_finalize(struct engine *e)
Kill all runners and de-allocate the data of an engine.
HRESULT engine_split_bisect(struct engine *e, int N, int particle_flags)
Split the computational domain over a number of nodes using bisection.
HRESULT engine_flush(struct engine *e)
Clear all particles from this engine.
HRESULT engine_bond_eval(struct engine *e)
Compute the bonded interactions stored in this engine.
int engine_next_partid(struct engine *e)
HRESULT engine_exclusion_eval(struct engine *e)
Compute the exclusioned interactions stored in this engine.
struct TissueForge::engine_set engine_set
HRESULT engine_rigid_add(struct engine *e, int pid, int pjd, FPTYPE d)
Add a rigid constraint to the engine.
HRESULT engine_next_partids(struct engine *e, int nr_ids, int *ids)
HRESULT space_setpos(struct space *s, int id, FPTYPE *x)
Set the absolute position of a particle.
int engine_unload_marked(struct engine *e, FPTYPE *x, FPTYPE *v, int *type, int *pid, int *vid, FPTYPE *q, unsigned int *flags, FPTYPE *epot, int N)
Unload a set of particle data from the marked cells of an engine.
int engine_addtype(struct engine *e, FPTYPE mass, FPTYPE charge, const char *name, const char *name2)
Add a type definition.
HRESULT engine_del_particle(struct engine *e, int pid)
HRESULT space_getpos(struct space *s, int id, FPTYPE *x)
Get the absolute position of a particle.
HRESULT engine_step(struct engine *e)
Run the engine for a single time step.
HRESULT engine_load(struct engine *e, FPTYPE *x, FPTYPE *v, int *type, int *pid, int *vid, FPTYPE *charge, unsigned int *flags, int N)
Load a set of particle data.
HRESULT engine_split(struct engine *e)
Set-up the engine for distributed-memory parallel operation.
struct ParticleType * engine_type(int id)
HRESULT engine_bonded_eval(struct engine *e)
Compute all bonded interactions stored in this engine.
HRESULT engine_exclusion_add(struct engine *e, int i, int j)
Add a exclusioned interaction to the engine.
HRESULT engine_addpot(struct engine *e, struct Potential *p, int i, int j)
Add an interaction potential.
HRESULT engine_flush_ghosts(struct engine *e)
Clear all particles from this engine's ghost cells.
int engine_unload(struct engine *e, FPTYPE *x, FPTYPE *v, int *type, int *pid, int *vid, FPTYPE *charge, unsigned int *flags, FPTYPE *epot, int N)
Unload a set of particle data from the engine.
HRESULT engine_rigid_sort(struct engine *e)
Split the rigids into local, semilocal and non-local.
HRESULT engine_reset(struct engine *e)
HRESULT engine_dihedral_eval(struct engine *e)
Compute the dihedral interactions stored in this engine.
engine _Engine
HRESULT engine_verlet_update(struct engine *e)
Check if the Verlet-list needs to be updated.
int engine_unload_strays(struct engine *e, FPTYPE *x, FPTYPE *v, int *type, int *pid, int *vid, FPTYPE *q, unsigned int *flags, FPTYPE *epot, int N)
Unload real particles that may have wandered into a ghost cell.
HRESULT engine_start(struct engine *e, int nr_runners, int nr_queues)
Start the runners in the given engine.
int engine_gettype(struct engine *e, char *name)
Look for a given type by name.
HRESULT engine_force_prep(struct engine *e)
HRESULT engine_add_singlebody_force(struct engine *e, struct Force *p, int typeId)
int engine_angle_alloc(struct engine *e, Angle **out)
HRESULT engine_addparts(struct engine *e, int nr_parts, struct Particle **parts, FPTYPE **x)
Add parts to space at given coordinates.
HRESULT engine_rigid_unsort(struct engine *e)
Shuffle the rigid constraints randomly.
HRESULT engine_nonbond_eval(struct engine *e)
Compute the nonbonded interactions in the current step.
struct TissueForge::engine_comm engine_comm
HRESULT engine_bonded_eval_sets(struct engine *e)
Compute all bonded interactions stored in this engine.
HRESULT engine_fluxonly_eval(struct engine *e)
Compute the flux interaction only in the current step.
HRESULT engine_exclusion_shrink(struct engine *e)
Remove duplicate exclusions.
HRESULT engine_force(struct engine *e)
Fluxes * engine_getfluxes(struct engine *e, int i, int j)
Get a fluxes between two particles.
int engine_gettype2(struct engine *e, char *name2)
Look for a given type by its second name.
A bond concerning an angle.
Definition tfAngle.h:60
Bonds apply a potential to a particular set of particles.
Definition tfBond.h:68
Definition tfBoundaryConditions.h:224
The BoundaryConditions class serves as a container for the six instances of the :class:BoundaryCondit...
Definition tfBoundaryConditions.h:117
A custom force function.
Definition tfForce.h:200
Definition tfDihedral.h:54
A flux is defined between a pair of types, and acts on the state vector between a pair of instances.
Definition tfFlux.h:88
Force is a metatype, in that Tissue Forge has lots of different instances of force functions,...
Definition tfForce.h:69
Particle * part()
Gets the actual particle of this handle.
Definition tfEngine.h:1414
int id
Definition tfParticle.h:315
ParticleType * type()
Gets the particle type of this handle.
Definition tfEngine.h:1418
Definition tfParticle.h:101
void set_global_position(const FVector3 &pos)
Set the global position.
Definition tfEngine.h:1409
Particle * particle(int i)
Definition tfEngine.h:1399
int32_t * parts
Definition tfParticle.h:209
FVector3 global_position()
Get the global position.
Definition tfEngine.h:1403
Structure containing information on each particle type.
Definition tfParticle.h:768
TissueForge::Particle * particle(int i)
get the i'th particle that's a member of this type.
Definition tfEngine.h:1429
TissueForge::ParticleList parts
list of particles that belong to this type.
Definition tfParticle.h:844
A Potential object is a compiled interpolation of a given function. The Universe applies potentials t...
Definition tfPotential.h:213
Definition tfEngine.h:447
Definition tfEngine.h:424
Definition tfEngine.h:164
int bonds_size
Definition tfEngine.h:261
unsigned int flags
Definition tfEngine.h:167
unsigned int integrator_flags
Definition tfEngine.h:172
std::vector< CustomForce * > custom_forces
Definition tfEngine.h:382
ticks timers[engine_timer_last]
Definition tfEngine.h:364
struct Fluxes ** fluxes
Definition tfEngine.h:212
struct Bond * bonds
Definition tfEngine.h:245
int * part2rigid
Definition tfEngine.h:276
int nr_active_bonds
Definition tfEngine.h:256
FPTYPE particle_max_dist_fraction
Definition tfEngine.h:395
pthread_mutex_t barrier_mutex
Definition tfEngine.h:219
FPTYPE tol_rigid
Definition tfEngine.h:282
int nr_rigids
Definition tfEngine.h:279
struct queue * queues
Definition tfEngine.h:231
struct engine_set * sets
Definition tfEngine.h:367
long time
Definition tfEngine.h:183
struct exclusion * exclusions
Definition tfEngine.h:267
struct runner * runners
Definition tfEngine.h:228
int nr_angles
Definition tfEngine.h:290
int nodeID
Definition tfEngine.h:235
static const int max_type
Definition tfEngine.h:193
static struct ParticleType * types
Definition tfEngine.h:197
std::vector< SubEngine * > subengines
Borrowed references to registered subengines.
Definition tfEngine.h:410
int dihedrals_size
Definition tfEngine.h:316
struct Dihedral * dihedrals
Definition tfEngine.h:302
int nr_active_dihedrals
Definition tfEngine.h:313
struct Potential ** p
Definition tfEngine.h:200
int angles_size
Definition tfEngine.h:299
struct engine_comm * send
Definition tfEngine.h:239
int nr_bonds
Definition tfEngine.h:250
int nr_runners
Definition tfEngine.h:225
BoundaryConditionsArgsContainer * _init_boundary_conditions
Definition tfEngine.h:416
struct Angle * angles
Definition tfEngine.h:285
struct rigid * rigids
Definition tfEngine.h:273
struct space s
Definition tfEngine.h:180
int nr_dihedrals
Definition tfEngine.h:307
struct Force ** forces
Definition tfEngine.h:206
int nr_exclusions
Definition tfEngine.h:270
std::set< unsigned int > pids_avail
Definition tfEngine.h:242
int nr_active_angles
Definition tfEngine.h:296
Definition tfExclusion.h:38
Definition tfQueue.h:43
Definition tfRigid.h:46
Definition tfRunner.h:115
Definition tfSpace.h:127
int32_t HRESULT
Definition tf_port.h:255