Page MenuHomec4science

system_base.hh
No OneTemporary

File Metadata

Created
Sat, Nov 16, 04:18

system_base.hh

/**
* file system_base.hh
*
* @author Till Junge <till.junge@epfl.ch>
*
* @date 09 May 2017
*
* @brief Base class representing a periodic cell and it's solution
*
* @section LICENCE
*
* Copyright (C) 2017 Till Junge
*
* µSpectre is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3, or (at
* your option) any later version.
*
* µSpectre 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "common/common.hh"
#include <unsupported/Eigen/CXX11/Tensor>
#include <memory>
#ifndef SYSTEM_BASE_H
#define SYSTEM_BASE_H
namespace muSpectre {
namespace Projection {
using vector = Eigen::Matrix<Real, 1, Eigen::Dynamic>;
//----------------------------------------------------------------------------//
//! computes fft frequecies. see function fftfreq in numpy's helper.py
vector fft_freqs(Uint nb_samples, Real length);
vector fft_freqs(Uint nb_samples);
template<Dim_t Dim>
class FreqStruc {
public:
FreqStruc(const std::array<Real, Dim>& sizes, const Index_t<Dim>& nb_pixels);
class iterator {
public:
iterator(const FreqStruc & parent, Index_t<Dim> index);
inline Eigen::Matrix<Real, Dim, 1> operator*();
inline iterator& operator++ ();
inline bool operator!=(const iterator & other) const
{return this->index !=other.index;}
protected:
inline Index_t<Dim> get_index();
const FreqStruc & parent;
size_t index;
};
inline iterator begin();
inline iterator end();
protected:
const Index_t<Dim>& nb_pixels;
const std::array<Real, Dim>& sizes;
//! scaled frequencies (k_i/L_i)
std::array<vector, Dim> xi;
};
} // Projection
//! DimS spatial dimension (dimension of problem
//! DimM material_dimension (dimension of constitutive law)
template<Dim_t DimS, Dim_t DimM>
class SystemBase
{
public:
using Index = Index_t<DimS>;
using T4Vector = Eigen::Tensor<Real, 5>;
using T2Vector = Eigen::Tensor<Real, 2 + DimS>;
using T4VecMap = Eigen::TensorMap<T4Vector>;
using T2VecMap = Eigen::TensorMap<T2Vector>;
enum class Formulation{finite_strain, small_strain};
SystemBase(std::array<Real, DimS> sizes, Index nb_pixels,
Formulation = Formulation::finite_strain);
virtual ~SystemBase() = default;
inline size_t size() {return this->nb_pixel;}
protected:
void build_ghats();
T4Vector get_scaled_freqs;
std::array<Real, DimS> sizes;
Index nb_pixels;
size_t nb_pixel;
Formulation form;
//! projection operator
T4Vector Ghats;
//! tangent stiffness tensors by pixel;
//T4VecMap Ks;
//! gradient or strain (depending on finite/small strain formulation)
//T2VecMap grad;
//! Cauchy or First Piola-Kirchhoff stress
//T2VecMap stress;
};
} // muSpectre
#endif /* SYSTEM_BASE_H */

Event Timeline