Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
ParticleSizeManager.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2024 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
18#ifndef LM_PARTICLE_SIZE_MANAGER_H
19#define LM_PARTICLE_SIZE_MANAGER_H
20
21#include <vector>
22#include <algorithm>
23#include <stdexcept>
24#include <string>
25#include <map>
26#include "core/Types.h"
27#include "core/Exceptions.h"
28
29// Ensure required types are defined
30#ifndef particle_t
31typedef uint32_t particle_t;
32#endif
33
34#ifndef site_size_t
35typedef uint32_t site_size_t;
36#endif
37
38namespace lm {
39namespace rdme {
40
49public:
54 explicit ParticleSizeManager(uint32_t maxParticleTypes = 256);
55
60
67 void setParticleSize(particle_t particleType, uint32_t size);
68
74 uint32_t getParticleSize(particle_t particleType) const;
75
82 uint32_t calculateSiteOccupancy(const particle_t* particles, site_size_t count) const;
83
92 bool canAddParticle(const particle_t* particles, site_size_t count,
93 particle_t newParticle, uint32_t maxCapacity) const;
94
104 bool canAddParticles(const particle_t* particles, site_size_t count,
105 const particle_t* newParticles, site_size_t newCount,
106 uint32_t maxCapacity) const;
107
115 uint32_t getMaxParticleCount(particle_t particleType, uint32_t currentOccupancy,
116 uint32_t maxCapacity) const;
117
122 void validateConfiguration() const;
123
128 const std::vector<uint32_t>& getParticleSizes() const;
129
133 void clear();
134
139 size_t getConfiguredParticleCount() const;
140
145 void setParticleSizesFromDict(const std::map<particle_t, uint32_t>& sizeDict);
146
151 std::map<particle_t, uint32_t> getParticleSizesDict() const;
152
153private:
154 std::vector<uint32_t> particleSizes_;
155 uint32_t maxParticleTypes_;
156
161 void ensureCapacity(particle_t particleType);
162};
163
168public:
169 explicit ParticleSizeException(const char* message)
170 : Exception(message) {}
171
172 explicit ParticleSizeException(const std::string& message)
173 : Exception(message.c_str()) {}
174};
175
176} // namespace rdme
177} // namespace lm
178
179#endif // LM_PARTICLE_SIZE_MANAGER_H
uint32_t site_size_t
Definition ByteLatticeExtended.h:23
uint32_t particle_t
Definition ByteLatticeExtended.h:19
Exception(const char *message="")
Create an Exception.
Definition Exceptions.h:62
ParticleSizeException(const char *message)
Definition ParticleSizeManager.h:169
ParticleSizeException(const std::string &message)
Definition ParticleSizeManager.h:172
bool canAddParticles(const particle_t *particles, site_size_t count, const particle_t *newParticles, site_size_t newCount, uint32_t maxCapacity) const
Check if particles can be added without exceeding capacity.
Definition ParticleSizeManager.cpp:68
std::map< particle_t, uint32_t > getParticleSizesDict() const
Get particle sizes as a dictionary/map.
Definition ParticleSizeManager.cpp:127
const std::vector< uint32_t > & getParticleSizes() const
Get all configured particle sizes.
Definition ParticleSizeManager.cpp:100
uint32_t getMaxParticleCount(particle_t particleType, uint32_t currentOccupancy, uint32_t maxCapacity) const
Get maximum number of particles of a type that can fit.
Definition ParticleSizeManager.cpp:77
ParticleSizeManager(uint32_t maxParticleTypes=256)
Constructor with maximum particle types.
Definition ParticleSizeManager.cpp:16
void setParticleSizesFromDict(const std::map< particle_t, uint32_t > &sizeDict)
Set particle sizes from a dictionary/map.
Definition ParticleSizeManager.cpp:121
uint32_t getParticleSize(particle_t particleType) const
Get the size for a specific particle type.
Definition ParticleSizeManager.cpp:39
void validateConfiguration() const
Validate particle size configuration.
Definition ParticleSizeManager.cpp:90
size_t getConfiguredParticleCount() const
Get number of configured particle types.
Definition ParticleSizeManager.cpp:108
~ParticleSizeManager()=default
Destructor.
void setParticleSize(particle_t particleType, uint32_t size)
Set the size for a specific particle type.
Definition ParticleSizeManager.cpp:21
void clear()
Clear all particle size configurations.
Definition ParticleSizeManager.cpp:104
bool canAddParticle(const particle_t *particles, site_size_t count, particle_t newParticle, uint32_t maxCapacity) const
Check if adding a particle would exceed capacity.
Definition ParticleSizeManager.cpp:60
uint32_t calculateSiteOccupancy(const particle_t *particles, site_size_t count) const
Calculate total size of particles at a site.
Definition ParticleSizeManager.cpp:46
Definition SimulationParameters.h:51
Definition LatticeBuilder.h:60
Definition Capsule.cpp:46