MPI-parallel regular grids
Project description
µGrid
µGrid is a library for discrete representation of fields on structured grids. A field is a physical quantity that varies in space. µGrid makes it easy to implement algorithms that operate on fields, such as solving partial differential equations. It supports parallelization using domain decomposition implemented using the Message Passing Interface (MPI).
µGrid is written in C++ and currently has language bindings for Python.
This README contains only a small quick start guide. Please refer to the full documentation for more help.
Quick start
To install µGrid, run
pip install muGrid
Note that on most platforms this will install a binary wheel, that was compiled with a minimal configuration. To compile for your specific platform use
pip install -v --no-binary muGrid muGrid
which will compile the code. µGrid will autodetect MPI. For I/O, it will try to use Unidata NetCDF for serial builds and PnetCDF for MPI-parallel builds. Monitor output to see which of these options were automatically detected.
Simple usage example
The following is a simple example for using µGrid through its convenient Python interface
#!/usr/bin/env python3
import numpy as np
import muGrid
# setting the geometry
nb_grid_pts = [51, 51]
center = np.array([r//2 for r in nb_grid_pts])
incl = nb_grid_pts[0]//5
lengths = [7., 5.]
formulation = µ.Formulation.small_strain
# creating the periodic cell
rve = µ.SystemFactory(nb_grid_pts,
lengths,
formulation)
hard = µ.material.MaterialLinearElastic1_2d.make(
rve, "hard", 10e9, .33)
soft = µ.material.MaterialLinearElastic1_2d.make(
rve, "soft", 70e9, .33)
# assign a material to each pixel
for i, pixel in enumerate(rve):
if np.linalg.norm(center - np.array(pixel),2)<incl:
hard.add_pixel(pixel)
else:
soft.add_pixel(pixel)
tol = 1e-5
cg_tol = 1e-8
# set macroscopic strain
Del0 = np.array([[.0, .0],
[0, .03]])
if formulation == µ.Formulation.small_strain:
Del0 = .5*(Del0 + Del0.T)
maxiter = 401
verbose = 2
solver = µ.solvers.SolverCG(rve, cg_tol, maxiter, verbose=False)
r = µ.solvers.newton_cg(rve, Del0, solver, tol, verbose)
print("nb of {} iterations: {}".format(solver.name(), r.nb_fev))
You can find more examples using both the Python and the C++ interface in the
examples
and tests
folder.
Funding
This development has received funding from the Swiss National Science Foundation within an Ambizione Project and by the European Research Council within Starting Grant 757343.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for mugrid-0.91.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 340b3602760aa39e73c5154f65bd88b0161c1384b76c255ed5ea8dd3292bb374 |
|
MD5 | 17eba59b2868ef84e3637e70e8f01923 |
|
BLAKE2b-256 | 980e75567b8293e090a07e2d3aaee1b9a67074b75e1c756c882fe6862226fd05 |
Hashes for mugrid-0.91.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b412ef84e733113b28ae2627944174bd222cf7edeada702f8bb97c93b64ce8a2 |
|
MD5 | 89747e99f1e365c6a92db8797d6942d1 |
|
BLAKE2b-256 | bb94c294b30efc5d65b6e1a6590384c9686cb2bdd2a241eb2364668a72cc3954 |
Hashes for mugrid-0.91.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce16cb12865b7a277180bdf1dcb3a4eac35d7f8101520db952ea20c03720e1b0 |
|
MD5 | ba1f4e982700c0e5aa68c734f783af6d |
|
BLAKE2b-256 | 7a1b556e91a6da851bce3b904c62966fb1b19eaa624383b888baef5f77ad2235 |
Hashes for mugrid-0.91.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be446290cb8339704e09ed36d563d27354ebee52458895699f24b9890c9ae206 |
|
MD5 | bfad09bc18efb697c4d767243d08259f |
|
BLAKE2b-256 | b0f0a59c2467f986fb0506fb55f46bba84654e141e82400d84f923213979d797 |
Hashes for mugrid-0.91.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ce00697891083a51c4366da6c88db936dfae33f5cf5a05504b3665f62dc9c08 |
|
MD5 | 5cda111d671fb0fbf8bf01b9e48969c5 |
|
BLAKE2b-256 | 8877016433c7566fb0981d7f065b33540a0bc034d08a94798951d0a51a179c63 |
Hashes for mugrid-0.91.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e98aec67f44736805c7f1c7de501633a277cee668cf7f91c0539ae544bc10fad |
|
MD5 | a62b5154bbca575ede4675cffd4cd5f4 |
|
BLAKE2b-256 | d4f709c2388173c047759318cd7c00a55be131c23708221b6d8f4dbfa3274718 |
Hashes for mugrid-0.91.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e213e8a99c5d49e82b0cd530da256f333748b4aaddb6355d330a8bc5c64e0b7e |
|
MD5 | 0c3d9b526770e045e8ab56c9a5b8516a |
|
BLAKE2b-256 | 2210e597be15bf3494d2519cf54d59c2c493d357a8ec4abc7e3fbc42e6debd81 |
Hashes for mugrid-0.91.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e579b60cbb3532913f654d110535fcd60062abd46f1840c09b49419bc8ff2fa |
|
MD5 | aabcef8493b346ff5413a8eee2619d0c |
|
BLAKE2b-256 | df47e14ed2aaa11b9cf87dfc0d46a4d1a323ad7ee4cb19983ca865c0cc623f59 |
Hashes for mugrid-0.91.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcbf1b5e7830c9e53c76f105ce518fe2dc2a3116caa74ea03c8bd73cb4288f01 |
|
MD5 | 700d8174b9b0ddad6660e96f68429907 |
|
BLAKE2b-256 | 29eae91933ef4b6d32fabffe0a4db7357ebcb288b24cc8ae558fced6538b0bb9 |
Hashes for mugrid-0.91.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed311f926a0d6e221a9f6270721dcc071297884cb9618c565e92cbe07f6c5588 |
|
MD5 | 611dc803d087cae3f6872804b281ecfd |
|
BLAKE2b-256 | 0b600eb05a2f9059a59e54e4af2fe837507d623ee3388d00f2d93353179a24f8 |