PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
influenceFn.h
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2024 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#ifndef MATERIAL_PD_INFLUENCEFN_H
12#define MATERIAL_PD_INFLUENCEFN_H
13
14#include "util/io.h"
15#include <cstring>
16#include <iostream>
17#include <vector>
18
19namespace material {
20
23
24public:
26 BaseInfluenceFn() = default;
27
34 virtual double getInfFn(const double &r) const = 0;
35
45 virtual double getMoment(const size_t &i) const = 0;
46
54 virtual std::string printStr(int nt, int lvl) const {
55
56 auto tabS = util::io::getTabS(nt);
57 std::ostringstream oss;
58 oss << tabS << "------- BaseInfluenceFn --------" << std::endl << std::endl;
59 oss << tabS << "Provides abstraction for different influence function "
60 "types" << std::endl;
61 oss << tabS << std::endl;
62
63 return oss.str();
64 }
65
72 virtual void print(int nt, int lvl) const { std::cout << printStr(nt, lvl); }
73
75 virtual void print() const { print(0, 0); }
76};
77
80
81public:
87 ConstInfluenceFn(const std::vector<double> &params, const size_t &dim);
88
95 double getInfFn(const double &r) const override;
96
106 double getMoment(const size_t &i) const override;
107
115 std::string printStr(int nt, int lvl) const override {
116
117 auto tabS = util::io::getTabS(nt);
118 std::ostringstream oss;
119 oss << tabS << "------- ConstInfluenceFn --------" << std::endl << std::endl;
120 oss << tabS << "Constant function with constant = " << d_a0 << std::endl;
121 oss << tabS << "First moment = " << getMoment(1)
122 << ", second moment = " << getMoment(2)
123 << ", third moment = " << getMoment(3) << std::endl;
124 oss << tabS << std::endl;
125
126 return oss.str();
127 }
128
135 void print(int nt, int lvl) const override {
136 std::cout << printStr(nt, lvl);
137 }
138
140 void print() const override { print(0, 0); }
141
142private:
144 double d_a0;
145};
146
152
153public:
159 LinearInfluenceFn(const std::vector<double> &params, const size_t &dim);
160
167 double getInfFn(const double &r) const override;
168
178 double getMoment(const size_t &i) const override;
179
187 std::string printStr(int nt, int lvl) const override {
188
189 auto tabS = util::io::getTabS(nt);
190 std::ostringstream oss;
191 oss << tabS << "------- LinearInfluenceFn --------" << std::endl << std::endl;
192 oss << tabS << "Linear function a0 + a1*r with constants: a0 = "
193 << d_a0 << ", a1 = " << d_a1 << std::endl;
194 oss << tabS << "First moment = " << getMoment(1)
195 << ", second moment = " << getMoment(2)
196 << ", third moment = " << getMoment(3) << std::endl;
197 oss << tabS << std::endl;
198
199 return oss.str();
200 }
201
208 void print(int nt, int lvl) const override {
209 std::cout << printStr(nt, lvl);
210 }
211
213 void print() const override { print(0, 0); }
214
215private:
217 double d_a0;
218
220 double d_a1;
221};
222
228
229public:
235 GaussianInfluenceFn(const std::vector<double> &params, const size_t &dim);
236
243 double getInfFn(const double &r) const override;
244
254 double getMoment(const size_t &i) const override;
255
263 std::string printStr(int nt, int lvl) const override {
264
265 auto tabS = util::io::getTabS(nt);
266 std::ostringstream oss;
267 oss << tabS << "------- GaussianInfluenceFn --------" << std::endl << std::endl;
268 oss << tabS << "Gaussian function a0 * exp(-r*r / a1) with constants: a0 = "
269 << d_alpha << ", a1 = " << d_beta << std::endl;
270 oss << tabS << "First moment = " << getMoment(1)
271 << ", second moment = " << getMoment(2)
272 << ", third moment = " << getMoment(3) << std::endl;
273 oss << tabS << std::endl;
274
275 return oss.str();
276 }
277
284 void print(int nt, int lvl) const override {
285 std::cout << printStr(nt, lvl);
286 }
287
289 void print() const override { print(0, 0); }
290
291private:
293 double d_alpha;
294
296 double d_beta;
297};
298
299} // namespace material
300
301#endif // MATERIAL_PD_INFLUENCEFN_H
A base class for computing influence function.
Definition influenceFn.h:22
BaseInfluenceFn()=default
Constructor.
virtual double getMoment(const size_t &i) const =0
Returns the moment of influence function.
virtual void print() const
Prints the information about the object.
Definition influenceFn.h:75
virtual std::string printStr(int nt, int lvl) const
Returns the string containing printable information about the object.
Definition influenceFn.h:54
virtual void print(int nt, int lvl) const
Prints the information about the object.
Definition influenceFn.h:72
virtual double getInfFn(const double &r) const =0
Returns the value of influence function.
A class to implement constant influence function.
Definition influenceFn.h:79
double getMoment(const size_t &i) const override
Returns the moment of influence function.
void print() const override
Prints the information about the object.
double getInfFn(const double &r) const override
Returns the value of influence function.
double d_a0
Constant such that J(r) = Constant.
void print(int nt, int lvl) const override
Prints the information about the object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
A class to implement Gaussian influence function.
double getInfFn(const double &r) const override
Returns the value of influence function.
double getMoment(const size_t &i) const override
Returns the moment of influence function.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
void print(int nt, int lvl) const override
Prints the information about the object.
void print() const override
Prints the information about the object.
A class to implement linear influence function.
double d_a0
Constants such that J(r) = d_a0 + d_a1 * r.
double getInfFn(const double &r) const override
Returns the value of influence function.
void print(int nt, int lvl) const override
Prints the information about the object.
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.
double d_a1
Constants such that J(r) = d_a0 + d_a1 * r.
void print() const override
Prints the information about the object.
double getMoment(const size_t &i) const override
Returns the moment of influence function.
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition io.h:40