Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91016281
Element.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
Wed, Nov 6, 23:17
Size
2 KB
Mime Type
text/x-c
Expires
Fri, Nov 8, 23:17 (2 d)
Engine
blob
Format
Raw Data
Handle
22180077
Attached To
rGOOSEFEM GooseFEM
Element.cpp
View Options
#include <catch2/catch.hpp>
#include <xtensor/xrandom.hpp>
#include <xtensor/xmath.hpp>
#include <GooseFEM/GooseFEM.h>
#define ISCLOSE(a,b) REQUIRE_THAT((a), Catch::WithinAbs((b), 1.e-12));
TEST_CASE
(
"GooseFEM::Element"
,
"Element.h"
)
{
SECTION
(
"QuadratureBase - AsTensor - e.g. Quad4"
)
{
size_t
nelem
=
3
;
size_t
nip
=
4
;
GooseFEM
::
Element
::
QuadratureBase
<
4
,
2
,
2
>
quad
(
nelem
,
nip
);
xt
::
xtensor
<
double
,
2
>
qscalar
=
xt
::
random
::
rand
<
double
>
({
nelem
,
nip
});
auto
qtensor
=
quad
.
AsTensor
<
2
>
(
qscalar
);
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qscalar
<
double
>
(),
qscalar
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qscalar
<
double
>
(
0.0
),
qscalar
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
2
,
double
>
(),
qtensor
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
2
,
double
>
(
0.0
),
qtensor
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
double
>
(
2
),
qtensor
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
double
>
(
2
,
0.0
),
qtensor
.
shape
()));
for
(
size_t
e
=
0
;
e
<
nelem
;
++
e
)
{
for
(
size_t
q
=
0
;
q
<
nip
;
++
q
)
{
REQUIRE
(
xt
::
allclose
(
xt
::
view
(
qtensor
,
xt
::
keep
(
e
),
xt
::
keep
(
q
)),
qscalar
(
e
,
q
)));
}
}
}
SECTION
(
"QuadratureBase - AsTensor - e.g. Hex8"
)
{
size_t
nelem
=
6
;
size_t
nip
=
8
;
GooseFEM
::
Element
::
QuadratureBase
<
8
,
3
,
3
>
quad
(
nelem
,
nip
);
xt
::
xtensor
<
double
,
2
>
qscalar
=
xt
::
random
::
rand
<
double
>
({
nelem
,
nip
});
auto
qtensor
=
quad
.
AsTensor
<
2
>
(
qscalar
);
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qscalar
<
double
>
(),
qscalar
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qscalar
<
double
>
(
0.0
),
qscalar
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
2
,
double
>
(),
qtensor
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
2
,
double
>
(
0.0
),
qtensor
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
double
>
(
2
),
qtensor
.
shape
()));
REQUIRE
(
xt
::
has_shape
(
quad
.
allocate_qtensor
<
double
>
(
2
,
0.0
),
qtensor
.
shape
()));
for
(
size_t
e
=
0
;
e
<
nelem
;
++
e
)
{
for
(
size_t
q
=
0
;
q
<
nip
;
++
q
)
{
REQUIRE
(
xt
::
allclose
(
xt
::
view
(
qtensor
,
xt
::
keep
(
e
),
xt
::
keep
(
q
)),
qscalar
(
e
,
q
)));
}
}
}
}
Event Timeline
Log In to Comment