27#ifndef _MDCORE_INCLUDE_TFPARTICLE_H_
28#define _MDCORE_INCLUDE_TFPARTICLE_H_
29#include "tf_platform.h"
45#define CLUSTER_PARTLIST_INCR 50
56 typedef enum ParticleTypeFlags {
57 PARTICLE_TYPE_NONE = 0,
58 PARTICLE_TYPE_INERTIAL = 1 << 0,
59 PARTICLE_TYPE_DISSAPATIVE = 1 << 1,
62 typedef enum ParticleDynamics {
63 PARTICLE_NEWTONIAN = 0,
64 PARTICLE_OVERDAMPED = 1,
68 typedef enum ParticleFlags {
70 PARTICLE_GHOST = 1 << 0,
71 PARTICLE_CLUSTER = 1 << 1,
72 PARTICLE_BOUND = 1 << 2,
73 PARTICLE_FROZEN_X = 1 << 3,
74 PARTICLE_FROZEN_Y = 1 << 4,
75 PARTICLE_FROZEN_Z = 1 << 5,
76 PARTICLE_FROZEN = PARTICLE_FROZEN_X | PARTICLE_FROZEN_Y | PARTICLE_FROZEN_Z,
77 PARTICLE_LARGE = 1 << 6,
85 struct ClusterParticleHandle;
101 struct CAPI_EXPORT Particle {
112 TF_ALIGNED(FPTYPE, 16) f[4];
113 TF_ALIGNED(FVector3, 16) force;
117 FPTYPE number_density;
127 TF_ALIGNED(FVector3, 16) force_i;
133 TF_ALIGNED(FPTYPE, 16) v[4];
134 TF_ALIGNED(FVector3, 16) velocity;
138 FPTYPE inv_number_density;
145 TF_ALIGNED(FPTYPE, 16) x[4];
146 TF_ALIGNED(FVector3, 16) position;
150 uint32_t creation_time;
157 TF_ALIGNED(FVector3, 16) persistent_force;
295 #define VERIFY_PARTICLES() Particle_Verify()
297 #define VERIFY_PARTICLES()
313 struct CAPI_EXPORT ParticleHandle {
337 ParticleHandle(
const int &
id) : id(id) {}
339 virtual std::string str()
const;
341 virtual ParticleHandle* fission();
389 virtual ParticleHandle*
split(
const FVector3& childDirection);
414 virtual ParticleHandle*
split(
const FPTYPE& childRatio);
439 virtual ParticleHandle*
split(
const std::vector<FPTYPE>& speciesRatios);
470 const FVector3& childDirection,
471 const FPTYPE& childRatio,
507 const FVector3& childDirection,
508 const FPTYPE& childRatio,
509 const std::vector<FPTYPE>& speciesRatios,
545 virtual FMatrix3
virial(FPTYPE *radius=NULL);
651 std::vector<struct TissueForge::BondHandle>
getBonds();
654 std::vector<struct TissueForge::AngleHandle>
getAngles();
768 struct CAPI_EXPORT ParticleType {
770 static const int MAX_NAME = 64;
839 char name2[MAX_NAME];
902 FVector3 *position=NULL,
903 FVector3 *velocity=NULL,
931 unsigned int nr_parts=0,
932 std::vector<FVector3> *positions=NULL,
933 std::vector<FVector3> *velocities=NULL,
934 std::vector<int> *clusterIds=NULL
948 bool has(
const int32_t &pid);
975 virtual ParticleType *
get();
977 ParticleType(
const bool &noReg=
false);
978 virtual ~ParticleType() {}
980 virtual std::string str()
const;
1087 const FVector3& childDirection,
1088 const FPTYPE& childRatio,
1089 const std::vector<FPTYPE>* speciesRatios=NULL,
1096 FVector3 *positn=NULL,
1097 FVector3 *velocity=NULL,
1101 std::vector<int> Particles_New(
1102 std::vector<ParticleType*>
types,
1103 std::vector<FVector3> *positions=NULL,
1104 std::vector<FVector3> *velocities=NULL,
1105 std::vector<int> *clusterIds=NULL
1108 std::vector<int> Particles_New(
1110 unsigned int nr_parts=0,
1111 std::vector<FVector3> *positions=NULL,
1112 std::vector<FVector3> *velocities=NULL,
1113 std::vector<int> *clusterIds=NULL
1133 CAPI_FUNC(
bool) ParticleType_checkRegistered(
ParticleType *type);
1146 inline bool operator<=(
const TissueForge::ParticleHandle& lhs,
const TissueForge::ParticleHandle& rhs) {
return !(lhs > rhs); }
1147 inline bool operator>=(
const TissueForge::ParticleHandle& lhs,
const TissueForge::ParticleHandle& rhs) {
return !(lhs < rhs); }
1148 inline bool operator==(
const TissueForge::ParticleHandle& lhs,
const TissueForge::ParticleHandle& rhs) {
return lhs.
id == rhs.
id; }
1149 inline bool operator!=(
const TissueForge::ParticleHandle& lhs,
const TissueForge::ParticleHandle& rhs) {
return !(lhs == rhs); }
1151 inline bool operator< (
const TissueForge::ParticleType& lhs,
const TissueForge::ParticleType& rhs) {
return lhs.
id < rhs.
id; }
1152 inline bool operator> (
const TissueForge::ParticleType& lhs,
const TissueForge::ParticleType& rhs) {
return rhs < lhs; }
1153 inline bool operator<=(
const TissueForge::ParticleType& lhs,
const TissueForge::ParticleType& rhs) {
return !(lhs > rhs); }
1154 inline bool operator>=(
const TissueForge::ParticleType& lhs,
const TissueForge::ParticleType& rhs) {
return !(lhs < rhs); }
1155 inline bool operator==(
const TissueForge::ParticleType& lhs,
const TissueForge::ParticleType& rhs) {
return lhs.
id == rhs.
id; }
1156 inline bool operator!=(
const TissueForge::ParticleType& lhs,
const TissueForge::ParticleType& rhs) {
return !(lhs == rhs); }
1164 os << p.str().c_str();
1170 os << p.str().c_str();
Native Tissue Forge type definitions.
Definition tfMatrix.h:33
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
unsigned int * Particle_Colors
Definition tfParticle.h:1130
Particle * Particle_Get(ParticleHandle *pypart)
ParticleType * ParticleType_ForEngine(struct engine *e, FPTYPE mass, FPTYPE charge, const char *name, const char *name2)
ParticleType * ParticleType_FindFromName(const char *name)
Get a registered particle type by type name.
HRESULT Particle_Verify()
HRESULT Particle_Become(Particle *part, ParticleType *type)
ParticleType * ParticleType_New(const char *_name)
The cluster analogue to :class:Particle.
Definition tfCluster.h:40
The cluster analogue to :class:ParticleHandle.
Definition tfCluster.h:102
The cluster analogue to :class:ParticleType.
Definition tfCluster.h:48
A handle to a particle.
Definition tfParticle.h:313
std::vector< int32_t > neighborIds(const std::vector< ParticleType > &types)
Gets a list of nearby particles ids within the global cutoff distance.
void setMass(const FPTYPE &mass)
std::vector< struct TissueForge::AngleHandle > getAngles()
virtual ParticleHandle * split(const FPTYPE &childRatio)
Splits a single particle into two with sizes according to a given ratio.
ParticleList neighbors(const FPTYPE &distance, const std::vector< ParticleType > &types)
Gets a list of nearby particles.
virtual ParticleHandle * split(const FVector3 &childDirection)
Splits a single particle into two along a given direction.
virtual ParticleHandle * split()
Splits a single particle into two.
Particle * part()
Gets the actual particle of this handle.
Definition tfEngine.h:1414
std::vector< int32_t > neighborIds(const FPTYPE &distance=-FPTYPE_ONE)
Gets a list of nearby particles ids of all types.
virtual ParticleHandle * split(const FVector3 &childDirection, const FPTYPE &childRatio, const std::vector< FPTYPE > &speciesRatios, ParticleType *parentType=NULL, ParticleType *childType=NULL)
Splits a single particle into two along a given direction, with sizes according to a given ratio,...
ParticleList neighbors(const FPTYPE &distance, const TissueForge::ParticleTypeList &types)
Gets a list of nearby particles.
std::vector< struct TissueForge::BondHandle > getBonds()
ParticleList neighbors(const std::vector< ParticleType > &types)
Gets a list of nearby particles within the global cutoff distance.
void setFrozenX(const bool frozen)
void setForceInit(FVector3 force)
FVector3 relativePosition(const FVector3 &origin, const bool &comp_bc=1)
Computes the relative position with respect to an origin while optionally account for boundary condit...
rendering::Style * getStyle()
std::vector< struct TissueForge::DihedralHandle > getDihedrals()
ParticleList neighbors(const FPTYPE &distance)
Gets a list of nearby particles of all types.
void setRadius(const FPTYPE &radius)
void setFrozenY(const bool frozen)
void setCharge(const FPTYPE &charge)
HRESULT destroy()
Destroys the particle and removes it from inventory.
void setFrozenZ(const bool frozen)
std::vector< int32_t > neighborIds(const FPTYPE &distance, const std::vector< ParticleType > &types)
Gets a list of nearby particles ids.
void setFrozen(const bool frozen)
int id
Definition tfParticle.h:315
ParticleList neighbors(const TissueForge::ParticleTypeList &types)
Gets a list of nearby particles within the global cutoff distance.
void setPosition(FVector3 position)
virtual FMatrix3 virial(FPTYPE *radius=NULL)
Computes the virial tensor. Optionally pass a distance to include a neighborhood.
virtual ParticleHandle * split(const FVector3 &childDirection, const FPTYPE &childRatio, ParticleType *parentType=NULL, ParticleType *childType=NULL)
Splits a single particle into two along a given direction, with sizes according to a given ratio,...
virtual ParticleHandle * split(const std::vector< FPTYPE > &speciesRatios)
Splits a single particle into two and allocates species according to given ratios.
std::vector< int32_t > neighborIds(const TissueForge::ParticleTypeList &types)
Gets a list of nearby particles ids within the global cutoff distance.
std::vector< int32_t > getBondedNeighborIds()
Gets a list of all bonded neighbor ids.
Particle * get()
Gets the actual particle of this handle.
Definition tfParticle.h:329
void setStyle(rendering::Style *style)
FPTYPE distance(ParticleHandle *_other)
Calculates the distance to another particle.
ParticleType * type()
Gets the particle type of this handle.
Definition tfEngine.h:1418
ParticleList getBondedNeighbors()
Gets a list of all bonded neighbors.
HRESULT become(ParticleType *type)
Dynamically changes the type of an object. We can change the type of a ParticleType-derived object to...
void setVelocity(FVector3 velocity)
std::vector< int32_t > neighborIds(const FPTYPE &distance, const TissueForge::ParticleTypeList &types)
Gets a list of nearby particles ids.
state::StateVector * getSpecies()
FVector3 sphericalPosition(Particle *particle=NULL, FVector3 *origin=NULL)
Calculates the particle's coordinates in spherical coordinates.
FVector3 & getForceInit()
Definition tfParticle.h:101
void set_global_position(const FVector3 &pos)
Set the global position.
Definition tfEngine.h:1409
int id
Definition tfParticle.h:182
struct state::StateVector * state_vector
Definition tfParticle.h:243
Particle * particle(int i)
Definition tfEngine.h:1399
int16_t typeId
Definition tfParticle.h:185
int32_t * parts
Definition tfParticle.h:209
FPTYPE q
Definition tfParticle.h:170
std::string toString()
Get a JSON string representation.
HRESULT addpart(int32_t uid)
static Particle * fromString(const std::string &str)
Create from a JSON string representation.
int32_t clusterId
Definition tfParticle.h:188
uint16_t size_parts
Definition tfParticle.h:215
FPTYPE radius
Definition tfParticle.h:164
struct ParticleHandle * _handle
Definition tfParticle.h:199
FPTYPE imass
Definition tfParticle.h:161
FVector3 global_position()
Get the global position.
Definition tfEngine.h:1403
uint16_t flags
Definition tfParticle.h:191
struct ParticleHandle * handle()
Get a handle for this particle.
FPTYPE mass
Definition tfParticle.h:167
uint16_t nr_parts
Definition tfParticle.h:212
rendering::Style * style
Definition tfParticle.h:236
HRESULT removepart(int32_t uid)
A special list with convenience methods for working with sets of particles.
Definition tfParticleList.h:52
Structure containing information on each particle type.
Definition tfParticle.h:768
ParticleType * newType(const char *_name)
Particle type constructor.
bool has(ParticleHandle *part)
TissueForge::ParticleHandle * operator()(const std::string &str, int *clusterId=NULL)
Particle constructor.
virtual HRESULT registerType()
Registers a type with the engine.
uint32_t type_flags
Definition tfParticle.h:778
FPTYPE radius
Default radius of particles.
Definition tfParticle.h:801
virtual ParticleType * get()
Get the type engine instance.
std::string toString()
Get a JSON string representation.
TissueForge::ParticleHandle * operator()(FVector3 *position=NULL, FVector3 *velocity=NULL, int *clusterId=NULL)
Particle constructor.
rendering::Style * style
style pointer, optional.
Definition tfParticle.h:854
void setFrozenZ(const bool &frozen)
TissueForge::Particle * particle(int i)
get the i'th particle that's a member of this type.
Definition tfEngine.h:1429
std::vector< int > factory(unsigned int nr_parts=0, std::vector< FVector3 > *positions=NULL, std::vector< FVector3 > *velocities=NULL, std::vector< int > *clusterIds=NULL)
Particle factory constructor, for making lots of particles quickly.
FPTYPE kinetic_energy
Kinetic energy of all particles of this type.
Definition tfParticle.h:806
FPTYPE getTargetTemperature()
FPTYPE eps
Definition tfParticle.h:827
void setTargetTemperature(const FPTYPE &temperature)
FPTYPE target_energy
Target energy of all particles of this type.
Definition tfParticle.h:816
FPTYPE charge
Default charge of particles.
Definition tfParticle.h:796
void setFrozen(const bool &frozen)
TissueForge::ParticleList parts
list of particles that belong to this type.
Definition tfParticle.h:844
std::vector< int32_t > getPartIds()
TissueForge::ParticleList & items()
Get all particles of this type.
bool isRegistered()
Tests whether this type is registered.
FPTYPE minimum_radius
Default minimum radius of this type.
Definition tfParticle.h:824
virtual void on_register()
A callback for when a type is registered.
Definition tfParticle.h:963
void setFrozenY(const bool &frozen)
void setFrozenX(const bool &frozen)
int16_t id
Definition tfParticle.h:773
uint16_t particle_flags
Definition tfParticle.h:784
HRESULT del_part(int32_t id)
char name[MAX_NAME]
Name of this particle type.
Definition tfParticle.h:837
struct state::SpeciesList * species
optional pointer to species list. This is the metadata for the species
Definition tfParticle.h:859
static std::set< short int > particleTypeIds()
Get all current particle type ids, excluding clusters.
static ParticleType * fromString(const std::string &str)
Create from a JSON string representation.
FPTYPE potential_energy
Potential energy of all particles of this type.
Definition tfParticle.h:811
unsigned char dynamics
Default dynamics of particles of this type.
Definition tfParticle.h:832
bool has(const int32_t &pid)
FPTYPE mass
Default mass of particles.
Definition tfParticle.h:789
TissueForge::ParticleTypeList types
list of particle types that belong to this type.
Definition tfParticle.h:849
HRESULT addpart(int32_t id)
A special list with convenience methods for working with sets of particle types.
Definition tfParticleTypeList.h:41
Definition tfEngine.h:164
The Tissue Forge style type.
Definition tfStyle.h:46
Definition tfSpeciesList.h:37
A state vector of an object.
Definition tfStateVector.h:50
int32_t HRESULT
Definition tf_port.h:255