Commit d350fef5 authored by Baptiste Durand's avatar Baptiste Durand

Merge branch 'reorganize_part_classes'

Improve structure of the code.
Better separation between the class definitions on one hand and the imports of the mesh and the subdomain data on the other hand.
parents 02a6ef7a 99c53448
......@@ -8,4 +8,5 @@
demo/loc_E12_u.pdf
*.pyc.*
*.egg-info/
ho_homog/.idea
\ No newline at end of file
ho_homog/.idea
.idea/HO_homog.iml
......@@ -153,7 +153,7 @@ msh.set_periodicity_pairs(micro_bndry[1], micro_bndry[3])
logger.info("Periodicity constraint : Done")
logger.info("Cleaning model")
factory.remove([(1, l.tag) for l in macro_ll.sides])
factory.remove([(1, s.tag) for s in macro_ll.sides])
factory.synchronize()
factory.removeAllDuplicates()
factory.synchronize()
......@@ -164,4 +164,3 @@ geo.PhysicalGroup.set_group_mesh(1)
gmsh.model.mesh.generate(2)
gmsh.write(str(mesh_file))
run(f"gmsh {str(mesh_file)} &", shell=True, check=True)
gmsh.fltk.run()
......@@ -79,7 +79,7 @@ from .transformations import plane_reflection, point_reflection, rotation, trans
DEFAULT_GMSH_OPTIONS = {
"General.Terminal": 1,
"General.Verbosity": 5,
"General.Verbosity": 3,
"Geometry.AutoCoherence": 0,
"Mesh.ColorCarousel": 2,
# * 0=by element type, 1=by elementary entity, 2=by physical entity,3=by partition
......
......@@ -61,7 +61,7 @@ class Fenics2DHomogenization(object):
"""
self.rve = fenics_2d_rve
self.topo_dim = topo_dim = fenics_2d_rve.mesh_dim
self.topo_dim = topo_dim = fenics_2d_rve.dim
try:
bottom_left_corner = fenics_2d_rve.bottom_left_corner
except AttributeError:
......
......@@ -58,7 +58,7 @@ class FenicsHomogenizationBeam(object):
"""
self.rve = fenics_2d_rve
self.topo_dim = topo_dim = fenics_2d_rve.mesh_dim
self.topo_dim = topo_dim = fenics_2d_rve.dim
self.pbc = periodicity.PeriodicDomain.pbc_dual_base(
fenics_2d_rve.gen_vect, "X", topo_dim
) # * Périodicité selon X seulement
......
......@@ -451,7 +451,6 @@ def Gmsh2DPartFromRVE(cell: Gmsh2DRVE, nb_cells, part_name=None):
tag = cell.phy_surf[i].tag + 1000
name = cell.phy_surf[i].name
phy_surfaces.append(geo.PhysicalGroup(all_surfaces, 2, name, tag))
# gmsh.fltk.run()
for gp in cell.phy_surf:
gp.remove_gmsh()
factory.synchronize()
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ DOLFIN_LU_METHODS = {
SUPPORTED_MESH_SUFFIX = (".xml", ".xdmf")
def get_MeshFunction_val(msh_fctn):
def get_mesh_function_value(msh_fctn):
"""
Get information about the set of values that a given MeshFunction outputs.
......@@ -56,7 +56,7 @@ def get_MeshFunction_val(msh_fctn):
val = np.unique(msh_fctn.array())
nb = len(val)
return (nb, val)
return nb, val
def facet_plot2d(
......@@ -116,13 +116,21 @@ def function_from_xdmf(function_space, function_name="", xdmf_path=""):
If multiple functions are requested: #TODO : test
the first argument must be a list of tuples (FunctionSpace, function name)
the second argument must be empty.
Ex: function_from_xdmf([(V,"u"),(W,"eps")], xdmf_path=checkpoint_path)
Returns
-------
dolfin.Function, list of dolfin.Function
New function(s) that is(are) identical to the previously saved function(s).
Example
--------
>>> import dolfin as fe
>>> mesh = xdmf_mesh("mesh.xdmf")
>>> V = fe.VectorFunctionSpace(mesh, "CG", 2)
>>> W = fe.VectorFunctionSpace(mesh, "DG", 1)
>>> function_from_xdmf([(V,"u"),(W,"eps")], xdmf_path="checkpoint.xdmf")
"""
if isinstance(function_space, list):
all_f = list()
with fe.XDMFFile(str(xdmf_path)) as f_in:
......@@ -181,8 +189,6 @@ def function_errornorm(u, v, norm_type="L2", enable_diff_fspace=False):
def local_project(v, fspace, solver_method: str = "", **kwargs):
"""
Info : https://comet-fenics.readthedocs.io/en/latest/tips_and_tricks.html#efficient-projection-on-dg-or-quadrature-spaces #noqa
Parameters
----------
v : [type]
......@@ -207,14 +213,20 @@ def local_project(v, fspace, solver_method: str = "", **kwargs):
Returns
-------
Function
Notes
-----
Source for this code:
https://comet-fenics.readthedocs.io/en/latest/tips_and_tricks.html#efficient-projection-on-dg-or-quadrature-spaces
"""
metadata = kwargs.get("metadata", {})
dX = kwargs.get("dx", fe.dx(metadata=metadata))
dx = kwargs.get("dx", fe.dx(metadata=metadata))
dv = fe.TrialFunction(fspace)
v_ = fe.TestFunction(fspace)
a_proj = fe.inner(dv, v_) * dX
b_proj = fe.inner(v, v_) * dX
a_proj = fe.inner(dv, v_) * dx
b_proj = fe.inner(v, v_) * dx
if solver_method == "LU":
solver = fe.LocalSolver(
......@@ -249,87 +261,138 @@ def _wrap_in_list(obj, name, types=type):
lst = [obj]
for obj in lst:
if not isinstance(obj, types):
raise TypeError(
"expected a (list of) %s as '%s' argument" % (str(types), name)
)
raise TypeError(f"expected a (list of) {types} as {name} argument")
return lst
def xdmf_mesh(mesh_file, import_subdomains=False, facet_file="", physical_file=""):
def xdmf_mesh(mesh_file):
"""Create a FeniCS mesh from a mesh file with xdmf format.
Parameters
----------
mesh_file : str or Path
Path of the file mesh (xdmf file)
import_subdomains : bool, optional
True if information about subdomains have to be imported.
The paths of the auxiliary files that contains information about subdomains
can be indicated with facet_file and physical_file.
The paths used by default are :
- "<mesh path>_facet_region.xdmf" and
- "<mesh path>_physical_region.xdmf" (for subdomains)
Returns
-------
dolfin.Mesh
"""
if not isinstance(mesh_file, PurePath):
mesh_file = Path(mesh_file)
if not mesh_file.suffix == ".xdmf":
raise TypeError("Wrong suffix for the path to the mesh.")
mesh = fe.Mesh()
with fe.XDMFFile(str(mesh_file)) as f_in:
f_in.read(mesh)
return mesh
_warning_message_ = "The {} file is missing for the mesh {}."
def import_subdomain_data_xml(mesh, mesh_file):
""" Import data from the _physical_region.xml and _facet_region.xml files
that result from the mesh conversion to .xml with dolfin-convert
Parameters
----------
mesh: dolfin.Mesh
mesh already imported from the `.xml` file (mesh_path)
mesh_file : pathlib.Path
Path to the mesh file (.xml).
The files that contain the data about the subdomains and the facet regions
are assumed to be in the same folder, with the names:
`[mesh_name]_physical_region.xml` and `[mesh_name]_facet_region.xml`.
"""
name = mesh_file.stem
subdo_path = mesh_file.with_name(name + "_physical_region.xml")
facet_path = mesh_file.with_name(name + "_facet_region.xml")
if subdo_path.exists():
subdomains = fe.MeshFunction("size_t", mesh, subdo_path.as_posix())
subdo_val = get_mesh_function_value(subdomains)
logger.info(f"{subdo_val[0]} physical regions imported. Tags : {subdo_val[1]}")
else:
logger.warning(_warning_message_.format("_physical_region.xml", mesh_file.name))
subdomains = None
if facet_path.exists():
facets = fe.MeshFunction("size_t", mesh, facet_path.as_posix())
facets_val = get_mesh_function_value(facets)
logger.info(f"{facets_val[0]} facet regions imported. Tags : {facets_val[1]}")
else:
logger.warning(_warning_message_.format("_facet_region.xml", mesh_file.name))
facets = None
return subdomains, facets
def import_subdomain_data_xdmf(mesh, mesh_file, facet_file="", physical_file=""):
"""Import information about subdomains from .xdmf files from
obtained with the mesh conversion .msh -> .xdmf with meshio.
The paths of the auxiliary files that contains information about subdomains
can be indicated with facet_file and physical_file.
The paths used by default are :
- "<mesh path>_facet_region.xdmf" and
- "<mesh path>_physical_region.xdmf" (for subdomains)
Parameters
----------
mesh: dolfin.Mesh
mesh already imported from the `.xdmf` file (mesh_path)
mesh_file : pathlib.Path
Path to the mesh file (.xdmf).
facet_file : str or Path, optional
Path to the mesh auxiliary file that contains subdomains data.
Defaults to "" i.e. the default path will be used.
physical_file : str or Path, optional
Path to the mesh auxiliary file that contains facet regions data.
Defaults to "" i.e. the default path will be used.
Returns
-------
Mesh / tuple
If subdomains are not requested :
- The Mesh instance
If subdomains are requested :
- The Mesh instance,
- The MeshFunction for subdomains if it exists else None,
- The MeshFunction for facets if it exists else None,
Tuple (length: 2)
- The MeshFunction for subdomains if it exists else None;
- The MeshFunction for facets if it exists else None.
Source
------
Gist meshtagging_mvc.py, June 2018, Michal Habera
https://gist.github.com/michalhabera/bbe8a17f788192e53fd758a67cbf3bed
"""
if not isinstance(mesh_file, PurePath):
mesh_file = Path(mesh_file)
if not mesh_file.suffix == ".xdmf":
raise TypeError("Wrong suffix for the path to the mesh.")
mesh = fe.Mesh()
with fe.XDMFFile(str(mesh_file)) as f_in:
f_in.read(mesh)
if not import_subdomains:
return mesh
"""
dim = mesh.geometric_dimension()
if not facet_file:
facet_file = mesh_file.with_name(f"{mesh_file.stem}_facet_region.xdmf")
else:
facet_file = Path(facet_file)
if not facet_file.suffix == ".xdmf":
raise TypeError("Wrong suffix for the path to facet regions.")
if not physical_file:
physical_file = mesh_file.with_name(f"{mesh_file.stem}_physical_region.xdmf")
if not facet_file:
facet_file = mesh_file.with_name(f"{mesh_file.stem}_facet_region.xdmf")
physical_file, facet_file = Path(physical_file), Path(facet_file)
for p, n in zip((physical_file, facet_file), ("subdomains", "facet regions")):
if not p.suffix == ".xdmf":
raise TypeError(f"Wrong suffix for the path to {n}.")
subdomains, facets = None, None
if physical_file.exists():
cell_vc = fe.MeshValueCollection("size_t", mesh, dim)
with fe.XDMFFile(str(physical_file)) as f_in:
f_in.read(cell_vc, "cell_data")
subdomains = fe.cpp.mesh.MeshFunctionSizet(mesh, cell_vc)
else:
physical_file = Path(physical_file)
if not physical_file.suffix == ".xdmf":
raise TypeError("Wrong suffix for the path to subdomains.")
logger.warning(
_warning_message_.format("_physical_region.xdmf", mesh_file.name)
)
if not facet_file.exists():
facet_regions = None
else:
if facet_file.exists():
facet_vc = fe.MeshValueCollection("size_t", mesh, dim - 1)
with fe.XDMFFile(str(facet_file)) as f_in:
f_in.read(facet_vc, "facet_data")
facet_regions = fe.cpp.mesh.MeshFunctionSizet(mesh, facet_vc)
if not physical_file.exists():
subdomains = None
facets = fe.cpp.mesh.MeshFunctionSizet(mesh, facet_vc)
else:
cell_vc = fe.MeshValueCollection("size_t", mesh, dim - 1)
with fe.XDMFFile(str(physical_file)) as f_in:
f_in.read(cell_vc, "cell_data")
subdomains = fe.cpp.mesh.MeshFunctionSizet(mesh, cell_vc)
return mesh, subdomains, facet_regions
logger.warning(_warning_message_.format("_facet_region.xdmf", mesh_file.name))
return subdomains, facets
......@@ -88,7 +88,7 @@ def conversion_to_xdmf(i_path, o_path, cell_reg, facet_reg, dim, subdomains=Fals
raise NotImplementedError("3D meshes are not supported yet.")
# * INFO :
else:
ValueError
raise ValueError
meshio.write(o_path, geo_only)
......
dolfin~=2019.1.0
gmsh~=4.6.0.post3
meshio~=4.3.1
h5py~=3.1.0
matplotlib~=3.3.3
numpy~=1.19.4
sympy~=1.1.1
pytest~=6.2.1
setuptools~=39.0.1
......@@ -6,7 +6,9 @@ Created on 21/03/2019
sources : http://sametmax.com/vive-setup-cfg-et-mort-a-pyproject-toml/,
http://sametmax.com/creer-un-setup-py-et-mettre-sa-bibliotheque-python-en-ligne-sur-pypi/
https://docs.pytest.org/en/stable/goodpractices.html
"""
from setuptools import setup
setup()
\ No newline at end of file
setup()
# coding: utf8
"""
Created on 12/07/2019
@author: baptiste
Give the individual tests import contex.
Source : https://docs.python-guide.org/writing/structure/#structure-of-the-repository
"""
import site
from pathlib import Path
cur_dir = Path(__file__).resolve().parent
repository_dir = cur_dir.parent
site.addsitedir(repository_dir)
import ho_homog
This source diff could not be displayed because it is too large. You can view the blob instead.
# coding: utf8
"""
Created on 12/07/2019
@author: baptiste
Give the individual tests import contex.
Source : https://docs.python-guide.org/writing/structure/#structure-of-the-repository
"""
import site
from pathlib import Path
import sys, os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
# cur_dir = Path(__file__).resolve().parent
# repository_dir = cur_dir.parent
# site.addsitedir(repository_dir)
import ho_homog
......@@ -6,7 +6,7 @@ Created on 08/04/2019
import logging
import dolfin as fe
from context.ho_homog import full_scale_pb as homog_full
from ho_homog import full_scale_pb as fsp
from pathlib import Path
from pytest import approx
......@@ -71,7 +71,7 @@ def test_reconstruction_vectors():
strain_fspace,
),
}
reconstr_sol = homog_full.reconstruction(
reconstr_sol = fsp.reconstruction(
localization_tensors, macro_fields, function_spaces, trunc_order=1
)
results_file_path = Path(__file__).with_name("test_reconstruction.xdmf")
......@@ -164,7 +164,7 @@ def test_reconstruction_with_constraint():
fe.Expression("0.5*x[0] + x[1] + 0.5*x[1] + 1.*x[0]", degree=2), scalar_fspace
)
reconstr_sol = homog_full.reconstruction(
reconstr_sol = fsp.reconstruction(
localization_tensors,
macro_fields,
function_spaces,
......@@ -191,7 +191,7 @@ def test_reconstruction_with_constraint():
def test_select_solver():
"The solver Mumps is selected."
"""The solver Mumps is selected."""
logger = logging.getLogger("test_reconstruction")
nb_x = nb_y = 20
L_x = 2
......@@ -239,7 +239,7 @@ def test_select_solver():
fe.Expression("0.5*x[0] + x[1] + 0.5*x[1] + 1.*x[0]", degree=2), scalar_fspace
)
reconstr_sol = homog_full.reconstruction(
reconstr_sol = fsp.reconstruction(
localization_tensors,
macro_fields,
function_spaces,
......
......@@ -5,18 +5,17 @@ Created on Mon Oct 15 11:00:18 2018
@author: Baptiste
"""
import os
from .context import ho_homog
import math
import numpy as np
import matplotlib.pyplot as plt
import copy
import logging
import math
import os
from logging.handlers import RotatingFileHandler
import gmsh
import matplotlib.pyplot as plt
import numpy as np
geo = ho_homog.geometry
import ho_homog.geometry as geo
# nice shortcuts
model = gmsh.model
......@@ -435,46 +434,21 @@ def test_ll_modif():
gmsh.model.add(name)
t = math.tan(math.pi / 6)
vertcs_lists = []
vertcs_lists.append(
[
geo.Point(np.array(c), 0.05)
for c in [
(0, 0),
(2, 0),
(2 - SR2, 0 + SR2),
(2, 2),
(2 - 1, 2 + t),
(0, 2),
]
]
) # angles : pi/4, pi/2 and 2*pi/3
vertcs_lists.append(
[
geo.Point(np.array(c), 0.05)
for c in [
(3, 0),
(5, 0),
(5 - SR2, 0 + SR2),
(5, 2),
(5 - 1, 2 + t),
(3, 2),
]
]
)
vertcs_lists.append(
[
geo.Point(np.array(c), 0.05)
for c in [
(6, 0),
(8, 0),
(8 - SR2, 0 + SR2),
(8, 2),
(8 - 1, 2 + t),
(6, 2),
]
]
)
vertcs_lists = [None, None, None]
vertcs_lists[0] = [
geo.Point(np.array(c), 0.05)
for c in [(0, 0), (2, 0), (2 - SR2, 0 + SR2), (2, 2), (2 - 1, 2 + t), (0, 2),]
] # angles : pi/4, pi/2 and 2*pi/3
vertcs_lists[1] = [
geo.Point(np.array(c), 0.05)
for c in [(3, 0), (5, 0), (5 - SR2, 0 + SR2), (5, 2), (5 - 1, 2 + t), (3, 2),]
]
vertcs_lists[2] = [
geo.Point(np.array(c), 0.05)
for c in [(6, 0), (8, 0), (8 - SR2, 0 + SR2), (8, 2), (8 - 1, 2 + t), (6, 2),]
]
vertcs_lists = [v_list_1, v_list_2, v_list_3]
lls = [geo.LineLoop(vl, explicit=False) for vl in vertcs_lists]
plt.figure()
......@@ -567,8 +541,8 @@ def test_gather_line():
gp_l = geo.PhysicalGroup(l_list, 1, n)
gp_l.add_gmsh()
gps.append(gp_l)
for l in l_list:
l.plot2D(col)
for ln in l_list:
ln.plot2D(col)
factory.synchronize()
gmsh.option.setNumber("Mesh.SaveAll", 1)
......@@ -863,11 +837,6 @@ if __name__ == "__main__":
# test_mesh_only_phy_groups()
# * Bloc de fin
gmsh.fltk.run()
# gmsh.fltk.run()
plt.show()
# * Il faut fermer toutes les fenêtres avant de passer à la GUI gmsh. (pertinent en mode non interactive) #noqa
# gmsh.fltk.run()
# ! A revoir, ça génère des "kernel died" dans Spyder, pas idéal
# # gmsh.fltk.initialize()
# gmsh.finalize()
# plt.show()
......@@ -5,27 +5,28 @@ Created on 09/01/2019
"""
import numpy as np
import gmsh
import meshio
from ho_homog import geometry, homog2d, materials, mesh_generate_2D, part
from pytest import approx
import logging
import time
import dolfin as fe
import gmsh
import meshio
import numpy as np
from pytest import approx
from ho_homog import geometry, homog2d, materials, mesh_generate, part
logger = logging.getLogger("Test_homog2d")
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter(
'%(asctime)s :: %(levelname)s :: %(name)s :: %(message)s',
"%H:%M:%S")
"%(asctime)s :: %(levelname)s :: %(name)s :: %(message)s", "%H:%M:%S"
)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
np.set_printoptions(suppress=False, floatmode='fixed', precision=8,
linewidth=150)
np.set_printoptions(suppress=False, floatmode="fixed", precision=8, linewidth=150)
def test_homog_EGG_pantograph_1x1(generate_mesh=False):
......@@ -33,15 +34,16 @@ def test_homog_EGG_pantograph_1x1(generate_mesh=False):
start = time.time()
if generate_mesh:
geometry.init_geo_tools()
geometry.set_gmsh_option('Mesh.MshFileVersion', 4.1)
geometry.set_gmsh_option("Mesh.MshFileVersion", 4.1)
a = 1
b, k = a, a/3
b, k = a, a / 3
r = 0.02
panto_test = mesh_generate_2D.Gmsh2DRVE.pantograph(
a, b, k, r, nb_cells=(1, 1), soft_mat=False, name='panto_rve_1x1')
lc_ratio = 1/6
lc_min_max = (lc_ratio*r*a, lc_ratio*a)
panto_test.main_mesh_refinement((2*r*a, a), lc_min_max, False)
panto_test = mesh_generate.pantograph.pantograph_RVE(
a, b, k, r, nb_cells=(1, 1), soft_mat=False, name="panto_rve_1x1"
)
lc_ratio = 1 / 6
lc_min_max = (lc_ratio * r * a, lc_ratio * a)
panto_test.main_mesh_refinement((2 * r * a, a), lc_min_max, False)
panto_test.mesh_generate()
gmsh.model.mesh.renumberNodes()
gmsh.model.mesh.renumberElements()
......@@ -49,44 +51,45 @@ def test_homog_EGG_pantograph_1x1(generate_mesh=False):
mesh = meshio.read("panto_rve_1x1.msh")
mesh.points = mesh.points[:, :2]
geo_only = meshio.Mesh(
points=mesh.points,
cells={"triangle": mesh.cells["triangle"]})
points=mesh.points, cells={"triangle": mesh.cells["triangle"]}
)
meshio.write("panto_rve_1x1.xdmf", geo_only)
geometry.reset()
E, nu = 1., 0.3
material = materials.Material(E, nu, 'cp')
gen_vect = np.array([[4., 0.], [0., 8.]])
rve = part.Fenics2DRVE.file_2_Fenics_2DRVE(
"panto_rve_1x1.xdmf", gen_vect, material)
E, nu = 1.0, 0.3
material = materials.Material(E, nu, "cp")
gen_vect = np.array([[4.0, 0.0], [0.0, 8.0]])
rve = part.Fenics2DRVE.rve_from_file("panto_rve_1x1.xdmf", gen_vect, material)
hom_model = homog2d.Fenics2DHomogenization(rve)
*localzt_dicts, constit_tensors = hom_model.homogenizationScheme('EGG')
*localzt_dicts, constit_tensors = hom_model.homogenizationScheme("EGG")
Chom_ref = np.array(
[[2.58608139e-04, 3.45496903e-04, 5.16572422e-12],
[3.45496903e-04, 3.81860676e-02, 6.48384646e-11],
[5.16572422e-12, 6.48384646e-11, 3.27924466e-04]])
[
[2.58608139e-04, 3.45496903e-04, 5.16572422e-12],
[3.45496903e-04, 3.81860676e-02, 6.48384646e-11],
[5.16572422e-12, 6.48384646e-11, 3.27924466e-04],
]
)
D_ref = np.array(
[[3.72630940e-02, 2.20371444e-02, 1.00603288e-09,
-1.51425656e-11, 6.18921191e-10, -1.39407898e-03],
[2.20371444e-02, -4.32257286e-03, 3.52427076e-09,
3.08504101e-09, 2.91393310e-09, 1.24155443e-02],
[1.00603288e-09, 3.52427076e-09, 1.30706023e-01,
1.59177545e-02, -9.94987221e-03, -6.34655280e-10],
[-1.51425656e-11, 3.08504101e-09, 1.59177545e-02,
1.58014087e-01, 1.28902572e-01, 1.06773326e-09],
[6.18921191e-10, 2.91393310e-09, -9.94987221e-03,
1.28902572e-01, 1.16274758e-01, 7.79908277e-10],
[-1.39407898e-03, 1.24155443e-02, -6.34655280e-10,
1.06773326e-09, 7.79908277e-10, 6.38090435e-05]]
[
[3.7266e-02, 2.2039e-02, 4.6218e-10, 1.5420e-10, 1.2646e-09, -1.3939e-03],
[2.2039e-02, -4.3185e-03, -3.4719e-11, 2.7544e-10, 7.0720e-10, 1.2415e-02],
[4.6218e-10, -3.4719e-11, 1.3071e-01, 1.5918e-02, -9.9492e-03, -2.9101e-10],
[1.5420e-10, 2.7544e-10, 1.5918e-02, 1.5802e-01, 1.2891e-01, 1.5962e-09],
[1.2646e-09, 7.0720e-10, -9.9492e-03, 1.2891e-01, 1.1628e-01, 1.3358e-09],
[-1.3939e-03, 1.2415e-02, -2.9101e-10, 1.5962e-09, 1.3358e-09, 6.3893e-05],
]
)
Chom = constit_tensors['E']['E']
G = constit_tensors['E']['EGGbis']
D = (constit_tensors['EG']['EG']
- np.vstack((G[:, :6], G[:, 6:])) - np.vstack((G[:, :6], G[:, 6:])).T)
Chom = constit_tensors["E"]["E"]
G = constit_tensors["E"]["EGGbis"]
D = (
constit_tensors["EG"]["EG"]
- np.vstack((G[:, :6], G[:, 6:]))
- np.vstack((G[:, :6], G[:, 6:])).T
)
logger.debug(f"Chom : \n {Chom}")
logger.debug(f"D : \n {D}")
logger.debug(f"Duration : {time.time() - start}")
......@@ -111,14 +114,15 @@ def test_homogeneous_pantograph(generate_mesh=False, save_results=False):
start = time.time()
if generate_mesh:
geometry.init_geo_tools()
geometry.set_gmsh_option('Mesh.MshFileVersion', 4.1)
geometry.set_gmsh_option("Mesh.MshFileVersion", 4.1)
a = 1
b, k, r = a, a/3, 0.1*a
geo_model = mesh_generate_2D.Gmsh2DRVE.pantograph(
a, b, k, r, soft_mat=True, name='homogeneous_panto')
b, k, r = a, a / 3, 0.1 * a
geo_model = mesh_generate.pantograph.pantograph_RVE(
a, b, k, r, soft_mat=True, name="homogeneous_panto"
)
lc_ratio = 1
lc_min_max = (lc_ratio*r, lc_ratio)
d_min_max = (2*r, a)
lc_min_max = (lc_ratio * r, lc_ratio)
d_min_max = (2 * r, a)
geo_model.main_mesh_refinement(d_min_max, lc_min_max, False)
geo_model.soft_mesh_refinement(d_min_max, lc_min_max, False)
geo_model.mesh_generate()
......@@ -128,41 +132,46 @@ def test_homogeneous_pantograph(generate_mesh=False, save_results=False):
mesh = meshio.read("homogeneous_panto.msh")