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.
calculate_laplacian_simplex_condition.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: Guillermo Casas gcasas@gmail.com
11 //
12 
13 #ifndef KRATOS_CALCULATE_LAPLACIAN_SIMPLEX_CONDITION_H
14 #define KRATOS_CALCULATE_LAPLACIAN_SIMPLEX_CONDITION_H
15 
16 // System includes
17 #include <string>
18 #include <iostream>
19 
20 
21 // External includes
22 
23 
24 // Project includes
25 #include "includes/define.h"
26 #include "includes/serializer.h"
27 #include "includes/condition.h"
28 #include "includes/process_info.h"
29 
30 // Application includes
33 #include "includes/cfd_variables.h"
34 
35 //Other Applications includes
36 
37 namespace Kratos
38 {
41 
44 
48 
52 
56 
60 
62 
63 template< unsigned int TDim, unsigned int TNumNodes = TDim >
64 class KRATOS_API(SWIMMING_DEM_APPLICATION) ComputeLaplacianSimplexCondition : public Condition
65 {
66 public:
67 
71 
72  typedef Node NodeType;
73 
75 
77 
79 
80  typedef Vector VectorType;
81 
82  typedef Matrix MatrixType;
83 
84  typedef std::size_t IndexType;
85 
86  typedef std::size_t SizeType;
87 
88  typedef std::vector<std::size_t> EquationIdVectorType;
89 
90  typedef std::vector< Dof<double>::Pointer > DofsVectorType;
91 
93 
95 
99 
101 
105  Condition(NewId)
106  {
107  }
108 
110 
115  const NodesArrayType& ThisNodes):
116  Condition(NewId,ThisNodes)
117  {
118  }
119 
121 
126  GeometryType::Pointer pGeometry):
127  Condition(NewId,pGeometry)
128  {
129  }
130 
132 
138  GeometryType::Pointer pGeometry,
139  PropertiesType::Pointer pProperties):
140  Condition(NewId,pGeometry,pProperties)
141  {}
142 
145  {}
146 
149 
150 
154 
157  {
158  Condition::operator=(rOther);
159 
160  return *this;
161  }
162 
166 
168 
173  Condition::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override
174  {
175  return Condition::Pointer(new ComputeLaplacianSimplexCondition(NewId, this->GetGeometry().Create(ThisNodes), pProperties));
176  }
177 
178  Condition::Pointer Create(IndexType NewId,
179  GeometryType::Pointer pGeom,
180  PropertiesType::Pointer pProperties) const override
181  {
182  return Kratos::make_intrusive< ComputeLaplacianSimplexCondition >(NewId, pGeom, pProperties);
183  }
184 
186 
189  void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix,
190  VectorType& rRightHandSideVector,
191  const ProcessInfo& rCurrentProcessInfo) override
192  {
193  const SizeType BlockSize = TDim;
194  const SizeType LocalSize = BlockSize * TNumNodes;
195 
196  if (rLeftHandSideMatrix.size1() != LocalSize)
197  rLeftHandSideMatrix.resize(LocalSize,LocalSize);
198 
199  if (rRightHandSideVector.size() != LocalSize)
200  rRightHandSideVector.resize(LocalSize);
201 
202  noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize,LocalSize);
203  noalias(rRightHandSideVector) = ZeroVector(LocalSize);
204 
205  }
206 
208 
211  void CalculateLeftHandSide(MatrixType& rLeftHandSideMatrix, const ProcessInfo& rCurrentProcessInfo) override
212  {
213  const SizeType BlockSize = TDim;
214  const SizeType LocalSize = BlockSize * TNumNodes;
215 
216  if (rLeftHandSideMatrix.size1() != LocalSize)
217  rLeftHandSideMatrix.resize(LocalSize,LocalSize);
218 
219  noalias(rLeftHandSideMatrix) = ZeroMatrix(LocalSize,LocalSize);
220  }
221 
223 
226  void CalculateRightHandSide(VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override
227  {
228 // const unsigned int BlockSize = TDim;
229 // const SizeType LocalSize = BlockSize * TNumNodes;
230 
231 // if (rRightHandSideVector.size() != LocalSize)
232 // rRightHandSideVector.resize(LocalSize);
233 
234 // noalias(rRightHandSideVector) = ZeroVector(LocalSize);
235 
236 // const GeometryType& rGeom = this->GetGeometry();
237 // const GeometryType::IntegrationPointsArrayType& IntegrationPoints = rGeom.IntegrationPoints(GeometryData::IntegrationMethod::GI_GAUSS_2);
238 // const unsigned int NumGauss = IntegrationPoints.size();
239 
240 // MatrixType NContainer = rGeom.ShapeFunctionsValues(GeometryData::IntegrationMethod::GI_GAUSS_2);
241 
242 // double Area;
243 // array_1d<double, TNumNodes> N;
244 // BoundedMatrix<double, TNumNodes, TDim> DN_DX;
245 // GeometryUtils::CalculateGeometryData(this->GetGeometry(), DN_DX, N, Area);
246 
247 // array_1d<double,3> Normal;s
248 // this->CalculateNormal(Normal); //this already contains the area
249 // double A = std::sqrt(Normal[0]*Normal[0]+Normal[1]*Normal[1]+Normal[2]*Normal[2]);
250 // Normal /= A;
251 
252 // // CAUTION: "Jacobian" is 2.0*A for triangles but 0.5*A for lines
253 // double J = (TDim == 2) ? 0.5*A : 2.0*A;
254 
255 // for (unsigned int g = 0; g < NumGauss; g++)
256 // {
257 // Vector N = row(NContainer,g);
258 // double Weight = J * IntegrationPoints[g].Weight();
259 
260 // // Neumann boundary condition
261 // for (unsigned int i = 0; i < TNumNodes; i++)
262 // {
263 // //unsigned int row = i*LocalSize;
264 // const NodeType& rConstNode = this->GetGeometry()[i];
265 
266 // for (unsigned int j = 0; j < TNumNodes; j++)
267 // {
268 // const array_1d<double,3>& rVel = this->GetGeometry()[j].FastGetSolutionStepValue(VELOCITY);
269 
270 // unsigned int row = j*LocalSize;
271 // for (unsigned int d = 0; d < TDim;d++)
272 // rLocalVector[row+d] -= Weight*DN_DX[j]*N[i]*rVel[d]*Normal[d];
273 // }
274 // }
275 // }
276  }
277 
278 
280 
284  void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override;
285 
286 
288 
292  void GetDofList(DofsVectorType& ConditionDofList, const ProcessInfo& CurrentProcessInfo) const override;
293 
297 
298 
302 
303 
307 
309  std::string Info() const override
310  {
311  std::stringstream buffer;
312  buffer << "ComputeLaplacianSimplexCondition" << TDim << "D";
313  return buffer.str();
314  }
315 
317  void PrintInfo(std::ostream& rOStream) const override
318  {
319  rOStream << "ComputeLaplacianSimplexCondition";
320  }
321 
325 
326 
328 
329 protected:
332 
333 
337 
338 
342 
343 
349 
353 
354 
358 
359 
363 
364 
366 
367 private:
370 
371 
375 
376 
380 
381  friend class Serializer;
382 
383  void save(Serializer& rSerializer) const override
384  {
386  }
387 
388  void load(Serializer& rSerializer) override
389  {
391  }
392 
396 
397 
401 
402 
406 
407 
411 
412 
416 
417 
419 
420 }; // Class ComputeLaplacianSimplexCondition
421 
422 
424 
427 
428 
432 
433 
435 template< unsigned int TDim, unsigned int TNumNodes >
436 inline std::istream& operator >> (std::istream& rIStream,
438 {
439  return rIStream;
440 }
441 
443 template< unsigned int TDim, unsigned int TNumNodes >
444 inline std::ostream& operator << (std::ostream& rOStream,
446 {
447  rThis.PrintInfo(rOStream);
448  rOStream << std::endl;
449  rThis.PrintData(rOStream);
450 
451  return rOStream;
452 }
453 
455 
457 
458 
459 } // namespace Kratos.
460 
461 #endif // KRATOS_CALCULATE_LAPLACIAN_SIMPLEX_CONDITION_H
Implements a wall condition for the laplacian recovery.
Definition: calculate_laplacian_simplex_condition.h:65
std::size_t SizeType
Definition: calculate_laplacian_simplex_condition.h:86
ComputeLaplacianSimplexCondition(ComputeLaplacianSimplexCondition const &rOther)
Copy constructor.
Definition: calculate_laplacian_simplex_condition.h:144
Geometry< NodeType > GeometryType
Definition: calculate_laplacian_simplex_condition.h:76
PointerVectorSet< Dof< double >, IndexedObject > DofsArrayType
Definition: calculate_laplacian_simplex_condition.h:92
std::vector< Dof< double >::Pointer > DofsVectorType
Definition: calculate_laplacian_simplex_condition.h:90
ComputeLaplacianSimplexCondition(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using Geometry.
Definition: calculate_laplacian_simplex_condition.h:125
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(ComputeLaplacianSimplexCondition)
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Return local right hand side of the correct size, filled with zeros (for compatibility with time sche...
Definition: calculate_laplacian_simplex_condition.h:226
Condition::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create a new ComputeLaplacianSimplexCondition object.
Definition: calculate_laplacian_simplex_condition.h:173
std::vector< std::size_t > EquationIdVectorType
Definition: calculate_laplacian_simplex_condition.h:88
Properties PropertiesType
Definition: calculate_laplacian_simplex_condition.h:74
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: calculate_laplacian_simplex_condition.h:317
Geometry< NodeType >::PointsArrayType NodesArrayType
Definition: calculate_laplacian_simplex_condition.h:78
std::size_t IndexType
Definition: calculate_laplacian_simplex_condition.h:84
void CalculateNormal(array_1d< double, 3 > &An)
Node NodeType
Definition: calculate_laplacian_simplex_condition.h:72
ComputeLaplacianSimplexCondition(IndexType NewId, const NodesArrayType &ThisNodes)
Constructor using an array of nodes.
Definition: calculate_laplacian_simplex_condition.h:114
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Return local contributions of the correct size, filled with zeros (for compatibility with time scheme...
Definition: calculate_laplacian_simplex_condition.h:189
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
Return a matrix of the correct size, filled with zeros (for compatibility with time schemes).
Definition: calculate_laplacian_simplex_condition.h:211
std::string Info() const override
Turn back information as a string.
Definition: calculate_laplacian_simplex_condition.h:309
Vector VectorType
Definition: calculate_laplacian_simplex_condition.h:80
virtual ~ComputeLaplacianSimplexCondition()
Destructor.
Definition: calculate_laplacian_simplex_condition.h:148
Condition::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
It creates a new condition pointer.
Definition: calculate_laplacian_simplex_condition.h:178
ComputeLaplacianSimplexCondition & operator=(ComputeLaplacianSimplexCondition const &rOther)
Assignment operator.
Definition: calculate_laplacian_simplex_condition.h:156
ComputeLaplacianSimplexCondition(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor using Properties.
Definition: calculate_laplacian_simplex_condition.h:137
Matrix MatrixType
Definition: calculate_laplacian_simplex_condition.h:82
ComputeLaplacianSimplexCondition(IndexType NewId=0)
Default constructor.
Definition: calculate_laplacian_simplex_condition.h:104
Base class for all Conditions.
Definition: condition.h:59
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: condition.h:1085
std::size_t SizeType
Definition: condition.h:94
Condition & operator=(Condition const &rOther)
Assignment operator.
Definition: condition.h:181
std::size_t IndexType
Definition: flags.h:74
Geometry base class.
Definition: geometry.h:71
This object defines an indexed object.
Definition: indexed_object.h:54
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
This class defines the node.
Definition: node.h:65
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
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
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def load(f)
Definition: ode_solve.py:307