27 : mesh(mesh), algorithm13_(mesh), algorithm23_(mesh), algorithm22_(mesh), algorithm12_(mesh)
39 else xprintf(
Err,
"Not implemented for dim %d\n.",dim);
46 double subtotal = 0.0;
50 double t1d_length = ele.
measure();
62 subtotal += local_length*t1d_length;
70 double subtotal = 0.0;
75 subtotal += 2*localArea*t2dArea;
83 double subtotal = 0.0;
94 val = arma::norm(from - to, 2);
108 template<u
int dim_A, u
int dim_B>
121 storage.push_back(isec);
132 template<u
int dim_A, u
int dim_B>
135 for(
auto &isec : storage) {
137 unsigned int ele_a_idx = isec.component_ele_idx();
138 unsigned int ele_b_idx = isec.bulk_ele_idx();
142 std::make_pair(ele_b_idx, &(isec)) );
148 std::make_pair(ele_a_idx, &(isec)) );
158 template<
unsigned int dim>
169 default:
ASSERT(0).error(
"Unsupported search algorithm.");
178 unsigned int idx = elm.idx();
180 if(elm->dim() == dim)
249 storage.shrink_to_fit();
331 bool mesh_in_2d_only =
false;
333 for(
uint axis = 0; axis < bb.dimension; axis++)
361 if( mesh_in_2d_only){
373 DebugOut() <<
"Intersection Algorithm d12_3\n";
380 DebugOut() <<
"Intersection Algorithm d12_2\n";
405 string t_name = name;
407 unsigned int number_of_intersection_points = 0;
415 file = fopen((t_name.append(
".msh")).c_str(),
"w");
417 fprintf(file,
"$MeshFormat\n");
419 fprintf(file,
"$EndMeshFormat\n");
423 unsigned int idx = 1;
426 fprintf(file,
"%d %.16f %.16f %.16f\n", idx, _nod[0], _nod[1], _nod[2]);
435 for(
unsigned int k = 0; k < il.
size();k++){
450 fprintf(file,
"%d %.16f %.16f %.16f\n", number_of_nodes, global[0], global[1], global[2]);
459 if(elee->dim() == 3){
460 int id1 = elee.node_accessor(0).idx() + 1;
461 int id2 = elee.node_accessor(1).idx() + 1;
462 int id3 = elee.node_accessor(2).idx() + 1;
463 int id4 = elee.node_accessor(3).idx() + 1;
465 fprintf(file,
"%d 4 2 %d %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3, id4);
466 }
else if(elee->dim() == 2){
467 int id1 = elee.node_accessor(0).idx() + 1;
468 int id2 = elee.node_accessor(1).idx() + 1;
469 int id3 = elee.node_accessor(2).idx() + 1;
470 fprintf(file,
"%d 2 2 %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3);
472 }
else if(elee->dim() == 1){
473 int id1 = elee.node_accessor(0).idx() + 1;
474 int id2 = elee.node_accessor(1).idx() + 1;
475 fprintf(file,
"%d 1 2 %d %d %d %d\n",elee.idx(), elee.region().id(), elee->pid(), id1, id2);
484 number_of_elements++;
487 fprintf(file,
"%d 1 2 1001 0 %d %d\n", number_of_elements, nodes, nodes);
488 }
else if(il.
size() == 2){
489 fprintf(file,
"%d 1 2 1001 0 %d %d\n", number_of_elements, nodes, nodes+1);
494 fprintf(file,
"$EndElements\n");
501 string t_name = name;
503 unsigned int number_of_intersection_points = 0;
511 file = fopen((t_name.append(
".msh")).c_str(),
"w");
513 fprintf(file,
"$MeshFormat\n");
515 fprintf(file,
"$EndMeshFormat\n");
519 unsigned int idx = 1;
522 fprintf(file,
"%d %.16f %.16f %.16f\n", idx, _nod[0], _nod[1], _nod[2]);
547 fprintf(file,
"%d %.16f %.16f %.16f\n", number_of_nodes, global[0], global[1], global[2]);
556 if(elee->dim() == 3){
557 int id1 = elee.node_accessor(0).idx() + 1;
558 int id2 = elee.node_accessor(1).idx() + 1;
559 int id3 = elee.node_accessor(2).idx() + 1;
560 int id4 = elee.node_accessor(3).idx() + 1;
562 fprintf(file,
"%d 4 2 %d %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3, id4);
563 }
else if(elee->dim() == 2){
564 int id1 = elee.node_accessor(0).idx() + 1;
565 int id2 = elee.node_accessor(1).idx() + 1;
566 int id3 = elee.node_accessor(2).idx() + 1;
567 fprintf(file,
"%d 2 2 %d %d %d %d %d\n", elee.idx(), elee.region().id(), elee->pid(), id1, id2, id3);
570 int id1 = elee.node_accessor(0).idx() + 1;
571 int id2 = elee.node_accessor(1).idx() + 1;
572 fprintf(file,
"%d 1 2 %d %d %d %d\n",elee.idx(), elee.region().id(), elee->pid(), id1, id2);
577 unsigned int last = 0;
583 for(
unsigned int k = 0; k < il.
size();k++){
585 number_of_elements++;
591 if((k+1) == il.
size() && il.
size()){
592 fprintf(file,
"%d 1 2 1002 0 %d %d\n", number_of_elements, nodes, last);
594 fprintf(file,
"%d 1 2 1002 0 %d %d\n", number_of_elements, nodes, nodes+1);
600 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.