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
8 changes: 5 additions & 3 deletions src/SofaMJEDFEM/MJEDTetrahedralForceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ namespace sofa::component::forcefield
using namespace sofa::defaulttype;

// Register in the Factory
int MJEDTetrahedralForceFieldClass = core::RegisterObject("Tetrahedral FEM model of visco-hyperelastic material using MJED")
.add< MJEDTetrahedralForceField<Vec3Types> >()
;
void registerMJEDTetrahedralForceField(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Tetrahedral FEM model of visco-hyperelastic material using MJED")
.add< MJEDTetrahedralForceField<Vec3Types> >());
}

template class SOFA_MJED_FEM_API MJEDTetrahedralForceField<Vec3Types>;

Expand Down
12 changes: 5 additions & 7 deletions src/SofaMJEDFEM/MJEDTetrahedralForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void MJEDTetrahedralForceField<DataTypes>::createTetrahedronRestInformation(unsi



const typename DataTypes::VecCoord& restPosition=this->mstate->read(sofa::core::ConstVecCoordId::restPosition())->getValue();
const typename DataTypes::VecCoord& restPosition=this->mstate->read(sofa::core::vec_id::read_access::restPosition)->getValue();

///describe the indices of the 4 tetrahedron vertices
const Tetrahedron &t= tetrahedronArray[tetrahedronIndex];
Expand Down Expand Up @@ -114,7 +114,6 @@ void MJEDTetrahedralForceField<DataTypes>::createTetrahedronRestInformation(unsi
materialTermArray = myMaterial->getMaterialTermArray();
typename vector<HyperelasticMatTerm *>::iterator it;
it=materialTermArray.begin();
int id=0;
std::vector<Real> number;
Real coefficient=0;
tinfo.coeff.resize(0);
Expand Down Expand Up @@ -181,7 +180,6 @@ void MJEDTetrahedralForceField<DataTypes>::createTetrahedronRestInformation(unsi
tinfo.Lij_second_k.push_back( Lijsecond );
}

id++;
tinfo.functionf.push_back(1);
tinfo.functiong.push_back(1);
tinfo.functionDf.push_back(0);
Expand Down Expand Up @@ -353,7 +351,7 @@ template <class DataTypes> void MJEDTetrahedralForceField<DataTypes>::init()
// get restPosition
if (_initialPoints.size() == 0)
{
const VecCoord& p = this->mstate->read(core::ConstVecCoordId::restPosition())->getValue();
const VecCoord& p = this->mstate->read(core::vec_id::read_access::restPosition)->getValue();
_initialPoints=p;
}

Expand Down Expand Up @@ -734,7 +732,7 @@ void MJEDTetrahedralForceField<DataTypes>::updateMatrixData()
helper::WriteOnlyAccessor< Data<sofa::type::vector<TetrahedronRestInformation> > > tetrahedronInf = tetrahedronInfo;

// VecDeriv& x = myposition; // to uncomment for test derivatives and comment next line
const VecCoord& x = this->mstate->read(core::ConstVecCoordId::position())->getValue();
const VecCoord& x = this->mstate->read(core::vec_id::read_access::position)->getValue();
EdgeInformation *einfo;

unsigned int m,n;
Expand Down Expand Up @@ -1136,7 +1134,7 @@ void MJEDTetrahedralForceField<DataTypes>::testDerivatives()
{
DataVecCoord d_pos;
VecCoord &pos = *d_pos.beginEdit();
pos = this->mstate->read(sofa::core::ConstVecCoordId::position())->getValue();
pos = this->mstate->read(sofa::core::vec_id::read_access::position)->getValue();

// perturbate original state:
srand( 0 );
Expand Down Expand Up @@ -1259,7 +1257,7 @@ void MJEDTetrahedralForceField<DataTypes>::testDerivatives()
template<class DataTypes>
void MJEDTetrahedralForceField<DataTypes>::saveMesh( const char *filename )
{
VecCoord pos(this->mstate->read(sofa::core::ConstVecCoordId::position())->getValue());
VecCoord pos(this->mstate->read(sofa::core::vec_id::read_access::position)->getValue());
core::topology::BaseMeshTopology::SeqTriangles triangles = _topology->getTriangles();
FILE *file = fopen( filename, "wb" );
if (!file) return;
Expand Down
6 changes: 6 additions & 0 deletions src/SofaMJEDFEM/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@
#else
# define SOFA_MJED_FEM_API SOFA_IMPORT_DYNAMIC_LIBRARY
#endif

namespace sofamjedfem
{
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
} // namespace sofamjedfem
90 changes: 54 additions & 36 deletions src/SofaMJEDFEM/initSofaMJEDFEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,72 @@
******************************************************************************/
#include <SofaMJEDFEM/config.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

using sofa::core::ObjectFactory;

namespace sofa::component
namespace sofamjedfem
{
extern void registerMJEDTetrahedralForceField(sofa::core::ObjectFactory *factory);
} // namespace sofamjedfem

extern "C" {
SOFA_MJED_FEM_API void initExternalModule();
SOFA_MJED_FEM_API const char* getModuleName();
SOFA_MJED_FEM_API const char* getModuleVersion();
SOFA_MJED_FEM_API const char* getModuleLicense();
SOFA_MJED_FEM_API const char* getModuleDescription();
SOFA_MJED_FEM_API const char* getModuleComponentList();
}

void initExternalModule()
namespace sofa::component
{
static bool first = true;
if (first)
using namespace sofamjedfem;

extern "C" {
SOFA_MJED_FEM_API void initExternalModule();
SOFA_MJED_FEM_API const char* getModuleName();
SOFA_MJED_FEM_API const char* getModuleVersion();
SOFA_MJED_FEM_API const char* getModuleLicense();
SOFA_MJED_FEM_API const char* getModuleDescription();
SOFA_MJED_FEM_API const char* getModuleComponentList();
SOFA_MJED_FEM_API void registerObjects(sofa::core::ObjectFactory* factory);
}

void initExternalModule()
{
first = false;
static bool first = true;
if (first)
{
// make sure that this plugin is registered into the PluginManager
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);

first = false;
}
}
}

const char* getModuleName()
{
return sofa_tostring(SOFA_TARGET);
}
const char* getModuleName()
{
return sofa_tostring(SOFA_TARGET);
}

const char* getModuleVersion()
{
return sofa_tostring(SOFAMJEDFEM_VERSION);
}
const char* getModuleVersion()
{
return sofa_tostring(SOFAMJEDFEM_VERSION);
}

const char* getModuleLicense()
{
return "LGPL";
}
const char* getModuleLicense()
{
return "LGPL";
}

const char* getModuleDescription()
{
return "This plugin implements the Multiplicative Jacobian Energy Decomposition or MJED method.";
}
const char* getModuleDescription()
{
return "This plugin implements the Multiplicative Jacobian Energy Decomposition or MJED method.";
}

const char* getModuleComponentList()
{
/// string containing the names of the classes provided by the plugin
static std::string classes = ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET));
return classes.c_str();
}
const char* getModuleComponentList()
{
/// string containing the names of the classes provided by the plugin
static std::string classes = ObjectFactory::getInstance()->listClassesFromTarget(sofa_tostring(SOFA_TARGET));
return classes.c_str();
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerMJEDTetrahedralForceField(factory);
}

} // namespace sofa::component
Loading