Commit 29f07322 authored by Michel Henry's avatar Michel Henry
Browse files

correction tag + ajout transformation

parent 2d59104f
Pipeline #8409 passed with stages
in 3 minutes and 13 seconds
......@@ -933,3 +933,9 @@ int gmsh_mesh_periodic_tag(GmshMesh *mesh, int ip) {
int gmsh_mesh_periodic_parent_tag(GmshMesh *mesh, int ip) {
return mesh->periodic[ip]->parent_tag;
}
size_t gmsh_mesh_periodic_n_nodes(GmshMesh *mesh, int ip) {
return mesh->periodic[ip]->n_nodes;
}
size_t gmsh_mesh_periodic_node(GmshMesh *mesh, int ip, int i) {
return mesh->periodic[ip]->nodes[i];
}
......@@ -82,4 +82,6 @@ int gmsh_mesh_n_periodic(GmshMesh *mesh);
int gmsh_mesh_periodic_dim(GmshMesh *mesh, int ip);
int gmsh_mesh_periodic_tag(GmshMesh *mesh, int ip);
int gmsh_mesh_periodic_parent_tag(GmshMesh *mesh, int ip);
size_t gmsh_mesh_periodic_n_nodes(GmshMesh *mesh, int ip);
size_t gmsh_mesh_periodic_node(GmshMesh *mesh, int ip, int i);
#endif
......@@ -80,10 +80,11 @@ class ParticleState(np.ndarray) :
return state
class entity():
def __init__(self, dim, physicals, elements) :
def __init__(self, dim, physicals, elements, tag = -1) :
self.dimension = dim
self.physicals = physicals
self.elements = elements
self.tag = tag
class ParticleProblem :
......@@ -517,10 +518,12 @@ class ParticleProblem :
phys_dims = self.physical_dims(_mesh,n_phys)
physicals = [{},{},{},{}]
periodic_tag = self.periodic_tag(_mesh)
print(periodic_tag)
for i in range(n_phys):
physicals[int(phys_dims[i])][phys_names[i].decode()] = int(phys_tag[i])
entities = self.get_entities(_mesh)
tmap = self.transform(_mesh)
# print(trans)
# exit(1)
self._addv = set()
if self._dim == 2 :
pnum = [self.getPhysicalNumber(physicals,1,i) for i in tags]
......@@ -529,10 +532,7 @@ class ParticleProblem :
continue
tag = 0 if not ent.physicals else ent.physicals[0]
stag = self.getPhysicalName(physicals,ent.dimension, tag) or str(tag)
flag = tag in periodic_tag[ent.dimension]
print(f"tag = {tag}")
print(f"periodic_tag[{ent.dimension}] = {periodic_tag[ent.dimension]}")
print(f"\t\t => FLAG = {flag}")
flag = ent.tag in periodic_tag[ent.dimension]
for i, el in enumerate(ent.elements) :
for v in el:
v0 = el[1]
......@@ -543,8 +543,8 @@ class ParticleProblem :
# if not flag : # influence du disque sur la frontiere periodique
self.add_boundary_disk((v[0] + shift[0], v[1] + shift[1]), 0.000, stag,material)
if flag:
transform = (0.0,0.0)
self.add_boundary_periodic_segment((v0[0] + shift[0], v0[1] + shift[1]), (v1[0] + shift[0], v1[1] + shift[1]), transform, stag)
transf = tmap[ent.dimension][int(ent.tag)]
self.add_boundary_periodic_segment((v0[0] + shift[0], v0[1] + shift[1]), (v1[0] + shift[0], v1[1] + shift[1]), (transf[0], transf[1]), stag)
continue
self.add_boundary_segment((v0[0] + shift[0], v0[1] + shift[1]), (v1[0] + shift[0], v1[1] + shift[1]), stag,material)
else :
......@@ -604,10 +604,11 @@ class ParticleProblem :
for ie in range(self.n_entities(_mesh,d)):
edim = self.entity_dim(_mesh,d,ie)
ephys = self.entity_physicals(_mesh,d,ie)
etag = self.entity_tag(_mesh,d,ie)
nelt = self.n_elements(_mesh,d,ie)
elts = [None]*nelt
elts = [[vmap[int(i)] for i in self.element_nodes_tag(_mesh,d,ie,id)] for id in range(nelt)]
entities.append(entity(edim, ephys, elts))
entities.append(entity(edim, ephys, elts, etag))
return entities
def n_physical_names(self,_mesh):
self._lib.gmsh_mesh_n_physical_names.restype = c_int
......@@ -653,6 +654,9 @@ class ParticleProblem :
f = getattr(self._lib, "gmsh_mesh_entity_physicals")
f.restype = POINTER(c_int)
return np.ctypeslib.as_array(f(_mesh, c_int(dim), c_int(ie)),shape=(n_physicals,))
def entity_tag(self,_mesh,dim,ie):
self._lib.gmsh_mesh_entity_tag.restype = c_int
return self._lib.gmsh_mesh_entity_tag(_mesh,c_int(dim), c_int(ie))
def n_elements(self,_mesh,dim,ie):
self._lib.gmsh_mesh_entity_n_elements.restype = c_size_t
return self._lib.gmsh_mesh_entity_n_elements(_mesh, c_int(dim), c_int(ie))
......@@ -669,7 +673,7 @@ class ParticleProblem :
return self._lib.gmsh_mesh_n_periodic(_mesh)
def periodic_tag(self,_mesh):
n_periodic = self.n_periodic(_mesh)
vtag = [{},{},{},{}]
vtag = [{},{},{}]
self._lib.gmsh_mesh_periodic_dim.restype = c_int
self._lib.gmsh_mesh_periodic_tag.restype = c_int
self._lib.gmsh_mesh_periodic_parent_tag.restype = c_int
......@@ -680,3 +684,31 @@ class ParticleProblem :
vtag[int(dim)][int(tag)] = parent_tag
vtag[int(dim)][int(parent_tag)] = tag
return vtag
def transform(self, _mesh):
n_periodic = self.n_periodic(_mesh)
self._lib.gmsh_mesh_periodic_dim.restype = c_int
self._lib.gmsh_mesh_periodic_n_nodes.restype = c_size_t
self._lib.gmsh_mesh_periodic_node.restype = c_size_t
self._lib.gmsh_mesh_periodic_tag.restype = c_int
self._lib.gmsh_mesh_periodic_parent_tag.restype = c_int
vmap = {}
n_nodes = self.n_nodes(_mesh,self._dim)
nodes = self.nodes(_mesh,self._dim,n_nodes)
nodes_tag = self.nodes_tag(_mesh, self._dim, n_nodes)
for i, node in enumerate(nodes):
vmap[int(nodes_tag[i])] = nodes[i]
tmap = [{},{},{}]
for ip in range(n_periodic):
periodic_n_nodes = self._lib.gmsh_mesh_periodic_n_nodes(_mesh, c_int(ip))
if periodic_n_nodes < 2:
continue
dim = self._lib.gmsh_mesh_periodic_dim(_mesh,c_int(ip))
nodeSlave = self._lib.gmsh_mesh_periodic_node(_mesh,c_int(ip),c_int(0))
nodeMaster = self._lib.gmsh_mesh_periodic_node(_mesh,c_int(ip),c_int(1))
tag = self._lib.gmsh_mesh_periodic_tag(_mesh,c_int(ip))
parent_tag = self._lib.gmsh_mesh_periodic_parent_tag(_mesh,c_int(ip))
x0 = vmap[nodeSlave]
x1 = vmap[nodeMaster]
tmap[dim][int(tag)] = x1-x0
tmap[dim][int(parent_tag)] = x0-x1
return tmap
Supports Markdown
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