Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87547556
ref_node_dd.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
Sun, Oct 13, 08:05
Size
3 KB
Mime Type
text/x-c++
Expires
Tue, Oct 15, 08:05 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
21616518
Attached To
rLIBMULTISCALE LibMultiScale
ref_node_dd.hh
View Options
/**
* @file ref_node_dd.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
* @author Max Hodapp <max.hodapp@epfl.ch>
* @author Jaehyun Cho <jaehyun.cho@epfl.ch>
*
* @date Fri Nov 15 14:49:04 2013
*
* @brief Generic reference to DD nodes
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* LibMultiScale 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.
*
* LibMultiScale 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 LibMultiScale. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __LIBMULTISCALE_REF_NODE_DD_HH__
#define __LIBMULTISCALE_REF_NODE_DD_HH__
/* ----------------------------------------------------------------- */
#include "ref_point.hh"
/* ----------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
/* ----------------------------------------------------------------- */
template
<
UInt
Dim
,
typename
DaughterClass
>
class
RefDDNode
;
/* ----------------------------------------------------------------- */
template
<
FieldType
ftype
>
struct
field_getter
{
template
<
typename
Ref
>
static
Real
*
get
(
Ref
&&
ref
)
{
LM_FATAL
(
"cannot get this field: "
<<
ftype
);
return
nullptr
;
};
};
#define DECLARE_FIELD_GETTER(_field) \
template <> struct field_getter<_##_field> { \
template <typename Ref> static auto get(Ref &&ref) { \
return ref._field(); \
}; \
};
DECLARE_FIELD_GETTER
(
position
);
DECLARE_FIELD_GETTER
(
position0
);
DECLARE_FIELD_GETTER
(
force
);
#undef DECLARE_FIELD_GETTER
/* ----------------------------------------------------------------- */
template
<
typename
Ref
,
FieldType
ftype
>
class
AccessorDDNodalDof
{
public
:
using
TensorType
=
decltype
(
field_getter
<
ftype
>::
get
(
Ref
()));
AccessorDDNodalDof
(
Ref
&
nd
)
:
field
(
field_getter
<
ftype
>::
get
(
nd
)){};
template
<
typename
T
>
inline
TensorType
&
operator
=
(
const
T
&
val
)
{
field
=
val
;
return
field
;
}
template
<
typename
T
>
inline
T
operator
=
(
const
T
val
[])
{
field
=
Eigen
::
Map
<
TensorType
>
(
val
);
return
field
;
}
template
<
typename
T
>
inline
T
operator
+=
(
const
T
&
val
)
{
field
+=
val
;
return
field
;
}
inline
Real
&
operator
[](
UInt
index
)
{
return
field
[
index
];
}
UInt
size
()
{
return
Ref
::
Dim
;
}
private
:
TensorType
field
;
};
/* ---------------------------------------------------------------------- */
/**
* Class RefDDNode
*
*/
template
<
UInt
Dim
,
typename
DaughterClass
>
class
RefDDNode
:
public
RefPoint
<
Dim
>
{
public
:
static
constexpr
UInt
dim
=
Dim
;
virtual
~
RefDDNode
(){};
RefDDNode
(){};
#define declare_accessor(_name) \
auto _name() { return static_cast<DaughterClass *>(this)->_name(); }
declare_accessor
(
position0
);
declare_accessor
(
position
);
declare_accessor
(
force
);
#undef declare_accessor
template
<
FieldType
ftype
>
AccessorDDNodalDof
<
RefDDNode
<
Dim
,
DaughterClass
>
,
ftype
>
field
()
{
AccessorDDNodalDof
<
RefDDNode
<
Dim
,
DaughterClass
>
,
ftype
>
acc
(
*
this
);
return
acc
;
}
};
/* ------------------------------------------------------------------------ */
__END_LIBMULTISCALE__
#endif
/* __LIBMULTISCALE_REF_NODE_DD_HH__ */
Event Timeline
Log In to Comment