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.
construct_system_matrix_elemental_process.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 
14 
15 #if !defined(KRATOS_CONSTRUCT_SYSTEM_MATRIX_ELEMENTAL_PROCESS_H_INCLUDED )
16 #define KRATOS_CONSTRUCT_SYSTEM_MATRIX_ELEMENTAL_PROCESS_H_INCLUDED
17 
18 
19 
20 // System includes
21 #include <string>
22 #include <iostream>
23 
24 
25 // External includes
26 
27 
28 // Project includes
29 #include "includes/define.h"
30 #include "processes/process.h"
32 
33 
34 namespace Kratos
35 {
36 
39 
43 
47 
51 
55 
57 
59 template<class TSystemSpaceType, class TDirichletSpaceType = TSystemSpaceType>
61 {
62 public:
65 
68 
70 
72 
74 
76 
80 
83  : mElements(rElements), mSystemMatrix(rSystemMatrix), mDirichletMatrix(rDirichletMatrix) {}
84 
87 
88 
92 
93 
97 
98  virtual void Execute()
99  {
100  std::size_t equation_size = TSystemSpaceType::Size1(mSystemMatrix);
101  std::vector<std::vector<std::size_t> > indices(equation_size);
102  std::vector<std::vector<std::size_t> > dirichlet_indices(TSystemSpaceType::Size1(mDirichletMatrix));
103 
104  ProcessInfo process_info;
105  for(ElementsContainerType::iterator i_element = mElements.begin() ; i_element != mElements.end() ; i_element++)
106  {
108 
109  i_element->EquationIdVector(ids, process_info);
110  for(std::size_t i = 0 ; i < 3 ; i++)
111  if(ids[i] < equation_size)
112  for(std::size_t j = 0 ; j < 3 ; j++)
113  if(ids[j] < equation_size)
114  indices[ids[i]].push_back(ids[j]);
115  else
116  dirichlet_indices[ids[i]].push_back(ids[j]- equation_size);
117 
118  }
119  for(std::size_t i = 0 ; i < indices.size() ; i++)
120  {
121  std::vector<std::size_t>& row_indices = indices[i];
122  std::vector<std::size_t>& dirichlet_row_indices = dirichlet_indices[i];
123  std::sort(row_indices.begin(), row_indices.end());
124  std::unique(row_indices.begin(), row_indices.end());
125  std::sort(dirichlet_row_indices.begin(), dirichlet_row_indices.end());
126  std::unique(dirichlet_row_indices.begin(), dirichlet_row_indices.end());
127  for(std::size_t j = 0 ; j < row_indices.size() ; j++)
128  mSystemMatrix()(i,row_indices[j]) = 0.00;
129  for(std::size_t j = 0 ; j < dirichlet_row_indices.size() ; j++)
130  mDirichletMatrix()(i,dirichlet_row_indices[j]) = 0.00;
131  }
132  for(std::size_t i = 0 ; i < indices.size() ; i++) // To make put at least one element per each row. Pooyan.
133  mDirichletMatrix()(i,0) = 0.00;
134  }
135 
136 
140 
141 
145 
146 
150 
152  virtual std::string Info() const
153  {
154  return "ConstructSystemMatrixElementalProcess";
155  }
156 
158  virtual void PrintInfo(std::ostream& rOStream) const
159  {
160  rOStream << "ConstructSystemMatrixElementalProcess";
161  }
162 
164  virtual void PrintData(std::ostream& rOStream) const
165  {
166  rOStream << " System matrix non zeros : " << mSystemMatrix().non_zeros() << std::endl;
167  rOStream << " Dirichlet matrix non zeros : " << mDirichletMatrix().non_zeros() << std::endl;
168  }
169 
170 
174 
175 
177 
178 protected:
181 
182 
186 
190 
194 
195 
199 
200 
204 
205 
209 
210 
214 
215 
217 
218 private:
221 
222 
226 
227 
231 
232 
236 
237 
241 
242 
246 
247 
251 
254 
257 
258 
260 
261 }; // Class ConstructSystemMatrixElementalProcess
262 
264 
267 
268 
272 
273 
275 
276 template<class TSystemSpaceType, class TDirichletSpaceType>
277 inline std::istream& operator >> (std::istream& rIStream,
279 
281 template<class TSystemSpaceType, class TDirichletSpaceType>
282 inline std::ostream& operator << (std::ostream& rOStream,
284 {
285  rThis.PrintInfo(rOStream);
286  rOStream << std::endl;
287  rThis.PrintData(rOStream);
288 
289  return rOStream;
290 }
292 
293 
294 } // namespace Kratos.
295 
296 #endif // KRATOS_CONSTRUCT_SYSTEM_MATRIX_ELEMENTAL_PROCESS_H_INCLUDED defined
297 
298 
Short class definition.
Definition: construct_system_matrix_elemental_process.h:61
ConstructSystemMatrixElementalProcess(ElementsContainerType &rElements, SystemMatrixType &rSystemMatrix, DirichletMatrixType &rDirichletMatrix)
Constructor.
Definition: construct_system_matrix_elemental_process.h:82
virtual ~ConstructSystemMatrixElementalProcess()
Destructor.
Definition: construct_system_matrix_elemental_process.h:86
virtual std::string Info() const
Turn back information as a string.
Definition: construct_system_matrix_elemental_process.h:152
DirichletMatrixType & mDirichletMatrix
Definition: construct_system_matrix_elemental_process.h:189
PointerVectorSet< ElementType, IndexedObject > ElementsContainerType
Definition: construct_system_matrix_elemental_process.h:75
Element ElementType
Definition: construct_system_matrix_elemental_process.h:73
virtual void Execute()
Execute method is used to execute the Process algorithms.
Definition: construct_system_matrix_elemental_process.h:98
TSystemSpaceType::MatrixType SystemMatrixType
Definition: construct_system_matrix_elemental_process.h:69
KRATOS_CLASS_POINTER_DEFINITION(ConstructSystemMatrixElementalProcess)
Pointer definition of ConstructSystemMatrixElementalProcess.
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: construct_system_matrix_elemental_process.h:164
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: construct_system_matrix_elemental_process.h:158
SystemMatrixType & mSystemMatrix
Definition: construct_system_matrix_elemental_process.h:188
ElementsContainerType & mElements
Definition: construct_system_matrix_elemental_process.h:187
TDirichletSpaceType::MatrixType DirichletMatrixType
Definition: construct_system_matrix_elemental_process.h:71
Base class for all Elements.
Definition: element.h:60
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
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
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
The base class for all processes in Kratos.
Definition: process.h:49
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Matrix MatrixType
Definition: geometrical_transformation_utilities.h:55
TSpaceType::IndexType Size1(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:117
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
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17