BELFEM
0.9.0
Berkeley Lab Finite Element Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
fn_inv2.hpp
Go to the documentation of this file.
1
/*
2
* BELFEM -- The Berkeley Lab Finite Element Framework
3
* Copyright (c) 2026, The Regents of the University of California,
4
* through Lawrence Berkeley National Laboratory (subject to receipt of any required
5
* approvals from the U.S. Dept. of Energy). All rights reserved.
6
*
7
* Developers: Christian Messe, Gregory Giard
8
*
9
* See the top-level LICENSE file for the complete license and disclaimer.
10
*/
11
17
18
#ifndef BELFEM_FN_INV2_HPP
19
#define BELFEM_FN_INV2_HPP
20
21
#include "
typedefs.hpp
"
22
#include "
assert.hpp
"
23
#include "
cl_Matrix.hpp
"
24
25
26
namespace
belfem
27
{
28
//------------------------------------------------------------------------------
29
48
inline
real
49
inv2
(
const
Matrix< real >
& aA,
Matrix< real >
& aB )
50
{
51
// compute determinant
52
real
aDetA = aA( 0, 0 )*aA( 1,1 )
53
- aA( 1, 0 )*aA( 0,1 );
54
55
aB( 0, 0 ) = aA( 1, 1 );
56
aB( 1, 0 ) = - aA( 1, 0 );
57
aB( 0, 1 ) = - aA( 0, 1 );
58
aB( 1, 1 ) = aA( 0, 0 );
59
60
// singularity test on the hadamard ratio |det| / prod( ||row_i|| ),
61
// which is dimensionless: an absolute bound on the determinant is a
62
// scale test, and rejects well conditioned but small matrices such as
63
// any fine mesh jacobian. squared here to avoid the square roots
64
BELFEM_ASSERT
( aDetA * aDetA >
BELFEM_EPSILON
*
BELFEM_EPSILON
65
* ( aA( 0, 0 ) * aA( 0, 0 ) + aA( 0, 1 ) * aA( 0, 1 ) )
66
* ( aA( 1, 0 ) * aA( 1, 0 ) + aA( 1, 1 ) * aA( 1, 1 ) ),
67
"Can't invert a singular matrix"
);
68
69
aB /= aDetA ;
70
71
return
aDetA ;
72
}
73
74
//------------------------------------------------------------------------------
75
}
76
#endif
//BELFEM_FN_INV2_HPP
assert.hpp
BELFEM_ASSERT
#define BELFEM_ASSERT(aCheck,...)
Definition
assert.hpp:244
cl_Matrix.hpp
belfem::Matrix< real >
belfem::inv2
real inv2(const Matrix< real > &aA, Matrix< real > &aB)
Inverse of a 2x2 matrix from the closed-form adjugate.
Definition
fn_inv2.hpp:49
belfem
USER GUIDES:
Definition
cl_Capacitor.cpp:16
belfem::BELFEM_EPSILON
constexpr real BELFEM_EPSILON
Definition
typedefs.hpp:90
belfem::real
double real
Definition
typedefs.hpp:36
typedefs.hpp
src
linalg
fn_inv2.hpp
Generated by
1.18.0