<commit_before>#include "Stabilization.h"

#include <sofa/core/ObjectFactory.h>
#include "../utils/map.h"

namespace sofa {
namespace component {
namespace odesolver {


SOFA_DECL_CLASS(Stabilization);
int StabilizationClass = core::RegisterObject("Kinematic constraint stabilization").add< Stabilization >();


Stabilization::Stabilization( mstate_type* mstate )
    : BaseConstraintValue( mstate )
    , mask(initData(&mask, "mask", "dofs to be stabilized")) {
	
}

void Stabilization::correction(SReal* dst, unsigned n) const {
	assert( mstate );
	assert( mask.empty() || mask.size() == n );
	
	mstate->copyToBuffer(dst, core::VecCoordId::position(), n);
	
	// TODO needed ?
	map(dst, n) = -map(dst, n) / this->getContext()->getDt();

	const mask_type& mask = this->mask.getValue();
	
	// non-zero for stabilized
	unsigned i = 0;
	for(SReal* last = dst + n; dst < last; ++dst, ++i) {
		if( !mask.empty() && !mask[i] ) *dst = 0;
	}
	
}


void Stabilization::dynamics(SReal* dst, unsigned n) const {
	assert( mstate );
	assert( mask.empty() || mask.size() == n );
	
	mstate->copyToBuffer(dst, core::VecCoordId::position(), n);
	map(dst, n) = -map(dst, n) / this->getContext()->getDt();
	
	const mask_type& mask = this->mask.getValue();
    // zero for stabilized, since the position error will be handled by the correction
	unsigned i = 0;
	for(SReal* last = dst + n; dst < last; ++dst, ++i) {
		if( mask.empty() || mask[i] ) *dst = 0;
	}

}




}
}
}
<commit_msg>r10438/sofa : fix compilation<commit_after>#include "Stabilization.h"

#include <sofa/core/ObjectFactory.h>
#include "../utils/map.h"

namespace sofa {
namespace component {
namespace odesolver {


SOFA_DECL_CLASS(Stabilization);
int StabilizationClass = core::RegisterObject("Kinematic constraint stabilization").add< Stabilization >();


Stabilization::Stabilization( mstate_type* mstate )
    : BaseConstraintValue( mstate )
    , mask(initData(&mask, "mask", "dofs to be stabilized")) {
	
}

void Stabilization::correction(SReal* dst, unsigned n) const {
	assert( mstate );
    assert( mask.getValue().empty() || mask.getValue().size() == n );
	
	mstate->copyToBuffer(dst, core::VecCoordId::position(), n);
	
	// TODO needed ?
	map(dst, n) = -map(dst, n) / this->getContext()->getDt();

	const mask_type& mask = this->mask.getValue();
	
	// non-zero for stabilized
	unsigned i = 0;
	for(SReal* last = dst + n; dst < last; ++dst, ++i) {
		if( !mask.empty() && !mask[i] ) *dst = 0;
	}
	
}


void Stabilization::dynamics(SReal* dst, unsigned n) const {
	assert( mstate );
    assert( mask.getValue().empty() || mask.getValue().size() == n );
	
	mstate->copyToBuffer(dst, core::VecCoordId::position(), n);
	map(dst, n) = -map(dst, n) / this->getContext()->getDt();
	
	const mask_type& mask = this->mask.getValue();
    // zero for stabilized, since the position error will be handled by the correction
	unsigned i = 0;
	for(SReal* last = dst + n; dst < last; ++dst, ++i) {
		if( mask.empty() || mask[i] ) *dst = 0;
	}

}




}
}
}

{'fraction_non_alphanumeric': 0.17823765020026702, 'fraction_numerical': 0.0043391188251001335, 'mean_word_length': 4.176165803108808, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5561172', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1032, 'n_words': 258}