MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LiquidFilmParticle.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 
27 #include "InteractionHandler.h"
31 #include "ParticleHandler.h"
32 #include "DPMBase.h"
33 
39 {
40  liquidVolume_ = 0;
41 }
42 
52  : BaseParticle(p)
53 {
55 }
56 
62 = default;
63 
70 {
71  return new LiquidFilmParticle(*this);
72 }
73 
80 void LiquidFilmParticle::write(std::ostream& os) const
81 {
83  os << " liquidVolume " << liquidVolume_;
84 }
85 
90 std::string LiquidFilmParticle::getName() const
91 {
92  return "LiquidFilmParticle";
93 }
94 
95 //todo Does mass and interaction radius change when a liquid film is added?
96 
105 void LiquidFilmParticle::read(std::istream& is)
106 {
107  BaseParticle::read(is);
108  std::string dummy;
109  is >> dummy >> liquidVolume_;
110  // a fix to allow reading of restart files pre-nonspherical
111  if (dummy == "invInertia")
112  {
113  is >> dummy >> liquidVolume_;
114  }
115 }
116 
118 {
119  return liquidVolume_;
120 }
121 
123 {
124  liquidVolume_ = liquidVolume;
125 }
126 
128 {
129  liquidVolume_ += liquidVolume;
130 }
131 
132 
134 {
135  return 3;
136 }
137 
138 std::string LiquidFilmParticle::getTypeVTK(unsigned i) const
139 {
140  return "Float32";
141 }
142 
143 std::string LiquidFilmParticle::getNameVTK(unsigned i) const
144 {
145  if (i==1)
146  return "liquidFilmVolume";
147  else if (i==2)
148  return "liquidBridgeVolume";
149  else /*i=0*/
150  return "fullLiquidVolume";
151 }
152 
153 std::vector<Mdouble> LiquidFilmParticle::getFieldVTK(unsigned i) const
154 {
155  if (i==1) {
156  return std::vector<Mdouble>(1, liquidVolume_);
157  } else /*i=2 or 0*/ {
158  Mdouble fullLiquidVolume = (i==2)?0:liquidVolume_;
159  for (auto k : getInteractions()) {
160  auto j = dynamic_cast<LiquidMigrationWilletInteraction*>(k);
161  if (j && j->getLiquidBridgeVolume()) {
162  fullLiquidVolume += 0.5*j->getLiquidBridgeVolume();
163 // } else {
164 // logger(WARN,"All contacts of % need to be LiquidMigrationWilletInteraction",i);
165  }
166  }
167  return std::vector<Mdouble>(1, fullLiquidVolume);
168  }
169 }
void read(std::istream &is) override
Particle read function, which accepts an std::istream as input.
LiquidFilmParticle * copy() const override
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
Defines the liquid bridge willet interaction between two particles or walls.
void addLiquidVolume(Mdouble liquidVolume)
double Mdouble
Definition: GeneralDefine.h:34
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
void read(std::istream &is) override
unsigned getNumberOfFieldsVTK() const override
void write(std::ostream &os) const override
Particle print function, which accepts an std::ostream as input.
void setLiquidVolume(Mdouble liquidVolume)
std::string getNameVTK(unsigned i) const override
Mdouble getLiquidVolume() const
std::vector< Mdouble > getFieldVTK(unsigned i) const override
void write(std::ostream &os) const override
std::string getTypeVTK(unsigned i) const override
std::string getName() const override
const std::vector< BaseInteraction * > & getInteractions() const
Returns a list of interactions which belong to this interactable.
LiquidFilmParticle()
Basic Particle constructor, creates an Particle at (0,0,0) with radius, mass and inertia equal to 1...
~LiquidFilmParticle() override
Particle destructor, needs to be implemented and checked if it removes tangential spring information...