NuTo
Numerics Tool
ElementCollection.h
Go to the documentation of this file.
1 #pragma once
6 
7 namespace NuTo
8 {
11 // coordinate element and the dof elements.
12 // b) allows storing elements (implementations of ElementInterface) by value
13 // in the class ElementCollectionImpl.
15 {
16 public:
17  virtual ~ElementCollection() = default;
18  virtual const ElementInterface& CoordinateElement() const = 0;
19  virtual const ElementInterface& DofElement(DofType) const = 0;
20  virtual const Shape& GetShape() const = 0;
21 };
22 
30 template <typename TElement>
32 {
33 public:
35  "TElement must be a descendant of ElementInterface");
36 
37  ElementCollectionImpl(TElement coordinateElement)
38  : mCoordinateElement(coordinateElement)
39  , mShape(coordinateElement.GetShape())
40  {
41  }
42 
46  void AddDofElement(DofType dofType, TElement dofElement)
47  {
48  mDofElements.Insert(dofType, dofElement);
49  // The alternative implementation with
50  // mDofElements[dofType] = dofElement
51  // will fail. The operator[] must be able default construct a new TElement, if it does not exist. It would then
52  // return a reference to it and dofElement can be copied/moved into it. Our elements are not default
53  // constructable (may require nodes, interpolations, ...). Thus, use Insert here, that copies/moves the entity
54  // into the DofContainer without a temporary, default constructed TElement.
55  }
56 
60  const TElement& CoordinateElement() const override
61  {
62  return mCoordinateElement;
63  }
64 
68  TElement& CoordinateElement()
69  {
70  return mCoordinateElement;
71  }
72 
77  const TElement& DofElement(DofType dofType) const override
78  {
79  return mDofElements[dofType];
80  }
81 
86  TElement& DofElement(DofType dofType)
87  {
88  return mDofElements.At(dofType);
89  }
90 
91  bool Has(DofType dof) const
92  {
93  return mDofElements.Has(dof);
94  }
95 
96  const Shape& GetShape() const override
97  {
98  return mShape;
99  }
100 
101 private:
102  TElement mCoordinateElement;
103  DofContainer<TElement> mDofElements;
104  const Shape& mShape;
105 };
106 
108 
109 template <int TDimParameter>
111 
112 } /* NuTo */
virtual const ElementInterface & DofElement(DofType) const =0
TElement & DofElement(DofType dofType)
nonconst Getter for DofElements
Definition: ElementCollection.h:86
interface for all the cell operations, simply forwarding the corresponding element interfaces ...
Definition: ElementCollection.h:14
bool Has(DofType dof) const
Definition: ElementCollection.h:91
virtual ~ElementCollection()=default
virtual const Shape & GetShape() const =0
ElementCollectionImpl(TElement coordinateElement)
Definition: ElementCollection.h:37
TElement & CoordinateElement()
nonconst Getter for CoordinateElement
Definition: ElementCollection.h:68
string value
Definition: single_edge_notch_tension_test.py:6
const TElement & CoordinateElement() const override
Getter for CoordinateElement.
Definition: ElementCollection.h:60
Definition: DofType.h:8
Definition: ElementInterface.h:8
virtual const ElementInterface & CoordinateElement() const =0
void AddDofElement(DofType dofType, TElement dofElement)
adds a dof element to the collection
Definition: ElementCollection.h:46
const Shape & GetShape() const override
Definition: ElementCollection.h:96
Definition: Shape.h:20
Definition: Exception.h:6
implementation of the interface ElementCollection for arbitrary element types that are derived from E...
Definition: ElementCollection.h:31
const TElement & DofElement(DofType dofType) const override
Getter for DofElements.
Definition: ElementCollection.h:77