Page MenuHomec4science

beck_teboulle.cpp
No OneTemporary

File Metadata

Created
Mon, May 13, 23:53

beck_teboulle.cpp

/**
* @file
*
* @author Son Pham-Ba <son.phamba@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "beck_teboulle.hh"
#include <iomanip>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
BeckTeboulle::BeckTeboulle(Model& model, const GridBase<Real>& surface,
Real tolerance, Real mu)
: Kato(model, surface, tolerance, mu) {}
/* -------------------------------------------------------------------------- */
Real BeckTeboulle::solve(GridBase<Real>& g0) {
Real cost = 0;
UInt n = 0;
// Printing column headers
std::cout << std::setw(5) << "Iter"
<< " " << std::setw(15) << "Cost_f"
<< " " << std::setw(15) << "Error" << '\n'
<< std::fixed;
*pressure = 0;
do {
engine.solveNeumann(*pressure, *gap);
(model.getType() == model_type::surface_1d) ?
addUniform<2>(*gap, g0) :
addUniform<3>(*gap, g0);
*gap -= surfaceComp;
*pressure -= *gap;
(model.getType() == model_type::surface_1d) ?
enforcePressureCoulomb<model_type::surface_1d>() :
enforcePressureCoulomb<model_type::surface_2d>();
cost = computeCost();
printState(n, cost, cost);
} while (cost > this->tolerance && n++ < this->max_iterations);
Real beta = 0;
switch (model.getType()) {
case model_type::surface_1d:
beta = computeBeta<model_type::surface_1d>();
computeFinalGap<model_type::surface_1d>(beta);
break;
case model_type::surface_2d:
beta = computeBeta<model_type::surface_2d>();
computeFinalGap<model_type::surface_2d>(beta);
break;
default:
break;
}
model.getDisplacement() = *gap;
return cost;
}
__END_TAMAAS__
/* -------------------------------------------------------------------------- */

Event Timeline