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.
stl_io.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: Pooyan Dadvand
11 //
12 
13 #pragma once
14 
15 // System includes
16 #include <string>
17 #include <iostream>
18 #include <filesystem>
19 
20 // External includes
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "includes/io.h"
25 
26 namespace Kratos
27 {
30 
33 
37 
41 
45 
49 
51 
81 class KRATOS_API(KRATOS_CORE) StlIO
82  : public IO
83 {
84 public:
87 
90 
93 
95  using IndexType = std::size_t;
96 
99 
103 
111  StlIO(
112  const std::filesystem::path& rFilename,
113  Parameters ThisParameters = Parameters()
114  );
115 
123  StlIO(
125  Parameters ThisParameters = Parameters()
126  );
127 
129  virtual ~StlIO(){}
130 
134 
138 
143  static Parameters GetDefaultParameters();
144 
150  void ReadModelPart(ModelPart& rThisModelPart) override;
151 
157  void WriteModelPart(const ModelPart& rThisModelPart) override;
158 
162 
166 
170 
172  std::string Info() const override;
173 
175  void PrintInfo(std::ostream& rOStream) const override;
176 
178  void PrintData(std::ostream& rOStream) const override;
179 
183 
185 protected:
188 
192 
194 
195  IndexType mNextNodeId = 0;
196  IndexType mNextElementId = 0;
197  IndexType mNextConditionId = 0;
198 
202 
206 
210 
214 
218 
220 private:
223 
227 
228  Kratos::shared_ptr<std::iostream> mpInputStream;
229  Flags mOptions;
230 
234 
238 
245  void ReadSolid(
246  ModelPart& rThisModelPart,
247  const std::function<void(ModelPart&, NodesArrayType&)>& rCreateEntityFunctor
248  );
249 
256  void ReadFacet(
257  ModelPart& rThisModelPart,
258  const std::function<void(ModelPart&, NodesArrayType&)>& rCreateEntityFunctor
259  );
260 
267  void ReadLoop(
268  ModelPart& rThisModelPart,
269  const std::function<void(ModelPart&, NodesArrayType&)>& rCreateEntityFunctor
270  );
271 
276  Point ReadPoint();
277 
282  void ReadKeyword(const std::string& Keyword);
283 
290  template<class TContainerType>
291  void WriteEntityBlock(const TContainerType& rThisEntities);
292 
298  void WriteGeometryBlock(const GeometriesMapType& rThisGeometries);
299 
307  template<class TContainerType>
308  void WriteEntityBlockMPI(
309  const TContainerType& rThisEntities,
310  const DataCommunicator& rDataCommunicator
311  );
312 
319  void WriteGeometryBlockMPI(
320  const GeometriesMapType& rThisGeometries,
321  const DataCommunicator& rDataCommunicator
322  );
323 
331  template<class TStreamType>
332  void WriteFacet(
333  const GeometryType& rGeom,
334  TStreamType& rStream
335  );
336 
344  bool IsValidGeometry(
345  const Geometry<Node>& rGeometry,
346  IndexType& rNumDegenerateGeos
347  ) const;
348 
352 
356 
360 
362  StlIO& operator=(StlIO const& rOther);
363 
365  StlIO(StlIO const& rOther);
366 
368 
369 }; // Class StlIO
370 
372 
375 
379 
380 
382 inline std::istream& operator >> (std::istream& rIStream,
383  StlIO& rThis);
384 
386 inline std::ostream& operator << (std::ostream& rOStream,
387  const StlIO& rThis)
388 {
389  rThis.PrintInfo(rOStream);
390  rOStream << std::endl;
391  rThis.PrintData(rOStream);
392 
393  return rOStream;
394 }
396 
398 
399 } // namespace Kratos.
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
Geometry< NodeType >::PointsArrayType NodesArrayType
definition of nodes container type, redefined from GeometryType
Definition: element.h:86
Definition: flags.h:58
Geometry base class.
Definition: geometry.h:71
IO provides different implementation of input output procedures which can be used to read and write w...
Definition: io.h:58
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
GeometryContainerType::GeometriesMapType GeometriesMapType
Geometry Hash Map Container. Stores with hash of Ids to corresponding geometries.
Definition: model_part.h:246
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Point class.
Definition: point.h:59
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
This class reads from STL file format and creates triangular elements in given model_part.
Definition: stl_io.h:83
KRATOS_CLASS_POINTER_DEFINITION(StlIO)
Pointer definition of StlIO.
virtual ~StlIO()
Destructor.
Definition: stl_io.h:129
std::size_t IndexType
The index type definition.
Definition: stl_io.h:95
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: stl_io.cpp:345
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: stl_io.cpp:350
Parameters mParameters
Definition: stl_io.h:193
string path
Definition: DEM_run_all_benchmarks_analysis.py:10
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
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
def ReadModelPart(model_part, inputfile)
Definition: read_modelpart_from_json.py:3