コード例 #1
0
def createSolidForceBVFields(pd):
    pd.bForceXField = fvmbaseExt.Field('bForceX')
    pd.bForceYField = fvmbaseExt.Field('bForceY')
    pd.bForceZField = fvmbaseExt.Field('bForceZ')
    bcMap = pd.smodel.getBCMap()
    for smesh in pd.solidMeshes:
        fgs = smesh.getAllFaceGroups()
        for fg in fgs:
            if fg.groupType != 'interior':
                bc = bcMap[fg.id]
                if bc.bcType == 'SpecifiedForce':
                    sfaces = fg.site
                    faceCount = sfaces.getCount()
                    areaMag = pd.geomFields.areaMag[sfaces]
                    fx = areaMag.newSizedClone(faceCount)
                    fy = areaMag.newSizedClone(faceCount)
                    fz = areaMag.newSizedClone(faceCount)
                    fxa = fx.asNumPyArray()
                    fya = fy.asNumPyArray()
                    fza = fz.asNumPyArray()
                    fxa[:] = 0
                    fya[:] = 0
                    fza[:] = 0
                    pd.bForceXField[sfaces] = fx
                    pd.bForceYField[sfaces] = fy
                    pd.bForceZField[sfaces] = fz
                    bc['specifiedXForce'] = pd.bForceXField
                    bc['specifiedYForce'] = pd.bForceYField
                    bc['specifiedZForce'] = pd.bForceZField
コード例 #2
0
ファイル: ServerCoupling.py プロジェクト: wuhao1938/fvm
 def createSolidForceBVFields(self):
     self.bForceXField = fvmbaseExt.Field('bForceX')
     self.bForceYField = fvmbaseExt.Field('bForceY')
     self.bForceZField = fvmbaseExt.Field('bForceZ')
     bcMap = self.solidModel.getBCMap()
     fgs = self.solidMesh.getBoundaryFaceGroups()
     for fg in fgs:
         bc = bcMap[fg.id]
         if bc.bcType == 'SpecifiedForce':
             sfaces = fg.site
             faceCount = sfaces.getCount()
             areaMag = self.geomField.areaMag[sfaces]
             fxA = areaMag.newSizedClone(faceCount)
             fyA = areaMag.newSizedClone(faceCount)
             fzA = areaMag.newSizedClone(faceCount)
             fx = fxA.asNumPyArray()
             fy = fyA.asNumPyArray()
             fz = fzA.asNumPyArray()
             fx[:] = 0
             fy[:] = 0
             fz[:] = 0
             self.bForceXField[sfaces] = fxA
             self.bForceYField[sfaces] = fyA
             self.bForceZField[sfaces] = fzA
             bc['specifiedXForce'] = self.bForceXField
             bc['specifiedYForce'] = self.bForceYField
             bc['specifiedZForce'] = self.bForceZField
コード例 #3
0
def createBV7Fields(geomFields,meshes,id):
    fxx7 = fvmbaseExt.Field('bvxx7')
    fxy7 = fvmbaseExt.Field('bvxy7')
    fyy7 = fvmbaseExt.Field('bvyy7')
    fxz7 = fvmbaseExt.Field('bvxz7')
    fyz7 = fvmbaseExt.Field('bvyz7')
    
    mesh = meshes[0]
    vol = geomFields.volume[mesh.getCells()]
    
    for mesh in meshes:
        fgs = mesh.getBoundaryGroups()
        for fg in fgs:
            if fg.id==7:                                
                nFaces = fg.site.getCount()
            
                sigmaXX = vol.newSizedClone(nFaces)
                sigmaXY = vol.newSizedClone(nFaces)
                sigmaYY = vol.newSizedClone(nFaces)
                sigmaXZ = vol.newSizedClone(nFaces)
                sigmaYZ = vol.newSizedClone(nFaces)

                sigmaXXa = sigmaXX.asNumPyArray()
                sigmaXYa = sigmaXY.asNumPyArray()
                sigmaYYa = sigmaYY.asNumPyArray()
                sigmaXZa = sigmaXZ.asNumPyArray()
                sigmaYZa = sigmaYZ.asNumPyArray()

                xf =  geomFields.coordinate[fg.site].asNumPyArray()
                a = 0.5
                tractionX = 10000.

                for i in range(0,nFaces):
                    x = xf[i][0]
                    y = xf[i][1]
                    r = math.sqrt(x*x+y*y)
                    theta = math.atan(y/x)

                    term1 = 1.0
                    term2 = ((a*a)/(r*r))*((3./2.)*math.cos(2.*theta)+math.cos(4.*theta))
                    term3 = (3./2.)*(math.pow(a,4.)/math.pow(r,4.))*math.cos(4.*theta)

                    term4 = ((a*a)/(r*r))*(0.5*math.cos(2.*theta)-math.cos(4.*theta))
                    term5 = 1.5*(math.pow(a,4.)/math.pow(r,4.))*math.cos(4.*theta)

                    term6 = ((a*a)/(r*r))*(0.5*math.sin(2.*theta)+math.sin(4.*theta))
                    term7 = (3./2.)*(math.pow(a,4.)/math.pow(r,4.))*math.sin(4.*theta)

                    sigmaXXa[i] = tractionX*(term1-term2+term3)
                    sigmaYYa[i] = tractionX*(-term4-term5)
                    sigmaXYa[i] = tractionX*(-term6+term7)
                    sigmaXZa[i] = 0.0
                    sigmaYZa[i] = 0.0
                    
                fxx7[fg.site] = sigmaXX
                fxy7[fg.site] = sigmaXY
                fyy7[fg.site] = sigmaYY
                fxz7[fg.site] = sigmaXZ
                fyz7[fg.site] = sigmaYZ
                return fxx7,fxy7,fyy7,fxz7,fyz7
コード例 #4
0
def createBVFields(geomFields, meshes):
    fx = fvmbaseExt.Field('bvx')
    fy = fvmbaseExt.Field('bvy')
    fz = fvmbaseExt.Field('bvz')

    mesh = meshes[0]
    vol = geomFields.volume[mesh.getCells()]

    for mesh in meshes:
        fgs = mesh.getBoundaryGroups()
        for fg in fgs:
            nFaces = fg.site.getCount()

            xvel = vol.newSizedClone(nFaces)
            yvel = vol.newSizedClone(nFaces)
            zvel = vol.newSizedClone(nFaces)

            xvela = xvel.asNumPyArray()
            yvela = yvel.asNumPyArray()
            zvela = zvel.asNumPyArray()

            xf = geomFields.coordinate[fg.site].asNumPyArray()

            a = 10.0
            U0 = 0.001

            for i in range(0, nFaces):
                x = xf[i][0]
                y = xf[i][1]
                z = xf[i][2]

                r = sqrt(x * x + y * y + z * z)
                alfa = acos(z / r)
                beta = atan2(y, x)

                Ur = U0 * cos(alfa) * (1 - 1.5 * a / r +
                                       0.5 * pow(a, 3) / pow(r, 3))
                Ualfa = -U0 * sin(alfa) * (1 - 0.75 * a / r -
                                           0.25 * pow(a, 3) / pow(r, 3))

                xvela[i] = Ur * sin(alfa) * cos(beta) + Ualfa * cos(
                    alfa) * cos(beta)
                yvela[i] = Ur * sin(alfa) * sin(beta) + Ualfa * cos(
                    alfa) * sin(beta)
                zvela[i] = Ur * cos(alfa) - Ualfa * sin(alfa)

            #pdb.set_trace()

            fx[fg.site] = xvel
            fy[fg.site] = yvel
            fz[fg.site] = zvel

    return fx, fy, fz
コード例 #5
0
def createBVFields(geomFields, meshes, id):
    fy = fvmbaseExt.Field('bvy')

    mesh = meshes[0]
    vol = geomFields.volume[mesh.getCells()]

    for mesh in meshes:
        fgs = mesh.getBoundaryGroups()
        for fg in fgs:
            if fg.id == id:
                nFaces = fg.site.getCount()
                forceY = vol.newSizedClone(nFaces)
                forceYa = forceY.asNumPyArray()
                xf = geomFields.coordinate[fg.site].asNumPyArray()

                pot_top = 10.0
                pot_bot = 0.0
                len = 400.e-6
                gap = 3.75e-6
                perm = 8.8542e-12
                dpot = (pot_top - pot_bot) / gap
                sigmat = -perm * dpot
                felec = (sigmat * sigmat) * len / (2. * perm)
                felecPerUnitLen = -felec / (len)
                print '\n electric force per unit length = %f' % (
                    felecPerUnitLen)

                for i in range(0, nFaces):
                    forceYa[i] = felecPerUnitLen
                    print '\n force %f %f %f' % (xf[i, 0], xf[i,
                                                              1], forceYa[i])
                fy[fg.site] = forceY
                return fy
コード例 #6
0
ファイル: ServerCoupling.py プロジェクト: wuhao1938/fvm
    def update(self):
        timeStep = self.solidModel.getOptions().getVar("timeStep")
        #get new coordinates of bMesh
        coordA = self.solidMesh.getUpdatedNodesCoordCoupling(
            self.geomField, self.solidBoundaryMesh)
        coord = coordA.asNumPyArray()
        self.nfaces = len(coord)
        #self.dumpSolidBoundaryCoord(coord,MPI.COMM_WORLD.Get_rank())
        recvbuf = coord.copy()
        #sending coordinate to client side as summing
        self.SERVER_COMM_CLIENT.Allreduce([coord, MPI.DOUBLE],
                                          [recvbuf, MPI.DOUBLE],
                                          op=MPI.SUM)

        #now sending velocities
        vField = fvmbaseExt.Field("velocity")
        self.deformationModel.updateBoundaryMesh(
            self.solidMesh, self.solidBoundaryMesh, vField,
            self.solidMesh.getCommonFacesMap(), timeStep)
        velA = vField[self.solidBoundaryMesh.getFaces()]
        vel = velA.asNumPyArray()
        #sending velocity to client side as summing (recvbuf is dummy, we use previous one)
        self.SERVER_COMM_CLIENT.Allreduce([vel, MPI.DOUBLE],
                                          [recvbuf, MPI.DOUBLE],
                                          op=MPI.SUM)
コード例 #7
0
    def setup(self):
         self.dt       = zeros(1,float)
         self.dtClient = zeros(1,float)
       
         self.procID = MPI.COMM_WORLD.Get_rank()
         #connect to server first get parent and port name then connect to port name
         self.PARENT = MPI.Comm.Get_parent()
         assert self.PARENT != MPI.COMM_NULL
	 assert MPI.COMM_WORLD.Get_size() == 1
         self.portName = str(0) 
         #print " ServerSide: self.portName = ", self.portName 
         #print " ServerSide: self.portName = ", self.portName.tostring();
          #get port name from parent (sent by MPM)
         if  self.procID == 0:
	   self.portName = MPI.Open_port(MPI.INFO_NULL)
           print " Server Side: self.portName = ", self.portName 
	   print "type= ", type(self.portName)
           self.PARENT.send(self.portName, dest=0, tag=7776)
         #print " Server Side: self.portName = ", self.portName.tostring();
         #Connect this port
         self.SERVER_COMM_CLIENT = MPI.COMM_WORLD.Accept(self.portName, MPI.INFO_NULL, root=0) 
         self.remoteSize   = self.SERVER_COMM_CLIENT.Get_remote_size()
        
	 #get coordinate from goemField
         self.coordA = self.solidBoundaryMesh.getNodeCoordinatesPtr()
         self.coord  = self.coordA.asNumPyArray()
	 self.coordRecvBuf = self.coord.copy() 
#         self.coordA  = self.geomFields.coordinate[self.solidBoundaryMesh.getNodes()]
#         self.coord   = self.coordA.asNumPyArray()
#         self.sendBuf = self.coord.copy()


	 #velocity field, adding face velocities
	 self.vField = fvmbaseExt.Field("velocity")
	 self.faces  = self.solidBoundaryMesh.getFaces()
	 self.nfaces = self.faces.getCount()
	 area  = self.geomField.area[self.faces]

         #initialize force to zero	
	 solidCells = self.solidMesh.getCells()
         forcePlate = self.plateField.force[solidCells].asNumPyArray() 
         forcePlate[:] = 0.0
	 thickness = self.plateField.thickness[solidCells].asNumPyArray()
         thickness[:] = self.thickness

         #ading 
         self.forceA  = area.newSizedClone(self.nfaces)
	 self.force   = self.forceA.asNumPyArray()
	 self.sendForceBuf = self.force.copy()
	 if not MPI.COMM_WORLD.Get_rank():
   	     print "from ServerSide, reporting remoteSize = ", self.remoteSize
コード例 #8
0
def createBVFields(geomFields, meshes, id, eid, structureFields,
                   electricFields):
    fy = fvmbaseExt.Field('bvy')

    mesh0 = meshes[0]
    mesh1 = meshes[1]
    vol = geomFields.volume[mesh0.getCells()]

    deflection = structureFields.deformation[mesh0.getCells()].asNumPyArray()
    fgs0 = mesh0.getBoundaryGroups()
    fgs1 = mesh1.getBoundaryGroups()
    for fg1 in fgs1:
        if fg1.id == eid:
            ewall = fg1.site
    bArea = geomFields.area[ewall].asNumPyArray().copy()
    bpflux = electricFields.potential_flux[ewall].asNumPyArray()
    for fg in fgs0:
        if fg.id == id:

            faceCells = mesh.getFaceCells(fg.site)
            nFaces = fg.site.getCount()
            forceY = vol.newSizedClone(nFaces)
            forceYa = forceY.asNumPyArray()
            xf = geomFields.coordinate[fg.site].asNumPyArray()

            pot_top = sPot
            pot_bot = 0.0
            bSurface = -3.75e-6
            perm = 8.8542e-12

            for i in range(0, nFaces):
                c0 = faceCells(i, 0)
                gap = deflection[c0, 1] - bSurface
                #                dpot = (pot_top-pot_bot)/gap
                magBArea = math.sqrt(bArea[i][0] * bArea[i][0] +
                                     bArea[i][1] * bArea[i][1] +
                                     bArea[i][2] * bArea[i][2])
                dpot = bpflux[i] / magBArea
                sigmat = -perm * dpot
                felec = -(sigmat * sigmat) / (2. * perm)
                forceYa[i] = felec
#                print 'force %f %f %f %e %e %e' % (xf[i,0],xf[i,1],forceYa[i],bpflux[i],dpot,magBArea)
            fy[fg.site] = forceY
            return fy
コード例 #9
0
def createBV4Fields(geomFields,meshes,id):
    fy = fvmbaseExt.Field('bvy')
    
    mesh = meshes[0]
    vol = geomFields.volume[mesh.getCells()]
    
    for mesh in meshes:
        fgs = mesh.getBoundaryGroups()
        for fg in fgs:
            xf =  geomFields.coordinate[fg.site].asNumPyArray()
            if fg.id==id:
                nFaces = fg.site.getCount()
                forceY = vol.newSizedClone(nFaces)
                forceYa = forceY.asNumPyArray()
                xf =  geomFields.coordinate[fg.site].asNumPyArray()
                for i in range(0,nFaces):
                    forceYa[i]=-1000./0.2
                fy[fg.site] = forceY
                return fy
コード例 #10
0
solidBoundaryMetricsCalculator.init()

### output files
probeFile = open(fileBase_output + "centerDisplacement.dat", "w")
forceFile = open(fileBase_output + "force.dat", "w")

### electric model and boundary condition ###

elecFields = models.ElectricFields('elec')

emodel = models.ElectricModelA(geomFields, elecFields, fluidMeshes)

bcMap = emodel.getBCMap()

### specify a potential field; use it as boundary condition
pf = fvmbaseExt.Field('potential')
fgs = fluidMeshes[0].getBoundaryFaceGroups()
for fg in fgs:
    if fg.id == fluidBot:
        faces = fg.site
        nFaces = faces.getCount()
        areaMag = geomFields.areaMag[faces]
        xf = geomFields.coordinate[faces].asNumPyArray()
        pot = areaMag.newSizedClone(nFaces)
        pota = pot.asNumPyArray()
        for f in range(0, nFaces):
            x = xf[f][0]
            y = xf[f][1]
            z = xf[f][2]
            if x >= 100e-6 and x <= 150e-6 and y >= -15e-6 and y <= 15e-6:
                pota[f] = applied_voltage