getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] [getfem-commits] branch master updated: small add


From: Yves Renard
Subject: [Getfem-commits] [getfem-commits] branch master updated: small add
Date: Thu, 07 Jul 2022 10:31:10 -0400

This is an automated email from the git hooks/post-receive script.

renard pushed a commit to branch master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
     new 134e0599 small add
134e0599 is described below

commit 134e0599f63052425f761cb1cc45f1944d3bacca
Author: Yves Renard <Yves.Renard@insa-lyon.fr>
AuthorDate: Thu Jul 7 16:30:59 2022 +0200

    small add
---
 interface/tests/python/demo_laplacian.py | 42 +++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/interface/tests/python/demo_laplacian.py 
b/interface/tests/python/demo_laplacian.py
index c8736ef1..84493754 100644
--- a/interface/tests/python/demo_laplacian.py
+++ b/interface/tests/python/demo_laplacian.py
@@ -31,6 +31,15 @@ import numpy as np
 # Import basic modules
 import getfem as gf
 
+plot_result = False;
+
+if plot_result:
+  import vtk
+  from matplotlib.pyplot import figure
+  import matplotlib.pyplot as plt
+  import meshio
+  from matplotlib import ticker
+
 ## Parameters
 NX = 100                           # Mesh parameter.
 Dirichlet_with_multipliers = True  # Dirichlet condition with multipliers
@@ -131,10 +140,37 @@ print('Error in L2 norm : ', L2error)
 print('Error in H1 norm : ', H1error)
 
 # Export data
-mfu.export_to_pos('laplacian.pos', Ue,'Exact solution',
-                                    U,'Computed solution')
+sl4 = gf.Slice(("none",), mfu, 1)
+sl4.export_to_vtk('laplacian.vtk', "ascii", mfu, Ue,'Exact_solution', mfu, 
U,'Computed_solution')
 print('You can view the solution with (for example):')
-print('gmsh laplacian.pos')
+print('Paraview laplacian.vtk')
+
+
+if plot_result:
+  reader = meshio.read('laplacian.vtk')
+  points = reader.points
+  cells = reader.cells[0].data
+  point_data = reader.point_data["Computed_solution"]
+  fig = figure(figsize=(7, 7))
+  axes2 = fig.add_subplot(aspect="auto",projection='3d')
+  axes2.triplot(points[:, 0], points[:, 1], cells, color="gray")
+  contour = axes2.plot_trisurf(points[:, 0], points[:, 1],
+                            point_data[:,0], cmap="jet")
+  fig.colorbar(contour)
+  axes2.view_init(30, 100)
+  fig.tight_layout()
+  formatter = ticker.ScalarFormatter(useMathText=True)
+  formatter.set_scientific(True)
+  axes2.yaxis.set_major_formatter(formatter)
+  axes2.set_title("uref")
+  fig.savefig("uref.pdf")
+  plt.show()
+
+
+
+
+
+
 
 
 if (H1error > 1e-3):



reply via email to

[Prev in Thread] Current Thread [Next in Thread]