Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e927d8f
Fix for DG
Jul 5, 2024
5b7fe51
Added labels atribute to mesh, makes it easier :)
Sep 6, 2024
6655efa
Vanilla embedded Trefftz
Sep 6, 2024
f32c97b
WIP
Sep 6, 2024
4c144a5
Merge branch 'uz/dglabels' into uz/Gottingen
Sep 6, 2024
a19653c
Added test for Trefftz methods
Sep 6, 2024
5ab079c
Finished implementing vanilla embedded Trefftz for polytopal method o…
Sep 6, 2024
27ab155
Using aggregation as a preconditioner
Sep 7, 2024
e016a77
Aggregation+Treffetz
Sep 7, 2024
e1ee112
Netgen hierarchy support for 3D
Sep 9, 2024
73f35cc
Fix linting
Sep 9, 2024
a2f6950
Fix typo
Sep 9, 2024
33a8698
Fix docker file
Sep 10, 2024
2141ca7
DG Labelling
Sep 10, 2024
d778ffd
Revert "Fix typo"
Sep 11, 2024
ff71aa8
WIP
Sep 11, 2024
daca457
Post processing flags added
Sep 11, 2024
afb4d9d
Added tollerance parameter in post process curving
Sep 11, 2024
0d9de86
Removed post processing
Sep 11, 2024
fd7b581
Fix for parallel
Sep 11, 2024
5472275
Better way of constructing boundary array
Sep 12, 2024
ae134b8
Fix for parallel part 2
Sep 12, 2024
1c2938f
Fix workflow for serial
Sep 12, 2024
1c00fe3
Fix for DG facet labels
Sep 12, 2024
a19dfd1
Fix for ngsolve 3D plex support
Sep 12, 2024
f9b2206
Making the linter happy
Sep 12, 2024
cad6e13
Merge branch 'uz/Gottingen' of github.com:NGSolve/ngsPETSc into uz/Fi…
Sep 13, 2024
4c24982
WIP Polygoanl DG
Sep 13, 2024
30096fa
WIP Polygonal of any order
Sep 13, 2024
02ff46c
Working Treftz ksp
Sep 13, 2024
209ab6c
Added test for Treftz aggregation and Treftz ksp
Sep 13, 2024
01ad566
Using trefftz KSP also for Laplace test
Sep 13, 2024
bf2561f
Making the linter happy
Sep 13, 2024
a4578d0
Extra test
Sep 13, 2024
27877b9
WIP
Sep 18, 2024
1272911
Firedrake only has object of codim 1.
Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions ngsPETSc/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class MeshMapping:

'''

def __init__(self, mesh=None, comm=MPI.COMM_WORLD, name="Default"):
def __init__(self, mesh=None, comm=MPI.COMM_WORLD, geo=None, name="Default"):
self.name = name
self.comm = comm
self.geo = geo
if isinstance(mesh,(ngs.comp.Mesh,ngm.Mesh)):
self.createPETScDMPlex(mesh)
elif isinstance(mesh,PETSc.DMPlex):
Expand All @@ -53,6 +54,8 @@ def createNGSMesh(self, plex):
self.petscPlex = plex
ngMesh = ngm.Mesh(dim=plex.getCoordinateDim())
self.ngMesh = ngMesh
if self.geo:
self.ngMesh.SetGeometry(self.geo)

if plex.getDimension() == 2:
coordinates = plex.getCoordinates().getArray().reshape([-1,2])
Expand Down Expand Up @@ -94,8 +97,12 @@ def createNGSMesh(self, plex):
for j in bcIndices:
bcIndex = plex.getCone(j)-vStart
if len(bcIndex) == 2:
edge = ngm.Element1D([v+1 for v in bcIndex],index=bcLabel)
self.ngMesh.Add(edge)
edge = ngm.Element1D([v+1 for v in bcIndex],
index=bcLabel,edgenr=bcLabel-1)
if self.geo:
self.ngMesh.Add(edge, project_geominfo=True)
else:
self.ngMesh.Add(edge)
elif plex.getDimension() == 3:
coordinates = plex.getCoordinates().getArray().reshape([-1,3])
self.ngMesh.AddPoints(coordinates)
Expand Down Expand Up @@ -139,9 +146,12 @@ def createNGSMesh(self, plex):
faces = faces + [face]
else:
faces = faces + [[face[0],face[2],face[1]]]
#fd = self.ngmesh.Add(ngm.FaceDescriptor(bc=bcLabel))
self.ngMesh.Add(ngm.FaceDescriptor(bc=bcLabel))
self.ngMesh.AddElements(dim=2, index=bcLabel,
self.ngMesh.Add(ngm.FaceDescriptor(bc=bcLabel, surfnr=bcLabel))
if self.geo:
self.ngMesh.AddElements(dim=2, index=bcLabel,
data=np.asarray(faces,dtype=np.int32), base=0, project_geometry=True)
else:
self.ngMesh.AddElements(dim=2, index=bcLabel, edgenr=bcLabel-1,
data=np.asarray(faces,dtype=np.int32), base=0)
else:
raise NotImplementedError("No implementation for dimension greater than 3.")
Expand All @@ -159,6 +169,7 @@ def createPETScDMPlex(self, mesh):
else:
self.ngMesh = mesh
comm = self.comm
self.geo = self.ngMesh.GetGeometry()
if self.ngMesh.dim == 3:
if comm.rank == 0:
V = self.ngMesh.Coordinates()
Expand Down
30 changes: 14 additions & 16 deletions ngsPETSc/utils/firedrake/hierarchies.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,34 @@

from netgen.meshing import MeshingParameters

from ngsPETSc.plex import MeshMapping
from ngsPETSc.utils.firedrake.meshes import flagsUtils

def snapToNetgenDMPlex(ngmesh, petscPlex):
'''
This function snaps the coordinates of a DMPlex mesh to the coordinates of a Netgen mesh.
'''
if petscPlex.getDimension() == 2:
ngCoordinates = ngmesh.Coordinates()
petscCoordinates = petscPlex.getCoordinatesLocal().getArray().reshape(-1, ngmesh.dim)
for i, pt in enumerate(petscCoordinates):
j = np.argmin(np.sum((ngCoordinates - pt)**2, axis=1))
petscCoordinates[i] = ngCoordinates[j]
petscPlexCoordinates = petscPlex.getCoordinatesLocal()
petscPlexCoordinates.setArray(petscPlexCoordinates)
petscPlex.setCoordinatesLocal(petscPlexCoordinates)
else:
raise NotImplementedError("Snapping to Netgen meshes is only implemented for 2D meshes.")
ngCoordinates = ngmesh.Coordinates()
petscCoordinates = petscPlex.getCoordinatesLocal().getArray().reshape(-1, ngmesh.dim)
for i, pt in enumerate(petscCoordinates):
j = np.argmin(np.sum((ngCoordinates - pt)**2, axis=1))
petscCoordinates[i] = ngCoordinates[j]
petscPlexCoordinates = petscPlex.getCoordinatesLocal()
petscPlexCoordinates.setArray(petscPlexCoordinates)
petscPlex.setCoordinatesLocal(petscPlexCoordinates)

def uniformRefinementRoutine(ngmesh, cdm):
'''
Routing called inside of NetgenHierarchy to compute refined ngmesh and plex.
'''
#We refine the netgen mesh uniformly
ngmesh.Refine(adaptive=False)
#We refine the DMPlex mesh uniformly
cdm.setRefinementUniform(True)
rdm = cdm.refine()
rdm.removeLabel("pyop2_core")
rdm.removeLabel("pyop2_owned")
rdm.removeLabel("pyop2_ghost")
return (rdm, ngmesh)
mapping = MeshMapping(rdm, geo=ngmesh.GetGeometry())
return (rdm, mapping.ngMesh)

def uniformMapRoutine(meshes):
'''
Expand Down Expand Up @@ -111,8 +108,9 @@ def NetgenHierarchy(mesh, levs, flags):
-tol, geometric tollerance adopted in snapToNetgenDMPlex.
-refinement_type, the refinment type to be used: uniform (default), Alfeld
'''
if mesh.geometric_dimension() == 3:
raise NotImplementedError("Netgen hierachies are only implemented for 2D meshes.")
if mesh.geometric_dimension() > 3:
raise NotImplementedError("Netgen hierachies are only implemented \
for meshes with dimension greater than 3.")
ngmesh = mesh.netgen_mesh
comm = mesh.comm
#Parsing netgen flags
Expand Down