Page MenuHomec4science

residual.hh
No OneTemporary

File Metadata

Created
Thu, Jun 6, 06:01

residual.hh

/**
* @file
* LICENSE
*
* Copyright (©) 2016-2021 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 RESIDUAL_HH
#define RESIDUAL_HH
/* -------------------------------------------------------------------------- */
#include "boussinesq.hh"
#include "materials/isotropic_hardening.hh"
#include "mindlin.hh"
#include "model_type.hh"
/* -------------------------------------------------------------------------- */
#include <unordered_set>
/* -------------------------------------------------------------------------- */
namespace tamaas {
/* -------------------------------------------------------------------------- */
/**
* @brief Residual manager
*/
class Residual {
public:
/// Constructor
Residual(Model* model) : model(model) {}
/// Destructor
virtual ~Residual() = default;
// Pure virtual methods
public:
/// Compute the residual vector for a given strain increment
virtual void computeResidual(GridBase<Real>& strain_increment) = 0;
/// Apply tangent
virtual void applyTangent(GridBase<Real>& output, GridBase<Real>& input,
GridBase<Real>& current_strain_increment) = 0;
/// Compute the stresses for a given strain increment
virtual void computeStress(GridBase<Real>& strain_increment) = 0;
/// Update the plastic state
virtual void updateState(GridBase<Real>& converged_strain_increment) = 0;
/// Get residual vector
virtual const GridBase<Real>& getVector() const = 0;
/// Get plastic strain
virtual const GridBase<Real>& getPlasticStrain() const = 0;
/// Get stresses
virtual const GridBase<Real>& getStress() const = 0;
/// Compute displacement
virtual void
computeResidualDisplacement(GridBase<Real>& strain_increment) = 0;
/// Set integration method (cutoff parameter ignored if linear integration)
virtual void setIntegrationMethod(integration_method method,
Real cutoff = 0) = 0;
// Accessors
public:
Model& getModel() { return *model; }
virtual Real getYieldStress() const = 0;
virtual void setYieldStress(Real sigma_y) = 0;
virtual Real getHardeningModulus() const = 0;
virtual void setHardeningModulus(Real h) = 0;
protected:
Model* model;
};
/**
* @brief Templated residual manager
*/
template <model_type type>
class ResidualTemplate : public Residual {
using trait = model_type_traits<type>;
static constexpr UInt dim = trait::dimension;
public:
ResidualTemplate(Model* model, Real sigma_0, Real h);
// Implementation
public:
/// Compute the residual vector for a given strain increment
void computeResidual(GridBase<Real>& strain_increment) override;
/// Apply tangent
void applyTangent(GridBase<Real>& output, GridBase<Real>& input,
GridBase<Real>& current_strain_increment) override;
/// Compute the stresses for a given strain increment
void computeStress(GridBase<Real>& strain_increment) override;
/// Update the plastic state
void updateState(GridBase<Real>& converged_strain_increment) override;
/// Compute displacement
void computeResidualDisplacement(GridBase<Real>& strain_increment) override;
/// Set integration method (cutoff parameter ignored if linear integration)
void setIntegrationMethod(integration_method method,
Real cutoff = 0) override;
// Accessors
public:
/// Get residual vector
const GridBase<Real>& getVector() const override { return *residual; }
/// Get plastic strain
const GridBase<Real>& getPlasticStrain() const override {
return hardening.getPlasticStrain();
}
/// Get stresses
const GridBase<Real>& getStress() const override { return *stress; }
Real getYieldStress() const override { return hardening.getYieldStress(); }
void setYieldStress(Real sigma_y) override {
hardening.setYieldStress(sigma_y);
}
Real getHardeningModulus() const override {
return hardening.getHardeningModulus();
}
void setHardeningModulus(Real h) override {
hardening.setHardeningModulus(h);
}
private:
/// Convenience function
const IntegralOperator& integralOperator(const std::string& name) const {
return *this->model->getIntegralOperator(name);
}
/// Add non-zero layers of plastic strain into the filter
void updateFilter(Grid<Real, dim>& plastic_strain_increment);
protected:
IsotropicHardening<type> hardening;
std::shared_ptr<Grid<Real, 3>> strain, stress, residual, tmp;
std::unordered_set<UInt> plastic_layers;
std::function<bool(UInt)> plastic_filter;
};
/* -------------------------------------------------------------------------- */
} // namespace tamaas
#endif // RESIDUAL_HH

Event Timeline