Пример #1
0
 def test_basisSubsetGaussPoint(self):
     dim = 1
     numBasis = 2
     gaussPoints = [-1/np.sqrt(3),1/np.sqrt(3)]
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     basisSubset = geas.basisSubsetGaussPoint(0,0,dim,basisArray,mCount,mSize)
     self.assertEqual(basisSubset.tolist(), [[0.7886751345948128655,	-0.5],[0.211324865405187079,	0.5]])
     
     basisSubset = geas.basisSubsetGaussPoint(0,1,dim,basisArray,mCount,mSize)
     self.assertEqual(basisSubset.tolist(), [[0.21132486540518708, -0.5],[0.7886751345948129, 0.5]])
     
     dim = 2
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     basisSubset = geas.basisSubsetGaussPoint(0,0,dim,basisArray,mCount,mSize)
     self.assertEqual(basisSubset.tolist(), [[0.6220084679281462, -0.39433756729740643, -0.39433756729740643],
                      [0.16666666666666663, 0.39433756729740643, -0.10566243270259354],
                      [0.16666666666666663, -0.10566243270259354, 0.39433756729740643],
                      [0.044658198738520435, 0.10566243270259354, 0.10566243270259354]])
     basisSubset = geas.basisSubsetGaussPoint(0,1,dim,basisArray,mCount,mSize)
     self.assertEqual(basisSubset.tolist(), [[0.16666666666666663, -0.39433756729740643, -0.10566243270259354],
                      [0.6220084679281462, 0.39433756729740643, -0.39433756729740643],
                      [0.044658198738520435, -0.10566243270259354, 0.10566243270259354],
                      [0.16666666666666663, 0.10566243270259354, 0.39433756729740643]])
     basisSubset = geas.basisSubsetGaussPoint(2,0,dim,basisArray,mCount,mSize)
     self.assertEqual(basisSubset.tolist(), [[0.0, -0.0, -0.39433756729740643],
                      [0.0, 0.0, -0.10566243270259354],
                      [0.7886751345948129, -0.5, 0.39433756729740643],
                      [0.21132486540518708, 0.5, 0.10566243270259354]])
     basisSubset = geas.basisSubsetGaussPoint(2,1,dim,basisArray,mCount,mSize)
     self.assertEqual(basisSubset.tolist(), [[0.0, -0.0, -0.10566243270259354],
                      [0.0, 0.0, -0.39433756729740643],
                      [0.21132486540518708, -0.5, 0.10566243270259354],
                      [0.7886751345948129, 0.5, 0.39433756729740643]])
Пример #2
0
    def test_newtonRaph(self):
        dim = 2
        numEle = [2]*dim
        eleSize = [1]*dim
        numBasis = 2
        gaussPoints = [-1/np.sqrt(3),1/np.sqrt(3)]
        E = 1#modulus
        v = 0.0 #poisons ratio

        constit = nr.fint.constitAssemble(E,v,dim)
        (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints =gaussPoints)
        basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray, mCount, mSize) 
        (nodeCoords,eleNodesArray,edgeNodesArray) = mas.meshAssemble(numEle,eleSize)
        forceType = np.zeros([np.prod(numEle),np.sum(mCount)])
        forceType[[1,3],4] = 3
        forces = np.zeros([np.prod(numEle),np.sum(mCount)*dim])
        forces[[1,3],4*dim+0]=.5
        disp = np.zeros([len(nodeCoords[:,0]),dim])      
        constraintes = np.ones([len(nodeCoords[:,0]),dim]) 
        constraintes[0:9:3,:] = 0
    
        ui = nr.newtonRaph(dim,numEle,constit,gPArray,gWArray, 
                   mCount, mSize,basisArray,nodeCoords,eleNodesArray,forces,forceType,disp,constraintes)
        self.assertEqual(ui.tolist(),
                               [[  0.00000000e+00,   0.00000000e+00],
                               [  2.5000000000000006e-01,  -2.0816681711721685e-17],
                               [  5.00000000e-01,  -4.097430972836398e-17],
                               [  0.00000000e+00,   0.00000000e+00],
                               [  2.500000000000001e-01,  -2.270991192460361e-17],
                               [  5.000000000000001e-01,  -5.972088998909374e-17],
                               [  0.00000000e+00,   0.00000000e+00],
                               [  2.5000000000000006e-01,  -2.0809619091596192e-17],
                               [  5.000000000000001e-01,  -5.205264538381372e-17]])
        
        a = 1
Пример #3
0
 def test_basisArrayAssemble(self):
     dim = 1
     numBasis = 2
     gaussPoints = [-1/np.sqrt(3),1/np.sqrt(3)]
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     self.assertAlmostEqual(basisArray.tolist(),
                            [[0.7886751345948129, -0.5, 0.21132486540518708, -0.5],
                             [0.21132486540518708, 0.5, 0.7886751345948129, 0.5]])
     dim = 2
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray, mCount, mSize)
     self.assertTrue((np.around(basisArray,8)==
                            np.array([[ 0.62200847, -0.39433757, -0.39433757,  0.16666667, -0.39433757,
                                 -0.10566243,  0.16666667, -0.10566243, -0.39433757,  0.0446582 ,
                                 -0.10566243, -0.10566243,  0.78867513, -0.5       , -0.39433757,
                                  0.21132487, -0.5       , -0.10566243,  0.        , -0.        ,
                                 -0.39433757,  0.        , -0.        , -0.10566243,  0.78867513,
                                 -0.39433757, -0.5       ,  0.21132487, -0.10566243, -0.5       ,
                                  0.        , -0.39433757, -0.        ,  0.        , -0.10566243,
                                 -0.        ],
                                [ 0.16666667,  0.39433757, -0.10566243,  0.62200847,  0.39433757,
                                 -0.39433757,  0.0446582 ,  0.10566243, -0.10566243,  0.16666667,
                                  0.10566243, -0.39433757,  0.21132487,  0.5       , -0.10566243,
                                  0.78867513,  0.5       , -0.39433757,  0.        ,  0.        ,
                                 -0.10566243,  0.        ,  0.        , -0.39433757,  0.        ,
                                  0.39433757, -0.        ,  0.        ,  0.10566243, -0.        ,
                                  0.78867513,  0.39433757, -0.5       ,  0.21132487,  0.10566243,
                                 -0.5       ],
                                [ 0.16666667, -0.10566243,  0.39433757,  0.0446582 , -0.10566243,
                                  0.10566243,  0.62200847, -0.39433757,  0.39433757,  0.16666667,
                                 -0.39433757,  0.10566243,  0.        , -0.        ,  0.39433757,
                                  0.        , -0.        ,  0.10566243,  0.78867513, -0.5       ,
                                  0.39433757,  0.21132487, -0.5       ,  0.10566243,  0.21132487,
                                 -0.10566243,  0.5       ,  0.78867513, -0.39433757,  0.5       ,
                                  0.        , -0.10566243,  0.        ,  0.        , -0.39433757,
                                  0.        ],
                                [ 0.0446582 ,  0.10566243,  0.10566243,  0.16666667,  0.10566243,
                                  0.39433757,  0.16666667,  0.39433757,  0.10566243,  0.62200847,
                                  0.39433757,  0.39433757,  0.        ,  0.        ,  0.10566243,
                                  0.        ,  0.        ,  0.39433757,  0.21132487,  0.5       ,
                                  0.10566243,  0.78867513,  0.5       ,  0.39433757,  0.        ,
                                  0.10566243,  0.        ,  0.        ,  0.39433757,  0.        ,
                                  0.21132487,  0.10566243,  0.5       ,  0.78867513,  0.39433757,
                                  0.5       ]])).all())
Пример #4
0
 def test_basisSubsetAssemble(self):
     dim = 1
     numBasis = 2
     gaussPoints = [-1/np.sqrt(3),1/np.sqrt(3)]
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     basisSubsetGP = geas.basisSubsetAssemble(0,dim,basisArray,mCount,mSize,divDim = 0)
     self.assertEqual(basisSubsetGP.tolist(),[[0.7886751345948129, 0.21132486540518708], [0.21132486540518708, 0.7886751345948129]])
     
     dim = 2
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     basisSubsetGP = geas.basisSubsetAssemble(0,dim,basisArray,mCount,mSize,divDim = 0)
     self.assertEqual(basisSubsetGP.tolist(),[[0.6220084679281462,0.16666666666666663,0.16666666666666663,0.044658198738520435],
                      [0.16666666666666663,0.6220084679281462,0.044658198738520435,0.16666666666666663],
                      [0.16666666666666663,0.044658198738520435,0.6220084679281462,0.16666666666666663],
                      [0.044658198738520435,0.16666666666666663,0.16666666666666663,0.6220084679281462]])
     basisSubsetGP = geas.basisSubsetAssemble(2,dim,basisArray,mCount,mSize,divDim = 0)
     self.assertEqual(basisSubsetGP.tolist(),[[0.21132486540518708, 0.0],
                      [0.7886751345948129, 0.0],
                      [0.0, 0.7886751345948129],
                      [0.0, 0.21132486540518708]])
Пример #5
0
 def test_gaussJacobian(self):
     dim = 1
     numBasis = 2
     numEle = [1]*dim
     eleSize = [1]*dim
     gaussPoints = [-1/np.sqrt(3),1/np.sqrt(3)]
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     (nodeCoords,eleNodesArray,edgeNodesArray) = mas.meshAssemble(numEle,eleSize)
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     (intScalFact,hardCodedJac) = geas.gaussJacobian(0,0,0,dim,basisArray,mCount,mSize,nodeCoords,eleNodesArray)
     self.assertEqual(intScalFact,0.5)
     self.assertEqual(hardCodedJac.tolist(),[[0.5, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
     (intScalFact,hardCodedJac) = geas.gaussJacobian(0,0,1,dim,basisArray,mCount,mSize,nodeCoords,eleNodesArray)
     self.assertEqual(intScalFact,0.5)
     self.assertEqual(hardCodedJac.tolist(),[[0.5, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
     
     dim = 2
     numBasis = 2
     numEle = [1]*dim
     eleSize = [1]*dim
     gaussPoints = [-1/np.sqrt(3),1/np.sqrt(3)]
     (gPArray,gWArray, mCount, mSize) = gas.parEleGPAssemble(dim,gaussPoints,[1,1])
     (nodeCoords,eleNodesArray,edgeNodesArray) = mas.meshAssemble(numEle,eleSize)
     basisArray = bas.basisArrayAssemble(dim,numBasis,gaussPoints,gPArray,mCount, mSize)
     
     (intScalFact,hardCodedJac) = geas.gaussJacobian(0,0,0,dim,basisArray,mCount,mSize,nodeCoords,eleNodesArray)
     self.assertEqual(intScalFact,0.25)
     self.assertEqual(hardCodedJac.tolist(),[[0.5, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.0]])
     (intScalFact,hardCodedJac) = geas.gaussJacobian(0,0,1,dim,basisArray,mCount,mSize,nodeCoords,eleNodesArray)
     self.assertEqual(intScalFact,0.25)
     self.assertEqual(hardCodedJac.tolist(),[[0.5, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.0]])
     (intScalFact,hardCodedJac) = geas.gaussJacobian(0,0,3,dim,basisArray,mCount,mSize,nodeCoords,eleNodesArray)
     self.assertEqual(intScalFact,0.25)
     self.assertEqual(hardCodedJac.tolist(),[[0.5, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.0]])
     
     (intScalFact,hardCodedJac) = geas.gaussJacobian(1,0,0,dim,basisArray,mCount,mSize,nodeCoords,eleNodesArray)
     self.assertEqual(intScalFact,0.5)
     self.assertEqual(hardCodedJac.tolist(),[[0.5, 0.0, 0.0], [0.0, 0.5, 0.0], [0.0, 0.0, 0.0]])
Пример #6
0
        Fint[eleNodesArray[:, i], :] = Fa + Fint[eleNodesArray[:, i], :]
    return (Fint)

if __name__ == '__main__':
    dim = 2
    numEle = [2] * dim
    eleSize = [1] * dim
    numBasis = 2
    gaussPoints = [-1 / np.sqrt(3), 1 / np.sqrt(3)]
    E = 200 * 10**9  #modulus
    v = 0  #poisons ratio

    #gaussPoints = [-1,1]
    (gPArray, gWArray, mCount,
     mSize) = gas.parEleGPAssemble(dim, gaussPoints=gaussPoints)
    basisArray = bas.basisArrayAssemble(dim, numBasis, gaussPoints, gPArray,
                                        mCount, mSize)

    (nodeCoords, eleNodesArray,
     edgeNodesArray) = mas.meshAssemble(numEle, eleSize)

    disp = np.zeros([len(nodeCoords[:, 0]), dim]) * 0

    disp[0:9:3, :] = 0
    #    disp[1:9:3,:] = .05
    disp[2:9:3, 0] = .1

    constit = constitAssemble(E, v, dim)

    Fin = fintAssemble(dim, numEle, gWArray, mCount, mSize, basisArray,
                       nodeCoords, eleNodesArray, constit, disp)