Commit 0e80f283 authored by Pit Nestle's avatar Pit Nestle

Bugfixes

parent ab635677
Pipeline #7475 failed with stages
in 5 minutes and 11 seconds
......@@ -2,3 +2,4 @@ Config/config.hh
*.orig
*.rej
.project
CMakeLists.txt.user
......@@ -27,6 +27,11 @@ public:
Eigen::Matrix2d j;
j << _j(i, 0), _j(i, 1),
_j(i, 2), _j(i, 3);
double det = _j(i, 0) * _j(i, 0) - _j(i, 1) *_j(i, 2);
if (det <= 0)
return std::numeric_limits<double>::infinity();
double j_n = j.norm();
double ji_n= j.inverse().norm();
......@@ -54,20 +59,21 @@ public:
return res;
}
void computeEnergyGradientSV(Eigen::Matrix2Xd& _sv, Eigen::Matrix2Xd& _g)
void computeEnergyGradientSV(Eigen::MatrixXd& _sv, Eigen::MatrixXd& _g)
{
for (int i = 0; i < _sv.cols(); i++)
_g.resize(sv.rows(), 2);
for (int i = 0; i < _sv.rows(); i++)
{
double s1 = _sv(0, i);
double s2 = _sv(1, i);
_g.col(i) << 2 * (s1 - std::pow(s1, -3)),
double s1 = _sv(i, 0);
double s2 = _sv(i, 1);
_g.row(i) << 2 * (s1 - std::pow(s1, -3)),
2 * (s2 - std::pow(s2, -3));
}
}
double computeEnergyGradientSV_i(double _sv)
{
return (_sv - std::pow(_sv, -3));
return 2 * (_sv - std::pow(_sv, -3));
}
double s_lambda_i(double sigma_i)
......
......@@ -165,9 +165,9 @@ void SLIMProblemInterface::init()
_dx.push_back(Eigen::Triplet<double>(i, b, (p_2y - p_0y)*(1/(2*area(i)))));
_dx.push_back(Eigen::Triplet<double>(i, c, (p_0y - p_1y)*(1/(2*area(i)))));
_dy.push_back(Eigen::Triplet<double>(i, a, (p_1x - p_2x)*(1/(2*area(i)))));
_dy.push_back(Eigen::Triplet<double>(i, b, (p_2x - p_0x)*(1/(2*area(i)))));
_dy.push_back(Eigen::Triplet<double>(i, c, (p_0x - p_1x)*(1/(2*area(i)))));
_dy.push_back(Eigen::Triplet<double>(i, a, (p_2x - p_1x)*(1/(2*area(i)))));
_dy.push_back(Eigen::Triplet<double>(i, b, (p_0x - p_2x)*(1/(2*area(i)))));
_dy.push_back(Eigen::Triplet<double>(i, c, (p_1x - p_0x)*(1/(2*area(i)))));
}
this->dx.setFromTriplets(_dx.begin(), _dx.end());
......
......@@ -72,7 +72,7 @@ public:
virtual double computeEnergy(Eigen::MatrixXd& _j, Eigen::VectorXd& _a) = 0; //Evaluates the energy. _j #Faces x 4
virtual double computeEnergySV(Eigen::MatrixXd& _sv, Eigen::VectorXd& _a) = 0;
virtual void computeEnergyGradientSV(Eigen::Matrix2Xd& _sv, Eigen::Matrix2Xd& _g) = 0;
virtual void computeEnergyGradientSV(Eigen::MatrixXd& _sv, Eigen::MatrixXd& _g) = 0;
virtual double computeEnergyGradientSV_i(double _sv) = 0;
virtual double s_lambda_i(double sigma_i) = 0;
......
......@@ -24,7 +24,7 @@ int SLIMSolver::solve(SLIMProblemInterface &problem, int iterations)
Eigen::VectorXd p;
Eigen::MatrixXd dir;
for (int i = 0; i < 6; i++)
for (int i = 0; i < 10; i++)
{
calculateJacobians(problem, problem.par, j);
calculateWeightAndLambda(problem, j, problem.lambda);
......@@ -109,12 +109,12 @@ void SLIMSolver::calculateWeightAndLambda(SLIMProblemInterface &p, Eigen::Matrix
p.s_lambda_i(sv(1));
if (sv(0) == sl(0))
sw(0) = 1;
sw(0) = 4;
else
sw(0) = std::sqrt(p.computeEnergyGradientSV_i(sv(0)) / (sv(0) - sl(0)));
if (sv(1) == sl(1))
sw(1) = 1;
sw(1) = 4;
else
sw(1) = std::sqrt(p.computeEnergyGradientSV_i(sv(1)) / (sv(1) - sl(1)));
......@@ -129,10 +129,10 @@ void SLIMSolver::calculateWeightAndLambda(SLIMProblemInterface &p, Eigen::Matrix
p.sv.row(i) << sv(0), sv(1); //Save the singular values for Energy computation
lambda(i*4 + 0) = lambda_i(0, 0); //small lambda in big lambda
lambda(i*4 + 1) = lambda_i(0, 1);
lambda(i*4 + 2) = lambda_i(1, 0);
lambda(i*4 + 3) = lambda_i(1, 1);
lambda(0*f + i) = lambda_i(0, 0); //small lambda in big lambda
lambda(1*f + i) = lambda_i(0, 1);
lambda(2*f + i) = lambda_i(1, 0);
lambda(3*f + i) = lambda_i(1, 1);
//std::cout << lambda_i << std::endl;
}
......@@ -200,10 +200,10 @@ void SLIMSolver::constructLinearSystem(SLIMProblemInterface &p, Eigen::SparseMat
//Adjusting weights of b/r/lambda
for (int i = 0; i < f; i++)
{
b(i*4+0) *= p.w(i, 0);
b(i*4+1) *= p.w(i, 1);
b(i*4+2) *= p.w(i, 2);
b(i*4+3) *= p.w(i, 3);
b(0*f+i) *= p.w(i, 0);
b(1*f+i) *= p.w(i, 1);
b(2*f+i) *= p.w(i, 2);
b(3*f+i) *= p.w(i, 3);
}
#warning proximal term and soft constraint to be added
ata = a.transpose()*a;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment