Page MenuHomec4science

epic.cpp
No OneTemporary

File Metadata

Created
Fri, Jun 21, 10:27

epic.cpp

/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016-2017 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 "epic.hh"
/* -------------------------------------------------------------------------- */
namespace tamaas {
/* -------------------------------------------------------------------------- */
EPICSolver::EPICSolver(ContactSolver& csolver, EPSolver& epsolver,
Real tolerance)
: csolver(csolver), epsolver(epsolver), tolerance(tolerance) {
auto& model = csolver.getModel();
surface.wrap(csolver.getSurface());
pressure.resize(model.getTraction().getNbPoints());
#define SET_VIEWS(_, __, type) \
case type: { \
setViews<type>(); \
break; \
}
switch (model.getType()) {
BOOST_PP_SEQ_FOR_EACH(SET_VIEWS, ~, TAMAAS_MODEL_TYPES);
}
#undef SET_VIEWS
}
/* -------------------------------------------------------------------------- */
void EPICSolver::solve(Real load) {
UInt n = 0, nmax = 100;
Real error = 0.;
const GridBase<Real> initial_surface(surface);
Real normalizing_factor = std::sqrt(initial_surface.dot(initial_surface));
GridBase<Real> previous_residual(*residual_disp);
GridBase<Real> relaxation_direction(*residual_disp);
previous_residual = 0;
do {
csolver.solve(load); // solve contact problem
*pressure_inc -= pressure; // compute pressure increment
epsolver.solve(); // compute residual displacement
surface = initial_surface;
relaxation_direction = *residual_disp;
relaxation_direction -= previous_residual;
relaxation_direction *= 0.5;
error = computeError(*residual_disp, previous_residual, normalizing_factor);
previous_residual += relaxation_direction;
surface -= previous_residual; // update surface
std::cout << "error = " << std::scientific << error << std::fixed
<< std::endl;
} while (error > tolerance && n++ < nmax);
// computing full pressure
pressure += *pressure_inc;
// setting the model pressure to full converged pressure
*pressure_inc = pressure;
// updating plastic state
epsolver.getResidual().updateState(epsolver.getStrainIncrement());
csolver.getModel().dump();
}
/* -------------------------------------------------------------------------- */
Real EPICSolver::computeError(const GridBase<Real>& current,
const GridBase<Real>& prev, Real factor) const {
GridBase<Real> error(current);
error -= prev;
return std::sqrt(error.dot(error)) / factor;
}
/* -------------------------------------------------------------------------- */
} // namespace tamaas

Event Timeline