Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60592616
model_type.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 1, 08:15
Size
3 KB
Mime Type
text/x-c++
Expires
Fri, May 3, 08:15 (2 d)
Engine
blob
Format
Raw Data
Handle
17380444
Attached To
rTAMAAS tamaas
model_type.hh
View Options
/**
* @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/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __MODEL_TYPE_HH__
#define __MODEL_TYPE_HH__
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include "grid_base.hh"
#include "tamaas.hh"
#include <boost/preprocessor/seq.hpp>
#include <memory>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/// Types for grid dimensions and number of components
enum
class
model_type
{
basic_1d
,
///< one component line
basic_2d
,
///< one component surface
surface_1d
,
///< two components line
surface_2d
,
///< three components surface
volume_1d
,
///< two components volume
volume_2d
///< three components volume
};
/// Trait class to store physical dimension of domain, of boundary and
/// number of components
template
<
model_type
type
>
struct
model_type_traits
{};
#define MODEL_TYPE_TRAITS_MACRO(type, dim, comp, bdim) \
template <> \
struct model_type_traits<model_type::type> { \
static constexpr UInt dimension = dim; \
static constexpr UInt components = comp; \
static constexpr UInt boundary_dimension = bdim; \
static std::vector<UInt> indices; \
}
MODEL_TYPE_TRAITS_MACRO
(
basic_1d
,
1
,
1
,
1
);
MODEL_TYPE_TRAITS_MACRO
(
basic_2d
,
2
,
1
,
2
);
MODEL_TYPE_TRAITS_MACRO
(
surface_1d
,
1
,
2
,
1
);
MODEL_TYPE_TRAITS_MACRO
(
surface_2d
,
2
,
3
,
2
);
MODEL_TYPE_TRAITS_MACRO
(
volume_1d
,
2
,
2
,
1
);
MODEL_TYPE_TRAITS_MACRO
(
volume_2d
,
3
,
3
,
2
);
#undef MODEL_TYPE_TRAITS_MACRO
#define TAMAAS_MODEL_TYPES \
(model_type::basic_1d)(model_type::basic_2d)(model_type::surface_1d)( \
model_type::surface_2d)(model_type::volume_1d)(model_type::volume_2d)
#define ALLOC_GRID_CASE_MACRO(a, b, type) \
case type: { \
constexpr UInt dim = (boundary) \
? model_type_traits<type>::boundary_dimension \
: model_type_traits<type>::dimension; \
ptr = new Grid<T, dim>(n, nc); \
break; \
}
/// Helper function for grid allocation
template
<
bool
boundary
,
typename
T
>
GridBase
<
T
>*
allocateGrid
(
model_type
type
,
const
std
::
vector
<
UInt
>
n
,
UInt
nc
)
{
GridBase
<
T
>*
ptr
=
nullptr
;
switch
(
type
)
{
BOOST_PP_SEQ_FOR_EACH
(
ALLOC_GRID_CASE_MACRO
,
~
,
TAMAAS_MODEL_TYPES
);
}
return
ptr
;
}
#undef ALLOC_GRID_CASE_MACRO
__END_TAMAAS__
/* -------------------------------------------------------------------------- */
#endif
// __MODEL_TYPE_HH__
Event Timeline
Log In to Comment