diff --git a/proteus/SpatialTools.py b/proteus/SpatialTools.py index d1446211c6..62aea5a9b4 100644 --- a/proteus/SpatialTools.py +++ b/proteus/SpatialTools.py @@ -1114,6 +1114,37 @@ def __init__(self, domain, filename): self.BC[key] = self.BC_class(shape=self, name=key) self.BC_list += [self.BC[key]] # self.BC = BCContainer(self.BC_dict) + + def reloadBCList(self): + """ + Allows for easier addition/modification of shape BC's from the input file directly. + Calls to this function should be made after adding a new entry to boundaryTags dict, + and before assignment of boundary conditions. + + ex: + tank.boundaryTags["top"]=2 #<-new BC flag + tank.reloadBCList() + """ + self.BC={} + self.BC_list=[] + for key,value in self.boundaryTags.items(): + self.BC[key] = self.BC_class(shape=self, name=key) + self.BC_list += [self.BC[key]] + + def assignFacetFlagsFromSTL(self,flag,boundary_stl): + """ + Add flags to ShapeSTL facets using a separate STL surface containing only the boundary facets. + + ex: + tank.assignFacetFlagsFromSTL(boundaryTags["inflow"],"inflow.stl") + """ + + boundary_stl_info=getInfoFromSTL(boundary_stl) + for i in range(len(self.facets)): + if ((self.vertices[self.facets[i][0][0]].tolist() in boundary_stl_info[0].tolist()) and + (self.vertices[self.facets[i][0][1]].tolist() in boundary_stl_info[0].tolist()) and + (self.vertices[self.facets[i][0][2]].tolist() in boundary_stl_info[0].tolist())): + self.facetFlags[i]=flag def getInfoFromSTL(filename): """ diff --git a/proteus/mprans/VOF.py b/proteus/mprans/VOF.py index 8d27f29386..d5c185a2b1 100644 --- a/proteus/mprans/VOF.py +++ b/proteus/mprans/VOF.py @@ -7,7 +7,7 @@ from builtins import range from past.utils import old_div import numpy as np -from math import fabs +from math import fabs, isclose import proteus from proteus import cfemIntegrals, Quadrature, Norms, Comm from proteus.NonlinearSolvers import NonlinearEquation @@ -1082,9 +1082,7 @@ def getMassMatrix(self): self.ML = np.zeros((self.nFreeDOF_global[0],), 'd') for i in range(self.nFreeDOF_global[0]): self.ML[i] = self.MC_a[self.rowptr[i]:self.rowptr[i + 1]].sum() - np.testing.assert_almost_equal(self.ML.sum(), - self.mesh.volume, - err_msg="Trace of lumped mass matrix should be the domain volume", verbose=True) + assert isclose(self.ML.sum(),self.mesh.volume,rel_tol=1e-7), "Trace of lumped mass matrix should be the domain volume"+": "+str(self.ML.sum())+" =/= "+str(self.mesh.volume) def initVectors(self): if self.coefficients.porosity_dof is None: