-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathgeometry.h
4301 lines (3673 loc) · 154 KB
/
geometry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// | / |
// ' / __| _` | __| _ \ __|
// . \ | ( | | ( |\__ `
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
// Riccardo Rossi
// Janosch Stascheit
// Felix Nagel
// contributors: Hoang Giang Bui
// Josep Maria Carbonell
// Carlos Roig
// Vicente Mataix Ferrandiz
//
#pragma once
// System includes
#include <typeinfo>
// External includes
// Project includes
#include "geometries/geometry_data.h"
#include "geometries/point.h"
#include "containers/pointer_vector.h"
#include "containers/data_value_container.h"
#include "utilities/math_utils.h"
#include "input_output/logger.h"
#include "integration/integration_info.h"
namespace Kratos
{
///@name Kratos Globals
///@{
///@}
///@name Type Definitions
///@{
///@}
///@name Enum's
///@{
///@}
///@name Functions
///@{
///@}
///@name Kratos Classes
///@{
///Geometry base class.
/** As a base class Geometry has all the common
* interface of Kratos' geometries. Also it contains array of
* pointers to its points, reference to shape functions values in
* all integrations points and also local gradients of shape
* functions evaluated in all integrations points.
*
* Geometry is a template class with just one template parameter:
* - TPointType which reperesent the type of the point this geometry
* type contain and build on.
*
* @see Point
* @see Node
* @see Formulation
* @see GeometryAndFormulationElement
*/
template<class TPointType>
class Geometry
{
public:
///@}
///@name Type Definitions
///@{
/// This Geometry type.
using GeometryType = Geometry<TPointType>;
/// Pointer definition of Geometry
KRATOS_CLASS_POINTER_DEFINITION( Geometry );
/** Different criteria to evaluate the quality of a geometry.
* Different criteria to evaluate the quality of a geometry.
*/
enum class QualityCriteria {
INRADIUS_TO_CIRCUMRADIUS,
AREA_TO_LENGTH,
SHORTEST_ALTITUDE_TO_LENGTH,
INRADIUS_TO_LONGEST_EDGE,
SHORTEST_TO_LONGEST_EDGE,
REGULARITY,
VOLUME_TO_SURFACE_AREA,
VOLUME_TO_EDGE_LENGTH,
VOLUME_TO_AVERAGE_EDGE_LENGTH,
VOLUME_TO_RMS_EDGE_LENGTH,
MIN_DIHEDRAL_ANGLE,
MAX_DIHEDRAL_ANGLE,
MIN_SOLID_ANGLE
};
/**
* @brief This defines the different methods to compute the lumping methods
* @details The three methods available are:
* - The row sum method
* - Diagonal scaling
* - Evaluation of M using a quadrature involving only the nodal points and thus automatically yielding a diagonal matrix for standard element shape function
*/
enum class LumpingMethods {
ROW_SUM,
DIAGONAL_SCALING,
QUADRATURE_ON_NODES
};
/** Array of counted pointers to point. This type used to hold
geometry's points.
*/
typedef PointerVector<TPointType> PointsArrayType;
/** Integration methods implemented in geometry.
*/
typedef GeometryData::IntegrationMethod IntegrationMethod;
/** A Vector of counted pointers to Geometries. Used for
returning edges of the geometry.
*/
typedef PointerVector<GeometryType> GeometriesArrayType;
/** Redefinition of geometry template parameter TPointType as this geometry point type.
*/
typedef TPointType PointType;
/** Type used for indexing in geometry class.std::size_t used for indexing
point or integration point access methods and also all other
methods which need point or integration point index.
*/
typedef std::size_t IndexType;
/** This typed used to return size or dimension in
geometry. Dimension, WorkingDimension, PointsNumber and
... return this type as their results.
*/
typedef std::size_t SizeType;
typedef typename PointType::CoordinatesArrayType CoordinatesArrayType;
/** This type used for representing an integration point in
geometry. This integration point is a point with an
additional weight component.
*/
typedef IntegrationPoint<3> IntegrationPointType;
/** A Vector of IntegrationPointType which used to hold
integration points related to an integration
method. IntegrationPoints functions used this type to return
their results.
*/
typedef std::vector<IntegrationPointType> IntegrationPointsArrayType;
/** A Vector of IntegrationPointsArrayType which used to hold
integration points related to different integration method
implemented in geometry.
*/
typedef std::array<IntegrationPointsArrayType, static_cast<int>(GeometryData::IntegrationMethod::NumberOfIntegrationMethods)> IntegrationPointsContainerType;
/** A third order tensor used as shape functions' values
continer.
*/
typedef std::array<Matrix, static_cast<int>(GeometryData::IntegrationMethod::NumberOfIntegrationMethods)> ShapeFunctionsValuesContainerType;
/** A fourth order tensor used as shape functions' local
gradients container in geometry.
*/
typedef GeometryData::ShapeFunctionsLocalGradientsContainerType ShapeFunctionsLocalGradientsContainerType;
/** A third order tensor to hold jacobian matrices evaluated at
integration points. Jacobian and InverseOfJacobian functions
return this type as their result.
*/
typedef DenseVector<Matrix > JacobiansType;
/** A third order tensor to hold shape functions' gradients.
ShapefunctionsGradients function return this
type as its result.
*/
typedef GeometryData::ShapeFunctionsGradientsType ShapeFunctionsGradientsType;
/** A third order tensor to hold shape functions' local second derivatives.
ShapefunctionsLocalGradients function return this
type as its result.
*/
typedef GeometryData::ShapeFunctionsSecondDerivativesType ShapeFunctionsSecondDerivativesType;
/** A fourth order tensor to hold shape functions' local third order derivatives
*/
typedef GeometryData::ShapeFunctionsThirdDerivativesType ShapeFunctionsThirdDerivativesType;
/** Type of the normal vector used for normal to edges in geomety.
*/
typedef DenseVector<double> NormalType;
/// data type stores in this container.
typedef typename PointType::Pointer PointPointerType;
typedef const PointPointerType ConstPointPointerType;
typedef TPointType& PointReferenceType;
typedef const TPointType& ConstPointReferenceType;
typedef std::vector<PointPointerType> PointPointerContainerType;
/// PointsArrayType typedefs
typedef typename PointsArrayType::iterator iterator;
typedef typename PointsArrayType::const_iterator const_iterator;
typedef typename PointsArrayType::ptr_iterator ptr_iterator;
typedef typename PointsArrayType::ptr_const_iterator ptr_const_iterator;
typedef typename PointsArrayType::difference_type difference_type;
static constexpr IndexType BACKGROUND_GEOMETRY_INDEX = std::numeric_limits<IndexType>::max();
///@}
///@name Life Cycle
///@{
/// Standard Constructor. Generates self assigned id.
Geometry()
: mId(GenerateSelfAssignedId())
, mpGeometryData(&GeometryDataInstance())
{
}
/// Standard Constructor with a geometry Id
Geometry(IndexType GeometryId)
: mpGeometryData(&GeometryDataInstance())
{
SetId(GeometryId);
}
/// Standard Constructor with a Name
Geometry(const std::string& GeometryName)
: mId(GenerateId(GeometryName))
, mpGeometryData(&GeometryDataInstance())
{
}
/** Complete argument constructor. This constructor gives a
complete set of arguments to pass all the initial value of
all the member variables of geometry class. Also it has
default value for integration variables to make it usefull
in the case of constructing new geometry without mapping and
integrating properties.
@param ThisPoints Vector of pointers to points which this
geometry constructing on them. Points must have dimension
equal or greater than working space dimension though there
is no control on it.
@param ThisDefaultMethod Default integration method. Its
default value is gaussian integration with orden one which
make no deference while in this condition there is no shape
function database exist and integrating is not possible
including by default method.
@param ThisIntegrationPoints All the integration points in
all methods. This is a Vector of IntegrationPointsArrayType
and It must have at least four component correspounding to
four integration method defined now. If there is some
geometry which don't have all this method implemented
related points Vector must exist but with zero size. For
example if a geometry don't have gaussian orden one
ThisIntegrationPoints[GI_GAUSS_1] must be an empty
IntegrationPointsArrayType.
@param ThisShapeFunctionsValues Values of all the shape
functions evaluated in all integrations points of all
integration methods. It's a three dimensional array \f$
F_{ijk} \f$ where i = GI_GAUSS_1,..., GI_GAUSS_4 and j is
the integration point index and k is the shape function
index. In the other word component \f$ f_{ijk} \f$ is the
value of the shape function related to node k evaluated in
integration point j of i integration method point set. Again
if there is some integration method unsupported an empty
Matrix must assigned to related place. For example if a
geometry don't have gaussian orden four
ThisShapeFunctionsValues[GI_GAUSS_4] must be an empty
Matrix.
@param ThisShapeFunctionsLocalGradients Values of local
gradients respected to all local coordinates of all the
shape functions evaluated in all integrations points of all
integration methods. It's a four dimensional array \f$
F_{ijkh} \f$ where i = GI_GAUSS_1,..., GI_GAUSS_4 and j is
the integration point index and k is the shape function
index and h is local coordinate index. In the other word
component \f$ f_{ijkh} \f$ is the value of h'th component of
local gradient of the shape function related to node k
evaluated in integration point j of i integration method
point set. Again if there is some integration method
unsupported an empty ShapeFunctionsGradientsType must
assigned to related place. For example if a geometry don't
have gaussian orden two ThisShapeFunctionsValues[GI_GAUSS_2]
must be an empty ShapeFunctionsGradientsType.
*/
Geometry(
const PointsArrayType &ThisPoints,
GeometryData const *pThisGeometryData = &GeometryDataInstance())
: mId(GenerateSelfAssignedId())
, mpGeometryData(pThisGeometryData)
, mPoints(ThisPoints)
{
}
Geometry(
IndexType GeometryId,
const PointsArrayType& ThisPoints,
GeometryData const* pThisGeometryData = &GeometryDataInstance())
: mpGeometryData(pThisGeometryData)
, mPoints(ThisPoints)
{
SetId(GeometryId);
}
Geometry(
const std::string& GeometryName,
const PointsArrayType& ThisPoints,
GeometryData const* pThisGeometryData = &GeometryDataInstance())
: mId(GenerateId(GeometryName))
, mpGeometryData(pThisGeometryData)
, mPoints(ThisPoints)
{
}
/**
* @brief Copy constructor
*
* @note Does not copy the points but shares same points with
* the original geometry. Any change to the points of the
* copied geometry affect point of original geometry, too.
* @note Copied geometry shares the same Id as the
* original geometry.
*/
Geometry( const Geometry& rOther )
: mId(rOther.mId),
mpGeometryData(rOther.mpGeometryData),
mPoints(rOther.mPoints),
mData(rOther.mData)
{
}
/**
* @brief Copy constructor with TOtherPointType
*
* Copies geometry with a different type of points.
* TOtherPointType* must be implicity convertible
* to TPointType of the original geometry.
*
* @note Does not copy the points but shares same points with
* the original geometry. Any change to the points of the
* copied geometry affect point of original geometry, too.
* @note Copied geometry shares the same Id as the
* original geometry.
*/
template<class TOtherPointType>
Geometry( Geometry<TOtherPointType> const & rOther )
: mId(rOther.mId),
mpGeometryData(rOther.mpGeometryData),
mData(rOther.mData)
{
mPoints = new PointsArrayType(rOther.begin(), rOther.end());
}
/// Destructor. Do nothing!!!
virtual ~Geometry() = default;
/**
* @brief Gets the geometry family.
* @details This function returns the family type of the geometry. The geometry family categorizes the geometry into a broader classification, aiding in its identification and processing.
* @return GeometryData::KratosGeometryFamily The geometry family.
*/
virtual GeometryData::KratosGeometryFamily GetGeometryFamily() const
{
return GeometryData::KratosGeometryFamily::Kratos_generic_family;
}
/**
* @brief Gets the geometry type.
* @details This function returns the specific type of the geometry. The geometry type provides a more detailed classification of the geometry.
* @return GeometryData::KratosGeometryType The specific geometry type.
*/
virtual GeometryData::KratosGeometryType GetGeometryType() const
{
return GeometryData::KratosGeometryType::Kratos_generic_type;
}
/**
* @brief Gets the geometry order type.
* @details This function returns the order type of the geometry. The order type relates to the polynomial degree of the geometry.
* @return GeometryData::KratosGeometryOrderType The geometry order type.
*/
virtual GeometryData::KratosGeometryOrderType GetGeometryOrderType() const
{
return GeometryData::KratosGeometryOrderType::Kratos_Unknown_Order;
}
///@}
///@name Operators
///@{
/** Assignment operator.
@note This operator don't copy the points and this
geometry shares points with given source geometry. It's
obvious that any change to this geometry's point affect
source geometry's points too.
@see Clone
@see ClonePoints
*/
Geometry& operator=( const Geometry& rOther )
{
mpGeometryData = rOther.mpGeometryData;
mPoints = rOther.mPoints;
mData = rOther.mData;
return *this;
}
/** Assignment operator for geometries with different point type.
@note This operator don't copy the points and this
geometry shares points with given source geometry. It's
obvious that any change to this geometry's point affect
source geometry's points too.
@see Clone
@see ClonePoints
*/
template<class TOtherPointType>
Geometry& operator=( Geometry<TOtherPointType> const & rOther )
{
this->clear();
for ( typename Geometry<TOtherPointType>::ptr_const_iterator i = rOther.ptr_begin() ; i != rOther.ptr_end() ; ++i )
push_back( typename PointType::Pointer( new PointType( **i ) ) );
mpGeometryData = rOther.mpGeometryData;
return *this;
}
operator PointsArrayType&()
{
return mPoints;
}
///@}
///@name PointerVector Operators
///@{
TPointType& operator[](const SizeType& i)
{
return mPoints[i];
}
TPointType const& operator[](const SizeType& i) const
{
return mPoints[i];
}
PointPointerType& operator()(const SizeType& i)
{
return mPoints(i);
}
ConstPointPointerType& operator()(const SizeType& i) const
{
return mPoints(i);
}
///@}
///@name PointerVector Operations
///@{
iterator begin()
{
return iterator(mPoints.begin());
}
const_iterator begin() const
{
return const_iterator(mPoints.begin());
}
iterator end()
{
return iterator(mPoints.end());
}
const_iterator end() const
{
return const_iterator(mPoints.end());
}
ptr_iterator ptr_begin()
{
return mPoints.ptr_begin();
}
ptr_const_iterator ptr_begin() const
{
return mPoints.ptr_begin();
}
ptr_iterator ptr_end()
{
return mPoints.ptr_end();
}
ptr_const_iterator ptr_end() const
{
return mPoints.ptr_end();
}
PointReferenceType front() /* nothrow */
{
assert(!empty());
return mPoints.front();
}
ConstPointReferenceType front() const /* nothrow */
{
assert(!empty());
return mPoints.front();
}
PointReferenceType back() /* nothrow */
{
assert(!empty());
return mPoints.back();
}
ConstPointReferenceType back() const /* nothrow */
{
assert(!empty());
return mPoints.back();
}
SizeType size() const
{
return mPoints.size();
}
/**
* @detail Returns the number of the points/ nodes
* belonging to this geometry.
* @return Number of points/ nodes.
*/
SizeType PointsNumber() const {
return this->size();
}
/// Returns number of points per direction.
virtual SizeType PointsNumberInDirection(IndexType LocalDirectionIndex) const
{
KRATOS_ERROR << "Trying to access PointsNumberInDirection from geometry base class." << std::endl;
}
SizeType max_size() const
{
return mPoints.max_size();
}
void swap(GeometryType& rOther)
{
mPoints.swap(rOther.mPoints);
}
void push_back(PointPointerType x)
{
mPoints.push_back(x);
}
void clear()
{
mPoints.clear();
}
void reserve(int dim)
{
mPoints.reserve(dim);
}
int capacity()
{
return mPoints.capacity();
}
/////@}
/////@name Access
/////@{
///** Gives a reference to underly normal container. */
PointPointerContainerType& GetContainer()
{
return mPoints.GetContainer();
}
/** Gives a constant reference to underly normal container. */
const PointPointerContainerType& GetContainer() const
{
return mPoints.GetContainer();
}
///@}
///@name Data Container
///@{
/**
* Access Data:
*/
DataValueContainer& GetData()
{
return mData;
}
DataValueContainer const& GetData() const
{
return mData;
}
void SetData(DataValueContainer const& rThisData)
{
mData = rThisData;
}
/**
* Check if the Data exists with Has(..) methods:
*/
template<class TDataType> bool Has(const Variable<TDataType>& rThisVariable) const
{
return mData.Has(rThisVariable);
}
/**
* Set Data with SetValue and the Variable to set:
*/
template<class TVariableType> void SetValue(
const TVariableType& rThisVariable,
typename TVariableType::Type const& rValue)
{
mData.SetValue(rThisVariable, rValue);
}
/**
* Get Data with GetValue and the Variable to get:
*/
template<class TVariableType> typename TVariableType::Type& GetValue(
const TVariableType& rThisVariable)
{
return mData.GetValue(rThisVariable);
}
template<class TVariableType> typename TVariableType::Type const& GetValue(
const TVariableType& rThisVariable) const
{
return mData.GetValue(rThisVariable);
}
///@}
///@name Dynamic access to internals
///@{
/* Assigns a value to the geometry,
* according to a variable.
* Allows dynamic interfaces with each respective geometry.
*/
/// Assign with bool
virtual void Assign(
const Variable<bool>& rVariable,
const bool Input) {}
/// Assign with int
virtual void Assign(
const Variable<int>& rVariable,
const int Input) {}
/// Assign with double
virtual void Assign(
const Variable<double>& rVariable,
const double Input) {}
/// Assign with array_1d<double, 2>
virtual void Assign(
const Variable<array_1d<double, 2>>& rVariable,
const array_1d<double, 2>& rInput) {}
/// Assign with array_1d<double, 3>
virtual void Assign(
const Variable<array_1d<double, 3>>& rVariable,
const array_1d<double, 3>& rInput) {}
/// Assign with array_1d<double, 6>
virtual void Assign(
const Variable<array_1d<double, 6>>& rVariable,
const array_1d<double, 6>& rInput) {}
/// Assign with Vector
virtual void Assign(
const Variable<Vector>& rVariable,
const Vector& rInput) {}
/// Assign with Matrix
virtual void Assign(
const Variable<Matrix>& rVariable,
const Matrix& rInput) {}
/* Calculate either provides, gets or calculates a certain value,
* according to a variable.
*/
/// Calculate with bool
virtual void Calculate(
const Variable<bool>& rVariable,
bool& rOutput) const {}
/// Calculate with int
virtual void Calculate(
const Variable<int>& rVariable,
int& rOutput) const {}
/// Calculate with double
virtual void Calculate(
const Variable<double>& rVariable,
double& rOutput) const {}
/// Calculate with array_1d<double, 2>
virtual void Calculate(
const Variable<array_1d<double, 2>>& rVariable,
array_1d<double, 2>& rOutput) const {}
/// Calculate with array_1d<double, 3>
virtual void Calculate(
const Variable<array_1d<double, 3>>& rVariable,
array_1d<double, 3>& rOutput) const {}
/// Calculate with array_1d<double, 6>
virtual void Calculate(
const Variable<array_1d<double, 6>>& rVariable,
array_1d<double, 6>& rOutput) const {}
/// Calculate with Vector
virtual void Calculate(
const Variable<Vector>& rVariable,
Vector& rOutput) const {}
/// Calculate with Matrix
virtual void Calculate(
const Variable<Matrix>& rVariable,
Matrix& rOutput) const {}
///@}
///@name Inquiry
///@{
/**
* @brief Checks if two GeometryType have the same type
* @return True if the objects are the same type, false otherwise
*/
inline static bool HasSameType(
const GeometryType& rLHS,
const GeometryType& rRHS)
{
return (typeid(rLHS) == typeid(rRHS));
}
/**
* @brief Checks if two GeometryType have the same type (pointer version)
* @return True if the objects are the same type, false otherwise
*/
inline static bool HasSameType(
const GeometryType * rLHS,
const GeometryType* rRHS)
{
return GeometryType::HasSameType(*rLHS, *rRHS);
}
/**
* @brief Checks if two GeometryType have the same geometry type
* @return True if the geometries are the same type, false otherwise
*/
inline static bool HasSameGeometryType(const GeometryType& rLHS, const GeometryType& rRHS) {
return (rLHS.GetGeometryType() == rRHS.GetGeometryType());
}
/**
* @brief Checks if two GeometryType have the same geometry type (pointer version)
* @return True if the geometries are the same type, false otherwise
*/
inline static bool HasSameGeometryType(
const GeometryType* rLHS,
const GeometryType* rRHS)
{
return GeometryType::HasSameGeometryType(*rLHS, *rRHS);
}
/**
* @brief Checks if two GeometryType are the same
* @return True if the object is the same, false otherwise
*/
inline static bool IsSame(
const GeometryType& rLHS,
const GeometryType& rRHS)
{
return GeometryType::HasSameType(rLHS, rRHS) && GeometryType::HasSameGeometryType(rLHS, rRHS);
}
/**
* @brief Checks if two GeometryType are the same (pointer version)
* @return True if the object is the same, false otherwise
*/
inline static bool IsSame(
const GeometryType* rLHS,
const GeometryType* rRHS)
{
return GeometryType::HasSameType(*rLHS, *rRHS) && GeometryType::HasSameGeometryType(*rLHS, *rRHS);
}
bool empty() const
{
return mPoints.empty();
}
///@}
///@name Operations
///@{
/**
* @brief Creates a new geometry pointer
* @param rThisPoints the nodes of the new geometry
* @return Pointer to the new geometry
*/
virtual Pointer Create(
PointsArrayType const& rThisPoints
) const
{
// Create geometry
auto p_geom = this->Create(0, rThisPoints);
// Generate Id
IndexType id = reinterpret_cast<IndexType>(p_geom.get());
// Sets second bit to zero.
p_geom->SetIdSelfAssigned(id);
// Sets first bit to zero.
p_geom->SetIdNotGeneratedFromString(id);
// Sets Id
p_geom->SetIdWithoutCheck(id);
return p_geom;
}
/**
* @brief Creates a new geometry pointer
* @param NewGeometryId the ID of the new geometry
* @param rThisPoints the nodes of the new geometry
* @return Pointer to the new geometry
*/
virtual Pointer Create(
const IndexType NewGeometryId,
PointsArrayType const& rThisPoints
) const
{
return Pointer( new Geometry( NewGeometryId, rThisPoints, mpGeometryData));
}
/**
* @brief Creates a new geometry pointer
* @param rNewGeometryName the name of the new geometry
* @param rThisPoints the nodes of the new geometry
* @return Pointer to the new geometry
*/
Pointer Create(
const std::string& rNewGeometryName,
PointsArrayType const& rThisPoints
) const
{
auto p_geom = this->Create(0, rThisPoints);
p_geom->SetId(rNewGeometryName);
return p_geom;
}
/**
* @brief Creates a new geometry pointer
* @param rGeometry Reference to an existing geometry
* @return Pointer to the new geometry
*/
virtual Pointer Create(
const GeometryType& rGeometry
) const
{
// Create geometry
auto p_geom = this->Create(0, rGeometry);
// Generate Id
IndexType id = reinterpret_cast<IndexType>(p_geom.get());
// Sets second bit to zero.
p_geom->SetIdSelfAssigned(id);
// Sets first bit to zero.
p_geom->SetIdNotGeneratedFromString(id);
// Sets Id
p_geom->SetIdWithoutCheck(id);
return p_geom;
}
/**
* @brief Creates a new geometry pointer
* @param NewGeometryId the ID of the new geometry
* @param rGeometry Reference to an existing geometry
* @return Pointer to the new geometry
*/
virtual Pointer Create(
const IndexType NewGeometryId,
const GeometryType& rGeometry
) const
{
auto p_geometry = Pointer( new Geometry( NewGeometryId, rGeometry.Points(), mpGeometryData));
p_geometry->SetData(rGeometry.GetData());
return p_geometry;
}
/**
* @brief Creates a new geometry pointer
* @param rNewGeometryName the name of the new geometry
* @param rGeometry Reference to an existing geometry
* @return Pointer to the new geometry
*/
Pointer Create(
const std::string& rNewGeometryName,
const GeometryType& rGeometry
) const
{
auto p_geom = this->Create(0, rGeometry);
p_geom->SetId(rNewGeometryName);
return p_geom;
}
/** This methods will create a duplicate of all its points and
substitute them with its points. */
void ClonePoints()
{
for ( ptr_iterator i = this->ptr_begin() ; i != this->ptr_end() ; i++ )
*i = typename PointType::Pointer( new PointType( **i ) );
}
///@}
///@name Geometry Data and Geometry Shape Function Container
///@{
/**
* @brief GeometryData contains all information about dimensions
* and has a set of precomputed values for integration points
* and shape functions, including derivatives.
* @return the geometry data of a certain geometry class.
*/
GeometryData const& GetGeometryData() const
{
return *mpGeometryData;
}
/* @brief SetGeometryShapeFunctionContainer updates the GeometryShapeFunctionContainer within
* the GeometryData. This function works only for geometries with a non-const GeometryData.
* E.g. QuadraturePointGeometries.
*/
virtual void SetGeometryShapeFunctionContainer(
const GeometryShapeFunctionContainer<GeometryData::IntegrationMethod>& rGeometryShapeFunctionContainer)
{
KRATOS_ERROR <<
"Calling SetGeometryShapeFunctionContainer from base geometry class."
<< std::endl;
}
///@}
///@name Id
///@{
/// Id of this Geometry
IndexType const& Id() const
{
return mId;
}
/// Returns if id was generated from a geometry name
bool IsIdGeneratedFromString()
{
return IsIdGeneratedFromString(mId);
}
/// Returns if id was generated by itself
bool IsIdSelfAssigned()
{
return IsIdSelfAssigned(mId);
}