BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_create_beam_poly.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
12#ifndef BELFEM_FN_CREATE_BEAM_POLY_HPP
13#define BELFEM_FN_CREATE_BEAM_POLY_HPP
14
15#include "typedefs.hpp"
16#include "cl_Vector.hpp"
17#include "cl_Matrix.hpp"
19
20namespace belfem
21{
22
23
24 inline void
25 create_beam_poly( const real aX1, const real aF1, const real adF1dX,
26 const real aX2, const real aF2, const real adF2dX,
27 Vector< real > & aCoefficients,
28 Matrix< real > & aWork,
29 Vector< int_t > & aPivot )
30 {
31 BELFEM_ASSERT( aWork.n_rows() == 4 && aWork.n_cols() == 4, "Work Matrix must be 4x4" );
32 BELFEM_ASSERT( aPivot.length() >= 4, "Pivot Vector must be at least of length 4" );
33
34 // populate the matrix
35 aWork( 0, 0 ) = aX1*aX1*aX1;
36 aWork( 1, 0 ) = 3.0 * aX1 * aX1;
37 aWork( 2, 0 ) = aX2*aX2*aX2;
38 aWork( 3, 0 ) = 3.0 * aX2 * aX2;
39 aWork( 0, 1 ) = aX1*aX1;
40 aWork( 1, 1 ) = 2.0 * aX1;
41 aWork( 2, 1 ) = aX2*aX2;
42 aWork( 3, 1 ) = 2.0 * aX2 ;
43 aWork( 0, 2 ) = aX1;
44 aWork( 1, 2 ) = 1.0;
45 aWork( 2, 2 ) = aX2;
46 aWork( 3, 2 ) = 1.0;
47 aWork( 0, 3 ) = 1.0;
48 aWork( 1, 3 ) = 0.0;
49 aWork( 2, 3 ) = 1.0;
50 aWork( 3, 3 ) = 0.0;
51
52 // create the right hand side
53 aCoefficients.set_size( 4 );
54
55 aCoefficients( 0 ) = aF1;
56 aCoefficients( 1 ) = adF1dX;
57 aCoefficients( 2 ) = aF2;
58 aCoefficients( 3 ) = adF2dX;
59
60 // solve the system and return the coefficients
61 gesv( aWork, aCoefficients, aPivot );
62 }
63
64 inline void
65 create_beam_poly( const real aX1, const real aF1, const real adF1dX,
66 const real aX2, const real aF2, const real adF2dX,
67 Vector< real > & aCoefficients )
68 {
69 // create the vandermonde matrix
70 Matrix< real > tVandermonde( 4, 4 );
71
72 // allocate the pivot vector
73 Vector< int_t > tPivot( 4 );
74
75 create_beam_poly( aX1, aF1, adF1dX, aX2, aF2, adF2dX, aCoefficients, tVandermonde, tPivot );
76 }
77}
78
79#endif //BELFEM_FN_CREATE_BEAM_POLY_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
size_t n_rows() const
Definition cl_AR_Matrix.hpp:205
size_t n_cols() const
Definition cl_AR_Matrix.hpp:213
void set_size(const size_t aNumRows)
change the size of the vector
Definition cl_AR_Vector.hpp:237
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:257
Solves a square linear system by LU factorization (LAPACK ?gesv).
USER GUIDES:
Definition cl_Capacitor.cpp:16
int_t gesv(Matrix< T > &A, Vector< T > &B, Vector< int_t > &Pivot, const bool AbortOnError=true)
solve the square linear system A * x = b via LAPACK ?gesv ( LU factorization with partial pivoting )
Definition fn_gesv.hpp:222
void create_beam_poly(const real aX1, const real aF1, const real adF1dX, const real aX2, const real aF2, const real adF2dX, Vector< real > &aCoefficients, Matrix< real > &aWork, Vector< int_t > &aPivot)
Definition fn_create_beam_poly.hpp:25
double real
Definition typedefs.hpp:36