118 for (
size_t s = 0; s < d_bcData.size(); s++) {
121 const auto &bc = d_bcData[s];
125 if (bc.d_isDisplacementZero && d_pZeroDisplacementApplied[s])
129 if (bc.d_isDisplacementZero)
130 d_pZeroDisplacementApplied[s] =
true;
133 if (!needToProcessParticle(
particle->getId(), bc))
137 auto reg_box = bc.d_regionGeomData.d_geom_p->box();
141 tf::Taskflow taskflow;
143 taskflow.for_each_index(
144 (std::size_t) 0,
particle->getNumNodes(), (std::size_t) 1,
145 [time, &
particle, bc, reg_box,
this] (std::size_t i) {
147 const auto x = particle->getXRefLocal(i);
149 double umax = bc.d_timeFnParams[0];
154 if (!bc.d_isRegionActive) {
156 box = particle->d_geom_p->box();
159 if (needToComputeDof(x,
particle->getId(), bc)) {
162 if (bc.d_spatialFnType ==
"hat_x") {
163 umax = bc.d_spatialFnParams[0] *
164 util::hatFunction(x.d_x, box.first.d_x,
166 }
else if (bc.d_spatialFnType ==
"hat_y") {
167 umax = bc.d_spatialFnParams[0] *
168 util::hatFunction(x.d_y, box.first.d_y,
170 }
else if (bc.d_spatialFnType ==
"sin_x") {
171 double a = M_PI * bc.d_spatialFnParams[0];
172 umax = umax * std::sin(a * x.d_x);
173 }
else if (bc.d_spatialFnType ==
"sin_y") {
174 double a = M_PI * bc.d_spatialFnParams[0];
175 umax = umax * std::sin(a * x.d_y);
176 }
else if (bc.d_spatialFnType ==
"linear_x") {
177 double a = bc.d_spatialFnParams[0];
178 umax = umax * a * x.d_x;
179 }
else if (bc.d_spatialFnType ==
"linear_y") {
180 double a = bc.d_spatialFnParams[0];
181 umax = umax * a * x.d_y;
185 if (bc.d_timeFnType ==
"constant")
187 else if (bc.d_timeFnType ==
"linear") {
190 }
else if (bc.d_timeFnType ==
"quadratic") {
191 du = umax * time + bc.d_timeFnParams[1] * time * time;
192 dv = umax + bc.d_timeFnParams[1] * time;
193 }
else if (bc.d_timeFnType ==
"sin") {
194 double a = M_PI * bc.d_timeFnParams[1];
195 du = umax * std::sin(a * time);
196 dv = umax * a * std::cos(a * time);
201 for (
auto d : bc.d_direction) {
206 if (bc.d_timeFnType ==
"rotation") {
207 auto x0 =
util::Point(bc.d_timeFnParams[1], bc.d_timeFnParams[2],
208 bc.d_timeFnParams[3]);
211 dx, bc.d_timeFnParams[0] * time);
213 dx, bc.d_timeFnParams[0] * time);
216 v_i += bc.d_timeFnParams[0] * dr_x;
219 for (
auto d : bc.d_direction) {
220 particle->setULocal(i, d-1, u_i[d-1]);
221 particle->setVLocal(i, d-1, v_i[d-1]);
222 auto xref =
particle->getXRefLocal(i)[d-1];
223 particle->setXLocal(i, d-1, u_i[d-1] + xref);
229 executor.run(taskflow).get();
std::vector< inp::PBCData > d_bcData
List of displacement bcs.
bool needToProcessParticle(size_t id, const inp::PBCData &bc)
Function that checks if given particle with id = id needs to be processed within boundary condition d...
ParticleULoading(std::vector< inp::PBCData > &bc_data)
Constructor.
bool needToComputeDof(const util::Point &x, size_t id, const inp::PBCData &bc)
Function that checks if we need to do computation at a given point x within a particle with id = id.
void apply(const double &time, particle::BaseParticle *particle)
Applies displacement boundary condition.
void setFixity(particle::BaseParticle *particle)
Sets fixity mask.
std::vector< bool > d_pZeroDisplacementApplied
Flag to indicate whether particles are fixed.
A class to store particle geometry, nodal discretization, and methods.
bool isInList(const size_t &i, const std::vector< size_t > &list)
Collection of methods and data related to particle object.