Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88626825
model_factory.cpp
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
Sat, Oct 19, 20:19
Size
3 KB
Mime Type
text/x-c++
Expires
Mon, Oct 21, 20:19 (2 d)
Engine
blob
Format
Raw Data
Handle
21627421
Attached To
rTAMAAS tamaas
model_factory.cpp
View Options
/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-2020 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "model_factory.hh"
#include "model_template.hh"
#include <boost/preprocessor/seq.hpp>
/* -------------------------------------------------------------------------- */
namespace
tamaas
{
#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
std
::
unique_ptr
<
Model
>
ModelFactory
::
createModel
(
model_type
type
,
const
std
::
vector
<
Real
>&
system_size
,
const
std
::
vector
<
UInt
>&
discretization
)
{
return
createFromModelType
<
Model
,
ModelTemplate
>
(
type
,
system_size
,
discretization
);
}
std
::
unique_ptr
<
Residual
>
ModelFactory
::
createResidual
(
Model
*
model
,
Real
sigma_y
,
Real
hardening
)
{
if
(
model
->
getType
()
!=
model_type
::
volume_2d
)
TAMAAS_EXCEPTION
(
"Cannot instanciate model: "
<<
model
);
return
std
::
make_unique
<
ResidualTemplate
<
model_type
::
volume_2d
>>
(
model
,
sigma_y
,
hardening
);
}
#define MODEL_TYPE_CASE_MACRO(truc, arguments, type) \
case type: { \
m.registerIntegralOperator<Mindlin<type, 2>>("mindlin_gradient"); \
m.registerIntegralOperator<Boussinesq<type, 1>>("boussinesq_gradient"); \
m.registerIntegralOperator<Mindlin<type, 1>>("mindlin"); \
m.registerIntegralOperator<Boussinesq<type, 0>>("boussinesq"); \
break; \
}
void
ModelFactory
::
registerVolumeOperators
(
Model
&
m
)
{
switch
(
m
.
getType
())
{
BOOST_PP_SEQ_FOR_EACH
(
MODEL_TYPE_CASE_MACRO
,
~
,
(
model_type
::
volume_2d
));
default
:
TAMAAS_EXCEPTION
(
"Registering volume operators not supported on "
<<
m
);
}
}
#undef MODEL_TYPE_CASE_MACRO
}
// namespace tamaas
Event Timeline
Log In to Comment