Skip to content

Commit

Permalink
#71: Sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ddundo committed Apr 17, 2024
1 parent 868597c commit 6a7b01d
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 32 deletions.
7 changes: 3 additions & 4 deletions demos/lineal_spring.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@
#
# We begin by importing from the namespaces of Firedrake and Movement. ::

from firedrake import *
from movement import *

# Let's start with a uniform mesh of the unit square. It has four boundary segments,
# which are tagged with the integers 1, 2, 3, and 4. Note that segment 4 corresponds to
# the top boundary. ::

import matplotlib.pyplot as plt
from firedrake import *
from firedrake.pyplot import triplot

from movement import *

n = 10
mesh = UnitSquareMesh(n, n)
fig, axes = plt.subplots()
Expand Down
1 change: 1 addition & 0 deletions demos/monge_ampere1.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
# We begin the example by importing from the namespaces of Firedrake and Movement.

from firedrake import *

from movement import *

# To start with a simple example, consider a uniform mesh of the unit square.
Expand Down
3 changes: 2 additions & 1 deletion demos/monge_ampere_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# can also be applied to 3D meshes. We employ the `sinatan3` function
# from :cite:`park2019` to introduce an interesting pattern.

import movement
from firedrake import *

import movement


def sinatan3(mesh):
x, y, z = SpatialCoordinate(mesh)
Expand Down
1 change: 1 addition & 0 deletions demos/monge_ampere_helmholtz.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# we instead apply Dirichlet boundary conditions based on the chosen analytical solution.

from firedrake import *

from movement import MongeAmpereMover

mesh = UnitSquareMesh(20, 20) # initial mesh
Expand Down
4 changes: 2 additions & 2 deletions movement/laplacian.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import firedrake
from firedrake.petsc import PETSc
import ufl
from firedrake.petsc import PETSc

import movement.solver_parameters as solver_parameters
from movement.mover import PrimeMover


__all__ = ["LaplacianSmoother"]


Expand Down
16 changes: 9 additions & 7 deletions movement/monge_ampere.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import firedrake
import numpy as np
import ufl
from firedrake.petsc import PETSc
from pyadjoint import no_annotations
import ufl
import numpy as np

import movement.solver_parameters as solver_parameters
from movement.mover import PrimeMover


__all__ = [
"MongeAmpereMover_Relaxation",
"MongeAmpereMover_QuasiNewton",
Expand Down Expand Up @@ -194,7 +194,7 @@ def l2_projector(self):
nzero = sum(iszero)
if nzero == self.dim:
raise ValueError(f"Invalid normal vector {_n}")
elif nzero == self.dim-1:
elif nzero == self.dim - 1:
idx = iszero.index(False)
bcs.append(firedrake.DirichletBC(self.P1_vec.sub(idx), 0, i))
continue
Expand All @@ -206,7 +206,10 @@ def l2_projector(self):

# Allow tangential movement, but only up until the end of boundary segments
a_bc = ufl.dot(tangential(v_cts, n), tangential(u_cts, n)) * self.ds
L_bc = ufl.dot(tangential(v_cts, n), tangential(ufl.grad(self.phi_old), n)) * self.ds
L_bc = (
ufl.dot(tangential(v_cts, n), tangential(ufl.grad(self.phi_old), n))
* self.ds
)
edges = set(self.mesh.exterior_facets.unique_markers)
if len(edges) == 0:
bbc = None # Periodic case
Expand Down Expand Up @@ -332,8 +335,7 @@ def equidistributor(self):
a = ufl.inner(tau, sigma) * self.dx
L = (
-ufl.dot(ufl.div(tau), ufl.grad(self.phi)) * self.dx
+ ufl.dot(ufl.dot(tangential(ufl.grad(self.phi), n), tau), n)
* self.ds
+ ufl.dot(ufl.dot(tangential(ufl.grad(self.phi), n), tau), n) * self.ds
)
problem = firedrake.LinearVariationalProblem(a, L, self.sigma)
sp = {
Expand Down
3 changes: 1 addition & 2 deletions movement/mover.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import firedrake
from firedrake.cython.dmcommon import create_section
import numpy as np

from firedrake.cython.dmcommon import create_section

__all__ = ["PrimeMover"]

Expand Down
6 changes: 3 additions & 3 deletions movement/spring.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import firedrake
from firedrake.petsc import PETSc
import ufl
import numpy as np
import ufl
from firedrake.petsc import PETSc

import movement.solver_parameters as solver_parameters
from movement.mover import PrimeMover


__all__ = ["SpringMover_Lineal", "SpringMover_Torsional", "SpringMover"]


Expand Down
4 changes: 2 additions & 2 deletions movement/tangling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import firedrake
import ufl
import warnings

import firedrake
import ufl

__all__ = ["MeshTanglingChecker"]

Expand Down
5 changes: 3 additions & 2 deletions test/test_demos.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""
Checks that all demo scripts run.
"""

import glob
import os
from os.path import splitext
import pytest
import shutil
import subprocess
import sys
from os.path import splitext

import pytest

# Set environment variable to specify that tests are being run so that we can
# cut down the length of the demos
Expand Down
7 changes: 4 additions & 3 deletions test/test_monge_ampere.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from movement import *
from monitors import *
import pytest
import numpy as np
import pytest
from monitors import *

from movement import *


@pytest.fixture(params=["relaxation", "quasi_newton"])
Expand Down
8 changes: 5 additions & 3 deletions test/test_smoothing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from firedrake import *
from movement import *
import numpy as np
import os

import numpy as np
import pytest
from firedrake import *

from movement import *


@pytest.fixture(params=["laplacian"])
Expand Down
6 changes: 4 additions & 2 deletions test/test_spring.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os

import firedrake
from movement import SpringMover
import numpy as np
import os
import pytest

from movement import SpringMover


@pytest.fixture(params=["lineal"])
def method(request):
Expand Down
4 changes: 3 additions & 1 deletion test/test_tangling.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import unittest

from firedrake import *

from movement import *
import unittest


class TestTangling(unittest.TestCase):
Expand Down

0 comments on commit 6a7b01d

Please sign in to comment.