PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
particleIC.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 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#include "particleIC.h"
12#include "particleLoadingUtil.h"
14#include <taskflow/taskflow/taskflow.hpp>
15#include <taskflow/taskflow/algorithm/for_each.hpp>
16
17void loading::applyIC(particle::BaseParticle *particle, const std::vector<inp::BCBaseDeck> &icVec) {
18 for (size_t s=0; s<icVec.size(); s++) {
19
20 // get alias for bc data
21 const auto &bc = icVec[s];
22
23 if (bc.d_icType != "Constant_Velocity")
24 continue;
25
26 // check if we need to process this particle
27 if (!needToProcessParticle(particle->getId(), bc))
28 continue;
29
30 // get bounding box (quite possibly be generic)
31 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();
32
33 tf::Executor executor(util::parallel::getNThreads());
34 tf::Taskflow taskflow;
35
36 taskflow.for_each_index(
37 (std::size_t) 0, particle->getNumNodes(), (std::size_t) 1,
38 [&particle, bc, reg_box] (std::size_t i) {
39
40 // currently, IC is implemented using particle list only
41 // apply velocity condition
42 particle->setVLocal(i, bc.d_icVec);
43 }
44 ); // for_each
45
46 executor.run(taskflow).get();
47 }
48}
A class to store particle geometry, nodal discretization, and methods.
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...
void applyIC(particle::BaseParticle *particle, const std::vector< inp::BCBaseDeck > &icVec)
Applies displacement initial condition.
Collection of methods and data related to particle object.
Definition modelData.h:36
unsigned int getNThreads()
Get number of threads to be used by taskflow.
A structure to represent 3d vectors.
Definition point.h:30