def DefineTestStructure1D(self, s):
        s.SetShowTime(False)
        s.SetNumTimeDerivatives(2)
        meshInfo = nuto.MeshGenerator.Grid(s, [L], [1])
        s.InterpolationTypeAdd(meshInfo[1], "Displacements", "Equidistant2")

        section = nuto.SectionTruss.Create(A)
        lawId = s.ConstitutiveLawCreate("Linear_Elastic_Engineering_Stress")
        s.ConstitutiveLawSetParameterDouble(lawId, "Youngs_Modulus", E)
        s.ConstitutiveLawSetParameterDouble(lawId, "Density", rho)

        s.ElementTotalConvertToInterpolationType()
        s.ElementTotalSetSection(section)
        s.ElementTotalSetConstitutiveLaw(lawId)

        nodeLeft = s.NodeGetAtCoordinate(np.array([0.0]), 1.e-10)
        s.Constraints().Add(nuto.eDof_DISPLACEMENTS, nuto.Value(nodeLeft))
        nodeRight = s.NodeGetIdAtCoordinate(np.array([L]), 1.e-10)
        nodeRightGroup = s.GroupCreate("nodes")
        s.GroupAddNode(nodeRightGroup, nodeRight)

        nodeRight = s.NodeGetNodePtr(nodeRight)
        s.Constraints().Add(nuto.eDof_DISPLACEMENTS,
                            nuto.Value(nodeRight, lambda t: u * t))

        return nodeRightGroup
示例#2
0
def SetupBoundaryConditions(structure, BCType):
    # fix left node at x = [0]
    nodeLeft = structure.NodeGetAtCoordinate(np.array([0.]))
    structure.Constraints().Add(nuto.eDof_DISPLACEMENTS, nuto.Value(nodeLeft))

    # apply nonzero BC at x = length
    nodeRight = structure.NodeGetAtCoordinate(np.array([Geometry.lx]))
    nodeRightId = structure.NodeGetIdAtCoordinate(np.array([Geometry.lx]))
    if BCType == "DisplacmentBC":
        structure.Constraints().Add(
            nuto.eDof_DISPLACEMENTS,
            nuto.Value(nodeRight, BoundaryCondition.displacement))
    if BCType == "ForceBC":
        xDirection = np.array([1.0])
        structure.LoadCreateNodeForce(nodeRightId, xDirection,
                                      BoundaryCondition.force)
示例#3
0
def define_bc_line_source(l_0, n):
    """Define the boundary conditions for a line source.

    Wave coming from the line defined by point l_0 and normal vector n.
    Assumes that l_0 is in the SOUTH_WEST of the domain and n pointing towards
    it. So the bcs are applied to the SOUTH and the WEST boundary and NORTH and
    EAST are in their shadow
    """
    nodes_west = s.GroupGetNodesAtCoordinate(nuto.eDirection_X, 0)
    nodes_south = s.GroupGetNodesAtCoordinate(nuto.eDirection_Y, 0)
    id_west = s.GroupGetId(nodes_west)
    id_south = s.GroupGetId(nodes_south)
    id_union = s.GroupUnion(id_west, id_south)

    for node_id in s.GroupGetMemberIds(id_union):
        node = s.NodeGetNodePtr(node_id)
        pos = node.Get(nuto.eDof_COORDINATES).flatten()

        distance_to_source = line_distance(l_0, n, pos)
        time_to_source = distance_to_source  # assumes: wave speed = 1
        s.Constraints().Add(
            nuto.eDof_ELECTRICPOTENTIAL,
            nuto.Value(
                node, partial(smooth_dirac_constraint_function,
                              time_to_source)))
示例#4
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)
示例#5
0
def define_bc_point_source():
    """Define the boundary conditions for a line source.

    This currently assumes that the point source only influences the WEST
    border of the domain. EAST, NORTH and SOUTH are in the _shadow_ of WEST
    """
    nodes_west = s.GroupGetNodesAtCoordinate(nuto.eDirection_X, 0)

    source_position = np.array([-1.5, 1.5])

    for node_id in nodes_west.GetMemberIds():
        node = s.NodeGetNodePtr(node_id)
        pos = node.Get(nuto.eDof_COORDINATES).flatten()
        distance_to_source = np.linalg.norm(pos - source_position)
        time_to_source = distance_to_source - 1.5  # assumens: wave speed = 1
        s.Constraints().Add(
            nuto.eDof_ELECTRICPOTENTIAL,
            nuto.Value(
                node, partial(smooth_dirac_constraint_function,
                              time_to_source)))