ThermalSpecies.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 THERMALSPECIES_H
27 #define THERMALSPECIES_H
28 
30 
31 class BaseInteraction;
32 
33 template<class NormalForceSpecies>
35 {
36 public:
37 
40 
43 
46 
48  virtual ~ThermalSpecies();
49 
51  void write(std::ostream& os) const;
52 
54  void read(std::istream& is);
55 
57  std::string getBaseName() const;
58 
60  Mdouble getHeatCapacity() const;
61 
63  void setHeatCapacity(Mdouble heatCapacity);
64 
67 
69  void setThermalConductivity(Mdouble thermalConductivity);
70 
71 private:
76 
81 };
82 
83 template<class NormalForceSpecies>
86 {
87  heatCapacity_ = 0.0;
89 }
90 
91 template<class NormalForceSpecies>
94 {
97 }
98 
99 template<class NormalForceSpecies>
101 {}
102 
103 template<class NormalForceSpecies>
104 void ThermalSpecies<NormalForceSpecies>::write(std::ostream& os) const
105 {
106  NormalForceSpecies::write(os);
107  os << " heatCapacity " << heatCapacity_;
108  os << " thermalConductivity " << thermalConductivity_;
109 }
110 
111 template<class NormalForceSpecies>
113 {
114  std::string dummy;
115  NormalForceSpecies::read(is);
116  is >> dummy >> heatCapacity_;
117  is >> dummy >> thermalConductivity_;
118 }
119 
120 template<class NormalForceSpecies>
122 {
123  return "Thermal" + NormalForceSpecies::getBaseName();
124 }
125 
126 
127 template<class NormalForceSpecies>
129 {
130  return heatCapacity_;
131 }
132 
133 template<class NormalForceSpecies>
135 {
136  logger.assert_always(heatCapacity > 0,
137  "[ThermalSpecies<>::setHeatCapacity(%)] value has to be positive",
138  heatCapacity);
139  heatCapacity_ = heatCapacity;
140 }
141 
142 template<class NormalForceSpecies>
144 {
145  return thermalConductivity_;
146 }
147 
148 template<class NormalForceSpecies>
150 {
151  logger.assert_always(thermalConductivity >= 0,
152  "[ThermalSpecies<>::setThermalConductivity(%)] value has to be positive",
153  thermalConductivity);
154  thermalConductivity_ = thermalConductivity;
155 }
156 
157 #endif
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Defines a contact force parallel to the contact normal.
Definition: ThermalInteraction.h:37
Definition: ThermalSpecies.h:35
void read(std::istream &is)
Reads the species properties from an input stream.
Definition: ThermalSpecies.h:112
void write(std::ostream &os) const
Writes the species properties to an output stream.
Definition: ThermalSpecies.h:104
Mdouble heatCapacity_
The heat capacity.
Definition: ThermalSpecies.h:75
Mdouble thermalConductivity_
The thermal conductivity.
Definition: ThermalSpecies.h:80
ThermalInteraction< typename NormalForceSpecies::InteractionType > InteractionType
The correct Interaction type for this FrictionForceSpecies.
Definition: ThermalSpecies.h:39
std::string getBaseName() const
Used in Species::getName to obtain a unique name for each Species.
Definition: ThermalSpecies.h:121
void setThermalConductivity(Mdouble thermalConductivity)
Allows heatCapacity_ to be changed.
Definition: ThermalSpecies.h:149
void setHeatCapacity(Mdouble heatCapacity)
Allows heatCapacity_ to be changed.
Definition: ThermalSpecies.h:134
virtual ~ThermalSpecies()
The default destructor.
Definition: ThermalSpecies.h:100
Mdouble getThermalConductivity() const
Allows heatCapacity_ to be accessed.
Definition: ThermalSpecies.h:143
ThermalSpecies()
The default constructor.
Definition: ThermalSpecies.h:84
Mdouble getHeatCapacity() const
Allows heatCapacity_ to be accessed.
Definition: ThermalSpecies.h:128