PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
inp::Input Class Reference

A class to read input file. More...

#include <input.h>

Collaboration diagram for inp::Input:

Public Member Functions

 Input (const json &j=json({}))
 Constructor.
 
Accessor methods
std::shared_ptr< inp::ModelDeck > getModelDeck ()
 Get the pointer to model deck.
 
std::shared_ptr< inp::OutputDeck > getOutputDeck ()
 Get the pointer to output deck.
 
std::shared_ptr< inp::RestartDeck > getRestartDeck ()
 Get the pointer to restart deck.
 
std::shared_ptr< inp::ParticleDeck > getParticleDeck ()
 Get the pointer to particle deck.
 
std::shared_ptr< inp::TestDeck > getTestDeck ()
 Get the pointer to model deck.
 
std::shared_ptr< inp::BCDeck > getBCDeck ()
 Get the pointer to model deck.
 
bool isMultiParticle ()
 Get particle simulation type.
 
bool isPeriDEM ()
 Specify if PeriDEM model should be run.
 
std::string printStr (int nt=0, int lvl=0) const
 Returns the string containing printable information about the object.
 
void print (int nt=0, int lvl=0) const
 Prints the information about the object.
 

Data Fields

Decks
std::shared_ptr< inp::ModelDeck > d_modelDeck_p
 Pointer to deck holding problem related data.
 
std::shared_ptr< inp::OutputDeck > d_outputDeck_p
 Pointer to deck holding output related data.
 
std::shared_ptr< inp::RestartDeck > d_restartDeck_p
 Pointer to deck holding restart related data.
 
std::shared_ptr< inp::TestDeck > d_testDeck_p
 Test deck.
 
std::shared_ptr< inp::BCDeck > d_bcDeck_p
 Boundary condition deck.
 
std::shared_ptr< inp::ParticleDeck > d_particleDeck_p
 Pointer to deck holding particle related data.
 

Detailed Description

A class to read input file.

In this class we read input file and read the data into the decks. Input file is a JSON file.

Definition at line 64 of file input.h.

Constructor & Destructor Documentation

◆ Input()

inp::Input::Input ( const json &  j = json({}))
explicit

Constructor.

Parameters
filenameFilename of input file

Definition at line 16 of file input.cpp.

16 {
17 d_modelDeck_p = j.find("Model") != j.end() ? std::make_unique<ModelDeck>(j["Model"]) : std::make_shared<ModelDeck>();
18 d_outputDeck_p = j.find("Output") != j.end() ? std::make_unique<OutputDeck>(j["Output"]) : std::make_shared<OutputDeck>();
19 d_restartDeck_p = j.find("Restart") != j.end() ? std::make_unique<RestartDeck>(j["Restart"]) : std::make_shared<RestartDeck>();
20 d_testDeck_p = j.find("Test") != j.end() ? std::make_unique<TestDeck>(j["Test"]) : std::make_shared<TestDeck>();
21 d_bcDeck_p = std::make_shared<inp::BCDeck>(j);
22
23 // particle deck
24 d_particleDeck_p = std::make_shared<inp::ParticleDeck>(j, d_modelDeck_p->d_particleSimType);
25
26 // Enable restart when a restart file is provided (Restart.File).
27 if (!d_restartDeck_p->d_file.empty())
28 d_modelDeck_p->d_isRestartActive = true;
29};
std::shared_ptr< inp::ParticleDeck > d_particleDeck_p
Pointer to deck holding particle related data.
Definition input.h:175
std::shared_ptr< inp::TestDeck > d_testDeck_p
Test deck.
Definition input.h:169
std::shared_ptr< inp::RestartDeck > d_restartDeck_p
Pointer to deck holding restart related data.
Definition input.h:166
std::shared_ptr< inp::BCDeck > d_bcDeck_p
Boundary condition deck.
Definition input.h:172
std::shared_ptr< inp::OutputDeck > d_outputDeck_p
Pointer to deck holding output related data.
Definition input.h:163
std::shared_ptr< inp::ModelDeck > d_modelDeck_p
Pointer to deck holding problem related data.
Definition input.h:160

References d_bcDeck_p, d_modelDeck_p, d_outputDeck_p, d_particleDeck_p, d_restartDeck_p, and d_testDeck_p.

Member Function Documentation

◆ getBCDeck()

std::shared_ptr< inp::BCDeck > inp::Input::getBCDeck ( )
inline

Get the pointer to model deck.

Returns
Pointer to ModelDeck

Definition at line 104 of file input.h.

104{return d_bcDeck_p;};

References d_bcDeck_p.

◆ getModelDeck()

std::shared_ptr< inp::ModelDeck > inp::Input::getModelDeck ( )
inline

Get the pointer to model deck.

Returns
Pointer to ModelDeck

Definition at line 82 of file input.h.

82{return d_modelDeck_p;};

References d_modelDeck_p.

◆ getOutputDeck()

std::shared_ptr< inp::OutputDeck > inp::Input::getOutputDeck ( )
inline

Get the pointer to output deck.

Returns
Pointer to OutputDeck

Definition at line 88 of file input.h.

88{return d_outputDeck_p;};

References d_outputDeck_p.

◆ getParticleDeck()

std::shared_ptr< inp::ParticleDeck > inp::Input::getParticleDeck ( )
inline

Get the pointer to particle deck.

Returns
Pointer to ParticleDeck

Definition at line 100 of file input.h.

100{return d_particleDeck_p;};

References d_particleDeck_p.

◆ getRestartDeck()

std::shared_ptr< inp::RestartDeck > inp::Input::getRestartDeck ( )
inline

Get the pointer to restart deck.

Returns
Pointer to RestartDeck

Definition at line 94 of file input.h.

94{return d_restartDeck_p;};

References d_restartDeck_p.

◆ getTestDeck()

std::shared_ptr< inp::TestDeck > inp::Input::getTestDeck ( )
inline

Get the pointer to model deck.

Returns
Pointer to ModelDeck

Definition at line 102 of file input.h.

102{return d_testDeck_p;};

References d_testDeck_p.

◆ isMultiParticle()

bool inp::Input::isMultiParticle ( )
inline

Get particle simulation type.

Returns
bool True if Multi_Particle else false

Definition at line 110 of file input.h.

110{return d_modelDeck_p->d_particleSimType == "Multi_Particle";};

References d_modelDeck_p.

◆ isPeriDEM()

bool inp::Input::isPeriDEM ( )
inline

Specify if PeriDEM model should be run.

Returns
bool True if PeriDEM is active

Definition at line 116 of file input.h.

116 {
117 if (d_modelDeck_p->d_particleSimType == "Multi_Particle" or
118 d_modelDeck_p->d_particleSimType == "Single_Particle")
119 return true;
120
121 return false;
122 };

References d_modelDeck_p.

◆ print()

void inp::Input::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 151 of file input.h.

151{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition input.h:131

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::Input::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 131 of file input.h.

131 {
132 auto tabS = util::io::getTabS(nt);
133 std::ostringstream oss;
134 oss << tabS << "------- Input --------" << std::endl << std::endl;
135 oss << tabS << "Particle sim type = " << d_modelDeck_p->d_particleSimType << std::endl;
136 oss << tabS << d_modelDeck_p->printStr(nt+1, lvl) << std::endl;
137 oss << tabS << d_outputDeck_p->printStr(nt+1, lvl) << std::endl;
138 oss << tabS << d_restartDeck_p->printStr(nt+1, lvl) << std::endl;
139 oss << tabS << d_testDeck_p->printStr(nt+1, lvl) << std::endl;
140 oss << tabS << d_bcDeck_p->printStr(nt+1, lvl) << std::endl;
141 oss << tabS << d_particleDeck_p->printStr(nt+1, lvl) << std::endl;
142 return oss.str();
143 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82

References d_bcDeck_p, d_modelDeck_p, d_outputDeck_p, d_particleDeck_p, d_restartDeck_p, d_testDeck_p, and util::io::getTabS().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ d_bcDeck_p

std::shared_ptr<inp::BCDeck> inp::Input::d_bcDeck_p

Boundary condition deck.

Definition at line 172 of file input.h.

Referenced by getBCDeck(), Input(), and printStr().

◆ d_modelDeck_p

std::shared_ptr<inp::ModelDeck> inp::Input::d_modelDeck_p

Pointer to deck holding problem related data.

Definition at line 160 of file input.h.

Referenced by getModelDeck(), Input(), isMultiParticle(), isPeriDEM(), and printStr().

◆ d_outputDeck_p

std::shared_ptr<inp::OutputDeck> inp::Input::d_outputDeck_p

Pointer to deck holding output related data.

Definition at line 163 of file input.h.

Referenced by getOutputDeck(), Input(), and printStr().

◆ d_particleDeck_p

std::shared_ptr<inp::ParticleDeck> inp::Input::d_particleDeck_p

Pointer to deck holding particle related data.

Definition at line 175 of file input.h.

Referenced by getParticleDeck(), Input(), and printStr().

◆ d_restartDeck_p

std::shared_ptr<inp::RestartDeck> inp::Input::d_restartDeck_p

Pointer to deck holding restart related data.

Definition at line 166 of file input.h.

Referenced by getRestartDeck(), Input(), and printStr().

◆ d_testDeck_p

std::shared_ptr<inp::TestDeck> inp::Input::d_testDeck_p

Test deck.

Definition at line 169 of file input.h.

Referenced by getTestDeck(), Input(), and printStr().


The documentation for this class was generated from the following files: