Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfFlux.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of mdcore.
3 * Copyright (c) 2022-2024 T.J. Sego
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
25#ifndef _MDCORE_INCLUDE_TFFLUX_H_
26#define _MDCORE_INCLUDE_TFFLUX_H_
27
28#include "tf_platform.h"
29#include <mdcore_config.h>
30#include <io/tf_io.h>
31#include "tfSpace_cell.h"
32
33#include <string>
34
35
36namespace TissueForge {
37
38
39 enum FluxKind {
40 FLUX_FICK = 0,
41 FLUX_SECRETE = 1,
42 FLUX_UPTAKE = 2
43 };
44
45
46 // keep track of the ids of the particle types, to determine
47 // the reaction direction.
48 struct TypeIdPair {
49 int16_t a;
50 int16_t b;
51 };
52
53 struct CAPI_EXPORT Flux {
54 int32_t size; // temporary size until we get SIMD instructions.
55 int8_t kinds[TF_SIMD_SIZE];
56 TypeIdPair type_ids[TF_SIMD_SIZE];
57 int32_t indices_a[TF_SIMD_SIZE];
58 int32_t indices_b[TF_SIMD_SIZE];
59 FPTYPE coef[TF_SIMD_SIZE];
60 FPTYPE decay_coef[TF_SIMD_SIZE];
61 FPTYPE target[TF_SIMD_SIZE];
62 FPTYPE cutoff[TF_SIMD_SIZE];
63 };
64
65 struct ParticleType;
66
87 struct CAPI_EXPORT Fluxes
88 {
89 int32_t size; // how many individual flux objects this has
90 int32_t fluxes_size; // how many fluxes (blocks) this has.
91 // static int32_t init;
92 Flux fluxes[]; // allocated in single block, this
93
94 static Fluxes* newFluxes(int32_t init_size);
95 static Fluxes *create(
96 FluxKind kind,
97 ParticleType *a,
98 ParticleType *b,
99 const std::string& name,
100 FPTYPE k,
101 FPTYPE decay,
102 FPTYPE target,
103 FPTYPE cutoff=-FPTYPE_ONE
104 );
105 static Fluxes *addFlux(
106 FluxKind kind,
107 Fluxes *fluxes,
108 int16_t typeId_a,
109 int16_t typeId_b,
110 int32_t index_a,
111 int32_t index_b,
112 FPTYPE k,
113 FPTYPE decay,
114 FPTYPE target,
115 FPTYPE cutoff
116 );
117
151 ParticleType *A,
152 ParticleType *B,
153 const std::string &name,
154 const FPTYPE &k,
155 const FPTYPE &decay=FPTYPE_ZERO,
156 const FPTYPE &cutoff=-FPTYPE_ONE
157 );
158
170 static Fluxes *flux(
171 ParticleType *A,
172 ParticleType *B,
173 const std::string &name,
174 const FPTYPE &k,
175 const FPTYPE &decay=FPTYPE_ZERO,
176 const FPTYPE &cutoff=-FPTYPE_ONE
177 );
178
213 ParticleType *A,
214 ParticleType *B,
215 const std::string &name,
216 const FPTYPE &k,
217 const FPTYPE &target,
218 const FPTYPE &decay=FPTYPE_ZERO,
219 const FPTYPE &cutoff=-FPTYPE_ONE
220 );
221
255 static Fluxes *uptake(
256 ParticleType *A,
257 ParticleType *B,
258 const std::string &name,
259 const FPTYPE &k,
260 const FPTYPE &target,
261 const FPTYPE &decay=FPTYPE_ZERO,
262 const FPTYPE &cutoff=-FPTYPE_ONE
263 );
264
270 std::string toString();
271
278 static Fluxes *fromString(const std::string &str);
279 };
280
284 HRESULT Fluxes_integrate(space_cell *cell, FPTYPE dt=-1.0);
285
290
291
292};
293
294#endif // _MDCORE_INCLUDE_TFFLUX_H_
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
HRESULT Fluxes_integrate(space_cell *cell, FPTYPE dt=-1.0)
Definition tfFlux.h:53
A flux is defined between a pair of types, and acts on the state vector between a pair of instances.
Definition tfFlux.h:88
static Fluxes * flux(ParticleType *A, ParticleType *B, const std::string &name, const FPTYPE &k, const FPTYPE &decay=FPTYPE_ZERO, const FPTYPE &cutoff=-FPTYPE_ONE)
Alias of fluxFick.
static Fluxes * fluxFick(ParticleType *A, ParticleType *B, const std::string &name, const FPTYPE &k, const FPTYPE &decay=FPTYPE_ZERO, const FPTYPE &cutoff=-FPTYPE_ONE)
Creates and binds a Fickian diffusion flux.
static Fluxes * secrete(ParticleType *A, ParticleType *B, const std::string &name, const FPTYPE &k, const FPTYPE &target, const FPTYPE &decay=FPTYPE_ZERO, const FPTYPE &cutoff=-FPTYPE_ONE)
Creates a secretion flux by active pumping.
static Fluxes * uptake(ParticleType *A, ParticleType *B, const std::string &name, const FPTYPE &k, const FPTYPE &target, const FPTYPE &decay=FPTYPE_ZERO, const FPTYPE &cutoff=-FPTYPE_ONE)
Creates an uptake flux by active pumping.
static Fluxes * fromString(const std::string &str)
Create from a JSON string representation.
std::string toString()
Get a JSON string representation.
Structure containing information on each particle type.
Definition tfParticle.h:768
Definition tfFlux.h:48
the space_cell structure
Definition tfSpace_cell.h:103
int32_t HRESULT
Definition tf_port.h:255