Page MenuHomec4science

adhesion_functional.cpp
No OneTemporary

File Metadata

Created
Sun, Jul 7, 15:27

adhesion_functional.cpp

/**
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 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 "adhesion_functional.hh"
#include <cmath>
/* -------------------------------------------------------------------------- */
AdhesionFunctional::AdhesionFunctional(BemFFTBase & bem):
ElasticEnergyFunctional(bem),
rho(1.),
surface_energy(1.),
exponential_term(bem.getSurface().size(), bem.getSurface().getL()),
spectral_gap(bem.getSurface().size(), bem.getSurface().getL())
{}
AdhesionFunctional::~AdhesionFunctional()
{}
void AdhesionFunctional::computeF() {
const Surface<Real> & surface = bem.getSurface();
const Surface<Real> & displacements = bem.getTrueDisplacements();
const Surface<Real> & tractions = bem.getTractions();
UInt n = surface.size();
UInt size = n*n;
Real res = 0;
Real d_max = SurfaceStatistics::computeMaximum(displacements);
// Real t_sum = std::abs(SurfaceStatistics::computeSum(tractions));
Real s_max = SurfaceStatistics::computeMaximum(surface);
#pragma omp parallel for reduction(+:res)
for (UInt i = 0; i < size; ++i) {
res += std::abs(tractions(i) * (displacements(i)-d_max-surface(i)+s_max));
// res +=
// this->surface_tractions[i].real()
// *(surface_displacements[i].real() - surface[i].real());
}
this->F = res;
this->computeExponentialTerm();
Real adhesion_term = 0.;
#pragma omp parallel for reduction(+:adhesion_term)
for (UInt i = 0 ; i < size ; ++i)
adhesion_term += this->exponential_term(i);
adhesion_term *= -this->surface_energy;
this->F += adhesion_term;
}
void AdhesionFunctional::computeGradF() {
this->computeExponentialTerm();
Surface<Real> & gap = const_cast<Surface<Real> &>(bem.getGap());
const Surface<Real> & influence_coefficients = this->bem.getSpectralInfluenceOverDisplacement();
const UInt n = this->exponential_term.size();
const UInt size = n * n;
/// Computation of elastic energy gradient
gap.FFTTransform(this->spectral_gap, bem.getNumberOfThreads());
this->spectral_gap(0) = 0;
#pragma omp parallel for
for (UInt i = 1 ; i < size ; ++i)
this->spectral_gap(i) /= influence_coefficients(i);
this->spectral_gap.FFTITransform(this->gradF, bem.getNumberOfThreads());
/// Computation of adhesion energy gradient
const Real factor = this->surface_energy / this->rho;
#pragma omp parallel for
for (UInt i = 0 ; i < size ; ++i)
this->gradF(i) += factor * this->exponential_term(i) + 0.5 * this->applied_pressure;
}
void AdhesionFunctional::computeExponentialTerm() {
const Surface<Real> & gap = bem.getGap();
const UInt n = gap.size();
const UInt size = n * n;
#pragma omp parallel for
for (UInt i = 0 ; i < size ; ++i) {
this->exponential_term(i) = exp(- gap(i) / this->rho);
}
}

Event Timeline