-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnumericalIntegrationScript.js
51 lines (47 loc) · 1.83 KB
/
numericalIntegrationScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// ______ ______ _____ _ _ //
// | ____| ____| /\ / ____| (_) | | //
// | |__ | |__ / \ | (___ ___ ____ _ ____ | |_ //
// | __| | __| / /\ \ \___ \ / __| __| | _ \| __| //
// | | | |____ / ____ \ ____) | (__| | | | |_) | | //
// |_| |______/_/ \_\_____/ \___|_| |_| __/| | //
// | | | | //
// |_| | |_ //
// Website: https://feascript.com/ \__| //
/**
* Class to handle numerical integration using Gauss quadrature
*/
export class numericalIntegration {
/**
* Constructor to initialize the numIntegration class
* @param {string} meshDimension - The dimension of the mesh
* @param {number} elementOrder - The order of elements
*/
constructor({ meshDimension, elementOrder }) {
this.meshDimension = meshDimension;
this.elementOrder = elementOrder;
}
/**
* Return Gauss points and weights based on element configuration
* @returns {object} An object containing:
* - gaussPoints: Array of Gauss points
* - gaussWeights: Array of Gauss weights
*/
getGaussPointsAndWeights() {
let gaussPoints = []; // Gauss points
let gaussWeights = []; // Gauss weights
if (this.elementOrder === "linear") {
// For linear elements, use 1-point Gauss quadrature
gaussPoints[0] = 0.5;
gaussWeights[0] = 1;
} else if (this.elementOrder === "quadratic") {
// For quadratic elements, use 3-point Gauss quadrature
gaussPoints[0] = (1 - Math.sqrt(3 / 5)) / 2;
gaussPoints[1] = 0.5;
gaussPoints[2] = (1 + Math.sqrt(3 / 5)) / 2;
gaussWeights[0] = 5 / 18;
gaussWeights[1] = 8 / 18;
gaussWeights[2] = 5 / 18;
}
return { gaussPoints, gaussWeights };
}
}