Add caching for flex stiffness computation.
This change introduces methods to cache and load the computed stiffness matrix and nodal masses for flex elements. The cache key is generated based on material properties (Young's modulus, Poisson's ratio), interpolation order, and the bounding box of the flex. This avoids redundant expensive computations when compiling models with identical flex definitions. PiperOrigin-RevId: 874689771 Change-Id: I6d1e299baf294a984b507e2a2602b2c068610536
This commit is contained in:
committed by
Copybara-Service
parent
f383e60721
commit
09c7633a76
@@ -992,6 +992,9 @@ class mjCFlex_ : public mjCBase {
|
||||
std::vector<int> spec_elem_;
|
||||
std::vector<float> spec_texcoord_;
|
||||
std::vector<int> spec_elemtexcoord_;
|
||||
|
||||
// caching
|
||||
std::vector<double> cached_stiffness_; // cached stiffness matrix
|
||||
};
|
||||
|
||||
class mjCFlex: public mjCFlex_, private mjsFlex {
|
||||
@@ -1040,6 +1043,11 @@ class mjCFlex: public mjCFlex_, private mjsFlex {
|
||||
std::vector<double> node0_; // node Cartesian positions
|
||||
|
||||
int order_ = 0; // interpolation order
|
||||
|
||||
// stiffness caching
|
||||
std::string ComputeStiffnessCacheKey() const;
|
||||
bool LoadCachedStiffness();
|
||||
void CacheStiffness();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user