26 : mesh(mesh), algorithm13_(mesh), algorithm23_(mesh), algorithm22_(mesh), algorithm12_(mesh)
38 else xprintf(
Err,
"Not implemented for dim %d\n.",dim);
45 double subtotal = 0.0;
49 double t1d_length = ele.
measure();
61 subtotal += local_length*t1d_length;
69 double subtotal = 0.0;
74 subtotal += 2*localArea*t2dArea;
82 double subtotal = 0.0;
93 val = arma::norm(from - to, 2);
107 template<u
int dim_A, u
int dim_B>
120 storage.push_back(isec);
131 template<u
int dim_A, u
int dim_B>
134 for(
auto &isec : storage) {
136 unsigned int ele_a_idx = isec.component_ele_idx();
137 unsigned int ele_b_idx = isec.bulk_ele_idx();
141 std::make_pair(ele_b_idx, &(isec)) );
147 std::make_pair(ele_a_idx, &(isec)) );
157 template<
unsigned int dim>
168 default:
ASSERT(0).error(
"Unsupported search algorithm.");
177 unsigned int idx = elm.idx();
179 if(elm->dim() == dim)
248 storage.shrink_to_fit();
330 bool mesh_in_2d_only =
false;
332 for(
uint axis = 0; axis < bb.dimension; axis++)
360 if( mesh_in_2d_only){
372 DebugOut() <<
"Intersection Algorithm d12_3\n";
379 DebugOut() <<
"Intersection Algorithm d12_2\n";
404 string t_name = name;
406 unsigned int number_of_intersection_points = 0;
414 file = fopen((t_name.append(
".msh")).c_str(),
"w");
416 fprintf(file,
"$MeshFormat\n");
418 fprintf(file,
"$EndMeshFormat\n");
422 unsigned int idx = 1;
425 fprintf(file,
"%d %.16f %.16f %.16f\n", idx, _nod[0], _nod[1], _nod[2]);
434 for(
unsigned int k = 0; k < il.
size();k++){
449 fprintf(file,
"%d %.16f %.16f %.16f\n", number_of_nodes, global[0], global[1], global[2]);
458 if(elee->dim() == 3){
459 int id1 = elee.node_accessor(0).idx() + 1;
460 int id2 = elee.node_accessor(1).idx() + 1;
461 int id3 = elee.node_accessor(2).idx() + 1;
462 int id4 = elee.node_accessor(3).idx() + 1;
464 fprintf(file,
"%d 4 2 %d %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3, id4);
465 }
else if(elee->dim() == 2){
466 int id1 = elee.node_accessor(0).idx() + 1;
467 int id2 = elee.node_accessor(1).idx() + 1;
468 int id3 = elee.node_accessor(2).idx() + 1;
469 fprintf(file,
"%d 2 2 %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3);
471 }
else if(elee->dim() == 1){
472 int id1 = elee.node_accessor(0).idx() + 1;
473 int id2 = elee.node_accessor(1).idx() + 1;
474 fprintf(file,
"%d 1 2 %d %d %d %d\n",elee.idx(), elee.region().id(), elee->pid(), id1, id2);
483 number_of_elements++;
486 fprintf(file,
"%d 1 2 1001 0 %d %d\n", number_of_elements, nodes, nodes);
487 }
else if(il.
size() == 2){
488 fprintf(file,
"%d 1 2 1001 0 %d %d\n", number_of_elements, nodes, nodes+1);
493 fprintf(file,
"$EndElements\n");
500 string t_name = name;
502 unsigned int number_of_intersection_points = 0;
510 file = fopen((t_name.append(
".msh")).c_str(),
"w");
512 fprintf(file,
"$MeshFormat\n");
514 fprintf(file,
"$EndMeshFormat\n");
518 unsigned int idx = 1;
521 fprintf(file,
"%d %.16f %.16f %.16f\n", idx, _nod[0], _nod[1], _nod[2]);
546 fprintf(file,
"%d %.16f %.16f %.16f\n", number_of_nodes, global[0], global[1], global[2]);
555 if(elee->dim() == 3){
556 int id1 = elee.node_accessor(0).idx() + 1;
557 int id2 = elee.node_accessor(1).idx() + 1;
558 int id3 = elee.node_accessor(2).idx() + 1;
559 int id4 = elee.node_accessor(3).idx() + 1;
561 fprintf(file,
"%d 4 2 %d %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3, id4);
562 }
else if(elee->dim() == 2){
563 int id1 = elee.node_accessor(0).idx() + 1;
564 int id2 = elee.node_accessor(1).idx() + 1;
565 int id3 = elee.node_accessor(2).idx() + 1;
566 fprintf(file,
"%d 2 2 %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3);
569 int id1 = elee.node_accessor(0).idx() + 1;
570 int id2 = elee.node_accessor(1).idx() + 1;
571 fprintf(file,
"%d 1 2 %d %d %d %d\n",elee.idx(), elee.region().id(), elee->pid(), id1, id2);
576 unsigned int last = 0;
582 for(
unsigned int k = 0; k < il.
size();k++){
584 number_of_elements++;
590 if((k+1) == il.
size() && il.
size()){
591 fprintf(file,
"%d 1 2 1002 0 %d %d\n", number_of_elements, nodes, last);
593 fprintf(file,
"%d 1 2 1002 0 %d %d\n", number_of_elements, nodes, nodes+1);
599 fprintf(file,
"$EndElements\n");
IntersectionType
Selection of intersections of different dimensions.
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
void compute_intersections_22(std::vector< IntersectionLocal< 2, 2 >> &storage)
Classes with algorithms for computation of intersections of meshes.
MixedMeshIntersections(Mesh *mesh)
void print_mesh_to_file_13(std::string name)
Generates a mesh file of the given name, including the intersection.
Class represents intersection of two elements.
Class represents an intersection point of simplex<N> and simplex<M>. It contains barycentric coordina...
InspectElementsAlgorithm< 1 > algorithm13_
static const double geometry_epsilon
std::vector< std::vector< ILpair > > element_intersections_
unsigned int n_intersections_
Counter for intersection among elements.
unsigned int size() const
Returns number of intersection points.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
virtual unsigned int n_nodes() const
unsigned int component_counter_
void compute_intersections_BIHtree(const BIHTree &bih)
Uses only BIHtree to find intersection candidates. (No prolongation).
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
unsigned int component_ele_idx() const
Returns index of component element.
void print_mesh_to_file_23(std::string name)
void compute_intersections(std::vector< std::vector< ILpair >> &intersection_map, std::vector< IntersectionLocal< 2, 2 >> &storage)
Runs the core algorithm for computing 2D-2D intersection in 3D.
Global macros to enhance readability and debugging, general constants.
std::vector< IntersectionAux< 1, 2 > > intersectionaux_storage12_
Stores temporarily 1D-2D intersections.
void compute_intersections_12_2(std::vector< IntersectionLocal< 1, 2 >> &storage)
void compute_intersections_3(std::vector< std::vector< ILpair >> &intersection_map, std::vector< IntersectionLocal< 1, 2 >> &storage)
Runs the algorithm (3): compute 1D-2D intersection inside 3D mesh. It directly fills the intersection...
std::vector< std::vector< IntersectionAux< dim, 3 > > > intersection_list_
Resulting vector of intersections.
InspectElementsAlgorithm< 2 > algorithm23_
IntersectionSearch get_intersection_search()
Getter for input type selection for intersection search algorithm.
FMT_FUNC int fprintf(std::ostream &os, CStringRef format, ArgList args)
void compute_intersections_12_1(std::vector< IntersectionLocal< 1, 2 >> &storage)
const BoundingBox & tree_box() const
#define START_TIMER(tag)
Starts a timer with specified tag.
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
std::vector< IntersectionLocal< 1, 3 > > intersection_storage13_
Stores 1D-3D intersections.
double measure() const
Computes the measure of the element.
void append_to_index(std::vector< IntersectionLocal< dim_A, dim_B >> &storage)
double measure_13()
Computes the size of the intersection in dim dimenstions.
const BIHTree & get_bih_tree()
Getter for BIH. Creates and compute BIH at first call.
arma::vec3 coords(ElementAccessor< 3 > comp_ele) const
void compute_intersections_BB()
virtual unsigned int n_elements(bool boundary=false) const
Returns count of boundary or bulk elements.
void compute_intersections(IntersectionType d=IntersectionType::all)
void store_intersection(std::vector< IntersectionLocal< dim_A, dim_B >> &storage, IntersectionAux< dim_A, dim_B > &isec_aux)
~MixedMeshIntersections()
unsigned int number_of_components(unsigned int dim)
Class implements algorithm for dim-dimensional intersections with 3D elements.
InspectElementsAlgorithm22 algorithm22_
void compute_intersections(const BIHTree &bih)
Uses BIHtree to find the initial candidate of a component and then prolongates the component interset...
InspectElementsAlgorithm12 algorithm12_
#define END_TIMER(tag)
Ends a timer with specified tag.
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...
Range< NodeAccessor< 3 > > node_range() const
Returns range of nodes.
void compute_intersections_2(const BIHTree &bih)
Runs the algorithm (2): compute 1D-2D intersection in 3D ambient space BIH is used to find intersecti...
void compute_intersections_1(const BIHTree &bih)
Runs the algorithm (1): compute 1D-2D intersection in 2D plane. BIH is used to find intersection cand...
IntersectionSearch
Types of search algorithm for finding intersection candidates.
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
std::vector< IntersectionLocal< 2, 2 > > intersection_storage22_
Stores 2D-2D intersections.
void compute_intersections_12_3(std::vector< IntersectionLocal< 1, 2 >> &storage)
#define DebugOut()
Macro defining 'debug' record of log.
Internal class representing intersection point.
std::vector< IntersectionLocal< 1, 2 > > intersection_storage12_
Stores 1D-2D intersections.
Implementation of range helper class.
std::vector< IntersectionLocal< 2, 3 > > intersection_storage23_
Stores 2D-3D intersections.
Internal class representing intersection object.