def __init__(self,domain,dim,ng=1,useMPI=False,np=1,rho=2.35e3,mIds=False,\
              FEDENodeMap=False,DE_ext=False,FEDEBoundMap=False,conf=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 rho: type float, density of material
   :param mIds: a list contains membrane node IDs
   :param FEDENodeMap: a dictionary with FE and DE boundary node IDs in keys and values
   :param DE_ext: name of file which saves initial state of exterior DE domain
   :param FEDEBoundMap: a dictionary with FE and DE boundary element IDs in keys and values (deprecated)
   :param conf: type float, conf pressure on membrane
   """
     self.__domain = domain
     self.__pde = LinearPDE(self.__domain,
                            numEquations=dim,
                            numSolutions=dim)
     self.__pde.getSolverOptions().setSolverMethod(
         SolverOptions.HRZ_LUMPING)
     self.__pde.setSymmetryOn()
     self.__numGaussPoints = ng
     self.__rho = rho
     self.__mIds = mIds
     self.__FEDENodeMap = FEDENodeMap
     self.__FEDEBoundMap = FEDEBoundMap
     self.__conf = conf
     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.__u = escript.Vector(0, escript.Solution(self.__domain))
     self.__u_last = escript.Vector(0, escript.Solution(self.__domain))
     self.__u_t = escript.Vector(0, escript.Solution(self.__domain))
     self.__dt = 0
     # ratio between timesteps in internal DE and FE domain
     self.__nsOfDE_int = 1
     # if FEDENodeMap is given, employ exterior DE domain
     if self.__FEDENodeMap:
         self.__sceneExt = self.__pool.apply(initLoadExt, (DE_ext, ))
         # ratio between timesteps in external DE and FE domain
         self.__nsOfDE_ext = 1
         # get interface nodal forces as boundary condition
         self.__FEf = self.__pool.apply(
             initNbc, (self.__sceneExt, self.__conf, mIds, FEDENodeMap))
         """
      # get interface nodal tractions as boundary condition (deprecated)
      self.__Nbc=escript.Vector(0,escript.Solution(self.__domain))
      FENbc = self.__pool.apply(initNbc,(self.__sceneExt,self.__conf,mIds,FEDENodeMap))
      for FEid in FENbc.keys():
         self.__Nbc.setValueOfDataPoint(FEid,FENbc[FEid])
      """
     # get stress tensor at material points
     s = self.__pool.map(getStress2D, self.__scenes)
     for i in xrange(ng):
         self.__stress.setValueOfDataPoint(i, s[i])
Beispiel #2
0
    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
Beispiel #3
0
    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])
Beispiel #4
0
    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])
Beispiel #5
0
 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])
Beispiel #6
0
 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 applyStrain_getStressDEM(self, st=escript.Data(), dynRelax=False):
     st = st.toListOfTuples()
     st = numpy.array(st).reshape(-1, 4)
     stress = escript.Tensor(0, escript.Function(self.__domain))
     # load DEM packing with strain
     scenes = self.__pool.map(
         shear2D, zip(self.__scenes, st, self.__nsOfDE_int,
                      repeat(dynRelax)))
     # return homogenized stress
     s = self.__pool.map(getStress2D, scenes)
     for i in xrange(self.__numGaussPoints):
         stress.setValueOfDataPoint(i, s[i])
     return stress, scenes
Beispiel #8
0
 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??
Beispiel #9
0
 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
Beispiel #10
0
 def getLocalFabric(self):
     fabric = escript.Tensor(0, escript.Function(self.__domain))
     f = self.__pool.map(getFabric, self.__scenes)
     for i in xrange(self.__numGaussPoints):
         fabric.setValueOfDataPoint(i, f[i])
     return fabric