Page MenuHomec4science

bem_fft_base.hh
No OneTemporary

File Metadata

Created
Thu, May 23, 07:22

bem_fft_base.hh

/**
*
* @author Guillaume Anciaux <guillaume.anciaux@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/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef BEM_FFT_BASE_H
#define BEM_FFT_BASE_H
/* -------------------------------------------------------------------------- */
#include "bem_interface.hh"
#include <cmath>
#include "surface_statistics.hh"
#include "elastic_energy_functional.hh"
/* -------------------------------------------------------------------------- */
class BemFFTBase : public BemInterface {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
BemFFTBase(Surface<Real> & p):
BemInterface(p),
functional(new ElasticEnergyFunctional(*this)),
surface_tractions(p.size(),p.getL()),
surface_displacements(p.size(),p.getL()),
surface_spectral_tractions(p.size(),p.getL()),
surface_spectral_displacements(p.size(),p.getL()),
surface_spectral_influence_disp(p.size(),p.getL()),
true_displacements(p.size(),p.getL()),
gap(p.size(),p.getL()),
e_star(std::nan("")),
nthreads(1),
tmp_coeff(1./M_PI){
this->setNumberOfThreads(this->nthreads);
max_iterations = 100000;
dump_freq = 100;
std::cerr << this << " is setting up the surfaces";
std::cerr << &p << " has size " << p.size() << std::endl;
};
virtual ~BemFFTBase() {
delete functional;
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
//! compute the influcence coefficients of pressure over displacement
virtual void computeSpectralInfluenceOverDisplacement();
//! compute real tractions from fourier represnetation (IFFT)
virtual void computeRealTractionsFromSpectral();
//! compute real displacements from fourier represnetation (IFFT)
virtual void computeRealDisplacementsFromSpectral();
//! compute the displacement in real space
virtual void computeDisplacements();
//! compute the displacement fourier space
virtual void computeSpectralDisplacements();
//! compute the tractions in fourier space
virtual void computeSpectralTractions();
//! compute the gradient the objective function (with respect to traction)
virtual void computeTrueDisplacements();
//! compute the gap
virtual void computeGaps();
//! get the number of iterations
virtual UInt getNbIterations() const = 0;
//! get the convergence steps of iterations
virtual const std::vector<Real> & getConvergenceIterations() const = 0;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
//! return the influcence coefficients
virtual const Surface<Real> & getSpectralInfluenceOverDisplacement();
//! return the actual tractions
virtual const Surface<Real> & getTractions() const;
//! return the actual displacements
virtual const Surface<Real> & getDisplacements()const;
//! return the actual displacements
virtual const SurfaceComplex<Real> & getSpectralDisplacements()const;
//! return the actual displacements
virtual const SurfaceComplex<Real> & getSpectralTractions()const;
//! get the computed true displacement
const Surface<Real> & getTrueDisplacements(){return true_displacements;};
//! get the computed gap
const Surface<Real> & getGap(){return gap;};
//! set the number of threads to be used to perform the calculations
void setNumberOfThreads(UInt nthreads);
//! get the number of threads
UInt getNumberOfThreads() const { return nthreads; }
//! set the elastic effective modulus
void setEffectiveModulus(Real e_star);
//! set the maximal number of iterations
void setMaxIterations(UInt max_iter){this->max_iterations = max_iter;};
//! set dump freq
void setDumpFreq(Real dump_freq){this->dump_freq = dump_freq;};
//! set functional
void setFunctional(Functional * new_funct);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
//! Functional for optimization
Functional * functional;
//! surface tractions
Surface<Real> surface_tractions;
//! surface displacement
Surface<Real> surface_displacements;
//! surface tractions
SurfaceComplex<Real> surface_spectral_tractions;
//! surface displacement
SurfaceComplex<Real> surface_spectral_displacements;
//! surface influcence coefficient over displacement
Surface<Real> surface_spectral_influence_disp;
//! shifted displacement in order to get the true displacement
Surface<Real> true_displacements;
//! computing of the gap
Surface<Real> gap;
//! Effective young modulus
Real e_star;
//! Number of threads to use during calculations
UInt nthreads;
//! maximum of iterations
UInt max_iterations;
//! number of iterations
UInt nb_iterations;
//! number of iterations
std::vector<Real> convergence_iterations;
//! frequency at which to dump iteration info
UInt dump_freq;
/* ------------------------------------------------------------------------ */
/* temporary trick about some obscure scaling factor */
/* ------------------------------------------------------------------------ */
/*
0 2 = 2*1
1 4 = 2*2
2 10 = 2*5
3 20 = 2*10
4 34 = 2*12
*/
//#define tmp_coeff (2.*n/M_PI)
//#define tmp_coeff (n/M_PI)
const Real tmp_coeff;
};
#endif /* BEM_FFT_BASE_H */

Event Timeline