Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F106925807
accessor_dof.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, Apr 2, 14:49
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Apr 4, 14:49 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25307432
Attached To
rLIBMULTISCALE LibMultiScale
accessor_dof.hh
View Options
#ifndef __LIBMULTISCALE_ACCESSOR_DOF_HH__
#define __LIBMULTISCALE_ACCESSOR_DOF_HH__
/* -------------------------------------------------------------------------- */
#include "lm_common.hh"
/* -------------------------------------------------------------------------- */
__BEGIN_LIBMULTISCALE__
template
<
typename
Ref
,
FieldType
ftype
>
class
AccessorDof
{
public
:
using
TensorType
=
typename
field_getter
<
ftype
,
Ref
>::
type
;
AccessorDof
(
Ref
&
nd
)
:
field
(
field_getter
<
ftype
,
Ref
>::
get
(
nd
)){};
template
<
typename
T
>
inline
TensorType
&
operator
=
(
const
Vector
<
Ref
::
Dim
>
&
val
)
{
field
=
val
;
return
field
;
}
template
<
typename
T
>
inline
TensorType
&
operator
=
(
const
VectorView
<
Ref
::
Dim
>
val
)
{
field
=
val
;
return
field
;
}
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
;
}
template
<
typename
T
=
TensorType
,
std
::
enable_if_t
<
not
std
::
is_same
<
std
::
decay_t
<
T
>
,
Real
>::
value
>
*
=
nullptr
>
decltype
(
auto
)
operator
[](
UInt
index
)
{
return
field
(
index
);
}
template
<
typename
T
=
TensorType
,
std
::
enable_if_t
<
std
::
is_same
<
T
,
Real
>::
value
or
std
::
is_same
<
T
,
Real
&>::
value
>
*
=
nullptr
>
decltype
(
auto
)
operator
[](
UInt
index
)
{
if
(
index
>
0
)
LM_FATAL
(
"invalid index"
);
return
field
;
}
UInt
size
()
{
return
Ref
::
Dim
;
}
template
<
typename
T
=
TensorType
,
std
::
enable_if_t
<
not
std
::
is_same
<
std
::
decay_t
<
T
>
,
Real
>::
value
>
*
=
nullptr
>
decltype
(
auto
)
data
()
{
return
field
.
data
();
}
template
<
typename
T
=
TensorType
,
std
::
enable_if_t
<
std
::
is_same
<
std
::
decay_t
<
T
>
,
Real
>::
value
>
*
=
nullptr
>
decltype
(
auto
)
data
()
{
return
&
field
;
}
template
<
typename
T
=
TensorType
,
std
::
enable_if_t
<
not
std
::
is_same
<
T
,
Real
*>::
value
>
*
=
nullptr
>
operator
Vector
<
Ref
::
Dim
>
()
{
return
field
;
}
template
<
typename
T
=
TensorType
,
std
::
enable_if_t
<
std
::
is_same
<
T
,
Real
*>::
value
>
*
=
nullptr
>
operator
Vector
<
Ref
::
Dim
>
()
{
LM_FATAL
(
"cannot call this conversion"
);
}
void
printself
(
std
::
ostream
&
os
)
{
os
<<
field
;
}
private
:
TensorType
field
;
};
__END_LIBMULTISCALE__
#endif
Event Timeline
Log In to Comment