Skip to content
Merged
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 @@ -59,7 +59,8 @@ class ConstantForceField : public core::behavior::ForceField<DataTypes>
Data< VecDeriv > d_forces;

/// Force applied at each point, if per-point forces are not specified
Data< Deriv > d_force;
SOFA_ATTRIBUTE_DISABLED__CONSTANTFF_FORCE_DATA()
sofa::core::objectmodel::lifecycle::RemovedData d_force{this, "force", "Replace \"force\" by using the \"forces\" data (providing only one force value) (PR #4019)}"};

/// Sum of the forces applied at each point, if per-point forces are not specified
Data< Deriv > d_totalForce;
Expand All @@ -70,18 +71,12 @@ class ConstantForceField : public core::behavior::ForceField<DataTypes>
/// display color
Data< sofa::type::RGBAColor > d_color;

/// Concerned DOFs indices are numbered from the end of the MState DOFs vector
Data< bool > indexFromEnd;

/// Link to be set to the topology container in the component graph.
SingleLink<ConstantForceField<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;

/// Init function
void init() override;

/// Re-init function
void reinit() override;

/// Add the forces
void addForce (const core::MechanicalParams* params, DataVecDeriv& f, const DataVecCoord& x, const DataVecDeriv& v) override;

Expand All @@ -100,16 +95,16 @@ class ConstantForceField : public core::behavior::ForceField<DataTypes>

void draw(const core::visual::VisualParams* vparams) override;

/// Update data and internal vectors
void doUpdateInternal() override;

/// Set a force to a given particle
void setForce( unsigned i, const Deriv& force );

using Inherit::addAlias ;
using Inherit::addKToMatrix;

void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final;
void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final
{
// No damping in this ForceField
}


protected:
Expand All @@ -125,12 +120,16 @@ class ConstantForceField : public core::behavior::ForceField<DataTypes>
bool checkForces(const VecDeriv& forces);

/// Functions computing and updating the constant force vector
void computeForceFromSingleForce();
void computeForceFromForceVector();
void computeForceFromTotalForce();
sofa::core::objectmodel::ComponentState computeForceFromSingleForce(const Deriv singleForce);
sofa::core::objectmodel::ComponentState computeForceFromForcesVector(const VecDeriv &forces);
sofa::core::objectmodel::ComponentState computeForceFromTotalForce(const Deriv &totalForce);

/// Save system size for update of indices (doUpdateInternal)
size_t m_systemSize;

/// Boolean specifying whether the data totalMass has been initially given
/// (else forces vector is being used)
bool m_isTotalForceUsed;
};

template <>
Expand Down
Loading