Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65014592
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
Fri, May 31, 02:43
Size
2 KB
Mime Type
text/x-c++
Expires
Sun, Jun 2, 02:43 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17990143
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
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