Page MenuHomec4science

model_template.cpp
No OneTemporary

File Metadata

Created
Sun, May 19, 22:37

model_template.cpp

/**
* @file
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016-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/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "model_template.hh"
#include "westergaard.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/* -------------------------------------------------------------------------- */
template <model_type type>
ModelTemplate<type>::ModelTemplate(const std::vector<Real>& system_size,
const std::vector<UInt>& discretization)
: Model(system_size, discretization), boundary_displacement(nullptr) {
constexpr UInt dim = trait::dimension;
constexpr UInt dim_b = trait::boundary_dimension;
constexpr UInt nb_components = trait::components;
if (system_size.size() != dim)
TAMAAS_EXCEPTION("System size does not match model type");
if (discretization.size() != dim)
TAMAAS_EXCEPTION("Discretization size does not match model type");
// Copying sizes for traction grid
std::array<UInt, dim_b> traction_size;
auto disc_it = discretization.begin();
if (dim > dim_b)
++disc_it;
std::copy(disc_it, discretization.end(), traction_size.begin());
// Allocating
traction = std::make_unique<Grid<Real, dim_b>>(traction_size, nb_components);
displacement =
std::make_unique<Grid<Real, dim>>(discretization, nb_components);
boundary_displacement =
std::make_unique<ViewType>(*displacement, trait::indices);
engine = std::make_unique<Westergaard<type>>(this);
engine->initInfluence();
}
/* -------------------------------------------------------------------------- */
template <model_type type>
GridBase<Real>& ModelTemplate<type>::getBoundaryDisplacement() {
return *boundary_displacement;
}
/* -------------------------------------------------------------------------- */
/* Template instanciation */
/* -------------------------------------------------------------------------- */
template class ModelTemplate<model_type::basic_1d>;
template class ModelTemplate<model_type::basic_2d>;
template class ModelTemplate<model_type::surface_1d>;
template class ModelTemplate<model_type::surface_2d>;
template class ModelTemplate<model_type::volume_1d>;
template class ModelTemplate<model_type::volume_2d>;
__END_TAMAAS__

Event Timeline