Hello,
I want to make a parameterized discrete geometry out of tesselated geometries. When I execute the code I get a strange error:
/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/tessellation.py:104: RuntimeWarning: divide by zero encountered in true_divide
np.full(x.shape, triangle_areas[index] / x.shape[0])
Traceback (most recent call last):
File "heatsink/heatsink_design/heatsink_debug.py", line 97, in <module>
main()
File "heatsink/heatsink_design/heatsink_debug.py", line 28, in wrapper
result = func(*args, **kwargs)
File "heatsink/heatsink_design/heatsink_debug.py", line 91, in main
s1 = (no_slip).sample_boundary(nr_points=nr_points)
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/geometry.py", line 488, in sample_boundary
[
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/geometry.py", line 489, in <listcomp>
curve.approx_area(parameterization, criteria=closed_boundary_criteria)
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/curve.py", line 148, in approx_area
computed_criteria = criteria(s, p)
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/geometry.py", line 480, in boundary_criteria
return self.boundary_criteria(invar, criteria=criteria, params=params)
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/geometry.py", line 401, in boundary_criteria
sdf_normal_plus = self.sdf(
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/discrete_geometry.py", line 73, in sdf
computed_sdf = f(
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/geometry.py", line 111, in scale_sdf
computed_sdf = sdf(scaled_invar, params, compute_sdf_derivatives)
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/geometry.py", line 189, in translate_sdf
computed_sdf = sdf(translated_invar, params, compute_sdf_derivatives)
File "/usr/local/lib/python3.8/dist-packages/modulus/sym/geometry/tessellation.py", line 135, in sdf
store_triangles *= 1 / max_dis
ZeroDivisionError: float division by zero
This error occures only when I try to make a discrete geometry out of tesselated geometries, I can sample points on each tesselated geometry that I use without any problem. Here is a code that produces an error:
# import Modulus library
import os
import psutil
from sympy import Symbol, Eq, tanh, Max
import numpy as np
import itertools
import os
import pandas as pd
from modulus.sym.geometry import Parameterization, Parameter
from modulus.sym.geometry.discrete_geometry import DiscreteGeometry
from modulus.sym.utils.io.vtk import var_to_polyvtk
from modulus.sym.geometry.tessellation import Tessellation
from modulus.sym.hydra import to_absolute_path
def parse_file(filename, airtight: bool = False):
geo = Tessellation.from_stl(
"/root/workspace/heatsink/stl_files/" + filename, airtight=airtight
)
geo_translated = geo.translate([0., -0.0261136, -0.02494])
return geo_translated
alpha = Symbol("alpha")
hc = Symbol("hc")
he = Symbol("he")
fixed_param_ranges = {
alpha: 1.72,
hc: 19.72,
he: 12.78,
}
noslip_geos = []
interior_geos = []
for n in range(1, 20):
noslip_geos.append(parse_file("Design_"+str(n)+"/no_slip.stl", False))
interior_geos.append(parse_file("Design_"+str(n)+"/interior.stl", True))
df = pd.read_csv("/root/workspace/heatsink/stl_files/DOE_Plan_OLH_Distribution.csv", sep="\t", header=0)
alpha_par = df.iloc[:, 1].values.copy()
hc_par = df.iloc[:, 2].values.copy()
he_par = df.iloc[:, 3].values.copy()
par = Parameterization(
{
Parameter("alpha"): alpha_par[:, None],
Parameter("he"): he_par[:, None],
Parameter("hc"): hc_par[:, None],
}
)
no_slip = DiscreteGeometry(noslip_geos, par)
interior = DiscreteGeometry(interior_geos, par)
nr_points = 100
s1 = (no_slip).sample_boundary(nr_points=nr_points)
print(s1)
s1 = (interior).sample_interior(nr_points=nr_points, compute_sdf_derivatives=True)
print(s1)
I would be great if you could help me resolve this issue.
Thank you