NimbleSM
NimbleSM is a solid mechanics simulation code for dynamic systems
Loading...
Searching...
No Matches
nimble::NarrowphaseFunc Struct Reference

Public Member Functions

 NarrowphaseFunc (BvhContactManager *cm)
 
bvh::narrowphase_result_pair operator() (const bvh::broadphase_collision< ContactEntity > &_a, const bvh::broadphase_collision< ContactEntity > &_b)
 

Public Attributes

BvhContactManagercontact_manager
 

Constructor & Destructor Documentation

◆ NarrowphaseFunc()

nimble::NarrowphaseFunc::NarrowphaseFunc ( BvhContactManager * cm)
inlineexplicit
123: contact_manager{cm} {}
BvhContactManager * contact_manager
Definition bvh_contact_manager.cc:210

Member Function Documentation

◆ operator()()

bvh::narrowphase_result_pair nimble::NarrowphaseFunc::operator() ( const bvh::broadphase_collision< ContactEntity > & _a,
const bvh::broadphase_collision< ContactEntity > & _b )
inline
128 {
129 std::size_t num_possible_contacts = _a.elements.extent(0) * _b.elements.extent(0);
130 auto res = bvh::narrowphase_result_pair();
131 res.a = bvh::narrowphase_result(sizeof(NarrowphaseResult), num_possible_contacts);
132 res.b = bvh::narrowphase_result(sizeof(NarrowphaseResult), num_possible_contacts);
133 auto resa = bvh::typed_narrowphase_result<NarrowphaseResult>(res.a);
134 auto resb = bvh::typed_narrowphase_result<NarrowphaseResult>(res.b);
135 auto tree = bvh::build_snapshot_tree_top_down(_a.elements);
136
137 Kokkos::parallel_for(_b.elements.extent(0), KOKKOS_LAMBDA(int i) {
138 auto elb = _b.elements(i);
139 auto ra = resa;
140 auto rb = resb;
141 query_tree_local(tree, elb, [&_a, &_b, &elb, &ra, &rb, this](std::size_t _i) {
142 const auto& face = _a.elements[_i];
143 const auto& node = elb;
144 NarrowphaseResult entry;
145
146 bool hit = false;
147 double norm[3];
148 ContactManager::Projection(node, face, hit, entry.gap, norm, entry.bary);
149
150 if (hit) {
151 details::getContactForce(contact_manager->GetPenaltyForceParam(), entry.gap, norm, entry.contact_force);
152
153 entry.local_index = face.local_id();
154 entry.node = false;
155 ra.emplace_back(entry);
156
157 entry.local_index = node.local_id();
158 entry.node = true;
159 rb.emplace_back(entry);
160 }
161 });
162 });
163
164 return res;
165 }
static void Projection(const ContactEntity &node, const ContactEntity &tri, bool &in, double &gap, double *normal, double *barycentric_coordinates, double tolerance=1.e-8)
Compute the projection of a point onto a triangular face.
Definition nimble_contact_manager.cc:1550
void getContactForce(const double penalty, const double gap, const double normal[3], double contact_force[3])
Definition nimble_contact_manager.h:82

Member Data Documentation

◆ contact_manager

BvhContactManager* nimble::NarrowphaseFunc::contact_manager

The documentation for this struct was generated from the following file: