Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82415144
detail.h
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, Sep 11, 07:01
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Sep 13, 07:01 (2 d)
Engine
blob
Format
Raw Data
Handle
20693655
Attached To
rGOOSEFEM GooseFEM
detail.h
View Options
/**
\file
\copyright Copyright 2017. Tom de Geus. All rights reserved.
\license This project is released under the GNU Public License (GPLv3).
*/
#ifndef GOOSEFEM_DETAIL_H
#define GOOSEFEM_DETAIL_H
namespace
GooseFEM
{
namespace
detail
{
template
<
size_t
nd
,
typename
=
void
>
struct
tensor
{
};
template
<
size_t
nd
>
struct
tensor
<
nd
,
typename
std
::
enable_if_t
<
nd
==
2
>>
{
/**
Inverse of a 2nd order tensor.
\param The tensor.
\param The inverse (overwritten).
\return Determinant.
*/
template
<
class
T
>
static
double
inv
(
const
T
&
A
,
T
&
Ainv
)
{
double
det
=
A
(
0
,
0
)
*
A
(
1
,
1
)
-
A
(
0
,
1
)
*
A
(
1
,
0
);
Ainv
(
0
,
0
)
=
A
(
1
,
1
)
/
det
;
Ainv
(
0
,
1
)
=
-
1.0
*
A
(
0
,
1
)
/
det
;
Ainv
(
1
,
0
)
=
-
1.0
*
A
(
1
,
0
)
/
det
;
Ainv
(
1
,
1
)
=
A
(
0
,
0
)
/
det
;
return
det
;
}
};
template
<
size_t
nd
>
struct
tensor
<
nd
,
typename
std
::
enable_if_t
<
nd
==
3
>>
{
/**
Inverse of a 2nd order tensor (shape: [3, 3]).
\param The tensor.
\param The inverse (overwritten).
\return Determinant.
*/
template
<
class
T
>
static
double
inv
(
const
T
&
A
,
T
&
Ainv
)
{
double
det
=
(
A
(
0
,
0
)
*
A
(
1
,
1
)
*
A
(
2
,
2
)
+
A
(
0
,
1
)
*
A
(
1
,
2
)
*
A
(
2
,
0
)
+
A
(
0
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