Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
ByteLattice.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2008-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Elijah Roberts
38 */
39
40#ifndef LM_RDME_BYTELATTICE_H_
41#define LM_RDME_BYTELATTICE_H_
42
43#include <map>
44#include "core/Types.h"
45#include "rdme/Lattice.h"
46
47namespace lm {
48namespace rdme {
49
52class ByteLattice : public Lattice
53{
54 // TODO: total hack. Needed to access the actual data structures
55 // Should modify CudaByteLattice to do what I need.
56 friend class MGPUMpdRdmeSolver;
57 friend class MPIMpdRdmeSolver;
58 friend class MpdRdmeSolver;
59
60public:
61 static void nativeSerialize(void * destBuffer, void * lattice, size_t latticeSize);
62 static void nativeSerializeSites(void * destBuffer, void * lattice, size_t latticeSize);
63 static void copyNativeToRowMajorByte(void * destBuffer, void * sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, uint particlesPerSite, size_t bufferSize);
64 static void copyRowMajorByteToNative(void * destBuffer, void * sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, uint particlesPerSite, size_t bufferSize);
65 static void copySitesRowMajorByteToNative(void * destBuffer, void * sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, size_t bufferSize);
66 static void copySitesNativeToRowMajorByte(void * destBuffer, void * sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, size_t bufferSize);
67
68public:
69 // Lattice limits.
70 virtual site_t getMaxSiteType() const;
71 virtual particle_t getMaxParticle() const;
72 virtual site_size_t getMaxOccupancy() const;
73
74public:
76 ByteLattice(lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, si_dist_t spacing, uint particlesPerSite);
77 virtual ~ByteLattice();
78
79 virtual void getNeighboringSites(lattice_size_t index, lattice_size_t * neighboringIndices);
80
81 // Lattice site methods.
83 virtual site_t getSiteType(lattice_size_t subvolume) const;
84 virtual void setSiteType(lattice_size_t x, lattice_size_t y, lattice_size_t z, site_t siteType);
85 virtual void setSiteType(lattice_size_t subvolume, site_t site);
86
87 void copySites(void * destBuffer, size_t latticeSize);
88
89 // Particle methods.
91 virtual site_size_t getOccupancy(lattice_size_t subvolume) const;
93 virtual particle_t getParticle(lattice_size_t subvolume, site_size_t particleIndex) const;
95 virtual void addParticle(lattice_size_t subvolume, particle_t particle);
97 virtual void removeParticles(lattice_size_t subvolume);
98 virtual void removeAllParticles();
99
100 // Particle searching.
101 /*virtual particle_loc_t findParticle(particle_t particle);
102 virtual particle_loc_t findNextParticle(particle_loc_t previousParticle);
103 virtual particle_loc_t findNearbyParticle(particle_loc_t particle)=0;
104 */
105
106 virtual std::map<particle_t,uint> getParticleCounts();
107 virtual std::vector<particle_loc_t> findParticles(particle_t minParticleType, particle_t maxParticleType);
108
109 // Methods to set the data directly.
110 virtual void setFromRowMajorByteData(void * buffer, size_t bufferSize);
111 virtual void setSitesFromRowMajorByteData(void * buffer, size_t bufferSize);
112
113 virtual void getParticleLatticeView(uint8_t **particleLattice, int *Nw, int *Nz, int *Ny, int *Nx, int *Np);
114 virtual void getSiteLatticeView(uint8_t **siteLattice, int *Nz, int *Ny, int *Nx);
115
116 virtual size_t getLatticeMemorySize() const;
117
118protected:
119 virtual void allocateMemory();
120 virtual void deallocateMemory();
121 virtual uint32_t* getParticlesMemory();
122 virtual uint8_t* getSitesMemory();
123
124protected:
125 size_t wordsPerSite; // Number of bytes per site
126 uint32_t * particles; // Array of lists of particles at each site
127 uint8_t * siteTypes; // Array of site types representing the lattice
128
129private:
130 static const uint PARTICLES_PER_WORD = 4;
131};
132
133}
134}
135
136#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
virtual std::vector< particle_loc_t > findParticles(particle_t minParticleType, particle_t maxParticleType)
Get the number of the specified particles types in the lattice.
Definition ByteLattice.cpp:522
static void nativeSerialize(void *destBuffer, void *lattice, size_t latticeSize)
Definition ByteLattice.cpp:350
virtual void getSiteLatticeView(uint8_t **siteLattice, int *Nz, int *Ny, int *Nx)
Definition ByteLattice.cpp:135
virtual void getParticleLatticeView(uint8_t **particleLattice, int *Nw, int *Nz, int *Ny, int *Nx, int *Np)
Definition ByteLattice.cpp:142
static void copyRowMajorByteToNative(void *destBuffer, void *sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, uint particlesPerSite, size_t bufferSize)
Definition ByteLattice.cpp:404
size_t wordsPerSite
Definition ByteLattice.h:125
virtual site_size_t getOccupancy(lattice_size_t x, lattice_size_t y, lattice_size_t z) const
Get the number of particles in the specified lattice site.
Definition ByteLattice.cpp:187
static void copySitesRowMajorByteToNative(void *destBuffer, void *sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, size_t bufferSize)
Definition ByteLattice.cpp:437
virtual void addParticle(lattice_size_t x, lattice_size_t y, lattice_size_t z, particle_t particle)
Add a particle to the specified site.
Definition ByteLattice.cpp:265
virtual site_t getMaxSiteType() const
Get the maximum number of site types possible in the lattice.
Definition ByteLattice.cpp:53
virtual void removeAllParticles()
Empty all particles from the specified site.
Definition ByteLattice.cpp:345
static void copySitesNativeToRowMajorByte(void *destBuffer, void *sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, size_t bufferSize)
Definition ByteLattice.cpp:461
virtual void deallocateMemory()
Definition ByteLattice.cpp:120
friend class MPIMpdRdmeSolver
Definition ByteLattice.h:57
virtual void getNeighboringSites(lattice_size_t index, lattice_size_t *neighboringIndices)
Get the sites that are neighbor to the indicated site.
Definition ByteLattice.cpp:81
virtual site_size_t getMaxOccupancy() const
Get the maximum number of particles that can live in a site.
Definition ByteLattice.cpp:55
virtual size_t getLatticeMemorySize() const
Definition ByteLattice.cpp:104
ByteLattice(lattice_coord_t size, si_dist_t spacing, uint particlesPerSite)
Definition ByteLattice.cpp:57
virtual void setSitesFromRowMajorByteData(void *buffer, size_t bufferSize)
Definition ByteLattice.cpp:490
virtual void setFromRowMajorByteData(void *buffer, size_t bufferSize)
Definition ByteLattice.cpp:485
friend class MGPUMpdRdmeSolver
Definition ByteLattice.h:56
uint32_t * particles
Definition ByteLattice.h:126
virtual particle_t getParticle(lattice_size_t x, lattice_size_t y, lattice_size_t z, site_size_t particleIndex) const
Get the particle at the specified site with at the specified number in the particle list.
Definition ByteLattice.cpp:228
void copySites(void *destBuffer, size_t latticeSize)
Definition ByteLattice.cpp:364
virtual void removeParticles(lattice_size_t x, lattice_size_t y, lattice_size_t z)
Remove a particle to the specified site.
Definition ByteLattice.cpp:316
virtual uint8_t * getSitesMemory()
Definition ByteLattice.cpp:555
virtual uint32_t * getParticlesMemory()
Definition ByteLattice.cpp:550
virtual std::map< particle_t, uint > getParticleCounts()
Get the number of each particle type in the lattice.
Definition ByteLattice.cpp:495
virtual void setSiteType(lattice_size_t x, lattice_size_t y, lattice_size_t z, site_t siteType)
Set the site type at the specified location.
Definition ByteLattice.cpp:169
virtual void allocateMemory()
Definition ByteLattice.cpp:109
uint8_t * siteTypes
Definition ByteLattice.h:127
virtual site_t getSiteType(lattice_size_t x, lattice_size_t y, lattice_size_t z) const
Get the site type at the specified location.
Definition ByteLattice.cpp:151
static void nativeSerializeSites(void *destBuffer, void *lattice, size_t latticeSize)
Definition ByteLattice.cpp:358
static void copyNativeToRowMajorByte(void *destBuffer, void *sourceBuffer, lattice_size_t xSize, lattice_size_t ySize, lattice_size_t zSize, uint particlesPerSite, size_t bufferSize)
Definition ByteLattice.cpp:371
virtual particle_t getMaxParticle() const
Get the maximum number of particle types possible in the lattice.
Definition ByteLattice.cpp:54
friend class MpdRdmeSolver
Definition ByteLattice.h:58
virtual ~ByteLattice()
Definition ByteLattice.cpp:76
Lattice(lattice_coord_t size, si_dist_t spacing)
Create a Lattice object.
Definition Lattice.cpp:65
lattice_coord_t size
Definition Lattice.h:256
si_dist_t spacing
Definition Lattice.h:258
Definition LatticeBuilder.h:60
Definition Capsule.cpp:46
Type to store a lattice coordinate.
Definition Lattice.h:59