15 #if !defined(KRATOS_COUPLING_GEOMETRY_H_INCLUDED )
16 #define KRATOS_COUPLING_GEOMETRY_H_INCLUDED
85 mpGeometries.resize(2);
87 mpGeometries[0] = pMasterGeometry;
88 mpGeometries[1] = pSlaveGeometry;
107 , mpGeometries(rOther.mpGeometries)
115 , mpGeometries( rOther.mpGeometries )
130 mpGeometries = rOther.mpGeometries;
135 template<
class TOtherPo
intType>
140 mpGeometries = rOther.mpGeometries;
151 return Kratos::make_shared<CouplingGeometry>();
168 <<
Index <<
" out of range. CouplingGeometry #" << this->
Id()
169 <<
" has " << mpGeometries.size() <<
" geometries." << std::endl;
171 return mpGeometries[
Index];
184 <<
Index <<
"\" out of range. CouplingGeometry #" << this->
Id()
185 <<
" has " << mpGeometries.size() <<
" geometries." << std::endl;
187 return mpGeometries[
Index];
201 <<
Index <<
" composite contains only of: "
202 << mpGeometries.size() <<
" geometries." << std::endl;
208 mpGeometries[
Index] = pGeometry;
217 const IndexType new_index = mpGeometries.size();
219 mpGeometries.push_back(pGeometry);
230 const IndexType geometry_id = pGeometry->Id();
232 for (
const auto& p_geom : mpGeometries) {
233 if (p_geom->Id() == geometry_id) {
248 KRATOS_ERROR_IF(
Index == 0) <<
"Master geometry should not be removed from the CouplingGeometry" << std::endl;
252 mpGeometries[
i] = mpGeometries[
i + 1];
254 mpGeometries[number_of_geometries - 1] =
nullptr;
255 mpGeometries.erase(mpGeometries.begin() + number_of_geometries - 1);
278 return mpGeometries.size();
291 KRATOS_DEBUG_ERROR_IF(mpGeometries.size() == 0) <<
"No master assigned. Geometry vector of size 0." << std::endl;
293 return mpGeometries[0]->DomainSize();
302 KRATOS_DEBUG_ERROR_IF(mpGeometries.size() == 0) <<
"No master assigned. Geometry vector of size 0." << std::endl;
304 return mpGeometries[0]->Center();
319 std::vector<double>& rSpans,
320 IndexType LocalDirectionIndex = 0)
const override
322 const double model_tolerance = 1
e-2;
325 std::vector<double> master_span_intersections_in_master_local_space;
326 std::vector<double> slave_span_intersections_in_master_local_space;
328 mpGeometries[0]->SpansLocalSpace(master_span_intersections_in_master_local_space);
333 *(mpGeometries[0].get()),
334 master_span_intersections_in_master_local_space,
342 std::vector<double> intersection_slave_spans;
343 mpGeometries[
i]->SpansLocalSpace(intersection_slave_spans);
345 for (
IndexType j = 0;
j < intersection_slave_spans.size(); ++
j) {
346 local_coords_span_intersection_on_slave[0] = intersection_slave_spans[
j];
348 mpGeometries[
i]->GlobalCoordinates(
349 global_coords_span_intersection_on_slave, local_coords_span_intersection_on_slave);
352 global_coords_span_intersection_on_slave, global_coords_master, local_coords_master);
354 int success = mpGeometries[0]->ProjectionPointGlobalToLocalSpace(
355 global_coords_span_intersection_on_slave, local_coords_master);
358 mpGeometries[0]->GlobalCoordinates(global_coords_master, local_coords_master);
361 || (success == 0 && (
norm_2(global_coords_span_intersection_on_slave - local_coords_master) < model_tolerance)))
362 <<
"Projection of intersection spans failed. Global Coordinates on slave: "
363 << global_coords_span_intersection_on_slave <<
", and global coordinates on master: "
364 << global_coords_master <<
". Difference: " <<
norm_2(global_coords_span_intersection_on_slave - global_coords_master)
365 <<
" larger than model tolerance: " << model_tolerance << std::endl;
368 slave_span_intersections_in_master_local_space.push_back(local_coords_master[0]);
372 MergeSpans(rSpans, master_span_intersections_in_master_local_space, slave_span_intersections_in_master_local_space);
385 std::vector<SizeType> number_of_points_per_span_per_direction(local_space_dimension);
386 std::vector<IntegrationInfo::QuadratureMethod> quadrature_method_per_direction(local_space_dimension);
392 number_of_points_per_span_per_direction[
i] = max_p;
396 return IntegrationInfo(number_of_points_per_span_per_direction, quadrature_method_per_direction);
411 std::vector<double> spans;
415 rIntegrationPoints, spans, rIntegrationInfo);
435 IndexType NumberOfShapeFunctionDerivatives,
439 const double model_tolerance = 1
e-2;
441 const SizeType num_integration_points = rIntegrationPoints.size();
443 if (rResultGeometries.
size() != num_integration_points) {
444 rResultGeometries.
resize(num_integration_points);
449 mpGeometries[0]->CreateQuadraturePointGeometries(
450 master_quadrature_points,
451 NumberOfShapeFunctionDerivatives,
457 for (
SizeType i = 0;
i < num_integration_points; ++
i) {
458 integration_points_global_coords_vector[
i] = master_quadrature_points[
i].Center();
466 if (!rIntegrationInfo.
Is(IntegrationInfo::DO_NOT_CREATE_TESSELLATION_ON_SLAVE)) {
471 for (
SizeType j = 0;
j < num_integration_points; ++
j) {
473 integration_points_global_coords_vector[
j],
477 mpGeometries[1]->ProjectionPointGlobalToLocalSpace(
478 integration_points_global_coords_vector[
j],
481 integration_points_slave[
j][0] = local_slave_coords[0];
482 integration_points_slave[
j][1] = local_slave_coords[1];
483 integration_points_slave[
j][2] = local_slave_coords[2];
488 <<
"-dimensional objects is not implemented." << std::endl;
492 for (
SizeType j = 0;
j < num_integration_points; ++
j) {
493 mpGeometries[1]->ProjectionPointGlobalToLocalSpace(
494 integration_points_global_coords_vector[
j],
497 integration_points_slave[
j][0] = local_slave_coords[0];
498 integration_points_slave[
j][1] = local_slave_coords[1];
499 integration_points_slave[
j][2] = local_slave_coords[2];
504 mpGeometries[1]->CreateQuadraturePointGeometries(
505 slave_quadrature_points,
506 NumberOfShapeFunctionDerivatives,
507 integration_points_slave,
510 for (
SizeType i = 0;
i < num_integration_points; ++
i) {
512 <<
"Difference between master and slave coordinates above model tolerance of " << model_tolerance
513 <<
". Location of master: " << master_quadrature_points(
i)->Center() <<
", location of slave: "
514 << slave_quadrature_points(
i)->Center() <<
". Distance: "
515 <<
norm_2(master_quadrature_points(
i)->
Center() - slave_quadrature_points(
i)->
Center()) << std::endl;
517 rResultGeometries(
i) = Kratos::make_shared<CouplingGeometry<PointType>>(
518 master_quadrature_points(
i), slave_quadrature_points(
i));
522 <<
"CreateQuadraturePointGeometries not implemented for coupling of more than 2 geomtries. "
523 << mpGeometries.size() <<
" are given." << std::endl;
528 IndexType NumberOfShapeFunctionDerivatives,
531 const double model_tolerance = 1
e-3;
537 rResultGeometries.
resize(1);
540 mpGeometries[0]->CreateQuadraturePointGeometries(
541 master_quadrature_points,
542 NumberOfShapeFunctionDerivatives,
546 mpGeometries[1]->CreateQuadraturePointGeometries(
547 slave_quadrature_points,
548 NumberOfShapeFunctionDerivatives,
552 <<
"Difference between master and slave coordinates above model tolerance of " << model_tolerance
553 <<
". Location of master: " << master_quadrature_points(0)->Center() <<
", location of slave: "
554 << slave_quadrature_points(0)->Center() <<
". Distance: "
555 <<
norm_2(master_quadrature_points(0)->
Center() - slave_quadrature_points(0)->
Center()) << std::endl;
557 rResultGeometries(0) = Kratos::make_shared<CouplingGeometry<PointType>>(
558 master_quadrature_points(0), slave_quadrature_points(0));
560 if (mpGeometries.size() > 2) {
563 mpGeometries[
i]->CreateQuadraturePointGeometries(
564 more_slave_quadrature_points,
565 NumberOfShapeFunctionDerivatives,
569 <<
"Difference between master and slave coordinates above model tolerance of " << model_tolerance
570 <<
". Location of master: " << master_quadrature_points(0)->Center() <<
", location of slave: "
571 << more_slave_quadrature_points(0)->Center() <<
". Distance: "
572 <<
norm_2(master_quadrature_points(0)->
Center() - more_slave_quadrature_points(0)->
Center()) << std::endl;
574 rResultGeometries(0)->AddGeometryPart(more_slave_quadrature_points(0));
585 std::vector<double>& rResultSpans,
586 const std::vector<double>& rSpans1,
587 const std::vector<double>& rSpans2,
588 double Tolerance = 1
e-6)
590 NurbsInterval interval_1(rSpans1[0], rSpans1[rSpans1.size() - 1]);
591 NurbsInterval interval_2(rSpans2[0], rSpans2[rSpans2.size() - 1]);
594 double temp = rSpans1[
i];
596 rResultSpans.push_back(
temp);
599 double temp = rSpans2[
i];
601 rResultSpans.push_back(
temp);
608 std::vector<double>& rResultSpans,
609 const double Tolerance)
611 std::sort(std::begin(rResultSpans),
std::end(rResultSpans));
613 auto last = std::unique(std::begin(rResultSpans),
std::end(rResultSpans),
614 [Tolerance](
double a,
double b) {
return b -
a < Tolerance; });
616 auto nb_unique = std::distance(std::begin(rResultSpans), last);
618 rResultSpans.resize(nb_unique);
640 std::string
Info()
const override
642 return "Coupling geometry that holds a master and a set of slave geometries.";
648 rOStream <<
"Coupling geometry that holds a master and a set of slave geometries.";
655 std::cout << std::endl;
656 rOStream <<
" CouplingGeometry with " << mpGeometries.size() <<
" geometries.";
672 void save(
Serializer& rSerializer )
const override
675 rSerializer.
save(
"Geometries", mpGeometries);
681 rSerializer.
load(
"Geometries", mpGeometries);
700 std::istream& rIStream,
706 std::ostream& rOStream,
710 rOStream << std::endl;
The CouplingGeometry connects two or more geometries of different types and entities.
Definition: coupling_geometry.h:41
KRATOS_CLASS_POINTER_DEFINITION(CouplingGeometry)
Pointer definition of CouplingGeometry.
BaseType::Pointer Create(PointsArrayType const &ThisPoints) const override
Creates a new geometry pointer.
Definition: coupling_geometry.h:148
void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) override
Definition: coupling_geometry.h:433
virtual void SpansLocalSpace(std::vector< double > &rSpans, IndexType LocalDirectionIndex=0) const override
Definition: coupling_geometry.h:318
BaseType::IndexType IndexType
Definition: coupling_geometry.h:59
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: coupling_geometry.h:652
CouplingGeometry(CouplingGeometry const &rOther)
Copy constructor.
Definition: coupling_geometry.h:105
PointerVector< GeometryType > GeometriesArrayType
Definition: coupling_geometry.h:66
void RemoveGeometryPart(const IndexType Index) override
Removes a geometry part.
Definition: coupling_geometry.h:246
void CreateIntegrationPoints(IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) const override
Definition: coupling_geometry.h:406
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: coupling_geometry.h:64
bool HasGeometryPart(const IndexType Index) const override
Use to check if certain Indexed object is within the geometry parts of this geometry.
Definition: coupling_geometry.h:263
CouplingGeometry(GeometryPointer pMasterGeometry, GeometryPointer pSlaveGeometry)
Constructor for coupling one master to one slave geometry.
Definition: coupling_geometry.h:80
static constexpr IndexType Master
Definition: coupling_geometry.h:72
Geometry< TPointType > GeometryType
Definition: coupling_geometry.h:49
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: coupling_geometry.h:630
CouplingGeometry & operator=(CouplingGeometry< TOtherPointType > const &rOther)
Assignment operator with different point type.
Definition: coupling_geometry.h:136
~CouplingGeometry() override=default
Destructor.
std::vector< GeometryPointer > GeometryPointerVector
Definition: coupling_geometry.h:52
void RemoveGeometryPart(GeometryPointer pGeometry) override
Removes a geometry part.
Definition: coupling_geometry.h:228
IndexType AddGeometryPart(GeometryPointer pGeometry) override
Allows to enhance the coupling geometry, with another geometry.
Definition: coupling_geometry.h:215
static constexpr IndexType Slave
Definition: coupling_geometry.h:73
GeometryPointer pGetGeometryPart(const IndexType Index) override
This function returns the pointer of the geometry part which is corresponding to the index....
Definition: coupling_geometry.h:165
BaseType::SizeType SizeType
Definition: coupling_geometry.h:60
CouplingGeometry(CouplingGeometry< TOtherPointType > const &rOther)
Copy constructor with other point type.
Definition: coupling_geometry.h:112
GeometryType::Pointer GeometryPointer
Definition: coupling_geometry.h:51
static void MergeSpans(std::vector< double > &rResultSpans, const std::vector< double > &rSpans1, const std::vector< double > &rSpans2, double Tolerance=1e-6)
Definition: coupling_geometry.h:584
double DomainSize() const override
Returns the domain size of the master geometry.
Definition: coupling_geometry.h:289
TPointType PointType
Definition: coupling_geometry.h:57
CouplingGeometry & operator=(const CouplingGeometry &rOther)
Assignment operator.
Definition: coupling_geometry.h:127
Geometry< TPointType > BaseType
Geometry as base class.
Definition: coupling_geometry.h:48
CouplingGeometry()
Definition: coupling_geometry.h:99
BaseType::PointsArrayType PointsArrayType
Definition: coupling_geometry.h:63
CouplingGeometry(GeometryPointerVector GeometryPointerVector)
Constructor for coupling multiple points.
Definition: coupling_geometry.h:92
std::vector< CoordinatesArrayType > CoordinatesArrayVectorType
Definition: coupling_geometry.h:65
void SetGeometryPart(const IndexType Index, GeometryPointer pGeometry) override
Allows to exchange certain geometries.
Definition: coupling_geometry.h:195
Point Center() const override
Returns the center of the master geometry.
Definition: coupling_geometry.h:300
const GeometryPointer pGetGeometryPart(const IndexType Index) const override
This function returns the const pointer of the geometry part which is corresponding to the index....
Definition: coupling_geometry.h:181
static void SortUnique(std::vector< double > &rResultSpans, const double Tolerance)
Definition: coupling_geometry.h:607
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: coupling_geometry.h:62
SizeType NumberOfGeometryParts() const override
The number of geometry part.
Definition: coupling_geometry.h:276
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: coupling_geometry.h:625
IntegrationInfo GetDefaultIntegrationInfo() const override
Provides the default integration per geometry.
Definition: coupling_geometry.h:381
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: coupling_geometry.h:646
std::string Info() const override
Turn back information as a string.
Definition: coupling_geometry.h:640
void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, IntegrationInfo &rIntegrationInfo) override
Definition: coupling_geometry.h:526
Definition: curve_tessellation.h:32
void Tessellate(const GeometryType &rGeometry, const int PolynomialDegree, const NurbsInterval DomainInterval, const std::vector< NurbsInterval > &rKnotSpanIntervals, const double Tolerance)
Definition: curve_tessellation.h:68
static void GetClosestPoint(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rClosestPointGlobalCoordinates, CoordinatesArrayType &rClosestPointLocalCoordinates, const TessellationType &rTesselation)
Definition: curve_tessellation.h:318
bool Is(Flags const &rOther) const
Definition: flags.h:274
KratosGeometryType
Definition: geometry_data.h:110
@ Kratos_Coupling_Geometry
KratosGeometryFamily
Definition: geometry_data.h:91
Geometry base class.
Definition: geometry.h:71
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: geometry.h:3834
Geometry & operator=(const Geometry &rOther)
Definition: geometry.h:400
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
void SetGeometryData(GeometryData const *pGeometryData)
updates the pointer to GeometryData of the respective geometry.
Definition: geometry.h:3878
SizeType LocalSpaceDimension() const
Definition: geometry.h:1300
std::size_t SizeType
Definition: geometry.h:144
std::size_t IndexType
Definition: geometry.h:137
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
virtual SizeType PolynomialDegree(IndexType LocalDirectionIndex) const
Return polynomial degree of the geometry in a certain direction.
Definition: geometry.h:1310
virtual void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo)
Definition: geometry.h:2331
GeometryData const & GetGeometryData() const
GeometryData contains all information about dimensions and has a set of precomputed values for integr...
Definition: geometry.h:942
Integration information for the creation of integration points.
Definition: integration_info.h:35
static void CreateIntegrationPoints1D(IntegrationPointsArrayType &rIntegrationPoints, const std::vector< double > &rSpansLocalSpace, const IntegrationInfo &rIntegrationInfo)
Definition: integration_point_utilities.cpp:18
Class for optimized use of intervals.
Definition: nurbs_interval.h:36
bool IsInside(double &ParameterT) const
Definition: nurbs_interval.h:143
Point class.
Definition: point.h:59
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
size_type size() const
Definition: pointer_vector.h:255
void resize(size_type dim)
Definition: pointer_vector.h:314
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
Short class definition.
Definition: array_1d.h:61
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
end
Definition: DEM_benchmarks.py:180
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
a
Definition: generate_stokes_twofluid_element.py:77
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
def load(f)
Definition: ode_solve.py:307
int j
Definition: quadrature.py:648
float temp
Definition: rotating_cone.py:85
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31