Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,58 @@ class SOFA_COMPONENT_SOLIDMECHANICS_FEM_HYPERELASTIC_API BaseMaterial : public v
this->core::objectmodel::BaseComponent::init();
}


//virtual VecN computeStress (VecN & strain,int idElement,int id_QP){return stress in the i-th quadrature point}
//So here needed the shapefunctionvalue * , quadratureformular* (verifie if shapfunctionvalue compute with the local method)
// The same principe for computing the strain given the displacement

/**
* !!! WARNING since v25.12 !!!
*
* The template method pattern has been applied to this part of the API.
* This method calls the newly introduced method "doComputeStress" internally,
* which is the method to override from now on.
*
**/
virtual void computeStress (type::Vec3 & stress, type::Vec3 & strain, unsigned int & elementIndex) final {
//TODO (SPRINT SED 2025): Component state mechamism
this->doComputeStress(stress, strain, elementIndex);
}

/**
* !!! WARNING since v25.12 !!!
*
* The template method pattern has been applied to this part of the API.
* This method calls the newly introduced method "doComputeDStress" internally,
* which is the method to override from now on.
*
**/
virtual void computeDStress (type::Vec3 & dstress, type::Vec3 & dstrain) final {
//TODO (SPRINT SED 2025): Component state mechamism
this->doComputeDStress(dstress, dstrain);
}

virtual void computeStress (type::Vec3 & ,type::Vec3 &,unsigned int &) {}
virtual void computeDStress (type::Vec3 & ,type::Vec3 &) {}
/**
* !!! WARNING since v25.12 !!!
*
* The template method pattern has been applied to this part of the API.
* This method calls the newly introduced method "doComputeStress" internally,
* which is the method to override from now on.
*
**/
virtual void computeStress (unsigned int elementIndex) final {
//TODO (SPRINT SED 2025): Component state mechamism
this->doComputeStress(elementIndex);
};

virtual void computeStress (unsigned int /*iElement*/)=0;//to be pure virtual

protected:
virtual void doComputeStress(type::Vec3 & stress, type::Vec3 & strain, unsigned int & idElement) = 0;
virtual void doComputeDStress(type::Vec3 & dstress, type::Vec3 & dstrain) = 0;
virtual void doComputeStress(unsigned int elementIndex) = 0;

private:
BaseMaterial(const BaseMaterial& n) ;
BaseMaterial& operator=(const BaseMaterial& n) ;


};

} // namespace sofa::component::solidmechanics::fem::hyperelastic::material
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PlasticMaterial::PlasticMaterial()
_sigma.push_back(Stress);
}

void PlasticMaterial::computeStress(Vec3& Stress, Vec3& Strain, unsigned int& elementIndex)
void PlasticMaterial::doComputeStress(Vec3& Stress, Vec3& Strain, unsigned int& elementIndex)
{
// Computes the Von Mises strain
const SReal vonMisesStrain = computeVonMisesStrain(Strain);
Expand Down Expand Up @@ -78,7 +78,7 @@ void PlasticMaterial::computeStress(Vec3& Stress, Vec3& Strain, unsigned int& el
_previousVonMisesStrain.push_back(vonMisesStrain);
}

void PlasticMaterial::computeDStress(Vec3& dStress, Vec3& dStrain)
void PlasticMaterial::doComputeDStress(Vec3& dStress, Vec3& dStrain)
{
dStress[0] = dStrain[0] + _poissonRatio.getValue() * dStrain[1];
dStress[1] = _poissonRatio.getValue() * dStrain[0] + dStrain[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ class PlasticMaterial : public BaseMaterial
VecDouble _previousVonMisesStrain;

PlasticMaterial();
void computeStress (Vec3& stress, Vec3& strain, unsigned int& elementIndex) override;
void computeDStress (Vec3& dstress, Vec3& dstrain) override;

SReal computeVonMisesStrain(Vec3 &strain);
void computeStressOnSection(Vec3& Stress, Vec3 Strain, int section); // computes the stress on a given section of the piecewise function

void computeStress (unsigned int /*iElement*/) override {}
protected:
void doComputeStress (Vec3& stress, Vec3& strain, unsigned int& elementIndex) override;
void doComputeDStress (Vec3& dstress, Vec3& dstrain) override;
void doComputeStress (unsigned int /*elementIndex*/) override {}

};

Expand Down
Loading