FrictionQPotFEM 0.23.3
Loading...
Searching...
No Matches
UniformSingleLayerThermal2d.h
Go to the documentation of this file.
1
7#ifndef FRICTIONQPOTFEM_UNIFORMSINGLELAYERTHERMAL2D_H
8#define FRICTIONQPOTFEM_UNIFORMSINGLELAYERTHERMAL2D_H
9
10#include <prrng.h>
11
12#include "Generic2d.h"
14#include "config.h"
15
16namespace FrictionQPotFEM {
17
25namespace UniformSingleLayerThermal2d {
26
30inline std::vector<std::string> version_dependencies()
31{
33}
34
38inline std::vector<std::string> version_compiler()
39{
41}
42
53
54public:
55 System() = default;
56
57public:
58 virtual ~System(){};
59
60public:
86 template <class C, class E, class L, class M, class Y>
88 const C& coor,
89 const E& conn,
90 const E& dofs,
91 const L& iip,
92 const L& elastic_elem,
93 const M& elastic_K,
94 const M& elastic_G,
95 const L& plastic_elem,
96 const M& plastic_K,
97 const M& plastic_G,
98 const Y& plastic_epsy,
99 double dt,
100 double rho,
101 double alpha,
102 double eta,
103 double temperature_dinc,
104 size_t temperature_seed,
105 double temperature)
106 {
107 this->initSystem(
108 coor,
109 conn,
110 dofs,
111 iip,
113 elastic_K,
114 elastic_G,
116 plastic_K,
117 plastic_G,
118 plastic_epsy,
119 dt,
120 rho,
121 alpha,
122 eta);
123
124 auto& pconn = m_vector_plas.conn();
125 double h = coor(pconn(0, 1), 0) - coor(pconn(0, 0), 0);
126 for (size_t d = 0; d < dofs.shape(1); ++d) {
127 FRICTIONQPOTFEM_REQUIRE(dofs(pconn(0, 0), d) == dofs(pconn(m_N - 1, 1), d));
128 FRICTIONQPOTFEM_REQUIRE(dofs(pconn(0, 3), d) == dofs(pconn(m_N - 1, 2), d));
129 }
130
131 for (size_t e = 0; e < m_N; ++e) {
132 FRICTIONQPOTFEM_REQUIRE(xt::allclose(coor(pconn(e, 1), 0) - coor(pconn(e, 0), 0), h));
133 FRICTIONQPOTFEM_REQUIRE(xt::allclose(coor(pconn(e, 2), 1) - coor(pconn(e, 1), 1), h));
134 FRICTIONQPOTFEM_REQUIRE(xt::allclose(coor(pconn(e, 2), 0) - coor(pconn(e, 3), 0), h));
135 FRICTIONQPOTFEM_REQUIRE(xt::allclose(coor(pconn(e, 3), 1) - coor(pconn(e, 1), 1), h));
136 }
137
139 m_std = m_T * h;
140 m_dinc = temperature_dinc;
141 m_fthermal = xt::zeros_like(m_fint);
142 m_gen = prrng::pcg32(temperature_seed, 0);
143 m_ncache = 100;
144 m_cache = m_gen.normal({size_t(m_ncache), m_N, size_t(3), size_t(2)}, 0, m_std);
145 m_cache_start = 0;
146 this->setInc(m_inc);
147 }
148
149protected:
150 size_t m_computed;
151 size_t m_dinc;
152 double m_T;
153 double m_std;
157 int64_t m_ncache;
158 prrng::pcg32 m_gen;
159
160public:
161 std::string type() const override
162 {
163 return "FrictionQPotFEM.UniformSingleLayerThermal2d.System";
164 }
165
171 {
172 return m_fthermal;
173 }
174
179 double temperature() const
180 {
181 return m_T;
182 }
183
184protected:
188 void updateCache(int64_t index)
189 {
190 if (index >= m_cache_start && index < m_cache_start + m_ncache) {
191 return;
192 }
193
194 int64_t advance = index - m_cache_start - m_ncache;
195 if (advance != 0) {
196 m_gen.advance(advance * static_cast<int64_t>(m_N * 6));
197 }
198
199 m_cache = m_gen.normal({size_t(m_ncache), m_N, size_t(3), size_t(2)}, 0, m_std);
200 m_cache_start = index;
201 }
202
203public:
204 void setInc(size_t arg) override
205 {
206 m_inc = arg;
207 this->computeThermalForce(true);
208 }
209
210protected:
215 void computeThermalForce(bool force = false)
216 {
217 if (m_inc == m_computed && !force) {
218 return;
219 }
220
221 if (m_inc % m_dinc != 0 && !force) {
222 return;
223 }
224
225 int64_t index = static_cast<int64_t>(m_inc / m_dinc);
226 this->updateCache(index);
227
228 auto& conn = m_vector_plas.conn();
229
230 std::fill(&m_fthermal(conn(0, 0), 0), &m_fthermal(conn(m_N - 1, 2), 1) + 1, 0);
231
232 for (size_t e = 0; e < m_N; ++e) {
233 const size_t* elem = &conn(e, 0);
234 double* cache = &m_cache(index - m_cache_start, e, 0, 0);
235
236 for (size_t d = 0; d < 2; ++d) {
237 m_fthermal(elem[0], d) += cache[0 + d];
238 m_fthermal(elem[3], d) -= cache[0 + d];
239 m_fthermal(elem[0], d) += cache[2 + d];
240 m_fthermal(elem[1], d) -= cache[2 + d];
241 m_fthermal(elem[2], d) += cache[4 + d];
242 m_fthermal(elem[3], d) -= cache[4 + d];
243 }
244 }
245
246 // apply periodic boundary conditions
247 for (size_t d = 0; d < 2; ++d) {
248 m_fthermal(conn(0, 0), d) += m_fthermal(conn(m_N - 1, 1), d);
249 m_fthermal(conn(0, 3), d) += m_fthermal(conn(m_N - 1, 2), d);
250 m_fthermal(conn(m_N - 1, 1), d) = m_fthermal(conn(0, 0), d);
251 m_fthermal(conn(m_N - 1, 2), d) = m_fthermal(conn(0, 3), d);
252 }
253
255 }
256
257protected:
267 {
268 this->computeThermalForce();
269 xt::noalias(m_fint) = m_fmaterial + m_fdamp + m_fthermal;
271 xt::noalias(m_fres) = m_fext - m_fint;
272 }
273};
274
275} // namespace UniformSingleLayerThermal2d
276} // namespace FrictionQPotFEM
277
278#endif
array_type::tensor< double, 2 > m_fext
Nodal force: total external force (reaction force)
Definition: Generic2d.h:2130
double eta() const
Get the damping at the interface.
Definition: Generic2d.h:478
double rho() const
Mass density.
Definition: Generic2d.h:406
array_type::tensor< double, 2 > m_fmaterial
Nodal force, deriving from elasticity.
Definition: Generic2d.h:2123
const auto & elastic_elem() const
List of elastic elements.
Definition: Generic2d.h:678
size_t m_N
Number of plastic elements, alias of m_nelem_plas.
Definition: Generic2d.h:2077
array_type::tensor< double, 2 > m_fres
Nodal force: residual force.
Definition: Generic2d.h:2131
GooseFEM::VectorPartitioned m_vector_plas
m_vector for plastic elements only.
Definition: Generic2d.h:2092
const auto & plastic_elem() const
List of plastic elements.
Definition: Generic2d.h:688
size_t m_inc
Current increment (current time = m_dt * m_inc).
Definition: Generic2d.h:2138
const auto & coor() const
Nodal coordinates.
Definition: Generic2d.h:708
array_type::tensor< double, 2 > m_fint
Nodal force: total internal force.
Definition: Generic2d.h:2129
const auto & conn() const
Connectivity.
Definition: Generic2d.h:698
array_type::tensor< double, 2 > m_fdamp
Nodal force from damping.
Definition: Generic2d.h:2126
double dt() const
Get time step.
Definition: Generic2d.h:566
GooseFEM::VectorPartitioned m_vector
Convert vectors between 'nodevec', 'elemvec', ....
Definition: Generic2d.h:2090
const auto & dofs() const
DOFs per node.
Definition: Generic2d.h:718
double alpha() const
Background damping density.
Definition: Generic2d.h:507
Class that uses GMatElastoPlasticQPot to evaluate stress everywhere.
Compared to UniformSingleLayer2d::System() this class adds thermal fluctuations.
array_type::tensor< double, 2 > m_fthermal
Nodal force from temperature.
prrng::pcg32 m_gen
Random generator for thermal forces.
double m_T
Definition of temperature (units of equivalent stress).
double m_std
Standard deviation for signed equivalent thermal stress.
double temperature() const
Return the target temperature.
const array_type::tensor< double, 2 > & fthermal() const
The force vector that represents the effect of temperature (on the weak layer only).
array_type::tensor< double, 4 > m_cache
Cache [ncache, m_elem_plas.size(), 3, 2].
size_t m_computed
Increment at which the thermal stress tensor was generated.
std::string type() const override
Return the type of system.
void computeThermalForce(bool force=false)
Update the thermal force vector.
void updateCache(int64_t index)
Update cache of thermal forces on the weak layer.
System(const C &coor, const E &conn, const E &dofs, const L &iip, const L &elastic_elem, const M &elastic_K, const M &elastic_G, const L &plastic_elem, const M &plastic_K, const M &plastic_G, const Y &plastic_epsy, double dt, double rho, double alpha, double eta, double temperature_dinc, size_t temperature_seed, double temperature)
Define the geometry, including boundary conditions and element sets.
size_t m_dinc
Duration to keep the same random thermal stress tensor.
void copy_p(const array_type::tensor< double, 2 > &nodevec_src, array_type::tensor< double, 2 > &nodevec_dest) const
Copy prescribed DOFs from "nodevec" to another "nodvec":
const array_type::tensor< size_t, 2 > & conn() const
Definition: Vector.h:92
std::vector< std::string > version_dependencies()
Return versions of this library and of all of its dependencies.
Definition: Generic2d.h:161
std::vector< std::string > version_compiler()
Version information of the compilers.
Definition: Generic2d.h:170
std::vector< std::string > version_compiler()
Version information of the compilers.
std::vector< std::string > version_dependencies()
Return versions of this library and of all of its dependencies.
xt::xtensor< T, N > tensor
Fixed (static) rank array.
Definition: config.h:160
Friction simulations based on a disorder potential energy landscape and the finite element method.
Definition: config.h:139
#define FRICTIONQPOTFEM_REQUIRE(expr)
Assertions that cannot be disabled.
Definition: config.h:70