Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
Lattice.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2008-2018 Luthey-Schulten Group,
4 * Copyright 2012 Roberts Group,
5 * All rights reserved.
6 *
7 * Developed by: Luthey-Schulten Group
8 * University of Illinois at Urbana-Champaign
9 * http://www.scs.uiuc.edu/~schulten
10 *
11 * Developed by: Roberts Group
12 * Johns Hopkins University
13 * http://biophysics.jhu.edu/roberts/
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a copy of
16 * this software and associated documentation files (the Software), to deal with
17 * the Software without restriction, including without limitation the rights to
18 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
19 * of the Software, and to permit persons to whom the Software is furnished to
20 * do so, subject to the following conditions:
21 *
22 * - Redistributions of source code must retain the above copyright notice,
23 * this list of conditions and the following disclaimers.
24 *
25 * - Redistributions in binary form must reproduce the above copyright notice,
26 * this list of conditions and the following disclaimers in the documentation
27 * and/or other materials provided with the distribution.
28 *
29 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
30 * Urbana-Champaign, the Roberts Group, Johns Hopkins University, nor the names
31 * of its contributors may be used to endorse or promote products derived from
32 * this Software without specific prior written permission.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
38 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
39 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 * OTHER DEALINGS WITH THE SOFTWARE.
41 *
42 * Author(s): Elijah Roberts
43 */
44
45#ifndef LM_RDME_LATTICE_H_
46#define LM_RDME_LATTICE_H_
47
48//using namespace std; //TODO: workaround for cuda compiler bug, remove this line when fixed.
49#include <vector>
50#include <map>
51#include "core/Types.h"
52#include "core/Exceptions.h"
53
54// Type to store a lattice index.
55typedef uint32_t lattice_size_t;
56
69
70// Type to store a particle index in a site.
71typedef uint32_t site_size_t;
72
73// Type to store a lattice site type.
74typedef uint32_t site_t;
75
76// Type to store a lattice particle type.
77typedef uint32_t particle_t;
78
97
98namespace lm {
99namespace rdme {
100
101unsigned int getCompiledLatticeMaxOccupancy();
102
117
121{
122public:
125 InvalidParticleException(site_size_t particleIndex) : InvalidArgException("particleIndex", "Invalid particle index", particleIndex) {}
126};
127
128
132{
133public:
134 static void rowMajorByteSerialize(void * destBuffer, void * lattice, size_t bufferSize);
135 static void rowMajorIntSerialize(void * destBuffer, void * lattice, size_t bufferSize);
136 static void rowMajorByteSerializeSites(void * destBuffer, void * lattice, size_t bufferSize);
137
138public:
139 // Lattice limits.
141 virtual site_t getMaxSiteType() const =0;
143 virtual particle_t getMaxParticle() const =0;
145 virtual site_size_t getMaxOccupancy() const =0;
146
147public:
159 virtual ~Lattice();
160
161 // Size related methods
163 virtual lattice_coord_t getSize() const;
165 virtual lattice_size_t getXSize() const;
167 virtual lattice_size_t getYSize() const;
169 virtual lattice_size_t getZSize() const;
171 virtual lattice_size_t getNumberSites() const;
173 virtual si_dist_t getSpacing() const;
174
175
179 virtual void getNeighboringSites(lattice_size_t index, lattice_size_t * neighboringIndices)=0;
180
181
182 // Lattice site methods.
186 virtual site_t getSiteType(lattice_size_t index) const = 0;
190 virtual void setSiteType(lattice_size_t index, site_t site) = 0;
197 std::vector<lattice_coord_t> getNearbySites(lattice_size_t xc, lattice_size_t yc, lattice_size_t zc, uint minDistance, uint maxDistance);
198
199// Need to remove this from the base class, can't assume a datatype for particlelattice
200// virtual void getParticleLatticeView(uint8_t **particleLattice, int *Nw, int *Nz, int *Ny, int *Nx, int *Np) = 0;
201// virtual void getSiteLatticeView(uint8_t **siteLattice, int *Nz, int *Ny, int *Nx) = 0;
202
203
204 // Particle methods.
208 virtual site_size_t getOccupancy(lattice_size_t index) const = 0;
209
213 virtual particle_t getParticle(lattice_size_t index, site_size_t particleIndex) const = 0;
214
218 virtual void addParticle(lattice_size_t index, particle_t particle) = 0;
222 virtual void removeParticles(lattice_size_t index) = 0;
224 virtual void removeAllParticles();
225
229
230 // Search for a particle from the start of the lattice.
231 /*virtual particle_loc_t findParticle(particle_t particle)=0;
232 virtual particle_loc_t findNextParticle(particle_loc_t previousParticle)=0;
233
234 // Search for a particle starting from a given location.
235 virtual particle_loc_t findNearbyParticle(particle_loc_t particle)=0;
236 */
237
238 // Counts all of the particles on the lattice.
240 virtual std::map<particle_t,uint> getParticleCounts()=0;
241
242 //Finds all of the particle of a given range of types.
244 virtual std::vector<particle_loc_t> findParticles(particle_t minParticleType, particle_t maxParticleType)=0;
245
247 virtual void print() const;
248
249 // Methods to set the data directly.
250 virtual void setFromRowMajorByteData(void * buffer, size_t bufferSize)=0;
251 virtual void setSitesFromRowMajorByteData(void * buffer, size_t bufferSize)=0;
252
253 virtual size_t getLatticeMemorySize() const = 0;
254
255protected:
256 lattice_coord_t size; // Dimension of lattice as (x, y, z)
257 lattice_size_t numberSites; // Number of total sites (e.g. x*y*z)
258 si_dist_t spacing; // Physical spacing of the lattice (i.e. in units of nm, um, mm, etc.)
259};
260
261
262}
263}
264
265#endif
uint32_t site_size_t
Definition ByteLatticeExtended.h:23
uint32_t particle_t
Definition ByteLatticeExtended.h:19
uint32_t lattice_size_t
Definition Lattice.h:55
uint32_t site_t
Definition Lattice.h:74
double si_dist_t
Definition Types.h:63
unsigned int uint
Definition Types.h:52
Lattice(lattice_coord_t size, si_dist_t spacing)
Create a Lattice object.
Definition Lattice.cpp:65
InvalidArgException(const char *argMessage)
Definition Exceptions.h:105
InvalidParticleException(site_size_t particleIndex)
Create an eception based on the particle index.
Definition Lattice.h:125
InvalidSiteException(lattice_size_t index)
Create an exception based on the lattice index.
Definition Lattice.h:115
InvalidSiteException(lattice_size_t x, lattice_size_t y, lattice_size_t z)
Create an exception based on the lattice location.
Definition Lattice.h:112
static void rowMajorIntSerialize(void *destBuffer, void *lattice, size_t bufferSize)
Definition Lattice.cpp:151
virtual ~Lattice()
Destroy the Lattice object.
Definition Lattice.cpp:74
Lattice(lattice_coord_t size, si_dist_t spacing)
Create a Lattice object.
Definition Lattice.cpp:65
virtual void removeParticles(lattice_size_t index)=0
Remove a particle to the specified site.
virtual void addParticle(lattice_size_t x, lattice_size_t y, lattice_size_t z, particle_t particle)=0
Add a particle to the specified site.
std::vector< lattice_coord_t > getNearbySites(lattice_size_t xc, lattice_size_t yc, lattice_size_t zc, uint minDistance, uint maxDistance)
Get a list of sites near the specified site within a certain distance.
Definition Lattice.cpp:106
virtual site_size_t getMaxOccupancy() const =0
Get the maximum number of particles that can live in a site.
virtual site_t getSiteType(lattice_size_t index) const =0
Get the site type at the specified location.
virtual particle_t getParticle(lattice_size_t index, site_size_t particleIndex) const =0
Get the particle at the specified site with at the specified number in the particle list.
virtual void addParticle(lattice_size_t index, particle_t particle)=0
Add a particle to the specified site.
virtual particle_t getMaxParticle() const =0
Get the maximum number of particle types possible in the lattice.
lattice_coord_t size
Definition Lattice.h:256
virtual si_dist_t getSpacing() const
Get spacing between lattice sites.
Definition Lattice.cpp:101
si_dist_t spacing
Definition Lattice.h:258
virtual void setSiteType(lattice_size_t index, site_t site)=0
Set the site type at the specified location.
virtual void print() const
Print the lattice to the console.
Definition Lattice.cpp:176
virtual site_t getSiteType(lattice_size_t x, lattice_size_t y, lattice_size_t z) const =0
Get the site type at the specified location.
virtual void setSitesFromRowMajorByteData(void *buffer, size_t bufferSize)=0
virtual void getNeighboringSites(lattice_size_t index, lattice_size_t *neighboringIndices)=0
Get the sites that are neighbor to the indicated site.
virtual lattice_size_t getZSize() const
Get z dimension of the Lattice.
Definition Lattice.cpp:91
virtual void removeParticles(lattice_size_t x, lattice_size_t y, lattice_size_t z)=0
Remove a particle to the specified site.
virtual lattice_size_t getXSize() const
Get x dimension of the Lattice.
Definition Lattice.cpp:81
virtual particle_t getParticle(lattice_size_t x, lattice_size_t y, lattice_size_t z, site_size_t particleIndex) const =0
Get the particle at the specified site with at the specified number in the particle list.
virtual site_size_t getOccupancy(lattice_size_t x, lattice_size_t y, lattice_size_t z) const =0
Get the number of particles in the specified lattice site.
lattice_size_t numberSites
Definition Lattice.h:257
virtual site_size_t getOccupancy(lattice_size_t index) const =0
Get the number of particles in the specified lattice site.
static void rowMajorByteSerializeSites(void *destBuffer, void *lattice, size_t bufferSize)
Definition Lattice.cpp:164
virtual std::map< particle_t, uint > getParticleCounts()=0
Get the number of each particle type in the lattice.
virtual lattice_size_t getYSize() const
Get y dimension of the Lattice.
Definition Lattice.cpp:86
virtual void removeAllParticles()
Empty all particles from the specified site.
Definition Lattice.cpp:130
virtual std::vector< particle_loc_t > findParticles(particle_t minParticleType, particle_t maxParticleType)=0
Get the number of the specified particles types in the lattice.
static void rowMajorByteSerialize(void *destBuffer, void *lattice, size_t bufferSize)
Definition Lattice.cpp:138
virtual lattice_coord_t getSize() const
Get size of the Lattice.
Definition Lattice.cpp:76
virtual void setFromRowMajorByteData(void *buffer, size_t bufferSize)=0
virtual lattice_size_t getNumberSites() const
Get total number of sites in the Lattice.
Definition Lattice.cpp:96
virtual void setSiteType(lattice_size_t x, lattice_size_t y, lattice_size_t z, site_t site)=0
Set the site type at the specified location.
virtual site_t getMaxSiteType() const =0
Get the maximum number of site types possible in the lattice.
virtual size_t getLatticeMemorySize() const =0
unsigned int getCompiledLatticeMaxOccupancy()
Definition Lattice.cpp:60
Definition Capsule.cpp:46
Type to store a lattice coordinate.
Definition Lattice.h:59
lattice_size_t y
Definition Lattice.h:66
lattice_coord_t(lattice_size_t x=0, lattice_size_t y=0, lattice_size_t z=0)
Create a lattice coordinate.
Definition Lattice.h:64
lattice_size_t z
Definition Lattice.h:67
lattice_size_t x
Definition Lattice.h:65
particle_t p
Definition Lattice.h:89
lattice_size_t z
Definition Lattice.h:94
lattice_size_t x
Definition Lattice.h:92
site_size_t index
Definition Lattice.h:95
particle_loc_t(particle_t p=0, lattice_size_t x=0, lattice_size_t y=0, lattice_size_t z=0, site_size_t index=0)
Create a particle location.
Definition Lattice.h:88
lattice_size_t y
Definition Lattice.h:93