dynLattice
Loading...
Searching...
No Matches
Line3D.h
Go to the documentation of this file.
1
7#pragma once
8
9#include "utils/helpers.h"
10#include <jem/numeric/algebra/MatmulChain.h>
11#include <jem/util/Properties.h>
12#include <jive/Array.h>
13#include <jive/geom/ParametricLine.h>
14#include <jive/geom/Shape.h>
15#include <jive/geom/StdShape.h>
16
17using jem::idx_t;
18using jem::String;
19using jem::numeric::MatmulChain;
20using jem::util::Properties;
21using jive::Cubix;
22using jive::Matrix;
23using jive::Vector;
24using jive::geom::ParametricLine;
25using jive::geom::Shape;
27
41class Line3D : public Shape
42{
43 public:
44 static const String PROP_NODES;
45 static const String PROP_INT;
46 static const String PROP_LOCAL;
47 static const idx_t GLOB_RANK;
48
55 explicit Line3D(const String &name,
56 const Properties &conf,
57 const Properties &props);
58
61 inline idx_t globalRank() const override;
62
65 inline idx_t localRank() const override;
66
69 inline idx_t nodeCount() const override;
70
73 inline idx_t vertexCount() const override;
74
77 inline idx_t ipointCount() const override;
78
81 inline idx_t shapeFuncCount() const override;
82
85 inline Matrix getVertexCoords() const override;
86
89 inline Matrix getIntegrationScheme() const override;
90
94 inline bool containsLocalPoint(const Vector &u) const override;
95
99 void getIntegrationWeights(const Vector &w,
100 const Matrix &c) const override;
101
104 inline Matrix getVertexFunctions() const override;
105
108 inline Matrix getShapeFunctions() const override;
109
114 void getGlobalPoint(const Vector &x,
115 const Vector &u,
116 const Matrix &c) const override;
117
122 void getShapeGradients(const Matrix &g,
123 const Vector &w,
124 const Matrix &c) const;
125
129 void getRotations(const Cubix &Ri,
130 const Cubix &Rn) const;
131
137 void getXi(const Quadix &Xi,
138 const Vector &w,
139 const Matrix &u,
140 const Matrix &c) const;
141
146 void getXi(const Quadix &Xi,
147 const Matrix &grads,
148 const Matrix &phiP) const;
149
154 void getPsi(const Quadix &Psi,
155 const Vector &w,
156 const Matrix &c) const;
157
162 void getPi(const Cubix &Pi,
163 const Cubix &Ri,
164 const Cubix &Rn) const;
165
169 void getPi(const Cubix &Pi,
170 const Cubix &Rn) const;
171
177 void getRotationGradients(const Cubix &LambdaP,
178 const Vector &w,
179 const Matrix &c,
180 const Cubix &nodeLambda) const;
181
187 void getRotationsAndGradients(const Cubix &Ri,
188 const Cubix &LambdaP,
189 const Matrix &grads,
190 const Cubix &nodeLambda) const;
191
192 //------------------------------------------------
193 // local location functions
194 //------------------------------------------------
198 inline void evalShapeFunctions(const Vector &h,
199 const Vector &u) const override;
200
205 inline void evalShapeGradients(const Vector &h,
206 const Vector &g,
207 const Vector &u) const;
208
214 inline void evalShapeGradGrads(const Vector &h,
215 const Vector &g,
216 const Vector &gg,
217 const Vector &u) const;
218
219 private:
224 void getRotations_(const Cubix &Ri,
225 const Matrix &node_psi,
226 const Matrix &Lambda_r) const;
227
234 void getRotationGradients_(const Cubix &LambdaP,
235 const Matrix &grads,
236 const Matrix &ip_psi,
237 const Matrix &node_psi,
238 const Matrix &Lambda_r) const;
239
243 void getRefRot_(const Matrix Lambda_r,
244 const Cubix Rn) const;
245
250 void getNodeRotVecs_(const Matrix psi,
251 const Matrix Lambda_r,
252 const Cubix Rn) const;
253
254 protected:
255 jem::Ref<ParametricLine> intLine_;
256
257 // Work arrays and matrix product of the functions that run for every element
258 // (see the note in utils/helpers.h): created once in the constructor and
259 // overwritten in every call. The object is not thread safe.
260 // The result of matmul_ is only valid until its next call.
261 mutable Matrix nodePsi_;
262 mutable Matrix lambdaR_;
263 mutable Matrix ipPsi_;
264 mutable MatmulChain<double, 2> matmul_;
265 mutable Matrix relRot_;
266 mutable Matrix skewP_;
267 mutable Vector phiIJ_;
268
275 mutable bool gradMemoValid_ = false;
276 mutable Matrix gradMemoCoords_;
277 mutable Matrix gradMemoGrads_;
278 mutable Vector gradMemoWeights_;
280};
281
282//=====================================================================
283// inline implementations
284//=====================================================================
288{
289 return GLOB_RANK;
290}
291
294idx_t Line3D::localRank() const
295{
296 return intLine_->localRank();
297}
298
301idx_t Line3D::nodeCount() const
302{
303 return intLine_->nodeCount();
304}
305
309{
310 return intLine_->vertexCount();
311}
312
316{
317 return intLine_->ipointCount();
318}
319
323{
324 return intLine_->shapeFuncCount();
325}
326
330{
331 return intLine_->getVertexCoords();
332}
333
337{
338 return intLine_->getIntegrationScheme();
339}
340
344bool Line3D::containsLocalPoint(const Vector &u) const
345{
346 return intLine_->containsLocalPoint(u);
347}
348
352{
353 return intLine_->getVertexFunctions();
354}
355
359void Line3D::evalShapeFunctions(const Vector &h,
360 const Vector &u) const
361{
362 JEM_ASSERT2(u.size() == localRank(), "internal coordinates do not match the rank");
363 intLine_->evalShapeFunctions(h, u);
364}
365
370void Line3D::evalShapeGradients(const Vector &h,
371 const Vector &g,
372 const Vector &u) const
373{
374 JEM_ASSERT2(u.size() == localRank(), "internal coordinates do not match the rank");
375 Matrix g_dummy(1, g.size());
376 intLine_->getSShape()->evalShapeGradients(h, g_dummy, u);
377 g = g_dummy(0, ALL);
378}
379
385void Line3D::evalShapeGradGrads(const Vector &h,
386 const Vector &g,
387 const Vector &gg,
388 const Vector &u) const
389{
390 JEM_ASSERT2(u.size() == localRank(), "internal coordinates do not match the rank");
391 Matrix g_dummy(1, g.size());
392 Matrix gg_dummy(1, gg.size());
393 intLine_->getSShape()->evalShapeGradGrads(h, g_dummy, gg_dummy, u);
394 g = g_dummy(0, ALL);
395 gg = gg_dummy(0, ALL);
396}
397
401{
402 return intLine_->getShapeFunctions();
403}
Shape function for 1D line elements in 3D space.
Definition Line3D.h:42
idx_t shapeFuncCount() const override
Get the number of shape functions.
Definition Line3D.h:322
idx_t globalRank() const override
Get the global rank (spatial dimension).
Definition Line3D.h:287
Matrix getVertexCoords() const override
Get the local coordinates of the vertices.
Definition Line3D.h:329
void getPi(const Cubix &Pi, const Cubix &Ri, const Cubix &Rn) const
Get the Pi at the integration points.
Definition Line3D.cpp:240
void evalShapeFunctions(const Vector &h, const Vector &u) const override
Evaluate shape functions at given local coordinates.
Definition Line3D.h:359
void getXi(const Quadix &Xi, const Vector &w, const Matrix &u, const Matrix &c) const
Get the Xi at the integration points.
Definition Line3D.cpp:174
Vector phiIJ_
relative rotation vector between the reference nodes
Definition Line3D.h:267
void getRotationGradients(const Cubix &LambdaP, const Vector &w, const Matrix &c, const Cubix &nodeLambda) const
Get the rotation gradients at the integration points from the rotations (Crisfield/Jelenic)
Definition Line3D.cpp:254
Matrix getVertexFunctions() const override
Get shape function values at the integration points.
Definition Line3D.h:351
void getRotationsAndGradients(const Cubix &Ri, const Cubix &LambdaP, const Matrix &grads, const Cubix &nodeLambda) const
Get the rotations and the rotation gradients at the integration points using one evaluation of the no...
Definition Line3D.cpp:274
static const String PROP_INT
Property name for integration scheme.
Definition Line3D.h:45
void getShapeGradients(const Matrix &g, const Vector &w, const Matrix &c) const
get the gradients of the shape functions at the integration points
Definition Line3D.cpp:111
MatmulChain< double, 2 > matmul_
matrix products without allocations
Definition Line3D.h:264
Matrix gradMemoCoords_
Definition Line3D.h:276
static const String PROP_LOCAL
Property name for local coordinates.
Definition Line3D.h:46
bool containsLocalPoint(const Vector &u) const override
Check whether a local point is inside the element.
Definition Line3D.h:344
idx_t localRank() const override
Get the local rank of the line element.
Definition Line3D.h:294
idx_t nodeCount() const override
Get the number of nodes in the line element.
Definition Line3D.h:301
Matrix lambdaR_
reference rotation, 3 x 3
Definition Line3D.h:262
Vector gradMemoWeights_
Definition Line3D.h:278
Matrix getIntegrationScheme() const override
Get the integration scheme.
Definition Line3D.h:336
void getIntegrationWeights(const Vector &w, const Matrix &c) const override
Compute integration weights for numerical integration.
Definition Line3D.cpp:100
void getPsi(const Quadix &Psi, const Vector &w, const Matrix &c) const
Get the Psi at the integration points.
Definition Line3D.cpp:209
Matrix nodePsi_
relative rotation vectors of the nodes, 3 x nodeCount
Definition Line3D.h:261
Matrix relRot_
relative rotation, 3 x 3
Definition Line3D.h:265
Matrix getShapeFunctions() const override
Get shape function values at the integration points.
Definition Line3D.h:400
void evalShapeGradients(const Vector &h, const Vector &g, const Vector &u) const
Evaluate shape functions and their gradients at local coordinates.
Definition Line3D.h:370
Matrix gradMemoGrads_
Definition Line3D.h:277
Matrix ipPsi_
rotation vectors at the integration points, 3 x ipointCount
Definition Line3D.h:263
void getRotations(const Cubix &Ri, const Cubix &Rn) const
return the rotations at the integration points
Definition Line3D.cpp:143
void getGlobalPoint(const Vector &x, const Vector &u, const Matrix &c) const override
Transform local coordinates to global coordinates.
Definition Line3D.cpp:90
static const String PROP_NODES
Property name for number of nodes.
Definition Line3D.h:44
jem::Ref< ParametricLine > intLine_
internal line element for some standard functions
Definition Line3D.h:255
idx_t vertexCount() const override
Get the number of vertices in the line element.
Definition Line3D.h:308
bool gradMemoValid_
Definition Line3D.h:275
static const idx_t GLOB_RANK
Global rank (always 3 for 3D space)
Definition Line3D.h:47
idx_t ipointCount() const override
Get the number of integration points.
Definition Line3D.h:315
Matrix skewP_
skew symmetric matrix of the tangent, 3 x 3
Definition Line3D.h:266
void evalShapeGradGrads(const Vector &h, const Vector &g, const Vector &gg, const Vector &u) const
Evaluate shape functions, gradients, and second derivatives.
Definition Line3D.h:385
file containing some basic helper functions
Array< double, 4 > Quadix
Definition helpers.h:47