Seismo-VLAB  1.3
An Open-Source Finite Element Software for Meso-Scale Simulations
Recorder.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // Seismo Virtual Laboratory
4 // Module for Serial and Parallel Analysis of seismic
5 // wave propagation and soil-structure interaction simulation
6 // Copyright (C) 2018-2021, The California Institute of Technology
7 // All Rights Reserved.
8 //
9 // Commercial use of this program without express permission of the California
10 // Institute of Technology, is strictly prohibited. See file "COPYRIGHT" in
11 // main directory for information on usage and redistribution, and for a
12 // DISCLAIMER OF ALL WARRANTIES.
13 //
14 //==============================================================================
15 //
16 // Written by:
17 // Danilo S. Kusanovic (dkusanov@caltech.edu)
18 // Elnaz E. Seylabi (elnaze@unr.edu)
19 //
20 // Supervised by:
21 // Domniki M. Asimaki (domniki@caltech.edu)
22 //
23 // References :
24 // [1]
25 //
26 // Description:
29 //------------------------------------------------------------------------------
30 
31 #ifndef _RECORDER_HPP_
32 #define _RECORDER_HPP_
33 
34 #include <map>
35 #include <vector>
36 #include <memory>
37 #include <string>
38 #include <fstream>
39 #include <Eigen/Dense>
40 
41 #include "Mesh.hpp"
42 
50 class Recorder{
51 
52  public:
61  Recorder(std::string file, std::string name, unsigned int nparaview, unsigned int nsample = 1, unsigned int precision = 10);
62 
72  Recorder(std::string file, std::string name, std::string type, std::vector<unsigned int> index, unsigned int nsample = 1, unsigned int precision = 10);
73 
84  Recorder(std::string file, std::string name, std::string type, std::vector<double> coordinates, std::vector<unsigned int> index, unsigned int nsample = 1, unsigned int precision = 10);
85 
87  ~Recorder();
88 
91  std::unique_ptr<Recorder> CopyRecorder();
92 
95  std::string GetName();
96 
100  void Initialize(std::shared_ptr<Mesh> &mesh, unsigned int nsteps);
101 
105  void WriteResponse(std::shared_ptr<Mesh> &mesh, unsigned int step);
106 
108  void Finalize();
109 
112  void SetComboName(std::string name);
113 
116  void SetDRMParaviewInterface(std::map<unsigned int, bool>& DRMElems);
117 
118  private:
120  std::string File;
121 
123  std::string Name;
124 
126  std::string Combo;
127 
129  std::string Response;
130 
132  unsigned int nSample;
133 
135  unsigned int Counter;
136 
138  unsigned int nParaview;
139 
141  unsigned int Precision;
142 
144  std::vector<double> Position;
145 
147  std::vector<unsigned int> IDs;
148 
150  std::map<unsigned int, unsigned int> Tag;
151 
153  std::map<unsigned int, bool> IsDRMElem;
154 
156  std::ofstream OutputFile;
157 
160  void WriteNodalResponse(std::shared_ptr<Mesh> &mesh);
161 
164  void WriteElementResponse(std::shared_ptr<Mesh> &mesh);
165 
168  void WriteSectionResponse(std::shared_ptr<Mesh> &mesh);
169 
173  void WriteVTKFiles(std::shared_ptr<Mesh> &mesh, unsigned int step);
174 
179  std::string GetSpacedName(std::string theFile, std::string toReplace);
180 
184  void SetThreshold(Eigen::VectorXd &U, double WinTol=1E-33);
185 };
186 
187 #endif
std::map< unsigned int, bool > IsDRMElem
Nodal Local indexes for this partition.
Definition: Recorder.hpp:153
void SetComboName(std::string name)
Sets the combination&#39;s name.
unsigned int nSample
The number of sampling points to record the solution.
Definition: Recorder.hpp:132
Class that stores the node, element, and section responses for a given analysis.
Definition: Recorder.hpp:50
unsigned int Counter
The sampling rate counter.
Definition: Recorder.hpp:135
std::string Name
The object name to record solution.
Definition: Recorder.hpp:123
std::string File
The name of the file to record.
Definition: Recorder.hpp:120
std::ofstream OutputFile
Name of the recorder handler.
Definition: Recorder.hpp:156
std::string GetName()
Return the recorder name.
void SetDRMParaviewInterface(std::map< unsigned int, bool > &DRMElems)
Sets the possible DRM Element indexes.
std::string GetSpacedName(std::string theFile, std::string toReplace)
Fix blank spaces provided by user in path.
std::vector< double > Position
Section position at strain/stress is computed.
Definition: Recorder.hpp:144
void WriteSectionResponse(std::shared_ptr< Mesh > &mesh)
Writes section element data to the file.
void WriteResponse(std::shared_ptr< Mesh > &mesh, unsigned int step)
Write information in the recorder.
~Recorder()
Destroys this Recorder object.
unsigned int nParaview
The number of features to be written in paraview.
Definition: Recorder.hpp:138
void WriteVTKFiles(std::shared_ptr< Mesh > &mesh, unsigned int step)
Writes output data in VTK format to the file.
void Finalize()
Finalize the recorder.
This file contains the "Mesh object" declarations, which stores nodes, materials, elements...
unsigned int Precision
The precision for results.
Definition: Recorder.hpp:141
std::vector< unsigned int > IDs
Nodal/Element indexes to be recorded.
Definition: Recorder.hpp:147
std::map< unsigned int, unsigned int > Tag
Nodal Local indexes for this partition.
Definition: Recorder.hpp:150
Recorder(std::string file, std::string name, unsigned int nparaview, unsigned int nsample=1, unsigned int precision=10)
Creates a Recorder object to store Paraview solutions.
void Initialize(std::shared_ptr< Mesh > &mesh, unsigned int nsteps)
Initialize the recorder.
std::string Combo
The name of the LoadCombo.
Definition: Recorder.hpp:126
std::unique_ptr< Recorder > CopyRecorder()
Clone the &#39;Recorder&#39; object.
std::string Response
The object response to be stored.
Definition: Recorder.hpp:129
void SetThreshold(Eigen::VectorXd &U, double WinTol=1E-33)
Windows patch for small values.
void WriteElementResponse(std::shared_ptr< Mesh > &mesh)
Writes element data to the file.
void WriteNodalResponse(std::shared_ptr< Mesh > &mesh)
Writes state variable data to the file.