BoxFactory in OpenFOAM coupling case

Asked by Daria

I'm trying to use BoxFactory in YADE OpenFOAM coupling case. But there is an error on OpenFOAM side. I think that I use incorrect fluid coupling settings. There is my scriptYade.py:

##############################
from __future__ import print_function
import sys
from yadeimport import *
from yade.wrapper import *
from yade.utils import *

initMPI() #Initialize the mpi environment, always required.
fluidCoupling = yade.FoamCoupling(); #Initialize the engine
fluidCoupling.getRank(); #part of Initialization.

#example of spheres in shear flow : two-way point force coupling
class simulation():

 def __init__(self):
  O.periodic = True
  O.cell.setBox(1,0.4,0.2)

  numspheres=1000
  young = 1e10#5e6
  young_steel = 2e11
  density = 2#2000
  density_steel = 7700
  poisson = 0.3#0.5
  normalCohesion = 1e7
  shearCohesion = 1e7
  frictionAngle = radians(15)

  mat1 = CohFrictMat(normalCohesion=normalCohesion, shearCohesion=shearCohesion, young=young, poisson=poisson, frictionAngle=frictionAngle, density=density, momentRotationLaw=True, label='spheremat')
  O.materials.append(mat1)
  mat2 = CohFrictMat(normalCohesion=normalCohesion, shearCohesion=shearCohesion, young=young_steel, poisson=poisson, frictionAngle=frictionAngle, density=density_steel, momentRotationLaw=True, label='wallmat')
  O.materials.append(mat2)

  epsilon = 1e-08
  minval = 0 + epsilon
  maxx = 1.0 - epsilon
  maxy = 0.4 - epsilon
  maxz = 0.2 - epsilon
  #wall coords, use facets for wall BC:
  v0 = Vector3(minval, minval, minval)
  v1 = Vector3(minval,minval,maxz)
  v2 = Vector3(maxx,minval,minval)
  v3 = Vector3(maxx,minval,maxz)

  v4 = Vector3(minval,maxy,minval)
  v5 = Vector3(minval,maxy,maxz)
  v6 = Vector3(maxx,maxy,minval)
  v7 = Vector3(maxx, maxy, maxz)

  lf0 = facet(vertices=[v0,v1,v2], material='wallmat')
  O.bodies.append(lf0)
  lf1 = facet(vertices=[v1,v2,v3], material='wallmat')
  O.bodies.append(lf1)

  uf0 = facet(vertices=[v4,v5,v6], material='wallmat')
  O.bodies.append(uf0)
  uf1 = facet(vertices=[v5,v6,v7], material='wallmat')
  O.bodies.append(uf1)

  ff0 = facet(vertices=[v0,v2,v6], material='wallmat')
  O.bodies.append(ff0)
  ff1 = facet(vertices=[v0,v6,v4], material='wallmat')
  O.bodies.append(ff1)

  bf0 = facet(vertices=[v1,v3,v7], material='wallmat')
  O.bodies.append(bf0)
  bf1 = facet(vertices=[v1,v7,v5], material='wallmat')
  O.bodies.append(bf1)

  oriBody = Quaternion(Vector3(1,0,0),(0))
  radius = 0.051
  O.bodies.append(geom.facetCylinder((0.5,0.2,0.1), radius=radius, height=0.2, orientation=oriBody, segmentsNumber=100, wallMask=4, material='wallmat'))

  # Integrator
  newton=NewtonIntegrator(damping=0.0, gravity = (0.0 ,0.0, 0.0))
  # add small damping in case of stability issues.. ~ 0.1 max, also note : If gravity is needed, set it in constant/g dir.

  O.timingEnabled==True

  O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()], allowBiggerThanPeriod=True),
   InteractionLoop(
    [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom6D()],
    [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=True)],
    [Law2_ScGeom6D_CohFrictPhys_CohesionMoment()]
   ),
   GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.3, label = "ts"),
   fluidCoupling, #to be called after timestepper
   PyRunner(command='sim.printMessage()', iterPeriod= 1, label='outputMessage'),
   newton,
   PyRunner(command='sim.particleFlow()', iterPeriod= 1, label='particleFlow'),
   DomainLimiter(lo=(-30e-3,-30e-3,0),hi=(30e-3,30e-3,60e-3),iterPeriod=200),
   VTKRecorder(fileName='yadep/3d-vtk-',recorders=['spheres', 'facets', 'intr', 'force'],virtPeriod=0.1)
  ]

 def particleFlow(self):
  bf = BoxFactory(maxParticles=10000,extents=(0,0.4,0.2),center=(0,0.2,0.1),rMin=0.001,rMax=0.003,vMin=100,vMax=100,vAngle=0,massFlowRate=1000,normal=(0,1.5,-1),label='factory',materialId='spheremat')
  O.bodies.append([sphere(center,rad,material='spheremat') for center,rad in bf])
  sphereIDs = [b.id for b in O.bodies if type(b.shape)==Sphere]
  fluidCoupling.setNumParticles(len(sphereIDs))
  fluidCoupling.setIdList(sphereIDs)
  fluidCoupling.isGaussianInterp=False

 def printMessage(self):
  print("********************************YADE-ITER = " + str(O.iter) +" **********************************")
  print("********************************YADE-TIME = " + str(O.time) +" **********************************")

 def irun(self,num):
  O.run(num,1)

if __name__=="__main__":
 sim = simulation()
 sim.irun(10000000)
 fluidCoupling.killMPI()

import builtins
builtins.sim=sim

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.