Skip to content

Commit 8ccf127

Browse files
committed
Get dofs/node for SolidLine element from parent
1 parent 4d27d36 commit 8ccf127

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/solid_3D_ele/4C_solid_3D_ele_line.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ std::shared_ptr<Core::Elements::Element> Discret::Elements::SolidLineType<dim>::
3535
return nullptr;
3636
}
3737

38+
39+
template <unsigned dim>
40+
Discret::Elements::SolidLine<dim>::SolidLine(const Discret::Elements::SolidLine<dim>& old) noexcept
41+
: Core::Elements::FaceElement(old), num_dof_per_node_(old.num_dof_per_node_)
42+
{
43+
}
44+
3845
template <unsigned dim>
3946
Discret::Elements::SolidLine<dim>::SolidLine(int id, int owner, int nnode, const int* nodeids,
4047
Core::Nodes::Node** nodes, Core::Elements::Element* parent, const int lline)
@@ -43,6 +50,15 @@ Discret::Elements::SolidLine<dim>::SolidLine(int id, int owner, int nnode, const
4350
set_node_ids(nnode, nodeids);
4451
build_nodal_pointers(nodes);
4552
set_parent_master_element(parent, lline);
53+
54+
num_dof_per_node_ = parent_element()->num_dof_per_node(*SolidLine::nodes()[0]);
55+
// Safety check if all nodes have the same number of dofs!
56+
for (int nlid = 1; nlid < num_node(); ++nlid)
57+
{
58+
if (num_dof_per_node_ != parent_master_element()->num_dof_per_node(*SolidLine::nodes()[nlid]))
59+
FOUR_C_THROW("You need different NumDofPerNode for each node on this solid line? ({} != {})",
60+
num_dof_per_node_, parent_master_element()->num_dof_per_node(*SolidLine::nodes()[nlid]));
61+
}
4662
}
4763

4864
template <unsigned dim>
@@ -72,6 +88,18 @@ Core::FE::CellType Discret::Elements::SolidLine<dim>::shape() const
7288
});
7389
}
7490

91+
template <unsigned dim>
92+
void Discret::Elements::SolidLine<dim>::pack(Core::Communication::PackBuffer& data) const
93+
{
94+
data.add_to_pack(num_dof_per_node_);
95+
}
96+
97+
template <unsigned dim>
98+
void Discret::Elements::SolidLine<dim>::unpack(Core::Communication::UnpackBuffer& buffer)
99+
{
100+
buffer.extract_from_pack(num_dof_per_node_);
101+
}
102+
75103
template <unsigned dim>
76104
void Discret::Elements::SolidLine<dim>::print(std::ostream& os) const
77105
{

src/solid_3D_ele/4C_solid_3D_ele_line.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,24 @@ namespace Discret::Elements
6868
SolidLine(int id, int owner, int nnode, const int* nodeids, Core::Nodes::Node** nodes,
6969
Core::Elements::Element* parent, const int lline);
7070

71+
explicit SolidLine(const SolidLine<dim>& old) noexcept;
72+
7173
[[nodiscard]] Core::Elements::Element* clone() const override;
7274

7375
[[nodiscard]] inline int unique_par_object_id() const override
7476
{
7577
return SolidLineType<dim>::instance().unique_par_object_id();
7678
}
7779

78-
void pack(Core::Communication::PackBuffer& data) const override {};
80+
void pack(Core::Communication::PackBuffer& data) const override;
7981

80-
void unpack(Core::Communication::UnpackBuffer& buffer) override {};
82+
void unpack(Core::Communication::UnpackBuffer& buffer) override;
8183

8284
[[nodiscard]] Core::FE::CellType shape() const override;
8385

8486
[[nodiscard]] inline int num_dof_per_node(const Core::Nodes::Node& node) const override
8587
{
86-
return dim;
88+
return num_dof_per_node_;
8789
}
8890

8991
[[nodiscard]] inline int num_dof_per_element() const override { return 0; }
@@ -99,6 +101,9 @@ namespace Discret::Elements
99101
const Core::Conditions::Condition& condition, std::vector<int>& lm,
100102
Core::LinAlg::SerialDenseVector& elevec1,
101103
Core::LinAlg::SerialDenseMatrix* elemat1 = nullptr) override;
104+
105+
private:
106+
int num_dof_per_node_ = 0;
102107
};
103108
} // namespace Discret::Elements
104109

0 commit comments

Comments
 (0)