You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should also consider geometries which also vary in r and z in cylindrical and spherical coordinate systems
here is an example test that could be adapted:
@pytest.mark.parametrize("length", [4, 5, 3])deftest_average_surface_rhombus(length):
# creating a mesh with FEniCS# Define the number of divisions in the x and y directionsnx, ny=10, 10mesh=f.RectangleMesh(f.Point(0, 0), f.Point(length, length), nx, ny)
# Access mesh coordinatescoordinates=mesh.coordinates()
# Rotation matrix for 45 degreestheta=np.pi/4# 45 degrees in radiansrotation_matrix=np.array(
[[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]]
)
# Apply rotation to each coordinatefori, coordinenumerate(coordinates):
# Rotate the point (x, y) using the rotation matrixcoordinates[i] =np.dot(rotation_matrix, np.array(coord))
surface_markers=f.MeshFunction("size_t", mesh, mesh.topology().dim() -1)
surface_markers.set_all(0)
# find all facets along y = x and mark themsurf_id=2forfacetinf.facets(mesh):
midpoint=facet.midpoint()
ifnp.isclose(midpoint[0], midpoint[1], atol=1e-10):
surface_markers[facet.index()] =surf_idds=f.Measure("ds", domain=mesh, subdomain_data=surface_markers)
my_export=AverageSurface("solute", surf_id)
V=f.FunctionSpace(mesh, "P", 1)
c_fun=lambdax, y: 2*x+yexpr=f.Expression(
ccode(c_fun(x, y)),
degree=1,
)
my_export.function=f.interpolate(expr, V)
my_export.ds=dsexpected_value= (3*length) / (2* (2**0.5))
computed_value=my_export.compute()
assertnp.isclose(computed_value, expected_value)
The text was updated successfully, but these errors were encountered:
We should also consider geometries which also vary in r and z in cylindrical and spherical coordinate systems
here is an example test that could be adapted:
The text was updated successfully, but these errors were encountered: