UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
XPBDCorotatedConstraints.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
5#include "ChaosStats.h"
10
11DECLARE_CYCLE_STAT(TEXT("Chaos XPBD Corotated Constraint"), STAT_ChaosXPBDCorotated, STATGROUP_Chaos);
12DECLARE_CYCLE_STAT(TEXT("Chaos XPBD Corotated Constraint Polar Compute"), STAT_ChaosXPBDCorotatedPolar, STATGROUP_Chaos);
13DECLARE_CYCLE_STAT(TEXT("Chaos XPBD Corotated Constraint Det Compute"), STAT_ChaosXPBDCorotatedDet, STATGROUP_Chaos);
14
15namespace Chaos::Softs
16{
17
18 template <typename T, typename ParticleType>
20 {
21
22 public:
23 //this one only accepts tetmesh input and mesh
25 const ParticleType& InParticles,
27 const bool bRecordMetricIn = true,
28 const T& EMesh = (T)10.0,
29 const T& NuMesh = (T).3
30 )
32 {
33
34 LambdaArray.Init((T)0., 2 * MeshConstraints.Num());
35 DmInverse.Init((T)0., 9 * MeshConstraints.Num());
36 Measure.Init((T)0., MeshConstraints.Num());
37 Lambda = EMesh * NuMesh / (((T)1. + NuMesh) * ((T)1. - (T)2. * NuMesh));
38 Mu = EMesh / ((T)2. * ((T)1. + NuMesh));
39 for (int e = 0; e < InMesh.Num(); e++)
40 {
42 PMatrix<T, 3, 3> DmInv = Dm.Inverse();
43 for (int r = 0; r < 3; r++) {
44 for (int c = 0; c < 3; c++) {
45 DmInverse[(3 * 3) * e + 3 * r + c] = DmInv.GetAt(r, c);
46 }
47 }
48
49 Measure[e] = Dm.Determinant() / (T)6.;
50
51 //part of preprocessing: if inverted element is found,
52 //invert it so that the measure is positive
53 if (Measure[e] < (T)0.)
54 {
55
56 Measure[e] = -Measure[e];
57 }
58
59 }
62 }
63
65 const ParticleType& InParticles,
67 const TArray<T>& EMeshArray,
68 const T& NuMesh = (T).3,
69 const bool bRecordMetricIn = false
70 )
72 {
73 ensureMsgf(EMeshArray.Num() == InMesh.Num(), TEXT("Input Young Modulus Array Size is wrong"));
74 LambdaArray.Init((T)0., 2 * MeshConstraints.Num());
75 DmInverse.Init((T)0., 9 * MeshConstraints.Num());
76 Measure.Init((T)0., MeshConstraints.Num());
79
80 for (int e = 0; e < InMesh.Num(); e++)
81 {
82 for (int32 j = 0; j < 4; j++)
83 {
84 ensure(MeshConstraints[e][j] > -1 && MeshConstraints[e][j] < int32(InParticles.Size()));
85 }
86 }
87
88 for (int e = 0; e < InMesh.Num(); e++)
89 {
90 LambdaElementArray[e] = EMeshArray[e] * NuMesh / (((T)1. + NuMesh) * ((T)1. - (T)2. * NuMesh));
91 MuElementArray[e] = EMeshArray[e] / ((T)2. * ((T)1. + NuMesh));
92
94 PMatrix<T, 3, 3> DmInv = Dm.Inverse();
95 for (int r = 0; r < 3; r++) {
96 for (int c = 0; c < 3; c++) {
97 DmInverse[(3 * 3) * e + 3 * r + c] = DmInv.GetAt(r, c);
98 }
99 }
100
101 Measure[e] = Dm.Determinant() / (T)6.;
102
103 if (Measure[e] < (T)0.)
104 {
105 Measure[e] = -Measure[e];
106 }
107 }
110 }
111
113 const ParticleType& InParticles,
115 const TArray<T>& EMeshArray,
116 const TArray<T>& NuMeshArray,
119 const T& NuMesh = (T).3,
120 const bool bRecordMetricIn = false,
121 const bool bDoColoring = true
122 )
124 {
125 ensureMsgf(EMeshArray.Num() == InMesh.Num(), TEXT("Input Young Modulus Array Size is wrong"));
126 LambdaArray.Init((T)0., 2 * MeshConstraints.Num());
127 DmInverse.Init((T)0., 9 * MeshConstraints.Num());
128 Measure.Init((T)0., MeshConstraints.Num());
130 MuElementArray.Init((T)0., MeshConstraints.Num());
131
132 for (int e = 0; e < InMesh.Num(); e++)
133 {
134 for (int32 j = 0; j < 4; j++)
135 {
136 ensure(MeshConstraints[e][j] > -1 && MeshConstraints[e][j] < int32(InParticles.Size()));
137
138 if (InParticles.InvM(MeshConstraints[e][j]) == (T)0.)
139 {
140 AlphaJArray[e] = (T)1.;
141 }
142 }
143
144 }
145
146 for (int e = 0; e < InMesh.Num(); e++)
147 {
148 LambdaElementArray[e] = EMeshArray[e] * NuMeshArray[e] / (((T)1. + NuMeshArray[e]) * ((T)1. - (T)2. * NuMeshArray[e]));
149 MuElementArray[e] = EMeshArray[e] / ((T)2. * ((T)1. + NuMeshArray[e]));
150
152 PMatrix<T, 3, 3> DmInv = Dm.Inverse();
153 for (int r = 0; r < 3; r++) {
154 for (int c = 0; c < 3; c++) {
155 DmInverse[(3 * 3) * e + 3 * r + c] = DmInv.GetAt(r, c);
156 }
157 }
158
159 Measure[e] = Dm.Determinant() / (T)6.;
160
161 if (Measure[e] < (T)0.)
162 {
163 Measure[e] = -Measure[e];
164 }
165 }
167 if (bDoColoring) {
169 }
170 }
171
173 const ParticleType& InParticles,
175 const T GridN = (T).1,
176 const T& EMesh = (T)10.0,
177 const T& NuMesh = (T).3
178 )
180 {
181 LambdaArray.Init((T)0., 2 * MeshConstraints.Num());
182 DmInverse.Init((T)0., 9 * MeshConstraints.Num());
183 Measure.Init((T)0., MeshConstraints.Num());
184 Lambda = EMesh * NuMesh / (((T)1. + NuMesh) * ((T)1. - (T)2. * NuMesh));
185 Mu = EMesh / ((T)2. * ((T)1. + NuMesh));
186 for (int e = 0; e < InMesh.Num(); e++)
187 {
189 PMatrix<T, 3, 3> DmInv = Dm.Inverse();
190 for (int r = 0; r < 3; r++) {
191 for (int c = 0; c < 3; c++) {
192 DmInverse[(3 * 3) * e + 3 * r + c] = DmInv.GetAt(r, c);
193 }
194 }
195
196 Measure[e] = Dm.Determinant() / (T)6.;
197
198 if (Measure[e] < (T)0.)
199 {
200 Measure[e] = -Measure[e];
201 }
202 }
204 }
205
207
208 PMatrix<T, 3, 3> DsInit(const int e, const ParticleType& InParticles) const {
209 PMatrix<T, 3, 3> Result((T)0.);
210 for (int i = 0; i < 3; i++) {
211 for (int c = 0; c < 3; c++) {
212 Result.SetAt(c, i, InParticles.GetX(MeshConstraints[e][i + 1])[c] - InParticles.GetX(MeshConstraints[e][0])[c]);
213 }
214 }
215 return Result;
216 }
217
218
219 PMatrix<T, 3, 3> Ds(const int e, const ParticleType& InParticles) const {
220 PMatrix<T, 3, 3> Result((T)0.);
221 for (int i = 0; i < 3; i++) {
222 for (int c = 0; c < 3; c++) {
223 Result.SetAt(c, i, InParticles.GetP(MeshConstraints[e][i+1])[c] - InParticles.GetP(MeshConstraints[e][0])[c]);
224 }
225 }
226 return Result;
227 }
228
229
230 PMatrix<T, 3, 3> F(const int e, const ParticleType& InParticles) const {
231 return ElementDmInv(e) * Ds(e, InParticles);
232 }
233
234 PMatrix<T, 3, 3> ElementDmInv(const int e) const {
235 PMatrix<T, 3, 3> DmInv((T)0.);
236 for (int r = 0; r < 3; r++) {
237 for (int c = 0; c < 3; c++) {
238 DmInv.SetAt(r, c, DmInverse[(3 * 3) * e + 3 * r + c]);
239 }
240 }
241 return DmInv;
242 }
243
245 PMatrix<T, 3, 3> DmInv((T)0.);
246 for (int r = 0; r < 3; r++) {
247 for (int c = 0; c < 3; c++) {
248 DmInv.SetAt(r, c, DmInverseSave[(3 * 3) * e + 3 * r + c]);
249 }
250 }
251 return DmInv;
252 }
253
254 virtual void Init() const
255 {
256 for (T& Lambdas : LambdaArray) { Lambdas = (T)0.; }
257 }
258
259 virtual void ApplyInSerial(ParticleType& Particles, const T Dt, const int32 ElementIndex) const
260 {
262
263 TVec4<TVector<T, 3>> PolarDelta = GetPolarDelta(Particles, Dt, ElementIndex);
264
265 for (int i = 0; i < 4; i++)
266 {
267 Particles.P(MeshConstraints[ElementIndex][i]) += PolarDelta[i];
268 }
269
270 TVec4<TVector<T, 3>> DetDelta = GetDeterminantDelta(Particles, Dt, ElementIndex);
271
272 for (int i = 0; i < 4; i++)
273 {
274 Particles.P(MeshConstraints[ElementIndex][i]) += DetDelta[i];
275 }
276
277 }
278
297
298 void ApplyInParallel(ParticleType& Particles, const T Dt) const
299 {
300 //code for error metric:
301 if (bRecordMetric)
302 {
303 GError.Init((T)0., 3 * Particles.Size());
304 HErrorArray.Init((T)0., 2 * MeshConstraints.Num());
305 }
306
307 {
310 if ((ConstraintsPerColorStartIndex.Num() > 1))//&& (MeshConstraints.Num() > Chaos_Spring_ParallelConstraintCount))
311 {
313
315 {
318
321 {
322 NumBatch += 1;
323 }
324
325 PhysicsParallelFor(NumBatch, [&](const int32 BatchIndex)
326 {
329 const int32 ConstraintIndex = ColorStart + TaskIndex;
330 if (ConstraintIndex < ColorStart + ColorSize)
331 {
332 ApplyInSerial(Particles, Dt, ConstraintIndex);
333 }
334 }
336 }
337 }
338 }
339 }
340
342 {
343 //TVector<T, 81> dRdF((T)0.);
344 //Chaos::dRdFCorotated(Fe, dRdF);
346 //dC1 = dC1dF * dFdX
347 PMatrix<T, 3, 3> A = DmInvT * (Fe - Re);
348 for (int alpha = 0; alpha < 3; alpha++) {
349 for (int l = 0; l < 3; l++) {
350 dC1[0][alpha] -= A.GetAt(alpha, l);
351 }
352 }
353 for (int ie = 0; ie < 3; ie++) {
354 for (int alpha = 0; alpha < 3; alpha++) {
355 dC1[ie + 1][alpha] = A.GetAt(alpha, ie);
356 }
357 }
358
359 if (C1 != 0)
360 {
361 for (int i = 0; i < 4; i++)
362 {
363 for (int j = 0; j < 3; j++)
364 {
365 dC1[i][j] /= C1;
366 }
367 }
368 }
369 return dC1;
370
371 }
372
374 {
376 //SCOPE_CYCLE_COUNTER(STAT_ChaosXPBDCorotatedDet);
377 //const TVec4<int32>& Constraint = MeshConstraints[ElementIndex];
378
379 //const PMatrix<T, 3, 3> Fe = F(ElementIndex, Particles);
380 //PMatrix<T, 3, 3> DmInvT = ElementDmInv(ElementIndex).GetTransposed();
382
384 JFinvT.SetAt(0, 0, Fe.GetAt(1, 1) * Fe.GetAt(2, 2) - Fe.GetAt(2, 1) * Fe.GetAt(1, 2));
385 JFinvT.SetAt(0, 1, Fe.GetAt(2, 0) * Fe.GetAt(1, 2) - Fe.GetAt(1, 0) * Fe.GetAt(2, 2));
386 JFinvT.SetAt(0, 2, Fe.GetAt(1, 0) * Fe.GetAt(2, 1) - Fe.GetAt(2, 0) * Fe.GetAt(1, 1));
387 JFinvT.SetAt(1, 0, Fe.GetAt(2, 1) * Fe.GetAt(0, 2) - Fe.GetAt(0, 1) * Fe.GetAt(2, 2));
388 JFinvT.SetAt(1, 1, Fe.GetAt(0, 0) * Fe.GetAt(2, 2) - Fe.GetAt(2, 0) * Fe.GetAt(0, 2));
389 JFinvT.SetAt(1, 2, Fe.GetAt(2, 0) * Fe.GetAt(0, 1) - Fe.GetAt(0, 0) * Fe.GetAt(2, 1));
390 JFinvT.SetAt(2, 0, Fe.GetAt(0, 1) * Fe.GetAt(1, 2) - Fe.GetAt(1, 1) * Fe.GetAt(0, 2));
391 JFinvT.SetAt(2, 1, Fe.GetAt(1, 0) * Fe.GetAt(0, 2) - Fe.GetAt(0, 0) * Fe.GetAt(1, 2));
392 JFinvT.SetAt(2, 2, Fe.GetAt(0, 0) * Fe.GetAt(1, 1) - Fe.GetAt(1, 0) * Fe.GetAt(0, 1));
393
395
396 for (int ie = 0; ie < 3; ie++) {
397 for (int alpha = 0; alpha < 3; alpha++) {
398 dC2[ie + 1][alpha] = JinvTDmInvT.GetAt(alpha, ie);
399 }
400 }
401 for (int alpha = 0; alpha < 3; alpha++) {
402 for (int l = 0; l < 3; l++) {
403 dC2[0][alpha] -= JinvTDmInvT.GetAt(alpha, l);
404 }
405 }
406 return dC2;
407 }
408
409 void ModifyDmInverseFromMuscleLength(const int32 ElemIdx, const T FiberLengthRatio, const PMatrix<T, 3, 3>& FiberDir, const T ContractionVolumeScale) const
410 {
413 if (FiberLengthRatio < 1)
414 {
415 PMatrix<T, 3, 3> D(1 / FiberLengthRatio, FMath::Pow(FiberLengthRatio, ContractionVolumeScale/T(2)), FMath::Pow(FiberLengthRatio, ContractionVolumeScale/T(2)));
416 PMatrix<T, 3, 3> Factor = FiberDir * D * FiberDir.GetTransposed();
417 DmInv = Factor * DmInv; //Matrix multiplication convention: AB = B*A
418 }
419 for (int Row = 0; Row < 3; Row++)
420 {
421 for (int Column = 0; Column < 3; Column++)
422 {
423 DmInverse[(3 * 3) * ElemIdx + 3 * Row + Column] = DmInv.GetAt(Row, Column);
424 }
425 }
426 }
427
428 void ModifyDmInverseSaveFromInflationVolumeScale(const int32 ElemIdx, const T InflationVolumeScale, const PMatrix<T, 3, 3>& FiberDir)
429 {
431 if (FMath::Abs(InflationVolumeScale - 1) > UE_SMALL_NUMBER)
432 {
433 T InvSqrt = FMath::InvSqrt(InflationVolumeScale);
434 PMatrix<T, 3, 3> D(1, InvSqrt, InvSqrt);
435 PMatrix<T, 3, 3> Factor = FiberDir * D * FiberDir.GetTransposed();
436 DmInv = Factor * DmInv; //Matrix multiplication convention: AB = B*A
437 }
438 for (int Row = 0; Row < 3; Row++)
439 {
440 for (int Column = 0; Column < 3; Column++)
441 {
442 DmInverseSave[(3 * 3) * ElemIdx + 3 * Row + Column] = DmInv.GetAt(Row, Column);
443 DmInverse[(3 * 3) * ElemIdx + 3 * Row + Column] = DmInv.GetAt(Row, Column);
444 }
445 }
446 }
447 protected:
448
449 void InitColor(const ParticleType& Particles)
450 {
451
452 {
453 const TArray<TArray<int32>> ConstraintsPerColor = FGraphColoring::ComputeGraphColoring(MeshConstraints, Particles);
454
455 // Reorder constraints based on color so each array in ConstraintsPerColor contains contiguous elements.
459 TArray<int32> OrigToReorderedIndices; // used to reorder stiffness indices
461 ReorderedMeasure.SetNumUninitialized(Measure.Num());
462 ReorderedDmInverse.SetNumUninitialized(DmInverse.Num());
463 OrigToReorderedIndices.SetNumUninitialized(MeshConstraints.Num());
464
465 ConstraintsPerColorStartIndex.Reset(ConstraintsPerColor.Num() + 1);
466
468 for (const TArray<int32>& ConstraintsBatch : ConstraintsPerColor)
469 {
472 {
476 for (int32 kk = 0; kk < 9; kk++)
477 {
479 }
481
483 }
484 }
486
490 }
491 }
492
493
494 virtual TVec4<TVector<T, 3>> GetDeterminantDelta(const ParticleType& Particles, const T Dt, const int32 ElementIndex, const T Tol = (T)1e-3) const
495 {
497 //SCOPE_CYCLE_COUNTER(STAT_ChaosXPBDCorotatedDet);
499
500 const PMatrix<T, 3, 3> Fe = F(ElementIndex, Particles);
501 PMatrix<T, 3, 3> DmInvT = ElementDmInv(ElementIndex).GetTransposed();
502
503 T J = Fe.Determinant();
504 if (J - AlphaJArray[ElementIndex] < Tol)
505 {
506 return TVec4<TVector<T, 3>>(TVector<T, 3>((T)0.));
507 }
508
510
511 //T AlphaTilde = (T)2. / (Dt * Dt * Lambda * Measure[ElementIndex]);
512 T AlphaTilde = (T)2. / (Dt * Dt * LambdaElementArray[ElementIndex] * Measure[ElementIndex]);
513
514 if (LambdaElementArray[ElementIndex] > (T)1. / (T)UE_SMALL_NUMBER)
515 {
516 AlphaTilde = (T)0.;
517 }
518
519 if (bRecordMetric)
520 {
521 HError += J - 1 + AlphaTilde * LambdaArray[2 * ElementIndex + 1];
522 for (int32 ie = 0; ie < 4; ie++)
523 {
524 for (int32 Alpha = 0; Alpha < 3; Alpha++)
525 {
526 GError[MeshConstraints[ElementIndex][ie] * 3 + Alpha] -= dC2[ie][Alpha] * LambdaArray[2 * ElementIndex + 1];
527 }
528 }
529 HErrorArray[2 * ElementIndex + 1] = J - 1 + AlphaTilde * LambdaArray[2 * ElementIndex + 1];
530 }
531
532
533 T DLambda = (AlphaJArray[ElementIndex] - J) - AlphaTilde * LambdaArray[2 * ElementIndex + 1];
534
535 T Denom = AlphaTilde;
536 for (int i = 0; i < 4; i++)
537 {
538 for (int j = 0; j < 3; j++)
539 {
540 Denom += dC2[i][j] * Particles.InvM(MeshConstraints[ElementIndex][i]) * dC2[i][j];
541 }
542 }
543 DLambda /= Denom;
544 LambdaArray[2 * ElementIndex + 1] += DLambda;
546 for (int i = 0; i < 4; i++)
547 {
548 for (int j = 0; j < 3; j++)
549 {
550 Delta[i][j] = Particles.InvM(MeshConstraints[ElementIndex][i]) * dC2[i][j] * DLambda;
551 }
552 }
553 return Delta;
554 }
555
556
557
558 virtual TVec4<TVector<T, 3>> GetPolarDelta(const ParticleType& Particles, const T Dt, const int32 ElementIndex, const T Tol = (T)1e-3) const
559 {
562 const PMatrix<T, 3, 3> Fe = F(ElementIndex, Particles);
563
564 PMatrix<T, 3, 3> Re((T)0.), Se((T)0.);
565
567
568 Re *= FGenericPlatformMath::Pow(AlphaJArray[ElementIndex], (T)1. / (T)3.);
569
570 T C1 = (T)0.;
571 for (int i = 0; i < 3; i++)
572 {
573 for (int j = 0; j < 3; j++)
574 {
575 C1 += FMath::Square((Fe - Re).GetAt(i, j));
576 }
577 }
578 C1 = FMath::Sqrt(C1);
579
580 if (C1 < Tol )
581 {
582 return TVec4<TVector<T, 3>>(TVector<T, 3>((T)0.));
583 }
584
585
586 PMatrix<T, 3, 3> DmInvT = ElementDmInv(ElementIndex).GetTransposed();
587
589
590 //T AlphaTilde = (T)1. / (Dt * Dt * Mu * Measure[ElementIndex]);
591 T AlphaTilde = (T)1. / (Dt * Dt * MuElementArray[ElementIndex] * Measure[ElementIndex]);
592
593 if (MuElementArray[ElementIndex] > (T)1./ (T)UE_SMALL_NUMBER)
594 {
595 AlphaTilde = (T)0.;
596 }
597
598 if (bRecordMetric)
599 {
600 HError += C1 + AlphaTilde * LambdaArray[2 * ElementIndex + 0];
601 for (int32 ie = 0; ie < 4; ie++)
602 {
603 for (int32 Alpha = 0; Alpha < 3; Alpha++)
604 {
605 GError[MeshConstraints[ElementIndex][ie] * 3 + Alpha] -= dC1[ie][Alpha] * LambdaArray[2 * ElementIndex + 0];
606 }
607 }
608 HErrorArray[2 * ElementIndex + 0] = C1 + AlphaTilde * LambdaArray[2 * ElementIndex + 0];
609 }
610
611 T DLambda = -C1 - AlphaTilde* LambdaArray[2 * ElementIndex + 0];
612
613 T Denom = AlphaTilde;
614 for (int i = 0; i < 4; i++)
615 {
616 for (int j = 0; j < 3; j++)
617 {
618 Denom += dC1[i][j] * Particles.InvM(MeshConstraints[ElementIndex][i]) * dC1[i][j];
619 }
620 }
621 DLambda /= Denom;
622 LambdaArray[2 * ElementIndex + 0] += DLambda;
624 for (int i = 0; i < 4; i++)
625 {
626 for (int j = 0; j < 3; j++)
627 {
628 Delta[i][j] = Particles.InvM(MeshConstraints[ElementIndex][i]) * dC1[i][j] * DLambda;
629 }
630 }
631 return Delta;
632
633 }
634
635
636 protected:
640 //parallel data:
642
643 //material constants calculated from E:
644 T Mu;
649 mutable T HError;
652 bool VariableStiffness = false;
653
656 ParticleType RestParticles;
657 TArray<int32> ConstraintsPerColorStartIndex; // Constraints are ordered so each batch is contiguous. This is ColorNum + 1 length so it can be used as start and end.
659};
660
661} // End namespace Chaos::Softs
662
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define DECLARE_CYCLE_STAT(CounterName, StatId, GroupId)
Definition Stats.h:669
#define SCOPE_CYCLE_COUNTER(Stat)
Definition Stats.h:650
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define TRACE_CPUPROFILER_EVENT_SCOPE(Name)
Definition CpuProfilerTrace.h:528
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
static TArray< TArray< int32 > > ComputeGraphColoring(const TArray< TVector< int32, N > > &Graph, const TDynamicParticles< T, 3 > &InParticles, const int32 GraphParticlesStart, const int32 GraphParticlesEnd)
Definition GraphColoring.h:24
Definition Matrix.h:21
Definition XPBDCorotatedConstraints.h:20
FXPBDCorotatedConstraints(const ParticleType &InParticles, const TArray< TVector< int32, 4 > > &InMesh, const TArray< T > &EMeshArray, const T &NuMesh=(T).3, const bool bRecordMetricIn=false)
Definition XPBDCorotatedConstraints.h:64
TArray< T > LambdaArray
Definition XPBDCorotatedConstraints.h:637
ParticleType RestParticles
Definition XPBDCorotatedConstraints.h:656
TArray< T > HErrorArray
Definition XPBDCorotatedConstraints.h:650
FXPBDCorotatedConstraints(const ParticleType &InParticles, const TArray< TVector< int32, 4 > > &InMesh, const T GridN=(T).1, const T &EMesh=(T) 10.0, const T &NuMesh=(T).3)
Definition XPBDCorotatedConstraints.h:172
void ApplyInSerial(ParticleType &Particles, const T Dt) const
Definition XPBDCorotatedConstraints.h:279
TArray< TVector< int32, 4 > > MeshConstraints
Definition XPBDCorotatedConstraints.h:654
TArray< T > Measure
Definition XPBDCorotatedConstraints.h:655
TArray< T > AlphaJArray
Definition XPBDCorotatedConstraints.h:648
void ModifyDmInverseSaveFromInflationVolumeScale(const int32 ElemIdx, const T InflationVolumeScale, const PMatrix< T, 3, 3 > &FiberDir)
Definition XPBDCorotatedConstraints.h:428
FXPBDCorotatedConstraints(const ParticleType &InParticles, const TArray< TVector< int32, 4 > > &InMesh, const TArray< T > &EMeshArray, const TArray< T > &NuMeshArray, TArray< T > &&AlphaJMeshArray, const FDeformableXPBDCorotatedParams &InParams, const T &NuMesh=(T).3, const bool bRecordMetricIn=false, const bool bDoColoring=true)
Definition XPBDCorotatedConstraints.h:112
void ApplyInParallel(ParticleType &Particles, const T Dt) const
Definition XPBDCorotatedConstraints.h:298
T Lambda
Definition XPBDCorotatedConstraints.h:645
FDeformableXPBDCorotatedParams CorotatedParams
Definition XPBDCorotatedConstraints.h:641
PMatrix< T, 3, 3 > DsInit(const int e, const ParticleType &InParticles) const
Definition XPBDCorotatedConstraints.h:208
T HError
Definition XPBDCorotatedConstraints.h:649
TArray< int32 > ConstraintsPerColorStartIndex
Definition XPBDCorotatedConstraints.h:657
void InitColor(const ParticleType &Particles)
Definition XPBDCorotatedConstraints.h:449
virtual void Init() const
Definition XPBDCorotatedConstraints.h:254
virtual void ApplyInSerial(ParticleType &Particles, const T Dt, const int32 ElementIndex) const
Definition XPBDCorotatedConstraints.h:259
TArray< T > DmInverse
Definition XPBDCorotatedConstraints.h:638
FXPBDCorotatedConstraints(const ParticleType &InParticles, const TArray< TVector< int32, 4 > > &InMesh, const bool bRecordMetricIn=true, const T &EMesh=(T) 10.0, const T &NuMesh=(T).3)
Definition XPBDCorotatedConstraints.h:24
PMatrix< T, 3, 3 > F(const int e, const ParticleType &InParticles) const
Definition XPBDCorotatedConstraints.h:230
TArray< T > MuElementArray
Definition XPBDCorotatedConstraints.h:646
TVec4< TVector< T, 3 > > GetDeterminantGradient(const PMatrix< T, 3, 3 > &Fe, const PMatrix< T, 3, 3 > &DmInvT) const
Definition XPBDCorotatedConstraints.h:373
virtual ~FXPBDCorotatedConstraints()
Definition XPBDCorotatedConstraints.h:206
virtual TVec4< TVector< T, 3 > > GetPolarDelta(const ParticleType &Particles, const T Dt, const int32 ElementIndex, const T Tol=(T) 1e-3) const
Definition XPBDCorotatedConstraints.h:558
TArray< T > DmInverseSave
Definition XPBDCorotatedConstraints.h:639
PMatrix< T, 3, 3 > ElementDmInv(const int e) const
Definition XPBDCorotatedConstraints.h:234
TVec4< TVector< T, 3 > > GetPolarGradient(const PMatrix< T, 3, 3 > &Fe, const PMatrix< T, 3, 3 > &Re, const PMatrix< T, 3, 3 > &DmInvT, const T C1) const
Definition XPBDCorotatedConstraints.h:341
TArray< T > LambdaElementArray
Definition XPBDCorotatedConstraints.h:647
PMatrix< T, 3, 3 > ElementDmInvSave(const int e) const
Definition XPBDCorotatedConstraints.h:244
TArray< T > GError
Definition XPBDCorotatedConstraints.h:658
bool VariableStiffness
Definition XPBDCorotatedConstraints.h:652
T Mu
Definition XPBDCorotatedConstraints.h:644
PMatrix< T, 3, 3 > Ds(const int e, const ParticleType &InParticles) const
Definition XPBDCorotatedConstraints.h:219
bool bRecordMetric
Definition XPBDCorotatedConstraints.h:651
void ModifyDmInverseFromMuscleLength(const int32 ElemIdx, const T FiberLengthRatio, const PMatrix< T, 3, 3 > &FiberDir, const T ContractionVolumeScale) const
Definition XPBDCorotatedConstraints.h:409
virtual TVec4< TVector< T, 3 > > GetDeterminantDelta(const ParticleType &Particles, const T Dt, const int32 ElementIndex, const T Tol=(T) 1e-3) const
Definition XPBDCorotatedConstraints.h:494
Definition Vector.h:41
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void Reset(SizeType NewSize=0)
Definition Array.h:2246
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
void Init(const ElementType &Element, SizeType Number)
Definition Array.h:3043
void SetNumUninitialized(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2369
Definition CollectionEmbeddedSpringConstraintFacade.cpp:6
void CHAOS_API PhysicsParallelFor(int32 InNum, TFunctionRef< void(int32)> InCallable, bool bForceSingleThreaded=false)
Definition Parallel.cpp:55
void PolarDecomposition(const PMatrix< T, 2, 2 > &A, GivensRotation< T > &R, PMatrix< T, 2, 2 > &S_Sym)
2x2 polar decomposition.
Definition ImplicitQRSVD.h:323
U16 Index
Definition radfft.cpp:71
Definition ChaosDeformableSolverTypes.h:219
int32 XPBDCorotatedBatchSize
Definition ChaosDeformableSolverTypes.h:220
int32 XPBDCorotatedBatchThreshold
Definition ChaosDeformableSolverTypes.h:221
static UE_FORCEINLINE_HINT float Pow(float A, float B)
Definition GenericPlatformMath.h:555
static constexpr UE_FORCEINLINE_HINT T Square(const T A)
Definition UnrealMathUtility.h:578