PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
material::LinearInfluenceFn Class Reference

A class to implement linear influence function. More...

#include <influenceFn.h>

Inheritance diagram for material::LinearInfluenceFn:
Collaboration diagram for material::LinearInfluenceFn:

Public Member Functions

 LinearInfluenceFn (const std::vector< double > &params, const size_t &dim)
 Constructor.
 
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.
 
- Public Member Functions inherited from material::BaseInfluenceFn
 BaseInfluenceFn ()=default
 Constructor.
 

Private Attributes

double d_a0
 Constants such that J(r) = d_a0 + d_a1 * r.
 
double d_a1
 Constants such that J(r) = d_a0 + d_a1 * r.
 

Detailed Description

A class to implement linear influence function.

\( J(r) = a0 + a1 r \)

Definition at line 151 of file influenceFn.h.

Constructor & Destructor Documentation

◆ LinearInfluenceFn()

material::LinearInfluenceFn::LinearInfluenceFn ( const std::vector< double > &  params,
const size_t &  dim 
)

Constructor.

Parameters
paramsList of parameters
dimDimension

Definition at line 29 of file influenceFn.cpp.

31 : BaseInfluenceFn(), d_a0(0.), d_a1(0.) {
32
33 if (params.empty()) {
34 // choose a0, a1 = -a0 such that \int_0^1 J(r) r^d dr = 1
35 // and J(r) = a0 (1 - r)
36 if (dim == 1) {
37 d_a0 = 6.;
38 d_a1 = -d_a0;
39 } else if (dim == 2) {
40 d_a0 = 12.;
41 d_a1 = -d_a0;
42 } else if (dim == 3) {
43 d_a0 = 20.;
44 d_a1 = -d_a0;
45 }
46 } else {
47 d_a0 = params[0];
48 if (params.size() < 2)
49 d_a1 = -d_a0;
50 else
51 d_a1 = params[1];
52 }
53}
BaseInfluenceFn()=default
Constructor.
double d_a0
Constants such that J(r) = d_a0 + d_a1 * r.
double d_a1
Constants such that J(r) = d_a0 + d_a1 * r.

References d_a0, and d_a1.

Member Function Documentation

◆ getInfFn()

double material::LinearInfluenceFn::getInfFn ( const double &  r) const
overridevirtual

Returns the value of influence function.

Parameters
rReference (initial) bond length
Returns
value Influence function at r

Implements material::BaseInfluenceFn.

Definition at line 55 of file influenceFn.cpp.

55 {
56 return d_a0 + d_a1 * r;
57}

◆ getMoment()

double material::LinearInfluenceFn::getMoment ( const size_t &  i) const
overridevirtual

Returns the moment of influence function.

If \( J(r) \) is the influence function for \( r\in [0,1)\) then \( i^{th}\) moment is given by

\[ M_i = \int_0^1 J(r) r^i dr. \]

Parameters
iith moment
Returns
moment Moment

Implements material::BaseInfluenceFn.

Definition at line 59 of file influenceFn.cpp.

59 {
60 return (d_a0 / double(i + 1)) + (d_a1 / double(i + 2));
61}

Referenced by printStr().

Here is the caller graph for this function:

◆ print() [1/2]

void material::LinearInfluenceFn::print ( ) const
inlineoverridevirtual

Prints the information about the object.

Reimplemented from material::BaseInfluenceFn.

Definition at line 213 of file influenceFn.h.

213{ print(0, 0); }
void print() const override
Prints the information about the object.

References print().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print() [2/2]

void material::LinearInfluenceFn::print ( int  nt,
int  lvl 
) const
inlineoverridevirtual

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Reimplemented from material::BaseInfluenceFn.

Definition at line 208 of file influenceFn.h.

208 {
209 std::cout << printStr(nt, lvl);
210 }
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string material::LinearInfluenceFn::printStr ( int  nt,
int  lvl 
) const
inlineoverridevirtual

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Reimplemented from material::BaseInfluenceFn.

Definition at line 187 of file influenceFn.h.

187 {
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 }
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

References d_a0, d_a1, getMoment(), and util::io::getTabS().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ d_a0

double material::LinearInfluenceFn::d_a0
private

Constants such that J(r) = d_a0 + d_a1 * r.

Definition at line 217 of file influenceFn.h.

Referenced by LinearInfluenceFn(), and printStr().

◆ d_a1

double material::LinearInfluenceFn::d_a1
private

Constants such that J(r) = d_a0 + d_a1 * r.

Definition at line 220 of file influenceFn.h.

Referenced by LinearInfluenceFn(), and printStr().


The documentation for this class was generated from the following files: