Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62673817
model_factory.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
Tue, May 14, 19:11
Size
2 KB
Mime Type
text/x-c++
Expires
Thu, May 16, 19:11 (2 d)
Engine
blob
Format
Raw Data
Handle
17645422
Attached To
rTAMAAS tamaas
model_factory.hh
View Options
/**
* @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 __MODEL_FACTORY_HH__
#define __MODEL_FACTORY_HH__
/* -------------------------------------------------------------------------- */
#include "be_engine.hh"
#include "model.hh"
#include "model_type.hh"
#include "residual.hh"
#include <boost/preprocessor/seq.hpp>
#include <vector>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/**
* @brief Factory class for model
* TODO put allocate grid in there (maybe)
*/
class
ModelFactory
{
public
:
/// Create new model (TODO make std::unique_ptr work in swig)
static
std
::
unique_ptr
<
Model
>
createModel
(
model_type
type
,
const
std
::
vector
<
Real
>&
system_size
,
const
std
::
vector
<
UInt
>&
discretization
);
static
std
::
unique_ptr
<
Residual
>
createResidual
(
Model
*
model
,
Real
hardening
,
Real
sigma_y
);
};
#define MODEL_TYPE_CASE_MACRO(truc, arguments, type) \
case type: { \
result = std::make_unique<Concrete<type>>(std::forward<Args>(args)...); \
break; \
}
#define IMPLEMENTED_MODEL_TYPES TAMAAS_MODEL_TYPES
template
<
typename
Abstract
,
template
<
model_type
>
class
Concrete
,
class
...
Args
>
std
::
unique_ptr
<
Abstract
>
createFromModelType
(
model_type
type
,
Args
&&
...
args
)
{
std
::
unique_ptr
<
Abstract
>
result
=
nullptr
;
switch
(
type
)
{
BOOST_PP_SEQ_FOR_EACH
(
MODEL_TYPE_CASE_MACRO
,
~
,
IMPLEMENTED_MODEL_TYPES
);
default
:
TAMAAS_EXCEPTION
(
"Model type not implemented"
);
}
return
result
;
}
#undef MODEL_TYPE_CASE_MACRO
#undef IMPLEMENTED_MODEL_TYPES
__END_TAMAAS__
#endif
// __MODEL_FACTORY_HH__
Event Timeline
Log In to Comment