From 143527f43e840e343d3bc632db19729729a9ce13 Mon Sep 17 00:00:00 2001 From: jhcollins <37124212+jhcollins@users.noreply.github.com> Date: Wed, 27 Jul 2022 14:51:22 -0400 Subject: [PATCH 1/3] Update SpatialTools.py Adding functions reloadBCList and assignFacetFlagsFromSTL for easier manipulation of ShapeSTL object. --- proteus/SpatialTools.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/proteus/SpatialTools.py b/proteus/SpatialTools.py index d1446211c6..80a09c0cd2 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): """ From 24dc171b9263fac2c88dc140adf0bfc3953daca8 Mon Sep 17 00:00:00 2001 From: jhcollins <37124212+jhcollins@users.noreply.github.com> Date: Wed, 27 Jul 2022 15:09:31 -0400 Subject: [PATCH 2/3] Update VOF.py making the lumped mass matrix/meshvolume check a relative test --- proteus/mprans/VOF.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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: From 214daf4cb0249eb9d357a511d11074d8c3818fc2 Mon Sep 17 00:00:00 2001 From: jhcollins Date: Thu, 28 Jul 2022 15:17:42 -0400 Subject: [PATCH 3/3] fixing whitespace --- proteus/SpatialTools.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/proteus/SpatialTools.py b/proteus/SpatialTools.py index 80a09c0cd2..62aea5a9b4 100644 --- a/proteus/SpatialTools.py +++ b/proteus/SpatialTools.py @@ -1116,29 +1116,29 @@ def __init__(self, domain, filename): # 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() - """ + """ + 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") - """ - + """ + 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