Page MenuHomec4science

volume_potential.hh
No OneTemporary

File Metadata

Created
Fri, Oct 11, 20:58

volume_potential.hh

/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 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/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef VOLUME_POTENTIAL_HH
#define VOLUME_POTENTIAL_HH
/* -------------------------------------------------------------------------- */
#include "integral_operator.hh"
#include "model_type.hh"
#include "grid_view.hh"
#include "grid_hermitian.hh"
#include "fft_plan_manager.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/**
* @brief Volume potential operator class. Applies the operators for computation
* of displacements and strains due to residual/eigen strains
*/
template <model_type type>
class VolumePotential : public IntegralOperator {
using trait = model_type_traits<type>;
public:
VolumePotential(Model * model);
/// Update from model (does nothing)
void updateFromModel() override {}
/// Kind
IntegralOperator::kind getKind() const override {
return IntegralOperator::neumann;
}
/// Type
model_type getType() const override { return this->model->getType(); }
protected:
/// Function to handle layer-by-layer Fourier treatment of operators
template <typename Func>
void fourierApply(Func func, GridBase<Real>& in, GridBase<Real>& out) const;
protected:
Grid<Real, trait::boundary_dimension> wavevectors;
using BufferType = GridHermitian<Real, trait::boundary_dimension>;
mutable std::vector<BufferType> source_buffers;
mutable BufferType disp_buffer;
};
/* -------------------------------------------------------------------------- */
/* Template implementation */
/* -------------------------------------------------------------------------- */
template <model_type type>
template <typename Func>
void VolumePotential<type>::fourierApply(Func func, GridBase<Real>& in,
GridBase<Real>& out) const {
constexpr UInt dim = trait::dimension;
Grid<Real, dim>& i = dynamic_cast<decltype(i)>(in);
Grid<Real, dim>& o = dynamic_cast<decltype(o)>(out);
// TAMAAS_ASSERT(i.sizes().front() == o.sizes().front(),
// "Number of layers does not match");
// ^^^^ not applicable for Boussinesq
for (UInt layer : Loop::range(i.sizes().front())) {
auto in_layer = make_view(i, layer);
FFTPlanManager::get()
.createPlan(in_layer, source_buffers[layer])
.forwardTransform();
}
for (UInt layer : Loop::range(o.sizes().front())) {
func(layer, source_buffers, disp_buffer);
auto out_layer = make_view(o, layer);
FFTPlanManager::get()
.createPlan(out_layer, disp_buffer)
.backwardTransform();
}
}
__END_TAMAAS__
#endif // VOLUME_POTENTIAL_HH

Event Timeline