Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

acasta-yhliu/xgrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XGrid

Installation

pip install xgrid

Test

Invoke python3 test.py in the root folder to perform the test cases.

Usage

See document for more information. Let's start with a simple kernel, the element-wise multiplication of two grid:

import xgrid
import numpy as np
import random

xgrid.init()

fvec = xgrid.grid[float, 1]

@xgrid.kernel()
def elementwise_mul(result: fvec, a: fvec, b: fvec) -> None:
    result[0] = a[0] * b[0]

and let's define some data:

a = xgrid.Grid((10000, ), float)
b = xgrid.Grid((10000, ), float)

for i in range(10000):
    a[i] = random.random()
    b[i] = random.random()

and the result:

result = xgrid.Grid((10000, ), float)

and invoke the kernel:

elementwise_mul(result, a, b)

We could check the result using numpy dot:

assert np.sum(result.now) == np.dot(a.now, b.now)

Examples

Solve the 2D Cavity flow with xgrid, see in examples folder.

cavity

About

domain-specific language for developing partial differential equation solvers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages