KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
model_part_graph_utilities.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Riccardo Rossi
11 //
12 
13 #pragma once
14 
15 // System includes
16 #include <string>
17 #include <iostream>
18 
19 // External includes
20 
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "includes/model_part.h"
26 
27 
28 namespace Kratos
29 {
32 
35 
39 
43 
47 
51 
53 
55 class KRATOS_API(KRATOS_CORE) ModelPartGraphUtilities
56 {
57 public:
60  typedef unsigned int IndexType;
61 
64 
68 
71 
74 
78 
81 
85 
93  static Kratos::unique_ptr<SparseContiguousRowGraph<>> ComputeGraph(const ModelPart& rModelPart);
94 
102  static std::pair<DenseVector<IndexType>, DenseVector<IndexType>> ComputeCSRGraph(const ModelPart& rModelPart);
103 
111  static std::pair<IndexType, DenseVector<double>> ComputeConnectedComponents(
112  const ModelPart::NodesContainerType& rNodes,
113  const DenseVector<IndexType>& rRowIndices,
114  const DenseVector<IndexType>& rColIndices
115  );
116 
117  //similar to the previous version, except that a "active_nodes" array needs to be passed
118  //the "active_nodes" array needs to be initialized without gaps in the same order in which the nodes are passed in the rNodes array
119  static std::pair<IndexType, DenseVector<double>> ComputeConnectedComponentsWithActiveNodesCheck(
120  const ModelPart::NodesContainerType& rNodes,
121  const DenseVector<IndexType>& rRowIndices,
122  const DenseVector<IndexType>& rColIndices,
123  const std::vector<bool>& active_nodes_list
124  );
125 
126  static std::vector<IndexType> ApplyMinimalScalarFixity(
128  const Variable<double>& rVar,
130  const IndexType ncolors
131  );
132 
136 
137 
141 
142 
146 
150 
151 
153 
154 protected:
157 
158 
162 
163 
167 
168 
172  // BFS algorithm for computing connected components - simplest version - only considers connectivity
173  static void BreadthFirstSearch(
174  const int startVertex,
175  const int color,
176  const DenseVector<IndexType>& rRowIndices,
177  const DenseVector<IndexType>& rColIndices,
178  std::unordered_map<IndexType, int>& rVisited);
179 
180  // BFS algorithm for computing connected components
181  // an edge is active only if both endpoints are marked as active in the "active_nodes" map
182  static void BreadthFirstSearchWithActiveNodesCheck(
183  const int startVertex,
184  const int color,
185  const DenseVector<IndexType>& rRowIndices,
186  const DenseVector<IndexType>& rColIndices,
187  std::unordered_map<IndexType, int>& rVisited,
188  const std::unordered_map<IndexType, bool>& rActiveNodes);
189 
193 
194 
198 
199 
203 
204 
206 
207 private:
210 
211 
215 
216 
220 
221 
225 
226 
230 
231 
235 
236 
240 
242 
243 }; // Class ModelPartGraphUtilities
244 
246 
249 
250 
254 
256 
258 
259 } // namespace Kratos.
260 
261 
262 
Definition: amatrix_interface.h:41
This file computes the graph representing the connectivity of a modelpart.
Definition: model_part_graph_utilities.h:56
ModelPartGraphUtilities(ModelPartGraphUtilities const &rOther)=delete
Copy constructor.
ModelPartGraphUtilities & operator=(ModelPartGraphUtilities const &rOther)=delete
Assignment operator.
KRATOS_CLASS_POINTER_DEFINITION(ModelPartGraphUtilities)
Pointer definition of ModelPartGraphUtilities.
ModelPartGraphUtilities()=delete
no constructor.
unsigned int IndexType
Definition: model_part_graph_utilities.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
color
Definition: all_t_win_vs_m_fixed_error.py:230
Definition: colors.py:1