Skip to content

Commit

Permalink
get_sampled_solution now returns el_id
Browse files Browse the repository at this point in the history
  • Loading branch information
teseoch committed Sep 3, 2021
1 parent 9256d2d commit 13d9bbe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ PYBIND11_MODULE(polyfempy, m)

s.args["export"]["vis_boundary_only"] = tmp;

return py::make_tuple(points, tets, fun);
return py::make_tuple(points, tets, el_id, fun);
},
"returns the solution on a densly sampled mesh, use 'vismesh_rel_area' to control density", py::arg("boundary_only") = bool(false))

Expand Down
15 changes: 8 additions & 7 deletions test/test_plane_hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@

class BendingTest(unittest.TestCase):
def test_run(self):
# self.run_one(1)
# self.run_one(2)
# self.run_one(1)
# self.run_one(2)

# def run_one(self, discr_order):
# def run_one(self, discr_order):
discr_order = 2
root_folder = os.path.join("..", "3rdparty.nosync" if platform.system() == 'Darwin' else "3rdparty", "data")
root_folder = os.path.join(
"..", "3rdparty.nosync" if platform.system() == 'Darwin' else "3rdparty", "data")

dir_path = os.path.dirname(os.path.realpath(__file__))
mesh_path = os.path.join(dir_path, root_folder, "plane_hole.obj")

settings = pf.Settings(discr_order=discr_order, pde=pf.PDEs.LinearElasticity)
settings = pf.Settings(discr_order=discr_order,
pde=pf.PDEs.LinearElasticity)

settings.set_material_params("E", 210000)
settings.set_material_params("nu", 0.3)
Expand All @@ -39,7 +41,7 @@ def test_run(self):

solver.solve()

pts, tets, disp = solver.get_sampled_solution()
pts, tets, el_id, disp = solver.get_sampled_solution()
vertices = pts + disp
mises, _ = solver.get_sampled_mises_avg()

Expand All @@ -48,6 +50,5 @@ def test_run(self):
# plot(vertices, tets, mises)



if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion test/test_pythonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_run(self):
print(log["time_solving"])

# Get the solution
pts, tris, fun = solution.get_sampled_solution()
pts, tris, el_id, fun = solution.get_sampled_solution()


if __name__ == '__main__':
Expand Down
14 changes: 9 additions & 5 deletions test/test_torsion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@

class TorsionTest(unittest.TestCase):
def test_run(self):
root_folder = os.path.join("..", "3rdparty.nosync" if platform.system() == 'Darwin' else "3rdparty", "data")
root_folder = os.path.join(
"..", "3rdparty.nosync" if platform.system() == 'Darwin' else "3rdparty", "data")
dir_path = os.path.dirname(os.path.realpath(__file__))
mesh_path = os.path.join(dir_path, root_folder, "square_beam_h.HYBRID")

settings = pf.Settings(discr_order=1, pde=pf.PDEs.NonLinearElasticity, nl_solver_rhs_steps=5)
settings = pf.Settings(
discr_order=1, pde=pf.PDEs.NonLinearElasticity, nl_solver_rhs_steps=5)

settings.set_material_params("E", 200)
settings.set_material_params("nu", 0.35)

problem = pf.Torsion(fixed_boundary=5, turning_boundary=6, axis_coordiante=2, n_turns=0.5)
problem = pf.Torsion(
fixed_boundary=5, turning_boundary=6, axis_coordiante=2, n_turns=0.5)
settings.problem = problem

solver = pf.Solver()
solver.settings(settings)
solver.load_mesh_from_path(mesh_path, normalize_mesh=False, vismesh_rel_area = 0.001)
solver.load_mesh_from_path(
mesh_path, normalize_mesh=False, vismesh_rel_area=0.001)

solver.solve()

pts, tets, disp = solver.get_sampled_solution()
pts, tets, el_id, disp = solver.get_sampled_solution()
vertices = pts + disp
mises, _ = solver.get_sampled_mises_avg()

Expand Down

0 comments on commit 13d9bbe

Please sign in to comment.