Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfSpace_cell.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_TFSPACE_CELL_H_
28#define _MDCORE_INCLUDE_TFSPACE_CELL_H_
29
30#include "tf_platform.h"
31#include <mdcore_config.h>
32#include <pthread.h>
33
34#include <random>
35
36
37/* some constants */
38#define cell_default_size 256
39#define cell_incr 10
40
42#define cell_partalign 64
43
44
45namespace TissueForge {
46
47
49
50 enum CellFlags {
51 cell_flag_none = 0,
52 cell_flag_ghost = 1 << 0,
53 cell_flag_wait = 1 << 1,
54 cell_flag_waited = 1 << 2,
55 cell_flag_marked = 1 << 3,
56 cell_flag_large = 1 << 4,
57
58 cell_active_top = 1 << 5,
59 cell_active_bottom = 1 << 6,
60 cell_active_left = 1 << 7,
61 cell_active_right = 1 << 8,
62 cell_active_front = 1 << 9,
63 cell_active_back = 1 << 10,
64
65 cell_periodic_top = 1 << 11,
66 cell_periodic_bottom = 1 << 12,
67 cell_periodic_left = 1 << 13,
68 cell_periodic_right = 1 << 14,
69 cell_periodic_front = 1 << 15,
70 cell_periodic_back = 1 << 16,
71
72 cell_periodic_x = cell_periodic_left | cell_periodic_right,
73 cell_periodic_y = cell_periodic_front | cell_periodic_back,
74 cell_periodic_z = cell_periodic_top | cell_periodic_bottom,
75
76 cell_active_x = cell_active_left | cell_active_right,
77 cell_active_y = cell_active_front | cell_active_back,
78 cell_active_z = cell_active_top | cell_active_bottom,
79
80 cell_active_any = cell_active_top |
81 cell_active_bottom |
82 cell_active_left |
83 cell_active_right |
84 cell_active_front |
85 cell_active_back
86 };
87
88 /* Map shift vector to sortlist. */
89 CAPI_DATA(const char) cell_sortlistID[27];
90 CAPI_DATA(const FPTYPE) cell_shift[13*3];
91 CAPI_DATA(const char) cell_flip[27];
92
103 typedef struct space_cell {
104
105 /* some flags */
106 unsigned int flags;
107
108 /* The ID of this cell. */
109 int id;
110
111 /* relative cell location */
112 int loc[3];
113
114 /* absolute cell origin */
115 FPTYPE origin[3];
116
117 /* cell dimensions */
118 FPTYPE dim[3];
119
120 /* size and count of particle buffer */
121 int size, count;
122
123 /* the particle buffer */
124 struct Particle *parts;
125
126 /* buffer to store the potential energy */
127 FPTYPE epot;
128
129 /* a buffer to store incomming parts. */
130 struct Particle *incomming;
131 int incomming_size, incomming_count;
132
133 /* Mutex for synchronized cell access. */
134 pthread_mutex_t cell_mutex;
135 pthread_cond_t cell_cond;
136
137 /* Old particle positions for the verlet lists. */
138 FPTYPE *oldx;
139 int oldx_size;
140
141 /* ID of the node this cell belongs to. */
142 int nodeID;
143
144 /* Pointer to sorted cell data. */
145 unsigned int *sortlist;
146
147 /* Sorting task for this cell. */
148 struct task *sort;
149
150 /* ID of the GPU this cell belongs to. */
151 int GPUID;
152
153 /* Volume contribution of this cell. */
154 FPTYPE computed_volume;
155
157
158
159 /* associated functions */
160
169 HRESULT space_cell_init(struct space_cell *c, int *loc, FPTYPE *origin, FPTYPE *dim);
170
182 struct Particle *space_cell_add(struct space_cell *c, struct Particle *p, struct Particle **partlist);
183
191 HRESULT space_cell_remove(struct space_cell *c, struct Particle *p, struct Particle **partlist);
192
206
218 int space_cell_add_incomming_multiple(struct space_cell *c, struct Particle *p, int count);
219
226 HRESULT space_cell_welcome(struct space_cell *c, struct Particle **partlist);
227
238 struct space_cell *c,
239 struct Particle *parts,
240 int nr_parts,
241 struct Particle **partlist,
242 struct space_cell **celllist
243 );
244
249 FPTYPE space_cell_gaussian(int cell_id);
250
258 HRESULT space_cell_flush(struct space_cell *c, struct Particle **partlist, struct space_cell **celllist);
259
260};
261
262#include <iostream>
263std::ostream& operator<<(std::ostream& os, const TissueForge::space_cell*);
264
265#endif // _MDCORE_INCLUDE_TFSPACE_CELL_H_
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
struct Particle * space_cell_add_incomming(struct space_cell *c, struct Particle *p)
Add a particle to the incomming array of a cell.
CellFlags
Definition tfSpace_cell.h:50
struct Particle * space_cell_add(struct space_cell *c, struct Particle *p, struct Particle **partlist)
Add a particle to a cell.
HRESULT space_cell_flush(struct space_cell *c, struct Particle **partlist, struct space_cell **celllist)
Flush all the parts from a #cell.
HRESULT space_cell_load(struct space_cell *c, struct Particle *parts, int nr_parts, struct Particle **partlist, struct space_cell **celllist)
Load a block of particles to the cell.
FPTYPE space_cell_gaussian(int cell_id)
HRESULT space_cell_welcome(struct space_cell *c, struct Particle **partlist)
Move particles from the incomming buffer to the cell.
struct TissueForge::space_cell space_cell
the space_cell structure
HRESULT space_cell_init(struct space_cell *c, int *loc, FPTYPE *origin, FPTYPE *dim)
Initialize the given cell.
int space_cell_add_incomming_multiple(struct space_cell *c, struct Particle *p, int count)
Add one or more particles to the incomming array of a cell.
HRESULT space_cell_remove(struct space_cell *c, struct Particle *p, struct Particle **partlist)
Remove a particle from a cell.
Definition tfParticle.h:101
the space_cell structure
Definition tfSpace_cell.h:103
Definition tfTask.h:60
int32_t HRESULT
Definition tf_port.h:255