BELFEM 0.9.0
Berkeley Lab Finite Element Framework
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
26namespace belfem
27{
28//------------------------------------------------------------------------------
29
48 inline real
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
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
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
real inv2(const Matrix< real > &aA, Matrix< real > &aB)
Inverse of a 2x2 matrix from the closed-form adjugate.
Definition fn_inv2.hpp:49
USER GUIDES:
Definition cl_Capacitor.cpp:16
constexpr real BELFEM_EPSILON
Definition typedefs.hpp:90
double real
Definition typedefs.hpp:36