/usr/include/palabos/particles/visualParticle2D.hh is in libplb-dev 1.5~r1+repack1-2build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | /* This file is part of the Palabos library.
*
* Copyright (C) 2011-2015 FlowKit Sarl
* Route d'Oron 2
* 1010 Lausanne, Switzerland
* E-mail contact: contact@flowkit.com
*
* The most recent release of Palabos can be downloaded at
* <http://www.palabos.org/>
*
* The library Palabos is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* The library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VISUAL_PARTICLE_2D_HH
#define VISUAL_PARTICLE_2D_HH
#include "core/globalDefs.h"
#include "particles/visualParticle2D.h"
namespace plb {
/* *************** class VisualParticle2D ************************************ */
template<typename T, template<typename U> class Descriptor>
int VisualParticle2D<T,Descriptor>::id =
meta::registerVisualParticle2D<T,Descriptor,VisualParticle2D<T,Descriptor> >("Visual");
template<typename T, template<typename U> class Descriptor>
VisualParticle2D<T,Descriptor>::VisualParticle2D()
{ }
template<typename T, template<typename U> class Descriptor>
VisualParticle2D<T,Descriptor>::VisualParticle2D (
plint tag_, Array<T,2> const& position )
: Particle2D<T,Descriptor>(tag_, position)
{ }
template<typename T, template<typename U> class Descriptor>
VisualParticle2D<T,Descriptor>::VisualParticle2D (
plint tag_, Array<T,2> const& position,
std::vector<T> const& scalars_,
std::vector<Array<T,2> > const& vectors_ )
: Particle2D<T,Descriptor>(tag_, position),
scalars(scalars_),
vectors(vectors_)
{ }
template<typename T, template<typename U> class Descriptor>
int VisualParticle2D<T,Descriptor>::getId() const {
return id;
}
template<typename T, template<typename U> class Descriptor>
void VisualParticle2D<T,Descriptor>::reset(Array<T,2> const& position_)
{
Particle2D<T,Descriptor>::reset(position_);
std::fill(scalars.begin(), scalars.end(), T());
std::fill(vectors.begin(), vectors.end(), Array<T,2>(T(),T(),T()));
}
template<typename T, template<typename U> class Descriptor>
void VisualParticle2D<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
{
Particle2D<T,Descriptor>::serialize(serializer);
pluint scalarSize = scalars.size();
serializer.addValue(scalarSize);
for (pluint iScalar=0; iScalar<scalars.size(); ++iScalar) {
serializer.addValue(scalars[iScalar]);
}
pluint vectorSize = vectors.size();
serializer.addValue(vectorSize);
for (pluint iVector=0; iVector<vectors.size(); ++iVector) {
serializer.addValues<T,2>(vectors[iVector]);
}
}
template<typename T, template<typename U> class Descriptor>
void VisualParticle2D<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
{
Particle2D<T,Descriptor>::unserialize(unserializer);
pluint scalarSize;
unserializer.readValue(scalarSize);
PLB_ASSERT(scalarSize == (pluint)scalars.size());
for (pluint iScalar=0; iScalar<scalars.size(); ++iScalar) {
unserializer.readValue(scalars[iScalar]);
}
pluint vectorSize;
unserializer.readValue(vectorSize);
PLB_ASSERT(vectorSize == (pluint)vectors.size());
for (pluint iVector=0; iVector<vectors.size(); ++iVector) {
unserializer.readValues<T,2>(vectors[iVector]);
}
}
template<typename T, template<typename U> class Descriptor>
VisualParticle2D<T,Descriptor>* VisualParticle2D<T,Descriptor>::clone() const {
return new VisualParticle2D<T,Descriptor>(*this);
}
template<typename T, template<typename U> class Descriptor>
bool VisualParticle2D<T,Descriptor>::getVector(plint whichVector, Array<T,2>& vector) const {
if (whichVector<(plint)vectors.size()) {
vector = vectors[whichVector];
return true;
}
return Particle2D<T,Descriptor>::getVector(whichVector, vector);
}
template<typename T, template<typename U> class Descriptor>
bool VisualParticle2D<T,Descriptor>::getScalar(plint whichScalar, T& scalar) const {
if (whichScalar<(plint)scalars.size()) {
scalar = scalars[whichScalar];
return true;
}
return Particle2D<T,Descriptor>::getScalar(whichScalar, scalar);
}
template<typename T, template<typename U> class Descriptor>
bool VisualParticle2D<T,Descriptor>::setScalar(plint whichScalar, T scalar)
{
if (whichScalar<(plint)scalars.size()) {
scalars[whichScalar] = scalar;
return true;
}
else {
return false;
}
}
template<typename T, template<typename U> class Descriptor>
bool VisualParticle2D<T,Descriptor>::setScalars(std::vector<T> const& scalars_)
{
scalars = scalars_;
return true;
}
template<typename T, template<typename U> class Descriptor>
bool VisualParticle2D<T,Descriptor>::setVectors(std::vector<Array<T,2> > const& vectors_)
{
vectors = vectors_;
return true;
}
template<typename T, template<typename U> class Descriptor>
bool VisualParticle2D<T,Descriptor>::setVector(plint whichVector, Array<T,2> const& vector)
{
if (whichVector<(plint)vectors.size()) {
vectors[whichVector] = vector;
return true;
}
else {
return false;
}
}
// /* *************** class MappingParticle2D ************************************ */
//
// template<typename T, template<typename U> class Descriptor>
// MappingParticle2D<T,Descriptor>::MappingParticle2D()
// : PointParticle2D<T,Descriptor>(),
// stage(0),
// pos1(T(),T(),T()),
// pos2(T(),T(),T())
// { }
//
// template<typename T, template<typename U> class Descriptor>
// MappingParticle2D<T,Descriptor>::MappingParticle2D(plint tag_, Array<T,2> const& position_, Array<T,2> const& velocity_)
// : PointParticle2D<T,Descriptor>(tag_, position_, velocity_),
// stage(0),
// pos1(T(),T(),T()),
// pos2(T(),T(),T())
// { }
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticle2D<T,Descriptor>::advance() {
// // Dynamics of a mapping particle.
// // Stage 0: The particle is behind the first surface and is flowing forward.
// // Stage 1: The particle is behind the second surface and is flowing forward.
// // Stage 2: The particle has crossed the second surface and is
// // now walking back along a straight line to the first surface.
// // Stage 3: The particle is back at the first surface and does nothing any more.
//
// // Forward flowing.
// if (stage==0 || stage==1) {
// this->getPosition() += this->getVelocity();
// }
// // Backward walking.
// else if (stage==2) {
// Array<T,2> homeArrow = pos1-this->getPosition();
// T l = norm(homeArrow);
// T step=0.5;
// if (l<step) {
// stage=3;
// this->getPosition() = pos1;
// }
// else {
// this->getPosition() += homeArrow *step/l;
// }
// }
// // Crossed first surface?
// if (stage==0 && crossedSurface1()) {
// stage=1;
// pos1 = this->getPosition();
// }
// // Crossed second surface?
// if (stage==1 && crossedSurface2()) {
// stage=2;
// pos2 = this->getPosition();
// }
// }
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticle2D<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
// {
// PointParticle2D<T,Descriptor>::serialize(serializer);
// serializer.addValue(stage);
// serializer.addValues<T,2>(pos1);
// serializer.addValues<T,2>(pos2);
// }
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticle2D<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
// {
// PointParticle2D<T,Descriptor>::unserialize(unserializer);
// unserializer.readValue(stage);
// unserializer.readValues<T,2>(pos1);
// unserializer.readValues<T,2>(pos2);
// }
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticle2D<T,Descriptor>::rescale(int dxScale, int dtScale) {
// PointParticle2D<T,Descriptor>::rescale(dxScale, dtScale);
// T posDimDx = 1.;
// T posDimDt = 0.;
// T posSaleFactor = scaleFromReference(dxScale, posDimDx, dtScale, posDimDt);
// pos1 *= posSaleFactor;
// pos2 *= posSaleFactor;
// }
//
//
// /* *************** class MappingParticleZslice2D ************************************ */
//
// template<typename T, template<typename U> class Descriptor>
// int MappingParticleZslice2D<T,Descriptor>::id =
// meta::registerGenericParticle2D<T,Descriptor,MappingParticleZslice2D<T,Descriptor> >("MappingZslice");
//
// template<typename T, template<typename U> class Descriptor>
// MappingParticleZslice2D<T,Descriptor>::MappingParticleZslice2D()
// : MappingParticle2D<T,Descriptor>(),
// zSlice1(T()), zSlice2(T())
// { }
//
// template<typename T, template<typename U> class Descriptor>
// MappingParticleZslice2D<T,Descriptor>::MappingParticleZslice2D (
// plint tag_, Array<T,2> const& position_, Array<T,2> const& velocity_, T zSlice1_, T zSlice2_)
// : MappingParticle2D<T,Descriptor>(tag_, position_, velocity_),
// zSlice1(zSlice1_),
// zSlice2(zSlice2_)
// { }
//
// template<typename T, template<typename U> class Descriptor>
// int MappingParticleZslice2D<T,Descriptor>::getId() const
// {
// return id;
// }
//
// template<typename T, template<typename U> class Descriptor>
// bool MappingParticleZslice2D<T,Descriptor>::crossedSurface1() const {
// if (zSlice2>zSlice1) {
// return this->getPosition()[2] > zSlice1;
// }
// else {
// return this->getPosition()[2] < zSlice1;
// }
// }
//
// template<typename T, template<typename U> class Descriptor>
// bool MappingParticleZslice2D<T,Descriptor>::crossedSurface2() const {
// if (zSlice2>zSlice1) {
// return this->getPosition()[2] > zSlice2;
// }
// else {
// return this->getPosition()[2] < zSlice2;
// }
// }
//
// template<typename T, template<typename U> class Descriptor>
// T MappingParticleZslice2D<T,Descriptor>::getSurfaceDistance() const {
// return std::fabs(zSlice2 - zSlice1);
// }
//
// template<typename T, template<typename U> class Descriptor>
// MappingParticleZslice2D<T,Descriptor>* MappingParticleZslice2D<T,Descriptor>::clone() const {
// return new MappingParticleZslice2D<T,Descriptor>(*this);
// }
//
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticleZslice2D<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
// {
// MappingParticle2D<T,Descriptor>::serialize(serializer);
// serializer.addValue(zSlice1);
// serializer.addValue(zSlice2);
// }
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticleZslice2D<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
// {
// MappingParticle2D<T,Descriptor>::unserialize(unserializer);
// unserializer.readValue(zSlice1);
// unserializer.readValue(zSlice2);
// }
//
//
// template<typename T, template<typename U> class Descriptor>
// void MappingParticleZslice2D<T,Descriptor>::rescale(int dxScale, int dtScale) {
// MappingParticle2D<T,Descriptor>::rescale(dxScale, dtScale);
// T posDimDx = 1.;
// T posDimDt = 0.;
// T posSaleFactor = scaleFromReference(dxScale, posDimDx, dtScale, posDimDt);
// zSlice1 *= posSaleFactor;
// zSlice2 *= posSaleFactor;
// }
} // namespace plb
#endif // VISUAL_PARTICLE_2D_H
|