BELFEM 0.9.3
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_symrationspace.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_SYMRATIONSPACE_HPP
13#define BELFEM_FN_SYMRATIONSPACE_HPP
14
15#include "typedefs.hpp"
16#include "cl_Vector.hpp"
17#include "assert.hpp"
18
19namespace belfem
20{
21 template < typename T >
22 void
23 symratiospace( const T & aXmin, const T & aXmax, const T & aRatio, const index_t aN, Vector< T > & aX )
24 {
25 BELFEM_ASSERT( aN % 2 == 1 , "aN must be odd" );
26
27 aX.set_size( aN );
28
29 // number of steps per height
30 index_t tN = ( aN - 1 ) / 2 ;
31
32 // stepper
33 T tDeltaX = 1.0 ;
34 T tX = 0.0 ;
35 for( index_t k=0; k<tN; ++k )
36 {
37 tX = tX + tDeltaX ;
38 tDeltaX *= aRatio ;
39 }
40
41 aX( 0 ) = aXmin ;
42 aX( aN - 1 ) = aXmax ;
43 aX( tN ) = aXmin + 0.5 * ( aXmax - aXmin );
44
45 // adapt scale
46 tDeltaX = aX( tN ) / tX ;
47
48 for( index_t k=1; k<tN; ++k )
49 {
50 aX( k ) = aX( k - 1 ) + tDeltaX ;
51 aX( aN - k - 1 ) = aX( aN - k ) - tDeltaX ;
52 tDeltaX *= aRatio ;
53 }
54 }
55
56}
57#endif //BELFEM_FN_SYMRATIONSPACE_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Column vector.
Definition cl_BZ_Vector.hpp:41
void set_size(const size_t aNumRows)
change the size of the vector
Definition cl_AR_Vector.hpp:215
USER GUIDES:
Definition cl_Capacitor.cpp:16
uint32_t index_t
Definition typedefs.hpp:52
void symratiospace(const T &aXmin, const T &aXmax, const T &aRatio, const index_t aN, Vector< T > &aX)
Definition fn_symrationspace.hpp:23