Skip to content
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

Deprecate MeshFromRefinements #893

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/source/api/meshing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ Meshing
:members:
:show-inheritance:

.. autoclass:: MeshFromRefinements
:members:
:show-inheritance:

.. autoclass:: MeshFromXDMF
:members:
:show-inheritance:
1 change: 0 additions & 1 deletion festim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

from .meshing.mesh import Mesh
from .meshing.mesh_1d import Mesh1D
from .meshing.mesh_from_refinements import MeshFromRefinements
from .meshing.mesh_from_vertices import MeshFromVertices
from .meshing.mesh_from_xdmf import MeshFromXDMF

Expand Down
65 changes: 0 additions & 65 deletions festim/meshing/mesh_from_refinements.py

This file was deleted.

5 changes: 3 additions & 2 deletions test/heat_transfer_problem/test_solving.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import festim
import pytest
import fenics as f
import numpy as np


@pytest.mark.parametrize("preconditioner", ["default", "icc"])
Expand All @@ -13,7 +14,7 @@ def test_create_functions_linear_solver_gmres(preconditioner):
preconditioner (str): the preconditioning method
"""

mesh = festim.MeshFromRefinements(10, size=0.1)
mesh = festim.MeshFromVertices(np.linspace(0, 0.1, num=11))

materials = festim.Materials([festim.Material(id=1, D_0=1, E_D=0, thermal_cond=1)])
mesh.define_measures(materials)
Expand Down Expand Up @@ -60,7 +61,7 @@ def sim(self):

def test_custom_solver(self):
"""Solves the system using the built-in solver and using the f.NewtonSolver"""
mesh = festim.MeshFromRefinements(10, size=0.1)
mesh = festim.MeshFromVertices(np.linspace(0, 0.1, num=11))
materials = festim.Materials(
[festim.Material(id=1, D_0=1, E_D=0, thermal_cond=1)]
)
Expand Down
10 changes: 6 additions & 4 deletions test/simulation/test_postprocessing_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def my_sim(self):
"""A pytest fixture defining the festim.Simulation object"""
my_sim = festim.Simulation({})
my_sim.t = 0
my_sim.mesh = festim.MeshFromRefinements(10, 1)
my_sim.mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))
my_sim.settings = festim.Settings(None, None, final_time=10)
mat1 = festim.Material(1, D_0=1, E_D=1)
my_sim.materials = festim.Materials([mat1])
Expand Down Expand Up @@ -120,10 +120,12 @@ def test_pure_diffusion(self, my_sim):
my_sim.run_post_processing()
data = derived_quantities.data

print(data)

assert len(data) == i + 1
assert data[i][0] == t
assert data[i][1] == 10
assert data[i][2] == 20
assert data[i][1] == pytest.approx(10)
assert data[i][2] == pytest.approx(20)
assert data[i][3] == pytest.approx(11)
assert data[i][4] == pytest.approx(11)

Expand Down Expand Up @@ -259,7 +261,7 @@ def test_surface_kinetics(self):
"""
my_sim = festim.Simulation({})
my_sim.t = 0
my_sim.mesh = festim.MeshFromRefinements(10, 1)
my_sim.mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))
my_sim.settings = festim.Settings(None, None, final_time=10)
mat1 = festim.Material(1, D_0=1, E_D=1)
my_sim.materials = festim.Materials([mat1])
Expand Down
2 changes: 1 addition & 1 deletion test/system/test_chemical_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def run(h):
festim.InitialCondition(field=0, value=u),
]

my_mesh = festim.MeshFromRefinements(round(size / h), size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, round(size / h) + 1))

my_bcs = [
festim.DirichletBC(surfaces=[1, 2], value=u, field=0),
Expand Down
3 changes: 2 additions & 1 deletion test/system/test_extrinsic_traps.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import festim as F
import numpy as np


def test_extrinsic_trap():
"""Runs a festim sim with an extrinsic trap"""
my_materials = F.Materials([F.Material(id=1, D_0=2, E_D=1, name="mat")])
my_mesh = F.MeshFromRefinements(10, 1)
my_mesh = F.MeshFromVertices(np.linspace(0, 1, 11))

my_traps = F.ExtrinsicTrap(
k_0=1,
Expand Down
4 changes: 2 additions & 2 deletions test/system/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_convective_flux(tmpdir):
def test_error_steady_state_with_stepsize():
"""Checks that an error is raised when a stepsize is given for a steady state simulation"""
my_model = F.Simulation()
my_model.mesh = F.MeshFromRefinements(1000, size=1)
my_model.mesh = F.MeshFromVertices(np.linspace(0, 1, num=1001))

my_model.materials = F.Materials([F.Material(D_0=1, E_D=0, id=1)])

Expand All @@ -67,7 +67,7 @@ def test_error_steady_state_with_stepsize():
def test_error_transient_without_stepsize():
"""Checks that an error is raised when a stepsize is not given for a transient simulation"""
my_model = F.Simulation()
my_model.mesh = F.MeshFromRefinements(1000, size=1)
my_model.mesh = F.MeshFromVertices(np.linspace(0, 1, num=100))

my_model.materials = F.Materials([F.Material(D_0=1, E_D=0, id=1)])

Expand Down
28 changes: 14 additions & 14 deletions test/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_run_temperature_stationary(tmpdir):

my_materials = [festim.Material(id=1, D_0=4.1e-7, E_D=0.39, thermal_cond=1)]

my_mesh = festim.MeshFromRefinements(200, size=size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, num=200))
my_boundary_conditions = [
festim.DirichletBC(value=1, field=0, surfaces=[1]),
festim.DirichletBC(value=u, field="T", surfaces=[1, 2]),
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_run_temperature_transient(tmpdir):
)
]
)
my_mesh = festim.MeshFromRefinements(200, size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, num=200))

my_bcs = [
festim.DirichletBC(surfaces=[1], value=1, field=0),
Expand Down Expand Up @@ -216,7 +216,7 @@ def run(h):
festim.InitialCondition(field=1, value=v),
]

my_mesh = festim.MeshFromRefinements(round(size / h), size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, num=round(size / h) + 1))

my_bcs = [
festim.DirichletBC(surfaces=[1, 2], value=u, field=0),
Expand Down Expand Up @@ -342,7 +342,7 @@ def run(h):
festim.InitialCondition(field=1, value=v),
]

my_mesh = festim.MeshFromRefinements(round(size / h), size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, num=round(size / h) + 1))

my_bcs = [
festim.DirichletBC(surfaces=[1, 2], value=u, field=0),
Expand Down Expand Up @@ -442,7 +442,7 @@ def test_run_chemical_pot_mass_balance(tmpdir):
festim.InitialCondition(field=0, value=1),
]

my_mesh = festim.MeshFromRefinements(5, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=6))

my_temp = festim.Temperature(700 + 210 * festim.t)

Expand Down Expand Up @@ -512,7 +512,7 @@ def run(h):
]

size = 0.1
my_mesh = festim.MeshFromRefinements(round(size / h), size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, num=round(size / h) + 1))

my_source = festim.Source(f, 1, "solute")

Expand Down Expand Up @@ -624,7 +624,7 @@ def run(h):
]

size = 0.1
my_mesh = festim.MeshFromRefinements(round(size / h), size)
my_mesh = festim.MeshFromVertices(np.linspace(0, size, num=round(size / h) + 1))

my_sources = [festim.Source(f, 1, "solute"), festim.Source(g, 1, "1")]

Expand Down Expand Up @@ -718,7 +718,7 @@ def test_chemical_pot_T_solve_stationary(tmpdir):
my_materials = festim.Materials(
[festim.Material(id=1, D_0=1, E_D=0.1, S_0=2, E_S=0.2, thermal_cond=1)]
)
my_mesh = festim.MeshFromRefinements(10, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))

my_temp = festim.HeatTransferProblem(transient=False)
my_bcs = [
Expand Down Expand Up @@ -772,7 +772,7 @@ def test_export_particle_flux_with_chemical_pot(tmpdir):
my_materials = festim.Materials(
[festim.Material(id=1, D_0=2, E_D=1, S_0=2, E_S=1, thermal_cond=2)]
)
my_mesh = festim.MeshFromRefinements(10, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))

my_temp = festim.Temperature(300)

Expand Down Expand Up @@ -885,7 +885,7 @@ def test_steady_state_traps_not_everywhere():
]
)

my_mesh = festim.MeshFromRefinements(100, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=101))

my_trap = festim.Trap(1, 0, 1, 0, ["mat_1", "mat_3"], 1)

Expand Down Expand Up @@ -922,7 +922,7 @@ def test_no_jacobian_update():
mat = festim.Material(id=1, D_0=1, E_D=0)
my_materials = festim.Materials([mat])

my_mesh = festim.MeshFromRefinements(10, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=100))

my_trap = festim.Trap(1, 0, 1, 0, [mat], 1)

Expand Down Expand Up @@ -959,7 +959,7 @@ def test_nb_iterations_bewteen_derived_quantities_compute():

def init_sim(nb_it_compute):
my_materials = festim.Materials([festim.Material(id=1, D_0=1, E_D=0)])
my_mesh = festim.MeshFromRefinements(10, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))

my_temp = festim.Temperature(300)

Expand Down Expand Up @@ -1011,7 +1011,7 @@ def test_error_steady_state_diverges():
]
)

my_mesh = festim.MeshFromRefinements(10, 1)
my_mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))

my_temp = festim.Temperature(-1)

Expand All @@ -1037,7 +1037,7 @@ def test_error_steady_state_diverges():
def test_completion_tone():
"""Checks that when a completion tone is enabled, sim is not affected"""
my_model = festim.Simulation(log_level=20)
my_model.mesh = festim.MeshFromRefinements(10, size=1)
my_model.mesh = festim.MeshFromVertices(np.linspace(0, 1, num=11))
my_model.materials = festim.Materials([festim.Material(id=1, D_0=1, E_D=0)])
my_model.T = festim.Temperature(100)
my_model.boundary_conditions = [
Expand Down
Loading
Loading