def getCurrentTangent(self): """ return current tangent operator type Tensor4 on FunctionSpace """ t = escript.Tensor4(0, escript.Function(self.__domain)) st = self.__pool.map(getStressAndTangent2D, self.__scenes) for i in xrange(self.__numGaussPoints): t.setValueOfDataPoint(i, st[i][1]) return t
def applyStrain_getStressTangentDEM(self, st=escript.Data()): st = st.toListOfTuples() st = numpy.array(st).reshape(-1, 9) stress = escript.Tensor(0, escript.Function(self.__domain)) S = escript.Tensor4(0, escript.Function(self.__domain)) scenes = self.__pool.map(shear, zip(self.__scenes, st)) st = self.__pool.map(getStressAndTangent, scenes) for i in xrange(self.__numGaussPoints): stress.setValueOfDataPoint(i, st[i][0]) S.setValueOfDataPoint(i, st[i][1]) return stress, S, scenes
def __init__(self, domain, pore0=0., perm=1.e-5, kf=2.2e9, dt=0.001, ng=1, useMPI=False, np=1, rtol=1.e-2): """ initialization of the problem, i.e. model constructor :param domain: type Domain, domain of the problem :param pore0: type float, initial pore pressure :param perm: type float, d^2/(150 mu_f) in KC equation :param kf: type float, bulk modulus of the fluid :param dt: type float, time step for calculation :param ng: type integer, number of Gauss points :param useMPI: type boolean, use MPI or not :param np: type integer, number of processors :param rtol: type float, relevative tolerance for global convergence """ self.__domain = domain self.__upde = LinearPDE(domain, numEquations=domain.getDim(), numSolutions=domain.getDim()) self.__ppde = LinearPDE(domain, numEquations=1, numSolutions=1) # use reduced interpolation for pore pressure self.__ppde.setReducedOrderOn() self.__upde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT) self.__ppde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT) self.__upde.setSymmetryOn() self.__ppde.setSymmetryOn() self.__dt = dt self.__bulkFluid = kf self.__numGaussPoints = ng self.__rtol = rtol self.__stress = escript.Tensor(0, escript.Function(domain)) self.__S = escript.Tensor4(0, escript.Function(domain)) self.__pool = get_pool(mpi=useMPI, threads=np) self.__scenes = self.__pool.map(initLoad, range(ng)) st = self.__pool.map(getStressAndTangent2D, self.__scenes) for i in xrange(ng): self.__stress.setValueOfDataPoint(i, st[i][0]) self.__S.setValueOfDataPoint(i, st[i][1]) self.__strain = escript.Tensor(0, escript.Function(domain)) self.__pore = escript.Scalar(pore0, escript.ReducedSolution(domain)) self.__pgauss = util.interpolate(pore0, escript.Function(domain)) self.__permeability = perm self.__meanStressRate = escript.Scalar(0, escript.Function(domain)) self.__r = escript.Vector( 0, escript.Solution(domain)) #Dirichlet BC for u
def __init__(self, domain, ng=1, useMPI=False, np=1, random=False, rtol=1.e-2, verbose=False): """ initialization of the problem, i.e. model constructor :param domain: type Domain, domain of the problem :param ng: type integer, number of Gauss points :param useMPI: type boolean, use MPI or not :param np: type integer, number of processors :param random: type boolean, if or not use random density field :param rtol: type float, relevant tolerance for global convergence :param verbose: type boolean, if or not print messages during calculation """ self.__domain = domain self.__pde = LinearPDE(domain, numEquations=self.__domain.getDim(), numSolutions=self.__domain.getDim()) try: self.__pde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT) except: #import time print( "=======================================================================" ) print( "For better performance compile python-escript with direct solver method" ) print( "=======================================================================" ) input("Press Enter to continue...") #time.sleep(5) self.__pde.setSymmetryOn() #self.__pde.getSolverOptions().setTolerance(rtol**2) #self.__pde.getSolverOptions().setPackage(SolverOptions.UMFPACK) self.__numGaussPoints = ng self.__rtol = rtol self.__verbose = verbose self.__pool = get_pool(mpi=useMPI, threads=np) self.__scenes = self.__pool.map(initLoad, list(range(ng))) self.__strain = escript.Tensor(0, escript.Function(self.__domain)) self.__stress = escript.Tensor(0, escript.Function(self.__domain)) self.__S = escript.Tensor4(0, escript.Function(self.__domain)) st = self.__pool.map(getStressAndTangent, self.__scenes) for i in range(ng): self.__stress.setValueOfDataPoint(i, st[i][0]) self.__S.setValueOfDataPoint(i, st[i][1])
def __init__(self, domain, ng=1, useMPI=False, np=1, random=False, rtol=1.e-2, usePert=False, pert=-2.e-6, verbose=False): """ initialization of the problem, i.e. model constructor :param domain: type Domain, domain of the problem :param ng: type integer, number of Gauss points :param useMPI: type boolean, use MPI or not :param np: type integer, number of processors :param random: type boolean, if or not use random density field :param rtol: type float, relevative tolerance for global convergence :param usePert: type boolean, if or not use perturbation method :param pert: type float, perturbated strain applied to DEM to obtain tangent operator :param verbose: type boolean, if or not print messages during calculation """ self.__domain = domain self.__pde = LinearPDE(domain, numEquations=self.__domain.getDim(), numSolutions=self.__domain.getDim()) self.__pde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT) self.__pde.setSymmetryOn() #self.__pde.getSolverOptions().setTolerance(rtol**2) #self.__pde.getSolverOptions().setPackage(SolverOptions.UMFPACK) self.__numGaussPoints = ng self.__rtol = rtol self.__usepert = usePert self.__pert = pert self.__verbose = verbose self.__pool = get_pool(mpi=useMPI, threads=np) self.__scenes = self.__pool.map(initLoad, range(ng)) self.__strain = escript.Tensor(0, escript.Function(self.__domain)) self.__stress = escript.Tensor(0, escript.Function(self.__domain)) self.__S = escript.Tensor4(0, escript.Function(self.__domain)) if self.__usepert: s = self.__pool.map(getStressTensor, self.__scenes) t = self.__pool.map(getTangentOperator, zip(self.__scenes, repeat(pert))) for i in xrange(ng): self.__stress.setValueOfDataPoint(i, s[i]) self.__S.setValueOfDataPoint(i, t[i]) else: st = self.__pool.map(getStressAndTangent2D, self.__scenes) for i in xrange(ng): self.__stress.setValueOfDataPoint(i, st[i][0]) self.__S.setValueOfDataPoint(i, st[i][1])
def applyStrain_getStressTangentDEM(self,st=escript.Data()): st = st.toListOfTuples() st = numpy.array(st).reshape(-1,4) #-1 means the num of rows if determined by column num 4(strain tensor of each GP has 4 values) stress = escript.Tensor(0,escript.Function(self.__domain)) S = escript.Tensor4(0,escript.Function(self.__domain)) scenes = self.__pool.map(shear2D,zip(self.__scenes,st)) #zip is from python; shear2D is the key part of DEM if self.__usepert: s = self.__pool.map(getStressTensor,scenes) t = self.__pool.map(getTangentOperator,zip(scenes,repeat(self.__pert))) for i in xrange(self.__numGaussPoints): stress.setValueOfDataPoint(i,s[i]) S.setValueOfDataPoint(i,t[i]) else: ST = self.__pool.map(getStressAndTangent2D,scenes) for i in xrange(self.__numGaussPoints): stress.setValueOfDataPoint(i,ST[i][0]) S.setValueOfDataPoint(i,ST[i][1]) return stress,S,scenes #stress is sigma. S means tangent operator. scenes??
def applyStrain_getStressTangentDEM(self, st=escript.Data()): st = st.toListOfTuples() st = numpy.array(st).reshape(-1, 4) stress = escript.Tensor(0, escript.Function(self.__domain)) S = escript.Tensor4(0, escript.Function(self.__domain)) scenes = self.__pool.map(shear2D, list(zip(self.__scenes, st))) if self.__usepert: s = self.__pool.map(getStressTensor, scenes) t = self.__pool.map(getTangentOperator, list(zip(scenes, repeat(self.__pert)))) for i in range(self.__numGaussPoints): stress.setValueOfDataPoint(i, s[i]) S.setValueOfDataPoint(i, t[i]) else: ST = self.__pool.map(getStressAndTangent2D, scenes) for i in range(self.__numGaussPoints): stress.setValueOfDataPoint(i, ST[i][0]) S.setValueOfDataPoint(i, ST[i][1]) return stress, S, scenes
def __init__(self,domain,ng=1,np=1,random=False,rtol=1.e-2,usePert=False,pert=-2.e-6,verbose=False): """ initialization of the problem, i.e. model constructor :param domain: type Domain, domain of the problem :param ng: type integer, number of Gauss points :param np: type integer, number of processors :param random: type boolean, if or not use random density field :param rtol: type float, relevative tolerance for global convergence :param usePert: type boolean, if or not use perturbation method :param pert: type float, perturbated strain applied to DEM to obtain tangent operator :param verbose: type boolean, if or not print messages during calculation """ self.__domain=domain self.__pde=LinearPDE(domain,numEquations=self.__domain.getDim(),numSolutions=self.__domain.getDim()) self.__pde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT) #self.__pde.getSolverOptions().setTolerance(rtol**2) #self.__pde.getSolverOptions().setPackage(SolverOptions.UMFPACK) self.__numGaussPoints=ng self.__rtol=rtol self.__usepert=usePert self.__pert=pert self.__verbose=verbose self.__pool=Pool(processes=np) self.__scenes=self.__pool.map(initLoad,range(ng))#where is initLoad???from simDEM.py,to load RVEs; map(function, iterable) self.__strain=escript.Tensor(0,escript.Function(self.__domain)) '''Tensor(value=0., what=FunctionSpace(), expanded=False) returns a Data object of shape (d,d) in the FunctionSpace what, where d is the spatial dimension of the Domain of what. Values are initialized with value, a double precision quantity(here is 0). If expanded is True the Data object is represented in expanded form. ''' self.__stress=escript.Tensor(0,escript.Function(self.__domain)) #Function(domain): returns the general FunctionSpace on the Domain domain. Data objects in this type of general FunctionSpace are defined over the whole geometric region defined by domain. self.__S=escript.Tensor4(0,escript.Function(self.__domain)) #Tensor4 is similar to Tensor, which returns a Data object of shape (d,d,d,d) #simDEM part if self.__usepert: #here usepert=false, so this is not invoked. s = self.__pool.map(getStressTensor,self.__scenes) #getstresstensor is defined in simDEM, but here it is not invoked. t = self.__pool.map(getTangentOperator,zip(self.__scenes,repeat(pert)))#to get initial D and sigma for i in xrange(ng): self.__stress.setValueOfDataPoint(i,s[i]) self.__S.setValueOfDataPoint(i,t[i]) else: st = self.__pool.map(getStressAndTangent2D,self.__scenes) for i in xrange(ng): self.__stress.setValueOfDataPoint(i,st[i][0]) self.__S.setValueOfDataPoint(i,st[i][1])