Skip to content

Commit

Permalink
change protected member
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger committed Sep 30, 2024
1 parent b594d9e commit 08fc814
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void AreaMapping<TIn, TOut>::init()
typename core::behavior::MechanicalState<In>::ReadVecCoord pos = this->getFromModel()->readPositions();

this->getToModel()->resize( nbTriangles );
this->jacobian.resizeBlocks(nbTriangles, pos.size());
this->m_jacobian.resizeBlocks(nbTriangles, pos.size());

Inherit1::init();

Expand All @@ -146,7 +146,7 @@ void AreaMapping<TIn, TOut>::apply(const core::MechanicalParams* mparams,

const auto& triangles = l_topology->getTriangles();

this->jacobian.clear();
this->m_jacobian.clear();

for (unsigned int triangleId = 0; triangleId < triangles.size(); ++triangleId)
{
Expand Down Expand Up @@ -176,17 +176,17 @@ void AreaMapping<TIn, TOut>::apply(const core::MechanicalParams* mparams,
//insertion in increasing column order
std::sort(jacobianEntries.begin(), jacobianEntries.end());

this->jacobian.beginRow(triangleId);
this->m_jacobian.beginRow(triangleId);
for (const auto& [vertexId, jacobianValue] : jacobianEntries)
{
for (unsigned d = 0; d < In::spatial_dimensions; ++d)
{
this->jacobian.insertBack(triangleId, vertexId * Nin + d, jacobianValue[d]);
this->m_jacobian.insertBack(triangleId, vertexId * Nin + d, jacobianValue[d]);
}
}
}

this->jacobian.compress();
this->m_jacobian.compress();
}

template <class TIn, class TOut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BaseNonLinearMapping : public core::Mapping<TIn, TOut>, public NonLinearMa
const Data<VecDeriv_t<In> >& parentDisplacement,
const Data<VecDeriv_t<Out> >& childForce) = 0;

SparseMatrixEigen jacobian; ///< Jacobian of the mapping
SparseMatrixEigen m_jacobian; ///< Jacobian of the mapping

virtual void doUpdateK(
const core::MechanicalParams* mparams, const Data<VecDeriv_t<Out> >& childForce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ init()
core::Mapping<TIn, TOut>::init();

m_baseMatrices.resize( 1 );
m_baseMatrices[0] = &this->jacobian;
m_baseMatrices[0] = &this->m_jacobian;
}

template <class TIn, class TOut, bool HasStabilizedGeometricStiffness>
Expand All @@ -43,11 +43,11 @@ void BaseNonLinearMapping<TIn, TOut, HasStabilizedGeometricStiffness>::applyJ(
const DataVecDeriv_t<In>& in)
{
SOFA_UNUSED( mparams );
if( jacobian.rowSize() )
if( m_jacobian.rowSize() )
{
auto dOutWa = sofa::helper::getWriteOnlyAccessor(out);
auto dInRa = sofa::helper::getReadAccessor(in);
jacobian.mult(dOutWa.wref(),dInRa.ref());
m_jacobian.mult(dOutWa.wref(),dInRa.ref());
}
}

Expand All @@ -57,11 +57,11 @@ void BaseNonLinearMapping<TIn, TOut, HasStabilizedGeometricStiffness>::applyJT(
const DataVecDeriv_t<Out>& in)
{
SOFA_UNUSED( mparams );
if( jacobian.rowSize() )
if( m_jacobian.rowSize() )
{
auto dOutRa = sofa::helper::getReadAccessor(in);
auto dInWa = sofa::helper::getWriteOnlyAccessor(out);
jacobian.addMultTranspose(dInWa.wref(),dOutRa.ref());
m_jacobian.addMultTranspose(dInWa.wref(),dOutRa.ref());
}
}

Expand All @@ -73,7 +73,7 @@ void BaseNonLinearMapping<TIn, TOut, HasStabilizedGeometricStiffness>::applyJT(
SOFA_UNUSED(cparams);
auto childMatRa = sofa::helper::getReadAccessor(in);
auto parentMatWa = sofa::helper::getWriteAccessor(out);
addMultTransposeEigen(parentMatWa.wref(), jacobian.compressedMatrix, childMatRa.ref());
addMultTransposeEigen(parentMatWa.wref(), m_jacobian.compressedMatrix, childMatRa.ref());
}

template <class TIn, class TOut, bool HasStabilizedGeometricStiffness>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void DistanceFromTargetMapping<TIn, TOut>::apply(const core::MechanicalParams *
const helper::ReadAccessor indices(d_indices);
const helper::ReadAccessor targetPositions(d_targetPositions);

this->jacobian.resizeBlocks(out.size(),in.size());
this->m_jacobian.resizeBlocks(out.size(),in.size());
directions.resize(out.size());
invlengths.resize(out.size());

Expand Down Expand Up @@ -166,15 +166,15 @@ void DistanceFromTargetMapping<TIn, TOut>::apply(const core::MechanicalParams *

for(unsigned j=0; j<Nout; j++)
{
this->jacobian.beginRow(i*Nout+j);
this->m_jacobian.beginRow(i*Nout+j);
for(unsigned k=0; k<Nin; k++ )
{
this->jacobian.insertBack( i*Nout+j, indices[i]*Nin+k, gap[k] );
this->m_jacobian.insertBack( i*Nout+j, indices[i]*Nin+k, gap[k] );
}
}
}

this->jacobian.compress();
this->m_jacobian.compress();
}

template <class TIn, class TOut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void DistanceMapping<TIn, TOut>::init()
typename core::behavior::MechanicalState<In>::ReadVecCoord pos = this->getFromModel()->readPositions();

this->getToModel()->resize( links.size() );
this->jacobian.resizeBlocks(links.size(),pos.size());
this->m_jacobian.resizeBlocks(links.size(),pos.size());

directions.resize(links.size());
invlengths.resize(links.size());
Expand Down Expand Up @@ -108,7 +108,7 @@ void DistanceMapping<TIn, TOut>::apply(const core::MechanicalParams * /*mparams*
helper::ReadAccessor<Data<type::vector<Real> > > restLengths(d_restLengths);
const SeqEdges& links = l_topology->getEdges();

this->jacobian.clear();
this->m_jacobian.clear();

for (unsigned int i = 0; i < links.size(); ++i)
{
Expand Down Expand Up @@ -144,17 +144,17 @@ void DistanceMapping<TIn, TOut>::apply(const core::MechanicalParams * /*mparams*
//invert to insert in increasing column order
std::sort(jacobianEntries.begin(), jacobianEntries.end());

this->jacobian.beginRow(i);
this->m_jacobian.beginRow(i);
for (const auto& [vertexId, jacobianValue] : jacobianEntries)
{
for (unsigned k = 0; k < In::spatial_dimensions; ++k)
{
this->jacobian.insertBack(i, vertexId * Nin + k, jacobianValue[k]);
this->m_jacobian.insertBack(i, vertexId * Nin + k, jacobianValue[k]);
}
}
}

this->jacobian.compress();
this->m_jacobian.compress();
}

template <class TIn, class TOut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void SquareDistanceMapping<TIn, TOut>::apply(
const helper::ReadAccessor in (dIn);
const SeqEdges& links = l_topology->getEdges();

this->jacobian.resizeBlocks(out.size(),in.size());
this->m_jacobian.resizeBlocks(out.size(),in.size());


Direction gap;
Expand Down Expand Up @@ -118,24 +118,24 @@ void SquareDistanceMapping<TIn, TOut>::apply(
// }


this->jacobian.beginRow(i);
this->m_jacobian.beginRow(i);
if( links[i][1]<links[i][0] )
{
for(unsigned k=0; k<In::spatial_dimensions; k++ )
this->jacobian.insertBack( i, links[i][1]*Nin+k, gap[k] );
this->m_jacobian.insertBack( i, links[i][1]*Nin+k, gap[k] );
for(unsigned k=0; k<In::spatial_dimensions; k++ )
this->jacobian.insertBack( i, links[i][0]*Nin+k, -gap[k] );
this->m_jacobian.insertBack( i, links[i][0]*Nin+k, -gap[k] );
}
else
{
for(unsigned k=0; k<In::spatial_dimensions; k++ )
this->jacobian.insertBack( i, links[i][0]*Nin+k, -gap[k] );
this->m_jacobian.insertBack( i, links[i][0]*Nin+k, -gap[k] );
for(unsigned k=0; k<In::spatial_dimensions; k++ )
this->jacobian.insertBack( i, links[i][1]*Nin+k, gap[k] );
this->m_jacobian.insertBack( i, links[i][1]*Nin+k, gap[k] );
}
}

this->jacobian.compress();
this->m_jacobian.compress();
}

template <class TIn, class TOut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ void SquareMapping<TIn, TOut>::apply(const core::MechanicalParams* mparams,

size_t size = in.size();
this->getToModel()->resize( size );
this->jacobian.resizeBlocks( size, size );
this->jacobian.reserve( size );
this->m_jacobian.resizeBlocks( size, size );
this->m_jacobian.reserve( size );

for( unsigned i=0 ; i<size ; ++i )
{
const Real& x = in[i][0];
out[i][0] = x*x;

this->jacobian.beginRow(i);
this->jacobian.insertBack( i, i, 2.0*x );
this->m_jacobian.beginRow(i);
this->m_jacobian.insertBack( i, i, 2.0*x );
}

this->jacobian.compress();
this->m_jacobian.compress();
}

template <class TIn, class TOut>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void VolumeMapping<TIn, TOut>::init()
typename core::behavior::MechanicalState<In>::ReadVecCoord pos = this->getFromModel()->readPositions();

this->getToModel()->resize( nbTetrahedra );
this->jacobian.resizeBlocks(nbTetrahedra, pos.size());
this->m_jacobian.resizeBlocks(nbTetrahedra, pos.size());

Inherit1::init();

Expand All @@ -125,7 +125,7 @@ void VolumeMapping<TIn, TOut>::apply(const core::MechanicalParams* mparams,

const auto& tetrahedra = l_topology->getTetrahedra();

this->jacobian.clear();
this->m_jacobian.clear();

for (unsigned int tetId = 0; tetId < tetrahedra.size(); ++tetId)
{
Expand Down Expand Up @@ -165,17 +165,17 @@ void VolumeMapping<TIn, TOut>::apply(const core::MechanicalParams* mparams,
//insertion in increasing column order
std::sort(jacobianEntries.begin(), jacobianEntries.end());

this->jacobian.beginRow(tetId);
this->m_jacobian.beginRow(tetId);
for (const auto& [vertexId, jacobianValue] : jacobianEntries)
{
for (unsigned d = 0; d < In::spatial_dimensions; ++d)
{
this->jacobian.insertBack(tetId, vertexId * Nin + d, jacobianValue[d]);
this->m_jacobian.insertBack(tetId, vertexId * Nin + d, jacobianValue[d]);
}
}
}

this->jacobian.compress();
this->m_jacobian.compress();
}

template <class TIn, class TOut>
Expand Down

0 comments on commit 08fc814

Please sign in to comment.