Skip to content

Commit c2dcd3e

Browse files
authored
Merge pull request #5 from projectchrono/Mesh_Particles_Exp
Temporarily fix maxTriTriPenetration
2 parents ae911cf + 775e2c1 commit c2dcd3e

5 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/DEM/APIPrivate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@ void DEMSolver::setSolverParams() {
11171117
// dT->solverFlags.should_sort_pairs = should_sort_contacts;
11181118

11191119
// Error out policies
1120-
kT->solverFlags.errOutAvgSphCnts = threshold_error_out_num_cnts;
1121-
dT->solverFlags.errOutAvgSphCnts = threshold_error_out_num_cnts;
1120+
kT->solverFlags.errOutAvgPrimitiveCnts = threshold_error_out_num_cnts;
1121+
dT->solverFlags.errOutAvgPrimitiveCnts = threshold_error_out_num_cnts;
11221122
// simParams-stored variables need to be sync-ed to device
11231123
kT->simParams->errOutBinSphNum = threshold_too_many_spheres_in_bin;
11241124
dT->simParams->errOutBinSphNum = threshold_too_many_spheres_in_bin;

src/DEM/Structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ struct SolverFlags {
556556
// The max number of average contacts per sphere has before the solver errors out. The reason why I didn't use the
557557
// number of contacts for the sphere that has the most is that, well, we can have a huge sphere and it just will
558558
// have more contacts. But if avg cnt is high, that means probably the contact margin is out of control now.
559-
float errOutAvgSphCnts = 300.;
559+
float errOutAvgPrimitiveCnts = 300.;
560560

561561
// Whether there are contacts that can never be removed.
562562
bool hasPersistentContacts = false;

src/algorithms/DEMContactDetection.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ void contactDetection(std::shared_ptr<JitHelper::CachedProgram>& bin_sphere_kern
11101110
(*pNumUniqueNewA > 0) ? (float)(*scratchPad.numPrimitiveContacts) / (float)(*pNumUniqueNewA) : 0.0;
11111111

11121112
DEME_DEBUG_PRINTF("Average number of contacts for each geometry: %.7g", stateParams.avgCntsPerPrimitive);
1113-
if (stateParams.avgCntsPerPrimitive > solverFlags.errOutAvgSphCnts) {
1113+
if (stateParams.avgCntsPerPrimitive > solverFlags.errOutAvgPrimitiveCnts) {
11141114
DEME_ERROR(
11151115
"On average a primitive (spheres, triangle facets) has %.7g contacts with other primitives, more "
11161116
"than the max allowance (%.7g).\nIf you believe this number is expected with the physics you are "
@@ -1123,7 +1123,7 @@ void contactDetection(std::shared_ptr<JitHelper::CachedProgram>& bin_sphere_kern
11231123
"a.k.a. elements initialized inside walls.\nIf none works and you are going to discuss this on "
11241124
"forum https://groups.google.com/g/projectchrono, please include a visual rendering of the "
11251125
"simulation before crash in the post.\n",
1126-
stateParams.avgCntsPerPrimitive, solverFlags.errOutAvgSphCnts);
1126+
stateParams.avgCntsPerPrimitive, solverFlags.errOutAvgPrimitiveCnts);
11271127
}
11281128

11291129
scratchPad.finishUsingTempVector("new_idA_runlength");

src/demo/DEMdemo_DrumCubes.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ int main() {
3030
DEMSim.SetNoForceRecord();
3131
DEMSim.SetMeshUniversalContact(true);
3232

33-
auto mat_type_cube = DEMSim.LoadMaterial({{"E", 1e9}, {"nu", 0.3}, {"CoR", 0.6}, {"mu", 0.5}, {"Crr", 0.01}});
34-
auto mat_type_drum = DEMSim.LoadMaterial({{"E", 2e9}, {"nu", 0.3}, {"CoR", 0.6}, {"mu", 0.5}, {"Crr", 0.01}});
33+
auto mat_type_cube = DEMSim.LoadMaterial({{"E", 1e6}, {"nu", 0.3}, {"CoR", 0.6}, {"mu", 0.5}, {"Crr", 0.01}});
34+
auto mat_type_drum = DEMSim.LoadMaterial({{"E", 2e6}, {"nu", 0.3}, {"CoR", 0.6}, {"mu", 0.5}, {"Crr", 0.01}});
3535
DEMSim.SetMaterialPropertyPair("mu", mat_type_cube, mat_type_drum, 0.5);
3636

3737
const float cube_size = 0.01f;
@@ -54,13 +54,17 @@ int main() {
5454
float IZZ = CylMass * CylRad * CylRad / 2;
5555
float IYY = (CylMass / 12) * (3 * CylRad * CylRad + CylHeight * CylHeight);
5656
auto Drum = DEMSim.AddExternalObject();
57-
Drum->AddCylinder(CylCenter, CylAxis, CylRad, mat_type_drum, 0);
57+
// Drum->AddCylinder(CylCenter, CylAxis, CylRad, mat_type_drum, 0);
58+
Drum->AddPlane(make_float3(CylRad, 0, 0), make_float3(-1, 0, 0), mat_type_drum);
59+
Drum->AddPlane(make_float3(-CylRad, 0, 0), make_float3(1, 0, 0), mat_type_drum);
60+
Drum->AddPlane(make_float3(0, CylRad, 0), make_float3(0, -1, 0), mat_type_drum);
61+
Drum->AddPlane(make_float3(0, -CylRad, 0), make_float3(0, 1, 0), mat_type_drum);
5862
Drum->SetMass(CylMass);
5963
Drum->SetMOI(make_float3(IYY, IYY, IZZ));
6064
auto Drum_tracker = DEMSim.Track(Drum);
6165
unsigned int drum_family = 100;
6266
Drum->SetFamily(drum_family);
63-
const float rpm = 20.0f;
67+
const float rpm = 200.0f;
6468
const float drum_ang_vel = rpm * 2.0f * PI / 60.0f;
6569
DEMSim.SetFamilyPrescribedAngVel(drum_family, "0", "0", to_string_with_precision(drum_ang_vel));
6670
auto top_bot_planes = DEMSim.AddExternalObject();
@@ -97,7 +101,7 @@ int main() {
97101
float max_v;
98102

99103
DEMSim.InstructBoxDomainDimension(0.4, 0.4, 0.4);
100-
float step_size = 5e-6f;
104+
float step_size = 1e-4f;
101105
DEMSim.SetInitTimeStep(step_size);
102106
DEMSim.SetGPUTimersEnabled(true);
103107
DEMSim.SetGravitationalAcceleration(make_float3(0, 0, -9.81));
@@ -134,7 +138,7 @@ int main() {
134138
<< drum_torque.z << std::endl;
135139

136140
float3 force_on_BC = planes_tracker->ContactAcc() * planes_tracker->Mass();
137-
std::cout << "Contact force on bottom plane is " << force_on_BC.z << std::endl;
141+
std::cout << "Contact force on bottom plane is " << std::abs(force_on_BC.z) << std::endl;
138142

139143
DEMSim.DoDynamics(frame_time);
140144
}

src/kernel/DEMKinematicMisc.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ __global__ void computeMarginFromAbsv_implTri(deme::DEMSimParams* simParams,
8282
// as our meshed particle representation is surface only, so we need to account for existing penetration length
8383
// in our future-proof contact detection, always.
8484
double penetrationMargin = *maxTriTriPenetration;
85-
penetrationMargin = (meshUniversalContact && penetrationMargin > 0.0) ? penetrationMargin : 0.0;
85+
//// TODO: Temporary measure
86+
penetrationMargin = 0.; // (meshUniversalContact && penetrationMargin > 0.0) ? penetrationMargin : 0.0;
8687
// Clamp penetration margin to the maximum allowed value to prevent super large margins
8788
if (penetrationMargin > simParams->capTriTriPenetration) {
8889
penetrationMargin = simParams->capTriTriPenetration;

0 commit comments

Comments
 (0)