-
-
Notifications
You must be signed in to change notification settings - Fork 3
Implement WebGPU Conjugate Gradient Solver with Enhanced Precision and Robust Fallback #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
19
commits into
webGPU
Choose a base branch
from
copilot/fix-b535ec9a-fd99-42fd-81b1-9115d3a62ff7
base: webGPU
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Made the initial build for npm * fix: update package.json with correct license, description and module type - Change license from AGPLv3 to MIT to match actual project license - Replace HTML image tag with proper text description - Update type to "module" to align with ES module syntax * Prepare package for npm publishing and bump version to 0.1.1 * Update package.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update rollup.config.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update rollup.config.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: update test script to use jest and add jest as a devDependency * fix: remove (still) unused wasm plugin from rollup configuration * fix: remove unused rollup-plugin-wasm from devDependencies * fix: revert test script to no tests configured and remove jest from devDependencies * Add plotly.js as a peer and dev dependency; update Rollup config for external globals * fix: remove unused rollup-plugin-typescript2 from configuration * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: update import paths in README for consistency with distribution bundle * fix: correct parameter syntax in addBoundaryCondition example --------- Co-authored-by: Sridhar.Mani <sridhar.mani@novacastindia.com> Co-authored-by: Nikos Chamakos <nikoscham@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Made the initial build for npm (#25) * Made the initial build for npm * fix: update package.json with correct license, description and module type - Change license from AGPLv3 to MIT to match actual project license - Replace HTML image tag with proper text description - Update type to "module" to align with ES module syntax * Prepare package for npm publishing and bump version to 0.1.1 * Update package.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update rollup.config.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update rollup.config.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: update test script to use jest and add jest as a devDependency * fix: remove (still) unused wasm plugin from rollup configuration * fix: remove unused rollup-plugin-wasm from devDependencies * fix: revert test script to no tests configured and remove jest from devDependencies * Add plotly.js as a peer and dev dependency; update Rollup config for external globals * fix: remove unused rollup-plugin-typescript2 from configuration * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: update import paths in README for consistency with distribution bundle * fix: correct parameter syntax in addBoundaryCondition example --------- Co-authored-by: Sridhar.Mani <sridhar.mani@novacastindia.com> Co-authored-by: Nikos Chamakos <nikoscham@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update author and contributors information in package.json * Add publishConfig to package.json for public access --------- Co-authored-by: sridhar <2019309038@student.annauniv.edu> Co-authored-by: Sridhar.Mani <sridhar.mani@novacastindia.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Added initial file for frontPropagationScript * Refactor Heat Conduction example: add JavaScript implementation, update README instructions, and enhance .gitignore * - Enhanced frontPropagationScript.js with a new function to assemble the front propagation matrix, including detailed JSDoc comments. - Updated version number in package.json and src/index.js to 0.1.2. - Added logging for FEAScript version in HeatConduction1DWall.js. - Updated peer dependency for plotly.js to version 2.35.3. - Removed unnecessary dependencies from package-lock.json and package.json. * Reorganize README sections for clarity: update installation options and example usage * Update README for improved clarity: reorganize installation options and example usage sections * Remove HTML examples and add Node.js implementations for heat conduction simulations * Add front propagation matrix assembly to FEAScriptModel * Enhance front propagation matrix assembly and initiate Newton-Raphson method * Update parameters names and improve convergence logic in Newton-Raphson method * Add Euclidean norm function and update Newton-Raphson method to use it for error calculation * Update README files to clarify Node.js environment suitability for heat conduction examples * Integrate Newton-Raphson method into front propagation solver * Refactor Newton-Raphson method to accept matrix assembly function and context, enhancing front propagation solver with eikonal viscous term parameterization * Add a seperate linear system solver function (linearSystemScript.js). Refactor linearSystemScript.js and FEAScript.js to utilize it * Include error logging for unknown linear solver * Refactor Jacobi and Newton-Raphson methods to standardize solution vector naming * Fix import path for logging utilities in Newton-Raphson script * Add todo statements in frontPropagationScript.js * Improve Readability and Maintainability of meshGenerationScript.js (#28) * Redefining the mesh script as a Class * Deleting meshGeneration class and replacing it to the Mesh1D and Mesh2D classes * Replace meshGeneration class with the Mesh1D and Mesh2D classes * Fix non-capitalized class names * Rename variables for consistency * Create a new file for generic boundary condutions (genericBoundaryConditionsScript.js). Possible need to consolidate with thermalBoundaryConditionsScript.js in the future * Add residual and Jacobian terms for the eikonal equation * Refactor Jacobian determinant calculation * Update boundary condition handling to use 'constantValue' instead of 'constantTemp' * Refactor Newton-Raphson implementation and improve debug logging in boundary conditions * Enhance eikonal equation solver with initial solution handling and improve logging in boundary condition applications * Refactor eikonal equation parameters and update Newton-Raphson convergence tolerance; add helper function for system size calculation * - Reduce the number of incremental steps for the eikonal term activation in FEAScript.js from 10 to 5 - Reorganize the return statement in meshGenerationScript.js since it was causing an error in the case of linear elements - Update logging messages in newtonRaphsonScript.js - Increase the base viscous term in frontPropagationScript.js from 1e-3 to 1e-2 to prevent stability issues --------- Co-authored-by: ferrari212 <felipe.ferrari.212@gmail.com>
…opagationScript - Removed the global declaration of eikonalActivationFlag in FEAScriptModel. - Initialized eikonalActivationFlag locally within the frontPropagationScript context. - Updated frontPropagationScript to accept eikonalActivationFlag as a parameter without a default value.
- Updated the context object in FEAScriptModel to explicitly assign eikonalActivationFlag. - Simplified the assembly function call in newtonRaphson by removing conditional logic for front propagation, ensuring consistent parameter passing.
* Added initial file for frontPropagationScript * Refactor Heat Conduction example: add JavaScript implementation, update README instructions, and enhance .gitignore * - Enhanced frontPropagationScript.js with a new function to assemble the front propagation matrix, including detailed JSDoc comments. - Updated version number in package.json and src/index.js to 0.1.2. - Added logging for FEAScript version in HeatConduction1DWall.js. - Updated peer dependency for plotly.js to version 2.35.3. - Removed unnecessary dependencies from package-lock.json and package.json. * Reorganize README sections for clarity: update installation options and example usage * Update README for improved clarity: reorganize installation options and example usage sections * Remove HTML examples and add Node.js implementations for heat conduction simulations * Add front propagation matrix assembly to FEAScriptModel * Enhance front propagation matrix assembly and initiate Newton-Raphson method * Update parameters names and improve convergence logic in Newton-Raphson method * Add Euclidean norm function and update Newton-Raphson method to use it for error calculation * Update README files to clarify Node.js environment suitability for heat conduction examples * Integrate Newton-Raphson method into front propagation solver * Refactor Newton-Raphson method to accept matrix assembly function and context, enhancing front propagation solver with eikonal viscous term parameterization * Add a seperate linear system solver function (linearSystemScript.js). Refactor linearSystemScript.js and FEAScript.js to utilize it * Include error logging for unknown linear solver * Refactor Jacobi and Newton-Raphson methods to standardize solution vector naming * Fix import path for logging utilities in Newton-Raphson script * Add todo statements in frontPropagationScript.js * Improve Readability and Maintainability of meshGenerationScript.js (#28) * Redefining the mesh script as a Class * Deleting meshGeneration class and replacing it to the Mesh1D and Mesh2D classes * Replace meshGeneration class with the Mesh1D and Mesh2D classes * Fix non-capitalized class names * Rename variables for consistency * Create a new file for generic boundary condutions (genericBoundaryConditionsScript.js). Possible need to consolidate with thermalBoundaryConditionsScript.js in the future * Add residual and Jacobian terms for the eikonal equation * Refactor Jacobian determinant calculation * Update boundary condition handling to use 'constantValue' instead of 'constantTemp' * Refactor Newton-Raphson implementation and improve debug logging in boundary conditions * Enhance eikonal equation solver with initial solution handling and improve logging in boundary condition applications * Refactor eikonal equation parameters and update Newton-Raphson convergence tolerance; add helper function for system size calculation * - Reduce the number of incremental steps for the eikonal term activation in FEAScript.js from 10 to 5 - Reorganize the return statement in meshGenerationScript.js since it was causing an error in the case of linear elements - Update logging messages in newtonRaphsonScript.js - Increase the base viscous term in frontPropagationScript.js from 1e-3 to 1e-2 to prevent stability issues * Add Solidification Front 2D example * Fix markdown link formatting in SolidificationFront2D README --------- Co-authored-by: ferrari212 <felipe.ferrari.212@gmail.com>
) * Update README.md to include npm version badge * Feature/frontal solver (#33) * Refactor solver imports * chore: bump version to 0.1.3 and update description in package.json - Updated version from 0.1.2 to 0.1.3 - Modified description for clarity - Added contributor Felipe Ferrari to package.json - Changed homepage URL to https://feascript.com/ - Updated version constant in src/index.js to 0.1.3
Co-authored-by: sridhar-mani <165501918+sridhar-mani@users.noreply.github.com>
Co-authored-by: sridhar-mani <165501918+sridhar-mani@users.noreply.github.com>
…isms Co-authored-by: sridhar-mani <165501918+sridhar-mani@users.noreply.github.com>
Co-authored-by: sridhar-mani <165501918+sridhar-mani@users.noreply.github.com>
Copilot finished work on behalf of
sridhar-mani
September 2, 2025 12:28
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a new WebGPU-accelerated Conjugate Gradient solver for FEAScript that provides enhanced precision for linear system solving. The solver addresses the need for more precise numerical computations in finite element analysis while maintaining compatibility with existing workflows.
Key Features
WebGPU Acceleration with CPU Fallback
Enhanced Precision
Robust Matrix Handling
Implementation Details
New Solver Method
The solver is integrated as
"conjugate-gradient-webgpu"
in the existing linear system solver framework:Async/Await Support
Updated the entire solving pipeline to support asynchronous operations:
newtonRaphson()
function is now asyncsolveLinearSystem()
function is now asyncFEAScriptModel.solve()
method is now asyncFiles Modified
src/methods/conjugateGradientWebGPUScript.js
(new): Core WebGPU CG implementationsrc/methods/linearSystemSolverScript.js
: Added new solver method integrationsrc/methods/newtonRaphsonScript.js
: Made async for WebGPU supportsrc/FEAScript.js
: Updated main solving pipeline for async operationssrc/workers/wrapperScript.js
: Added async support for worker contextTesting and Validation
Comprehensive Test Results
Browser Demo
Includes an interactive HTML demo (
examples/webgpu_demo.html
) that:Backward Compatibility
This implementation maintains full backward compatibility:
"lusolve"
,"jacobi"
) continue to work unchangedUsage Example
Performance Characteristics
This implementation significantly enhances FEAScript's numerical capabilities while maintaining the library's ease of use and robustness.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.