Commit b24a59e5 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

re-structure contact solver

parent 8a72a9e8
Pipeline #8798 passed with stages
in 5 minutes and 28 seconds
......@@ -42,10 +42,8 @@ assert(np.lib.NumpyVersion(np.__version__) >= "1.17.0")
dir_path = os.path.dirname(os.path.realpath(__file__))
lib2 = np.ctypeslib.load_library("libscontact2",dir_path)
lib2f = np.ctypeslib.load_library("libscontact2f",dir_path)
lib2fwr = np.ctypeslib.load_library("libscontact2fwr",dir_path)
lib3 = np.ctypeslib.load_library("libscontact3",dir_path)
lib3f = np.ctypeslib.load_library("libscontact3f",dir_path)
lib3fwr = np.ctypeslib.load_library("libscontact3fwr",dir_path)
is_64bits = sys.maxsize > 2**32
......@@ -101,16 +99,14 @@ class ParticleProblem :
"""
self._dim = dim
self._friction_enabled = friction_enabled
self._rotation_enabled = False if not friction_enabled else rotation_enabled
if not friction_enabled :
rotation_enabled = False;
self._rotation_enabled = rotation_enabled
if dim == 2 :
if friction_enabled:
self._lib = lib2f if rotation_enabled else lib2fwr
else:
self._lib = lib2
self._lib = lib2 if rotation_enabled else lib2fwr
self._coord_type = c_double*2
elif dim == 3 :
self._lib = (lib3f if rotation_enabled else lib3fwr) if (friction_enabled) else lib3
self._lib = lib3 if rotation_enabled else lib3fwr
self._coord_type = c_double*3
else :
raise ValueError("Dimension should be 2 or 3.")
......@@ -121,8 +117,8 @@ class ParticleProblem :
bndtype =[('material',np.int32),('tag',np.int32)]
self._disktype = np.dtype(bndtype+[('x',np.float64,dim),('v',np.float64,dim),('r',np.float64)])
self._segmenttype = np.dtype(bndtype+[('p',np.float64,(2,dim)),('v',np.float64,(2,dim))])
self._triangletype = np.dtype(bndtype+[('p',np.float64,(3,dim)),('v',np.float64,(3,dim))])
self._segmenttype = np.dtype(bndtype+[('p',np.float64,(2,dim)),('v',np.float64,(dim))])
self._triangletype = np.dtype(bndtype+[('p',np.float64,(3,dim)),('v',np.float64,(dim))])
self._periodicEntitytype = np.dtype([('etag', np.int32),('edim', np.int32),('periodic_transformation', np.float64, dim)])
self._periodicSegmenttype = np.dtype([('entity_id', np.int64), ('p',np.float64,(2,dim))])
self._periodicTriangletype = np.dtype([('entity_id', np.int64),('p', np.float64,(3,dim))])
......@@ -261,7 +257,7 @@ class ParticleProblem :
f += f2
if self._dim == 3:
f+= compute_fn_ft("particle_triangle",self.triangles(),tag)
return f
return -f
def set_boundary_velocity(self, tag, v) :
"""Sets the velocity of a boundary to a given value.
......
......@@ -26,23 +26,17 @@ set(SRC
include_directories(. ../tools)
add_library(scontact3f SHARED ${SRC})
target_compile_definitions(scontact3f PUBLIC -DDIMENSION=3 -DFRICTION_ENABLED=1 -DROTATION_ENABLED=1)
add_library(scontact3 SHARED ${SRC})
target_compile_definitions(scontact3 PUBLIC -DDIMENSION=3 -DROTATION_ENABLED=1)
add_library(scontact2 SHARED ${SRC})
target_compile_definitions(scontact2 PUBLIC "-DDIMENSION=2")
add_library(scontact2f SHARED ${SRC})
target_compile_definitions(scontact2f PUBLIC -DDIMENSION=2 -DFRICTION_ENABLED=1 -DROTATION_ENABLED=1)
target_compile_definitions(scontact2 PUBLIC -DDIMENSION=2 -DROTATION_ENABLED=1)
add_library(scontact2fwr SHARED ${SRC})
target_compile_definitions(scontact2fwr PUBLIC -DDIMENSION=2 -DFRICTION_ENABLED=1)
add_library(scontact3 SHARED ${SRC})
target_compile_definitions(scontact3 PUBLIC "-DDIMENSION=3")
target_compile_definitions(scontact2fwr PUBLIC -DDIMENSION=2)
add_library(scontact3fwr SHARED ${SRC})
target_compile_definitions(scontact3fwr PUBLIC -DDIMENSION=3 -DFRICTION_ENABLED=1)
target_compile_definitions(scontact3fwr PUBLIC -DDIMENSION=3)
......
This diff is collapsed.
......@@ -60,9 +60,9 @@ outf1 = 100000
ii = 0
tic = time.clock()
forces = np.zeros((p.n_particles(),p.dim())
forces = np.zeros((p.n_particles(),p.dim()))
print(forces[:,1].shape)
tic = time.process_time()
while t < tEnd :
forces[:,1] = g*p.mass()[0]-p.velocity()[:,1]
vn = p.velocity() + forces * dt / p.mass()
......@@ -76,6 +76,6 @@ while t < tEnd :
ioutput = int(ii/outf) + 1
p.write_vtk(outputdir, ioutput, t)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.process_time() - tic))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment