Page MenuHomec4science

polonsky_keer_rey.hh
No OneTemporary

File Metadata

Created
Sun, Apr 28, 09:35

polonsky_keer_rey.hh

/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-19 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __POLONSKY_KEER_REY_HH__
#define __POLONSKY_KEER_REY_HH__
/* -------------------------------------------------------------------------- */
#include "contact_solver.hh"
#include "grid_view.hh"
#include "meta_functional.hh"
#include "westergaard.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
class PolonskyKeerRey : public ContactSolver {
public:
/// Types of algorithm (primal/dual) or constraint
enum type { gap, pressure };
public:
/// Constructor
PolonskyKeerRey(Model& model, const GridBase<Real>& surface, Real tolerance,
type variable_type, type constraint_type);
public:
using ContactSolver::solve;
/// Solve
Real solve(std::vector<Real> target) override;
/// Mean on unsaturated constraint zone
Real meanOnUnsaturated(const GridBase<Real>& field) const;
/// Compute squared norm
Real computeSquaredNorm(const GridBase<Real>& field) const;
/// Update search direction
void updateSearchDirection(Real factor);
/// Compute critical step
Real computeCriticalStep(Real target = 0);
/// Update primal and check non-admissible state
bool updatePrimal(Real step);
/// Compute error/stopping criterion
Real computeError();
/// Add term to functional
void addFunctionalTerm(functional::Functional* func);
private:
/// Set correct views on normal traction and gap
template <model_type type>
void setViews();
protected:
type variable_type, constraint_type;
model_type operation_type;
GridBase<Real>* primal = nullptr; ///< non-owning pointer for primal varaible
GridBase<Real>* dual = nullptr; ///< non-owning pointer for dual variable
/// CG search direction
std::unique_ptr<GridBase<Real>> search_direction = nullptr;
/// Projected CG search direction
std::unique_ptr<GridBase<Real>> projected_search_direction = nullptr;
/// View on normal pressure, gap, displacement
std::unique_ptr<GridBase<Real>> pressure_view, gap_view,
displacement_view = nullptr;
/// Integral operator for gradient computation
IntegralOperator* integral_op = nullptr;
};
/* -------------------------------------------------------------------------- */
template <model_type mtype>
void PolonskyKeerRey::setViews() {
constexpr UInt dim = model_type_traits<mtype>::dimension;
constexpr UInt bdim = model_type_traits<mtype>::boundary_dimension;
constexpr UInt comp = model_type_traits<mtype>::components;
pressure_view = std::unique_ptr<GridBase<Real>>{
new GridView<Grid, Real, bdim, bdim>(model.getTraction(), {}, comp - 1)};
gap_view = std::unique_ptr<GridBase<Real>>{
new GridView<Grid, Real, bdim, bdim>(*this->_gap, {}, comp - 1)};
displacement_view =
std::unique_ptr<GridBase<Real>>{new GridView<Grid, Real, dim, bdim>(
model.getDisplacement(), model_type_traits<mtype>::indices,
comp - 1)};
#define WESTERGAARD(type, kind, desc) \
this->model.registerIntegralOperator< \
Westergaard<model_type::type, IntegralOperator::kind>>(desc)
// I noz is fugly - TODO factory?
if (bdim == 1) {
operation_type = model_type::basic_1d;
if (variable_type == gap)
integral_op = WESTERGAARD(basic_1d, dirichlet, "westergaard_dirichlet");
else
integral_op = WESTERGAARD(basic_1d, neumann, "westergaard_neumann");
} else if (bdim == 2) {
operation_type = model_type::basic_2d;
if (variable_type == gap)
integral_op = WESTERGAARD(basic_2d, dirichlet, "westergaard_dirichlet");
else
integral_op = WESTERGAARD(basic_2d, neumann, "westergaard_neumann");
}
#undef WESTERGAARD
}
__END_TAMAAS__
#endif // __POLONSKY_KEER_REY_HH__

Event Timeline