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.
pfem_fluid_gid_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: Miguel Angel Celigueta maceli@cimne.upc.edu
11 //
12 
13 #if !defined(PFEM_FLUID_GID_IO_BASE_H_INCLUDED)
14 #define PFEM_FLUID_GID_IO_BASE_H_INCLUDED
15 
16 // External includes
17 #define USE_CONST
18 #include "gidpost/source/gidpost.h"
19 
20 // Project includes
21 #include "includes/gid_io.h"
22 
23 namespace Kratos
24 {
25 
26 template <class TGaussPointContainer = GidGaussPointsContainer, class TMeshContainer = GidMeshContainer>
27 class PfemFluidGidIO : public GidIO<TGaussPointContainer, TMeshContainer>
28 {
29 
30  typedef Node NodeType;
31  typedef Properties PropertiesType;
32  typedef Element ElementType;
33  typedef Condition ConditionType;
35 
36 public:
39 
42 
44  // enum WriteDeformedMeshFlag{WriteDeformed, WriteUndeformed};
45  // enum WriteConditionsFlag{WriteConditions, WriteElementsOnly};
46  // enum MultiFileFlag{SingleFile, MultipleFiles};
47 
50  PfemFluidGidIO(const std::string &rDatafilename,
51  GiD_PostMode Mode,
52  MultiFileFlag use_multiple_files_flag,
53  WriteDeformedMeshFlag write_deformed_flag,
54  WriteConditionsFlag write_conditions_flag) : BaseType(rDatafilename, Mode, use_multiple_files_flag, write_deformed_flag, write_conditions_flag) {}
55 
57  ~PfemFluidGidIO() override
58  {
59  }
60 
61  void WriteNodeMesh(MeshType &rThisMesh) override
62  {
64 
65  Timer::Start("Writing Mesh");
66 
67  GiD_fBeginMesh(BaseType::mMeshFile, "Kratos Mesh", GiD_3D, GiD_Point, 1);
68  GiD_fBeginCoordinates(BaseType::mMeshFile);
69  for (MeshType::NodeIterator node_iterator = rThisMesh.NodesBegin();
70  node_iterator != rThisMesh.NodesEnd();
71  ++node_iterator)
72  {
74  GiD_fWriteCoordinates(BaseType::mMeshFile, node_iterator->Id(), node_iterator->X0(),
75  node_iterator->Y0(), node_iterator->Z0());
77  GiD_fWriteCoordinates(BaseType::mMeshFile, node_iterator->Id(), node_iterator->X(),
78  node_iterator->Y(), node_iterator->Z());
79  else
80  KRATOS_ERROR << "Undefined WriteDeformedMeshFlag" << std::endl;
81  }
82  GiD_fEndCoordinates(BaseType::mMeshFile);
83  int nodes_id[2];
84  GiD_fBeginElements(BaseType::mMeshFile);
85 
86  for (MeshType::NodeIterator node_iterator = rThisMesh.NodesBegin();
87  node_iterator != rThisMesh.NodesEnd();
88  ++node_iterator)
89  {
90  unsigned int ID=0;
91  nodes_id[0] = node_iterator->Id();
92  if(node_iterator->Is(FREE_SURFACE)){
93  ID = 1;
94  }else if(node_iterator->Is(ISOLATED)){
95  ID = 2;
96  }
97  nodes_id[1] = ID;
98  GiD_fWriteElementMat(BaseType::mMeshFile, node_iterator->Id(), nodes_id);
99  }
100 
101  GiD_fEndElements(BaseType::mMeshFile);
102  GiD_fEndMesh(BaseType::mMeshFile);
103 
104  Timer::Stop("Writing Mesh");
105 
106  KRATOS_CATCH("")
107  } //WriteNodeMesh
108 
109 protected:
110 private:
111  PfemFluidGidIO &operator=(PfemFluidGidIO const &rOther);
112  PfemFluidGidIO(PfemFluidGidIO const &rOther);
113 
114 }; // Class PfemFluidGidIO
115 
116 inline std::ostream &operator<<(std::ostream &rOStream, const PfemFluidGidIO<> &rThis)
117 {
118  rThis.PrintInfo(rOStream);
119  rOStream << std::endl;
120  rThis.PrintData(rOStream);
121  return rOStream;
122 }
123 
124 } // namespace Kratos.
125 
126 #endif // PFEM_FLUID_GID_IO_BASE_H_INCLUDED defined
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
This class defines an interface to the GiDPost library in order to provide GiD compliant I/O function...
Definition: gid_io.h:112
WriteDeformedMeshFlag mWriteDeformed
Definition: gid_io.h:1517
GiD_FILE mMeshFile
Definition: gid_io.h:1511
void PrintInfo(std::ostream &rOStream) const override
Definition: gid_io.h:547
void PrintData(std::ostream &rOStream) const override
Definition: gid_io.h:555
NodeIterator NodesEnd()
Definition: mesh.h:336
typename NodesContainerType::iterator NodeIterator
Iterator for nodes in the container. Provides direct references to nodes.
Definition: mesh.h:114
NodeIterator NodesBegin()
Definition: mesh.h:326
This class defines the node.
Definition: node.h:65
Definition: pfem_fluid_gid_io.h:28
PfemFluidGidIO(const std::string &rDatafilename, GiD_PostMode Mode, MultiFileFlag use_multiple_files_flag, WriteDeformedMeshFlag write_deformed_flag, WriteConditionsFlag write_conditions_flag)
Flags for mesh writing.
Definition: pfem_fluid_gid_io.h:50
KRATOS_CLASS_POINTER_DEFINITION(PfemFluidGidIO)
pointer definition of PfemFluidGidIO
~PfemFluidGidIO() override
Destructor.
Definition: pfem_fluid_gid_io.h:57
void WriteNodeMesh(MeshType &rThisMesh) override
This method writes the node mesh.
Definition: pfem_fluid_gid_io.h:61
GidIO< TGaussPointContainer, TMeshContainer > BaseType
typedefs
Definition: pfem_fluid_gid_io.h:41
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
static void Start(std::string const &rIntervalName)
This method starts the timer meassures.
Definition: timer.cpp:109
static void Stop(std::string const &rIntervalName)
This method stops the timer meassures.
Definition: timer.cpp:125
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
WriteDeformedMeshFlag
Flags for mesh writing.
Definition: gid_io.h:52
@ WriteUndeformed
Definition: gid_io.h:52
@ WriteDeformed
Definition: gid_io.h:52
MultiFileFlag
Definition: gid_io.h:54
WriteConditionsFlag
Definition: gid_io.h:53
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432