示例#1
0
    def runTest(self):
        width = 100.
        height = 100.
        length = 200.
        numElementsX = 4
        numElementsY = 2
        numElementsZ = 2

        # create three-dimensional structure
        structure = nuto.Structure(3)

        nuto.MeshGenerator.Grid(structure, [length, width, height],
                                [numElementsX, numElementsY, numElementsZ])

        initialElements = structure.GetNumElements()
        initialNodes = structure.GetNumNodes()

        structure.ElementDelete(0)
        structure.NodeDelete(0)

        structure.ElementDelete(numElementsX)
        structure.NodeDelete(numElementsX + 1)
        structure.NodeDelete(2 * (numElementsX + 1))

        numNodes = structure.GetNumNodes()
        numElements = structure.GetNumElements()

        self.assertEqual(numElements, initialElements - 2)
        self.assertEqual(numNodes, initialNodes - 3)
示例#2
0
    def setUp(self):
        self.s = nuto.Structure(1)
        self.s.SetNumTimeDerivatives(2)
        self.s.SetShowTime(False)
        self.s.SetVerboseLevel(7)  # sounds about right

        mesh_info = nuto.MeshGenerator_Grid(self.s, [2.], [25])
        self.s.InterpolationTypeAdd(mesh_info[1], "ElectricPotential",
                                    "Lobatto4")
        self.s.ElementTotalConvertToInterpolationType()

        law_id = self.s.ConstitutiveLawCreate("Linear_Dielectric")
        dielectric_tensor = np.eye(3)
        self.s.ConstitutiveLawSetParameterMatrixDouble(law_id,
                                                       "Dielectric_Tensor",
                                                       -dielectric_tensor)
        self.s.ElementTotalSetConstitutiveLaw(law_id)
        self.s.ElementTotalSetSection(nuto.SectionTruss_Create(12.))
        self.s.AddVisualizationComponent(self.s.GroupGetElementsTotal(),
                                         "ElectricPotential")

        n = self.s.NodeGetAtCoordinate(0)
        self.s.Constraints().Add(nuto.eDof_ELECTRICPOTENTIAL,
                                 nuto.Value(n, self.load))

        self.rk4 = nuto.RungeKutta4(self.s)
        self.rk4.SetTimeStep(0.01)
        self.rk4.SetShowTime(False)
示例#3
0
    def setUp(self):
        self.structure = nuto.Structure(3)
        self.structure.SetNumTimeDerivatives(1)

        _, interpolation = nuto.MeshGenerator.Grid(self.structure,
                                                   [1.0, 1.0, 1.0], [1, 1, 1])

        SetConstitutiveLaw(self.structure)

        self.structure.InterpolationTypeAdd(interpolation, "Displacements",
                                            "Equidistant2")
        self.structure.InterpolationTypeAdd(interpolation, "Nonlocaleqstrain",
                                            "Equidistant1")
        self.structure.ElementTotalConvertToInterpolationType()

        SetBCs(self.structure)

        force_application = np.array([[0, 0], [1.0, 1.0]])

        newmark = nuto.NewmarkDirect(self.structure)
        newmark.SetTimeDependentLoadCase(0, force_application)
        newmark.SetPerformLineSearch(True)
        newmark.SetTimeStep(1.0)
        newmark.PostProcessing().SetResultDirectory("./NonlinearLoadOut", True)
        newmark.Solve(1.0)
示例#4
0
    def setUp(self):
        # create structure
        self.structure = nuto.Structure(3)

        # create nodes
        node1 = self.structure.NodeCreate(np.array([-1., -1., -1.]))
        node2 = self.structure.NodeCreate(np.array([+1., -1., -1.]))
        node3 = self.structure.NodeCreate(np.array([+1., +1., -1.]))
        node4 = self.structure.NodeCreate(np.array([-1., +1., -1.]))
        node5 = self.structure.NodeCreate(np.array([-1., -1., +1.]))
        node6 = self.structure.NodeCreate(np.array([+1., -1., +1.]))
        node7 = self.structure.NodeCreate(np.array([+1., +1., +1.]))
        node8 = self.structure.NodeCreate(np.array([-1., +1., +1.]))

        # create interpolation type
        interpolationType = self.structure.InterpolationTypeCreate("Brick3D")
        self.structure.InterpolationTypeAdd(interpolationType, "coordinates",
                                            "equidistant1")
        self.structure.InterpolationTypeAdd(interpolationType, "displacements",
                                            "equidistant1")

        # create element
        nodeIds = [node1, node2, node3, node4, node5, node6, node7, node8]
        self.element = self.structure.ElementCreate(interpolationType, nodeIds)
        self.structure.ElementTotalConvertToInterpolationType()

        # create constitutive law
        material = self.structure.ConstitutiveLawCreate(
            "Linear_Elastic_Engineering_Stress")
        self.structure.ConstitutiveLawSetParameterDouble(
            material, "Youngs_Modulus", 10)
        self.structure.ConstitutiveLawSetParameterDouble(
            material, "Poissons_Ratio", 0.25)

        # assign constitutive law
        self.structure.ElementSetConstitutiveLaw(self.element, material)

        # set displacements of right node
        self.structure.NodeSetDisplacements(node2, np.array([0.2, 0.2, 0.2]))
        self.structure.NodeSetDisplacements(node3, np.array([0.2, 0.2, 0.2]))
        self.structure.NodeSetDisplacements(node6, np.array([0.2, 0.2, 0.2]))
        self.structure.NodeSetDisplacements(node7, np.array([0.2, 0.2, 0.2]))

        # make group of boundary nodes
        self.groupBoundaryNodes = self.structure.GroupCreate("Nodes")
        self.structure.GroupAddNode(self.groupBoundaryNodes, node1)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node4)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node5)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node8)

        # make group of boundary elements (in this case it is just one
        self.groupBoundaryElements = self.structure.GroupCreate("Elements")
        self.structure.GroupAddElementsFromNodes(self.groupBoundaryElements,
                                                 self.groupBoundaryNodes,
                                                 False)
示例#5
0
def Run(BCType):
    # create one-dimensional structure
    structure = nuto.Structure(1)

    SetupGeometry(structure)
    SetupMaterial(structure)
    SetupBoundaryConditions(structure, BCType)

    Solve(structure)

    Visualize(structure, "Truss1D2N_" + BCType + ".vtk")
示例#6
0
    def test3DVolume(self):
        meshSize = 5.0
        geoFile = resultDir + "/3D.geo"
        self.spheres.ExportParticlesToGmsh3D(geoFile, self.box, meshSize)
        mshFile = mesh(geoFile, 3)
        structure = nuto.Structure(3)
        groups = structure.ImportFromGmsh(mshFile)

        boxVolume = (2 * self.a)**3
        sphereVolume = 4.0 / 3.0 * math.pi * self.r**3
        meshedVolumeMatrix = structure.ElementGroupGetVolume(groups[0][0])
        meshedVolumeSphere = structure.ElementGroupGetVolume(groups[1][0])
        self.assertAlmostEqual(meshedVolumeMatrix,
                               boxVolume - sphereVolume,
                               delta=4)
        self.assertAlmostEqual(self.box.GetVolume(), boxVolume)
        self.assertAlmostEqual(meshedVolumeSphere, sphereVolume, delta=4)
        self.assertAlmostEqual(self.spheres.GetVolume(), sphereVolume)
示例#7
0
    def test2DSomething(self):
        meshSize = 5.0
        geoFile = resultDir + "/2D.geo"
        zPlane = 0.0
        minRadius = 1.0
        self.spheres.ExportParticlesToGmsh2D(geoFile, self.box, meshSize,
                                             zPlane, minRadius)
        mshFile = mesh(geoFile, 2)
        structure = nuto.Structure(2)
        groups = structure.ImportFromGmsh(mshFile)

        rectangleArea = (2 * self.a)**2
        circleArea = math.pi * self.r**2
        meshedVolumeMatrix = structure.ElementGroupGetVolume(groups[0][0])
        meshedVolumeCircle = structure.ElementGroupGetVolume(groups[1][0])
        self.assertAlmostEqual(meshedVolumeMatrix,
                               rectangleArea - circleArea,
                               delta=1)
        self.assertAlmostEqual(meshedVolumeCircle, circleArea, delta=1)
示例#8
0
    def __init__(self, interpolationOrder, integrationOrder):
        self.lx = 42.
        self.ly = 13.
        self.lz = 73.
        self.rho = 0.6174

        self.s = nuto.Structure(1)
        self.s.SetShowTime(False)
        meshInfo = nuto.MeshGenerator.Grid(self.s, [self.lx], [1])
        self.s.InterpolationTypeAdd(meshInfo[1], "Displacements", GetInterpolationType(interpolationOrder)) 
        self.s.InterpolationTypeSetIntegrationType(meshInfo[1], GetIntegrationType(integrationOrder))

        section = nuto.SectionTruss.Create(self.ly * self.lz)

        lawId = self.s.ConstitutiveLawCreate("Linear_Elastic_Engineering_Stress");
        self.s.ConstitutiveLawSetParameterDouble(lawId, "Youngs_Modulus", 41)
        self.s.ConstitutiveLawSetParameterDouble(lawId, "Density", self.rho)

        self.s.ElementTotalConvertToInterpolationType()
        self.s.ElementTotalSetSection(section)
        self.s.ElementTotalSetConstitutiveLaw(lawId)
示例#9
0
def SetupStructure(dimension):
    assert (dimension in [1, 2, 3])
    structure = nuto.Structure(dimension)

    if dimension == 1:
        structure = OneDimensional(structure)
    elif dimension == 2:
        structure = TwoDimensional(structure)
    else:
        structure = ThreeDimensional(structure)

    # create material law
    conductivity = 1.0
    material = structure.ConstitutiveLawCreate("Heat_Conduction")
    structure.ConstitutiveLawSetParameterDouble(material,
                                                "Thermal_Conductivity",
                                                conductivity)

    structure.ElementTotalConvertToInterpolationType()
    structure.ElementTotalSetConstitutiveLaw(material)

    return structure
示例#10
0
    def testVolumes(self):
        r = 10.0
        h = 20.0
        boundingBox = np.array([[-r, r], [-r, r], [0.0, h]])
        # the magic number "2" here means cylinder specimen
        # the interface is not my fault
        cylinder = nuto.Specimen(boundingBox, 2)
        r_sphere = 5.0
        sphereArray = np.array([[0.0, 0.0, h / 2.0, r_sphere]])
        sphere = nuto.ParticleHandler(sphereArray, 0, 0, 0)
        geoFile = os.path.join(resultDir, "cylinder.geo")
        sphere.ExportParticlesToGmsh3D(geoFile, cylinder, r / 4.0)
        mshFile = mesh(geoFile, 3)
        structure = nuto.Structure(3)
        groups = structure.ImportFromGmsh(mshFile)

        cylinderVolume = math.pi * r**2 * h
        sphereVolume = 4.0 / 3.0 * math.pi * r_sphere**3
        meshedVolumeMatrix = structure.ElementGroupGetVolume(groups[0][0])
        meshedVolumeSphere = structure.ElementGroupGetVolume(groups[1][0])
        self.assertAlmostEqual(meshedVolumeMatrix,
                               cylinderVolume - sphereVolume,
                               delta=1)
        self.assertAlmostEqual(meshedVolumeSphere, sphereVolume, delta=1)
示例#11
0
#!/usr/bin/env python3
from IPython import embed
import nuto
import numpy as np

# geometry
thickness = 1.0

# boundaries
boundary_temperature = 0.0
boundary_flux = 10.0

# create one-dimensional structure
structure = nuto.Structure(2)
structure.SetNumTimeDerivatives(1)

# create section
plane_section = structure.SectionCreate("Plane_Strain")
structure.SectionSetThickness(plane_section, thickness)

# load mesh
groupIndices = structure.ImportFromGmsh("../meshes/2D/ShellMeso.msh")

matrix_group = groupIndices[0][0]
aggregate_group = groupIndices[1][0]

interpolationMatrix = groupIndices[0][1]
interpolationAggreg = groupIndices[1][1]

structure.InterpolationTypeAdd(interpolationMatrix, "temperature",
                               "equidistant2")
示例#12
0
    def setUp(self):
        # create structure
        self.structure = nuto.Structure(3)

        # create nodes
        node1 = self.structure.NodeCreate(np.array([0.0, 0.0, 0.0]))
        node2 = self.structure.NodeCreate(np.array([1.0, 0.0, 0.0]))
        node3 = self.structure.NodeCreate(np.array([0.0, 1.0, 0.0]))
        node4 = self.structure.NodeCreate(np.array([0.0, 0.0, 1.0]))
        node5 = self.structure.NodeCreate(np.array([0.5, 0.0, 0.0]))
        node6 = self.structure.NodeCreate(np.array([0.5, 0.5, 0.0]))
        node7 = self.structure.NodeCreate(np.array([0.0, 0.5, 0.0]))
        node8 = self.structure.NodeCreate(np.array([0.0, 0.0, 0.5]))
        node9 = self.structure.NodeCreate(np.array([0.0, 0.5, 0.5]))
        node10 = self.structure.NodeCreate(np.array([0.5, 0.0, 0.5]))

        interpolationType = self.structure.InterpolationTypeCreate(
            "TETRAHEDRON3D")
        self.structure.InterpolationTypeAdd(interpolationType, "Coordinates",
                                            "EQUIDISTANT2")
        self.structure.InterpolationTypeAdd(interpolationType, "Displacements",
                                            "EQUIDISTANT2")

        # create element
        self.element = self.structure.ElementCreate(interpolationType, [
            node1, node2, node3, node4, node5, node6, node7, node8, node9,
            node10
        ])
        self.structure.ElementTotalConvertToInterpolationType()

        # create constitutive law
        material = self.structure.ConstitutiveLawCreate(
            "Linear_Elastic_Engineering_Stress")
        self.structure.ConstitutiveLawSetParameterDouble(
            material, "Youngs_Modulus", 10)
        self.structure.ConstitutiveLawSetParameterDouble(
            material, "Poissons_Ratio", 0.25)

        # assign constitutive law
        self.structure.ElementSetConstitutiveLaw(self.element, material)

        # make group of boundary nodes
        self.groupBoundaryNodes = self.structure.GroupCreate("Nodes")
        self.structure.GroupAddNode(self.groupBoundaryNodes, node1)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node3)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node4)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node7)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node8)
        self.structure.GroupAddNode(self.groupBoundaryNodes, node9)

        # make group of boundary elements (in this case it is just one)
        self.groupBoundaryElements = self.structure.GroupCreate("Elements")
        self.structure.GroupAddElementsFromNodes(self.groupBoundaryElements,
                                                 self.groupBoundaryNodes,
                                                 False)

        # set displacements of right node
        self.structure.NodeSetDisplacements(node2, np.array([0.2, 0.2, 0.2]))
        self.structure.NodeSetDisplacements(node3, np.array([0.2, 0.2, 0.2]))
        self.structure.NodeSetDisplacements(node6, np.array([0.2, 0.2, 0.2]))
        self.structure.NodeSetDisplacements(node7, np.array([0.2, 0.2, 0.2]))
 def test_DisplacementControlRK4(self):
     s = nuto.Structure(1)
     TI = nuto.RungeKutta4(s)
     TI.SetTimeStep(0.001)
     self.RunTest(s, TI, "LoadRK4")
 def test_DisplacementControlNewmark(self):
     s = nuto.Structure(1)
     TI = nuto.NewmarkDirect(s)
     TI.SetTimeStep(1.)
     self.RunTest(s, TI, "LoadNewmark")
示例#15
0
def SetupStructure(stressState):
    structure = nuto.Structure(2)
    structure.SetShowTime(False)

    # create material law
    myMatLin = structure.ConstitutiveLawCreate(
        "Linear_Elastic_Engineering_Stress")
    structure.ConstitutiveLawSetParameterDouble(myMatLin, "Youngs_Modulus", E)
    structure.ConstitutiveLawSetParameterDouble(myMatLin, "Poissons_Ratio", v)

    # create section
    mySection = nuto.SectionPlane.Create(1.0, False)

    structure.NodesCreate(
        np.array([[0, 10, 2, 8, 4, 8, 0, 10], [0, 0, 2, 3, 7, 7, 10, 10]],
                 dtype=float))

    elementIncidence = np.array(
        [[3, 4, 5, 7, 7], [2, 6, 4, 5, 6], [0, 0, 2, 3, 4], [1, 2, 3, 1, 5]],
        dtype=c_int)

    interpolationType = structure.InterpolationTypeCreate("Quad2D")
    structure.InterpolationTypeAdd(interpolationType, "Coordinates",
                                   "Equidistant1")
    structure.InterpolationTypeAdd(interpolationType, "Displacements",
                                   "Equidistant1")

    structure.ElementsCreate(interpolationType, elementIncidence)
    structure.ElementTotalConvertToInterpolationType()
    structure.ElementTotalSetConstitutiveLaw(myMatLin)
    structure.ElementTotalSetSection(mySection)

    LoadNodesXNeg = structure.GroupGetNodesAtCoordinate(nuto.eDirection_X, 0.)
    LoadNodesXPos = structure.GroupGetNodesAtCoordinate(
        nuto.eDirection_X, 10.)

    LoadNodesYNeg = structure.GroupGetNodesAtCoordinate(nuto.eDirection_Y, 0.)
    LoadNodesYPos = structure.GroupGetNodesAtCoordinate(
        nuto.eDirection_Y, 10.)

    origin = structure.NodeGetAtCoordinate(np.array([0., 0.]))
    if stressState == "XX":
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesXNeg, [nuto.eDirection_X]))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesXPos, [nuto.eDirection_X],
                           BoundaryDisplacement))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS, nuto.Component(origin,
                                                    [nuto.eDirection_Y]))
    elif stressState == "YY":
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesYNeg, [nuto.eDirection_Y]))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesYPos, [nuto.eDirection_Y],
                           BoundaryDisplacement))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS, nuto.Component(origin,
                                                    [nuto.eDirection_X]))
    elif stressState == "XY":
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesXNeg, [nuto.eDirection_X]))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesXNeg, [nuto.eDirection_Y]))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesXPos, [nuto.eDirection_Y],
                           BoundaryDisplacement))
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Component(LoadNodesXPos, [nuto.eDirection_X]))

    # start analysis
    # build global dof numbering
    structure.NodeBuildGlobalDofs()
    structure.CalculateMaximumIndependentSets()

    structure.SolveGlobalSystemStaticElastic()
    return structure