hemocell
Loading...
Searching...
No Matches
hemoCellParticle.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along with this program. If not, see <http://www.gnu.org/licenses/>.
23*/
24#ifndef SURFACE_PARTICLE_3D_H
25#define SURFACE_PARTICLE_3D_H
26namespace hemo {
27class HemoCellParticle;
28}
29#include "helper/array.h"
30#include "core/cell.hh"
31#include "config/error.h"
32
33#include <cstdint>
34#include <cstring>
35#include <type_traits>
36#include <utility>
37
38#ifndef PARTICLE_ID
39#define PARTICLE_ID 0
40#endif
41
42namespace hemo {
43
45public:
46 //VARIABLES
47 //Store variables in struct for fast serialization
53#if HEMOCELL_MATERIAL_INTEGRATION == 2
54 hemo::Array<T, 3> vPrevious;
55#endif
57
58 uint16_t vertexId;
59 unsigned int restime;
60
61 unsigned char celltype;
62
63#ifdef SOLIDIFY_MECHANICS
64 bool solidify;
65#endif
66 };
67
69
72#ifdef INTERIOR_VISCOSITY
73 hemo::Array<T, 3> normalDirection;
74 //Is vector, optimize with hemo::Array possible
75 std::vector<hemo::Array<plint, 3>> kernelCoordinates;
76#endif
77
78 std::vector<plb::Cell<T, DESCRIPTOR> *> kernelLocations;
79 std::vector<T> kernelWeights;
80
85 &sv.force; //Default to pointing to force, if output is desired, it can be stored seperately
88
89
90private:
96 inline void adoptForcePointers(const HemoCellParticle & from) {
97 if (from.force_volume == &from.sv.force) {
99 } else {
102 force_link = from.force_link;
103 force_area = from.force_area;
104 force_visc = from.force_visc;
106 }
107 }
108
109public:
112 : sv(copy.sv), force_total(copy.force_total), tag(copy.tag),
113#ifdef INTERIOR_VISCOSITY
114 normalDirection(copy.normalDirection), kernelCoordinates(copy.kernelCoordinates),
115#endif
117 adoptForcePointers(copy);
118 }
119
123 : sv(other.sv), force_total(other.force_total), tag(other.tag),
124#ifdef INTERIOR_VISCOSITY
125 normalDirection(other.normalDirection), kernelCoordinates(std::move(other.kernelCoordinates)),
126#endif
127 kernelLocations(std::move(other.kernelLocations)), kernelWeights(std::move(other.kernelWeights)) {
128 adoptForcePointers(other);
129 }
130
131 HemoCellParticle(hemo::Array<T, 3> position_, plint cellId_, plint vertexId_, pluint celltype_) {
132 // Zero the padding bytes as well: sv is written as raw bytes to
133 // checkpoints, which are then the same for identical runs.
134 static_assert(std::is_trivially_copyable<serializeValues_t>::value, "sv is transferred as raw bytes");
135 std::memset(static_cast<void *>(&sv), 0, sizeof(sv));
136 sv.v = {0., 0., 0.};
137 sv.position = position_;
138 sv.force = {0., 0., 0.};
139 sv.force_repulsion = {0., 0., 0.};
140 sv.cellId = cellId_;
141 sv.vertexId = vertexId_;
142 sv.celltype = celltype_;
143 sv.restime = 0;
144#if HEMOCELL_MATERIAL_INTEGRATION == 2
145 sv.vPrevious = {0., 0., 0.};
146#endif
147#ifdef SOLIDIFY_MECHANICS
148 sv.solidify = false;
149#endif
150 force_total = {0., 0., 0.};
151#ifdef INTERIOR_VISCOSITY
152 normalDirection = {0., 0., 0.};
153#endif
154 tag = -1;
155
156 if (vertexId_ > UINT16_MAX) { fatal("A cell can have at most ", UINT16_MAX + 1, " vertices."); }
157 }
158
160 sv = sv_;
161 force_total = {0., 0., 0.};
162 tag = -1;
163 }
164
166 if (this == &copy) { return *this; }
167 sv = copy.sv;
169 tag = copy.tag;
172#ifdef INTERIOR_VISCOSITY
173 normalDirection = copy.normalDirection;
174 kernelCoordinates = copy.kernelCoordinates;
175#endif
176 adoptForcePointers(copy);
177 return *this;
178 }
179
181 if (this == &other) { return *this; }
182 sv = other.sv;
183 force_total = other.force_total;
184 tag = other.tag;
185 kernelLocations = std::move(other.kernelLocations);
186 kernelWeights = std::move(other.kernelWeights);
187#ifdef INTERIOR_VISCOSITY
188 normalDirection = other.normalDirection;
189 kernelCoordinates = std::move(other.kernelCoordinates);
190#endif
191 adoptForcePointers(other);
192 return *this;
193 }
194
196 HemoCellParticle * sparticle = new HemoCellParticle(*this);
197 return sparticle;
198 }
199
208
210 void advance() {
211/* scheme:
212 * 1: Euler
213 * 2: Adams-Bashforth
214 */
215#if HEMOCELL_MATERIAL_INTEGRATION == 1
216 sv.position += sv.v;
217
218#elif HEMOCELL_MATERIAL_INTEGRATION == 2
219 // vPrevious starts at zero, so the first step uses 1.5*v.
220 const hemo::Array<T, 3> dxyz = (1.5 * sv.v - 0.5 * sv.vPrevious);
221 sv.position += dxyz;
222 sv.vPrevious = sv.v; // Store velocity
223#endif
224 //v = {0.0,0.0,0.0};
225 }
226
227 inline int getId() const { return PARTICLE_ID; }
228 inline plint getTag() { return tag; } //TODO remove for direct access
229 inline void setTag(plint tag_) { tag = tag_; }
230};
231
232}
233#endif // SURFACE_PARTICLE_3D_H
Definition hemoCellParticle.h:44
hemo::Array< T, 3 > * force_area
Definition hemoCellParticle.h:84
hemo::Array< T, 3 > * force_inner_link
Definition hemoCellParticle.h:87
HemoCellParticle & operator=(HemoCellParticle &&other) noexcept
Definition hemoCellParticle.h:180
hemo::Array< T, 3 > * force_visc
Definition hemoCellParticle.h:86
void advance()
Implements Euler integration with velocity alone.
Definition hemoCellParticle.h:210
std::vector< T > kernelWeights
Definition hemoCellParticle.h:79
HemoCellParticle(hemo::Array< T, 3 > position_, plint cellId_, plint vertexId_, pluint celltype_)
Definition hemoCellParticle.h:131
int getId() const
Definition hemoCellParticle.h:227
hemo::Array< T, 3 > force_total
Definition hemoCellParticle.h:70
plint tag
Definition hemoCellParticle.h:71
HemoCellParticle(HemoCellParticle &&other) noexcept
Definition hemoCellParticle.h:122
serializeValues_t sv
Definition hemoCellParticle.h:68
void setTag(plint tag_)
Definition hemoCellParticle.h:229
HemoCellParticle & operator=(const HemoCellParticle &copy)
Definition hemoCellParticle.h:165
std::vector< plb::Cell< T, DESCRIPTOR > * > kernelLocations
Definition hemoCellParticle.h:78
hemo::Array< T, 3 > * force_bending
Definition hemoCellParticle.h:82
hemo::Array< T, 3 > * force_volume
Definition hemoCellParticle.h:81
plint getTag()
Definition hemoCellParticle.h:228
HemoCellParticle(const serializeValues_t &sv_)
Definition hemoCellParticle.h:159
~HemoCellParticle()
Definition hemoCellParticle.h:110
hemo::Array< T, 3 > * force_link
Definition hemoCellParticle.h:83
HemoCellParticle(const HemoCellParticle &copy)
Definition hemoCellParticle.h:111
void adoptForcePointers(const HemoCellParticle &from)
Definition hemoCellParticle.h:96
void repoint_force_vectors()
Definition hemoCellParticle.h:200
HemoCellParticle * clone() const
Definition hemoCellParticle.h:195
long int plint
Definition constant_defaults.h:149
long unsigned int pluint
Definition constant_defaults.h:152
#define PARTICLE_ID
Definition hemoCellParticle.h:39
Definition config.cpp:37
void fatal(const std::string &message)
Report a fatal error and end the whole MPI job.
Definition error.cpp:59
Definition array.h:40
Definition hemoCellParticle.h:48
hemo::Array< T, 3 > v
Definition hemoCellParticle.h:49
unsigned char celltype
Definition hemoCellParticle.h:61
hemo::Array< T, 3 > force_repulsion
Definition hemoCellParticle.h:52
hemo::Array< T, 3 > force
Definition hemoCellParticle.h:51
unsigned int restime
Definition hemoCellParticle.h:59
uint16_t vertexId
Definition hemoCellParticle.h:58
hemo::Array< T, 3 > position
Definition hemoCellParticle.h:50
plint cellId
Definition hemoCellParticle.h:56