PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
loading::ParticleFLoading Class Reference

A class to apply force boundary condition. More...

#include <particleFLoading.h>

Inheritance diagram for loading::ParticleFLoading:
Collaboration diagram for loading::ParticleFLoading:

Public Member Functions

 ParticleFLoading (std::vector< inp::BCBaseDeck > &bc_data)
 Constructor.
 
void apply (const double &time, particle::BaseParticle *particle)
 Applies force boundary condition.
 
- Public Member Functions inherited from loading::ParticleLoading
 ParticleLoading ()=default
 Constructor.
 

Additional Inherited Members

- Protected Attributes inherited from loading::ParticleLoading
std::vector< inp::BCBaseDeck > d_bcData
 List of displacement bcs.
 

Detailed Description

A class to apply force boundary condition.

Definition at line 31 of file particleFLoading.h.

Constructor & Destructor Documentation

◆ ParticleFLoading()

loading::ParticleFLoading::ParticleFLoading ( std::vector< inp::BCBaseDeck > &  bc_data)

Constructor.

Parameters
bc_dataBoundary condition data

Definition at line 28 of file particleFLoading.cpp.

29 {
30
31 d_bcData = bc_data;
32}
std::vector< inp::BCBaseDeck > d_bcData
List of displacement bcs.

References loading::ParticleLoading::d_bcData.

Member Function Documentation

◆ apply()

void loading::ParticleFLoading::apply ( const double &  time,
particle::BaseParticle *  particle 
)

Applies force boundary condition.

Parameters
timeCurrent time
particleParticle object pointer

Definition at line 34 of file particleFLoading.cpp.

35 {
36
37 for (size_t s = 0; s < d_bcData.size(); s++) {
38
39 // get alias for bc data
40 const auto &bc = d_bcData[s];
41
42 // check if we need to process this particle
43 if (!needToProcessParticle(particle->getId(), bc))
44 continue;
45
46 // get bounding box (quite possibly be generic)
47 auto reg_box = bc.d_regionGeomData.d_geom_p == nullptr ? std::pair<util::Point, util::Point>(util::Point(), util::Point()) : bc.d_regionGeomData.d_geom_p->box();
48
49 for (size_t i = 0; i < particle->getNumNodes(); i++) {
50
51 const auto x = particle->getXRefLocal(i);
52 double fmax = 1.0;
53
54 auto box = reg_box;
55 if (!bc.d_isRegionActive) {
56 // get box from particle
57 box = particle->d_geom_p->box();
58 }
59
60 if (needToComputeDof(x, particle->getId(), bc)) {
61
62 // apply spatial function
63 if (bc.d_spatialFnType == "hat_x") {
64 fmax = bc.d_spatialFnParams[0] *
65 util::hatFunction(x.d_x, box.first.d_x,
66 box.second.d_x);
67 } else if (bc.d_spatialFnType == "hat_y") {
68 fmax = bc.d_spatialFnParams[0] *
69 util::hatFunction(x.d_y, box.first.d_y,
70 box.second.d_y);
71 } else if (bc.d_spatialFnType == "sin_x") {
72 double a = M_PI * bc.d_spatialFnParams[0];
73 fmax = bc.d_spatialFnParams[0] * std::sin(a * x.d_x);
74 } else if (bc.d_spatialFnType == "sin_y") {
75 double a = M_PI * bc.d_spatialFnParams[0];
76 fmax = bc.d_spatialFnParams[0] * std::sin(a * x.d_y);
77 } else if (bc.d_spatialFnType == "linear_x") {
78 double a = bc.d_spatialFnParams[0];
79 fmax = bc.d_spatialFnParams[0] * a * x.d_x;
80 } else if (bc.d_spatialFnType == "linear_y") {
81 double a = bc.d_spatialFnParams[0];
82 fmax = bc.d_spatialFnParams[0] * a * x.d_y;
83 }
84
85 // apply time function
86 if (bc.d_timeFnType == "linear")
87 fmax *= time;
88 else if (bc.d_timeFnType == "linear_step")
89 fmax *= util::linearStepFunc(time, bc.d_timeFnParams[1],
90 bc.d_timeFnParams[2]);
91 else if (bc.d_timeFnType == "linear_slow_fast") {
92 if (util::isGreater(time, bc.d_timeFnParams[1]))
93 fmax *= bc.d_timeFnParams[3] * time;
94 else
95 fmax *= bc.d_timeFnParams[2] * time;
96 } else if (bc.d_timeFnType == "sin") {
97 double a = M_PI * bc.d_timeFnParams[1];
98 fmax *= std::sin(a * time);
99 }
100
101 // multiply by the slope
102 fmax *= bc.d_timeFnParams[0];
103
104 auto force_i = util::Point();
105 for (auto d : bc.d_direction) {
106 force_i[d-1] = fmax;
107 }
108
109 // add force
110 particle->addFLocal(i, force_i);
111 } // if compute force
112 }
113 } // loop over bc sets
114}
bool needToProcessParticle(size_t id, const inp::BCBaseDeck &bc)
Function that checks if given particle with id = id needs to be processed within boundary condition d...
bool needToComputeDof(const util::Point &x, size_t id, const inp::BCBaseDeck &bc)
Function that checks if we need to do computation at a given point x within a particle with id = id.
Collection of methods and data related to particle object.
Definition modelData.h:36
bool isGreater(const double &a, const double &b)
Returns true if a > b.
Definition function.cpp:17
double hatFunction(const double &x, const double &x_min, const double &x_max)
Computes hat function at given point.
Definition function.cpp:27
double linearStepFunc(const double &x, const double &x1, const double &x2)
Compute linear step function.
Definition function.cpp:64
A structure to represent 3d vectors.
Definition point.h:30

References util::hatFunction(), util::isGreater(), util::linearStepFunc(), loading::needToComputeDof(), and loading::needToProcessParticle().

Here is the call graph for this function:

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