-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
import matplotlib.pyplot as plt | ||
import sys, os, time | ||
import numpy as np | ||
from numpy import linspace, meshgrid | ||
from matplotlib import cm | ||
import collections | ||
from argparse import ArgumentParser | ||
import random | ||
import scipy.sparse as sp | ||
from scipy.sparse import csr_matrix | ||
from scipy.sparse.csgraph import reverse_cuthill_mckee | ||
|
||
from mesh_utils import printDicPretty | ||
|
||
def removeStepCells(meshObj, xBd, yBd): | ||
|
||
stepXb = [xBd[2], xBd[3]] | ||
stepYb = [yBd[1], yBd[2]] | ||
print("stepXb ", stepXb) | ||
print("stepYb ", stepYb) | ||
|
||
totNumCells = meshObj.getTotCells() | ||
[x, y] = meshObj.getCoordinates() | ||
gids = meshObj.getGIDs() | ||
G = meshObj.getGraph() | ||
|
||
a = np.where(x>stepXb[0]) | ||
b = np.where(x<stepXb[1]) | ||
c = np.where(y>stepYb[0]) | ||
d = np.where(y<stepYb[1]) | ||
r1 = np.intersect1d(a,b) | ||
r2 = np.intersect1d(r1,c) | ||
stepCellsGids = np.intersect1d(r2,d) | ||
domainGids = list(set(np.arange(totNumCells)).difference(set(stepCellsGids))) | ||
#print("stepCellsGids = ", stepCellsGids) | ||
#print("domainGids = ", domainGids) | ||
|
||
G2 = {} | ||
for k,v in G.items(): | ||
if k not in stepCellsGids: | ||
v2 = [i if i not in stepCellsGids else -1 for i in v] | ||
G2[k] = v2 | ||
#printDicPretty(G2) | ||
|
||
# reindex | ||
newIds = {} | ||
count = 0 | ||
for k in G2.keys(): | ||
newIds[k] = count | ||
count+=1 | ||
|
||
# fix graph | ||
G3 = {} | ||
for k,v in G2.items(): | ||
v2 = [newIds[i] if i != -1 else -1 for i in v] | ||
G3[newIds[k]] = v2 | ||
|
||
gids = np.array(list(G3.keys())) | ||
return x[domainGids], y[domainGids], G3, gids |