14 #if !defined(KRATOS_REORDER_AND_OPTIMIZE_MODELPART_PROCESS_H_INCLUDED )
15 #define KRATOS_REORDER_AND_OPTIMIZE_MODELPART_PROCESS_H_INCLUDED
77 void Execute()
override;
95 std::string
Info()
const override;
98 void PrintInfo(std::ostream& rOStream)
const override;
101 void PrintData(std::ostream& rOStream)
const override;
125 void ActualizeSubModelPart(
ModelPart& subpart);
126 void OptimizeOrdering();
127 void ReorderElements();
138 template <
bool reverse = false>
141 template <
class Matrix>
144 const int n =
A.size1();
145 std::vector<int> perm(
n);
163 std::vector<int> degree(
n);
164 std::vector<int> levelSet(
n, 0);
165 std::vector<int> nextSameDegree(
n, -1);
167 for(
int i = 0;
i <
n; ++
i)
169 degree[
i] =
A.index1_data()[
i+1] -
A.index1_data()[
i];
170 maxDegree =
std::max(maxDegree, degree[
i]);
173 std::vector<int> firstWithDegree(maxDegree + 1, -1);
174 std::vector<int> nFirstWithDegree(maxDegree + 1);
177 perm[0] = initialNode;
178 int currentLevelSet = 1;
179 levelSet[initialNode] = currentLevelSet;
180 int maxDegreeInCurrentLevelSet = degree[initialNode];
181 firstWithDegree[maxDegreeInCurrentLevelSet] = initialNode;
184 for (
int next = 1; next <
n; )
187 std::fill(nFirstWithDegree.begin(), nFirstWithDegree.end(), -1);
190 int firstVal = reverse ? maxDegreeInCurrentLevelSet : 0;
191 int finalVal = reverse ? -1 : maxDegreeInCurrentLevelSet + 1;
192 int increment = reverse ? -1 : 1;
194 for(
int soughtDegree = firstVal; soughtDegree != finalVal; soughtDegree += increment)
196 int node = firstWithDegree[soughtDegree];
200 for(
auto a =
A.index1_data()[
node] ;
a<
A.index1_data()[
node+1]; ++
a)
202 int c =
A.index2_data()[
a];
203 if (levelSet[
c] == 0)
205 levelSet[
c] = currentLevelSet + 1;
209 nextSameDegree[
c] = nFirstWithDegree[degree[
c]];
210 nFirstWithDegree[degree[
c]] =
c;
219 maxDegreeInCurrentLevelSet = nMDICLS;
220 for(
int i = 0;
i <= nMDICLS; ++
i)
221 firstWithDegree[
i] = nFirstWithDegree[
i];
228 for(
int i = 0;
i <
n; ++
i)
230 if (levelSet[
i] == 0)
234 levelSet[
i] = currentLevelSet;
235 maxDegreeInCurrentLevelSet = degree[
i];
236 firstWithDegree[maxDegreeInCurrentLevelSet] =
i;
281 rOStream << std::endl;
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Geometry base class.
Definition: geometry.h:71
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
The base class for all processes in Kratos.
Definition: process.h:49
Short class definition.
Definition: reorder_and_optimize_modelpart_process.h:41
ModelPart & mrModelPart
Definition: reorder_and_optimize_modelpart_process.h:119
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: reorder_and_optimize_modelpart_process.cpp:248
ReorderAndOptimizeModelPartProcess(ReorderAndOptimizeModelPartProcess const &rOther)=delete
The object is not copyable.
KRATOS_CLASS_POINTER_DEFINITION(ReorderAndOptimizeModelPartProcess)
Pointer definition of ReorderAndOptimizeModelPartProcess.
~ReorderAndOptimizeModelPartProcess() override
Destructor.
Definition: reorder_and_optimize_modelpart_process.h:64
ReorderAndOptimizeModelPartProcess()=delete
Default constructor is deleted.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: reorder_and_optimize_modelpart_process.cpp:243
ReorderAndOptimizeModelPartProcess & operator=(ReorderAndOptimizeModelPartProcess const &rOther)=delete
It is not assignable.
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
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
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17
Definition: reorder_and_optimize_modelpart_process.h:140
static void get(const Matrix &A, std::vector< int > &invperm)
Definition: reorder_and_optimize_modelpart_process.h:142
Definition: mesh_converter.cpp:38