LiquidFilmParticle.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef LiquidFilmParticle_H
27 #define LiquidFilmParticle_H
28 #include "DPMBase.h"
29 
34 template<class Particle>
35 class LiquidFilm : public Particle
36 {
37 public:
43  {
44  liquidVolume_ = 0;
45  }
46 
57  {
59  }
60 
66  ~LiquidFilm() override
67  = default;
68 
75  LiquidFilm* copy() const override
76  {
77  return new LiquidFilm(*this);
78  }
79 
86  void write(std::ostream& os) const override
87  {
88  Particle::write(os);
89  os << " liquidVolume " << liquidVolume_;
90  }
91 
96  std::string getName() const override
97  {
98  return "LiquidFilm";
99  }
100 
101  void read(std::istream& is) override;
102 
104  {
105  return liquidVolume_;
106  }
107 
108  void setLiquidVolume(Mdouble liquidVolume)
109  {
110  liquidVolume_ = liquidVolume;
111  }
112 
113  void addLiquidVolume(Mdouble liquidVolume)
114  {
115  liquidVolume_ += liquidVolume;
116  }
117 
118  unsigned getNumberOfFieldsVTK() const override
119  {
120  return 3;
121  }
122 
123  std::string getTypeVTK(unsigned i) const override
124  {
125  return "Float32";
126  }
127 
128  std::string getNameVTK(unsigned i) const override;
129 
130  std::vector<Mdouble> getFieldVTK(unsigned i) const override;
131 
132  bool isSphericalParticle() const override {return true;}
133 
134 protected:
135 
137 };
138 
139 
140 //todo Does mass and interaction radius change when a liquid film is added?
149 template<class Particle>
150 void LiquidFilm<Particle>::read(std::istream& is)
151 {
152  Particle::read(is);
153  std::string dummy;
154  is >> dummy >> liquidVolume_;
155  // a fix to allow reading of restart files pre-nonspherical
156  if (dummy == "invInertia")
157  {
158  is >> dummy >> liquidVolume_;
159  }
160 }
161 
162 template<class Particle>
163 std::string LiquidFilm<Particle>::getNameVTK(unsigned i) const
164 {
165  if (i==1)
166  return "liquidFilmVolume";
167  else if (i==2)
168  return "liquidBridgeVolume";
169  else /*i=0*/
170  return "fullLiquidVolume";
171 }
172 
173 template<class Particle>
174 std::vector<Mdouble> LiquidFilm<Particle>::getFieldVTK(unsigned i) const
175 {
176  if (i==1) {
177  return std::vector<Mdouble>(1, liquidVolume_);
178  } else /*i=2 or 0*/ {
179  Mdouble fullLiquidVolume = (i==2)?0:liquidVolume_;
180  for (auto k : this->getInteractions()) {
181  if(dynamic_cast<LiquidMigrationWilletInteraction*>(k)){
182  auto j = dynamic_cast<LiquidMigrationWilletInteraction*>(k);
183  if (j && j->getLiquidBridgeVolume()) {
184  fullLiquidVolume += 0.5*j->getLiquidBridgeVolume();
185  }
186  }
187  if(dynamic_cast<LiquidMigrationLSInteraction*>(k)) {
188  auto j = dynamic_cast<LiquidMigrationLSInteraction*>(k);
189  if (j && j->getLiquidBridgeVolume()) {
190  fullLiquidVolume += 0.5 * j->getLiquidBridgeVolume();
191  }
192  }
193 
194  }
195  return std::vector<Mdouble>(1, fullLiquidVolume);
196  }
197 }
198 
200 
201 #endif
LiquidFilm< SphericalParticle > LiquidFilmParticle
Definition: LiquidFilmParticle.h:199
Definition: LiquidFilmParticle.h:36
void setLiquidVolume(Mdouble liquidVolume)
Definition: LiquidFilmParticle.h:108
~LiquidFilm() override=default
Particle destructor, needs to be implemented and checked if it removes tangential spring information.
std::vector< Mdouble > getFieldVTK(unsigned i) const override
Definition: LiquidFilmParticle.h:174
LiquidFilm()
Basic Particle constructor, creates an Particle at (0,0,0) with radius, mass and inertia equal to 1.
Definition: LiquidFilmParticle.h:42
Mdouble getLiquidVolume() const
Definition: LiquidFilmParticle.h:103
LiquidFilm(const LiquidFilm &p)
Particle copy constructor, which accepts as input a reference to a Particle. It creates a copy of thi...
Definition: LiquidFilmParticle.h:56
LiquidFilm * copy() const override
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
Definition: LiquidFilmParticle.h:75
std::string getName() const override
Definition: LiquidFilmParticle.h:96
void read(std::istream &is) override
Definition: LiquidFilmParticle.h:150
Mdouble liquidVolume_
Definition: LiquidFilmParticle.h:136
std::string getTypeVTK(unsigned i) const override
Definition: LiquidFilmParticle.h:123
void addLiquidVolume(Mdouble liquidVolume)
Definition: LiquidFilmParticle.h:113
void write(std::ostream &os) const override
Definition: LiquidFilmParticle.h:86
std::string getNameVTK(unsigned i) const override
Definition: LiquidFilmParticle.h:163
bool isSphericalParticle() const override
Definition: LiquidFilmParticle.h:132
unsigned getNumberOfFieldsVTK() const override
Definition: LiquidFilmParticle.h:118
Defines the liquid bridge LS interaction between two particles or walls.
Definition: LiquidMigrationLSInteraction.h:45
Defines the liquid bridge willet interaction between two particles or walls.
Definition: LiquidMigrationWilletInteraction.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51