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
from mpi4py import MPI | |
try: | |
from petsc4py import PETSc | |
import dolfinx | |
if not dolfinx.has_petsc: | |
print("This demo requires DOLFINx to be compiled with PETSc enabled.") | |
exit(0) |
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
import dolfinx | |
import ufl | |
import basix | |
import numpy as np | |
from mpi4py import MPI | |
comm = MPI.COMM_WORLD | |
# (3) | |
# | |
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
from mpi4py import MPI | |
import numpy as np | |
import dolfinx | |
import ufl | |
import basix.ufl | |
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10) | |
V = dolfinx.fem.functionspace(mesh, ("Lagrange", 1, (2,))) | |
u = dolfinx.fem.Function(V) |
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
""" | |
Hermite as coordinate element in DOLFINx | |
Author: Jørgen S. Dokken | |
SPDX License identifier: MIT | |
""" | |
from mpi4py import MPI | |
import dolfinx | |
import basix.ufl |
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
from dataclasses import dataclass | |
import shutil | |
from mpi4py import MPI | |
from petsc4py import PETSc | |
import dolfinx.fem.petsc | |
from dolfinx_external_operator import ( | |
FEMExternalOperator, | |
evaluate_external_operators, | |
evaluate_operands, |
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
from mpi4py import MPI | |
import dolfinx | |
import numpy as np | |
from pathlib import Path | |
cube = dolfinx.mesh.create_unit_cube(MPI.COMM_WORLD, nx=3, ny=3, nz=3) | |
def left_cells(x): |
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
# Consistently orient jump integrals on a mesh with a bifurcation | |
# | |
# The idea of this demo is to say that the jump at a bifurcation with three cells should be: | |
# u(0) - u(1) - u(2) where u(0) is taken from the cell with the lowest value, while u(1) and u(2) are taken from the two other cells. | |
# | |
# \ / | |
# \ u1 / u2 | |
# \ / | |
# \ / | |
# \ / |
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
# This file was generated by running | |
# | |
# python cmake/scripts/generate-cmakefiles.py from dolfinx/cpp | |
# | |
cmake_minimum_required(VERSION 3.19) | |
set(PROJECT_NAME demo_real_space) | |
project(${PROJECT_NAME} LANGUAGES C CXX) | |
# Set C++20 standard |
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
# Illustration of submesh facet integral with parent coefficient | |
# Author: Jørgen S. Dokken | |
# SPDX-License-Identifier: MIT | |
def transfer_meshtags_to_submesh( | |
mesh, entity_tag, submesh, sub_vertex_to_parent, sub_cell_to_parent | |
): | |
""" | |
Transfer a meshtag from a parent mesh to a sub-mesh. |
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
# Author: Jørgen S. Dokken | |
# SPDX-License-Identifier: MIT | |
import numpy as np | |
from mesh_converter import Mesh, CellType, vtk | |
points = np.array( | |
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [2.0, 0.0], | |
[2., 2.], [3., 2.],[3,3],[2.5,2],[3, 2.5], [2.3, 2.7]], dtype=np.float64 | |
) |
NewerOlder