MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
segment.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12
13#include "mesh_headers.hpp"
14
15namespace mfem
16{
17
18Segment::Segment( const int *ind, int attr ) : Element(Geometry::SEGMENT)
19{
20 attribute = attr;
21 for (int i=0; i<2; i++)
22 {
23 indices[i] = ind[i];
24 }
25}
26
27Segment::Segment( int ind1, int ind2, int attr ) : Element(Geometry::SEGMENT)
28{
29 attribute = attr;
30 indices[0] = ind1;
31 indices[1] = ind2;
32}
33
34void Segment::SetVertices(const int *ind)
35{
36 indices[0] = ind[0];
37 indices[1] = ind[1];
38}
39
41{
42 v.SetSize(2);
43 std::copy(indices, indices + 2, v.begin());
44}
45
47{
48 MFEM_ASSERT(v.Size() == 2, "!");
49 std::copy(v.begin(), v.end(), indices);
50}
51
53
54}
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:697
int Size() const
Return the logical size of the array.
Definition array.hpp:144
T * end()
STL-like end. Returns pointer after the last element of the array.
Definition array.hpp:305
T * begin()
STL-like begin. Returns pointer to the first element of the array.
Definition array.hpp:302
Abstract data type element.
Definition element.hpp:29
int attribute
Element's attribute (specifying material property, etc).
Definition element.hpp:33
A 1D linear element with nodes on the endpoints.
void SetVertices(const Array< int > &v) override
Set the indices defining the vertices.
Definition segment.cpp:46
int * GetVertices() override
Definition segment.hpp:48
int indices[2]
Definition segment.hpp:25
Linear1DFiniteElement SegmentFE
Definition segment.cpp:52