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.
Classes | Public Member Functions | List of all members
Kratos::Parameters Class Reference

This class provides to Kratos a data structure for I/O based on the standard of JSON. More...

#include <kratos_parameters.h>

Collaboration diagram for Kratos::Parameters:

Public Member Functions

template<>
bool Is () const
 
Life Cycle
 Parameters ()
 Default constructor. More...
 
 Parameters (const std::string &rJsonString)
 String constructor. It takes a string as input, which parses into a nlohmann::json class. More...
 
 Parameters (std::ifstream &rStringStream)
 File constructor. It takes a file stream as input, which parses into a nlohmann::json class. More...
 
 Parameters (Parameters const &rOther)
 Copy constructor. More...
 
 Parameters (Parameters &&rOther)
 Move constructor. More...
 
virtual ~Parameters ()
 Destructor. More...
 
Operators
Parametersoperator= (Parameters const &rOther)
 Assignment operator. More...
 
Parameters operator[] (const std::string &rEntry)
 This metrod returns the Parameter corresponding to a given key. More...
 
Parameters operator[] (const std::string &rEntry) const
 This metrod returns the Parameter corresponding to a given key (const version) More...
 
Parameters operator[] (const IndexType Index)
 This method allows to access to an array item with the operator []. More...
 
Parameters operator[] (const IndexType Index) const
 This method allows to access to an array item with the operator [] (const version) More...
 
Parametersoperator= (Parameters &&rOther)
 This is the move operator. More...
 
Operations
Parameters Clone () const
 Generates a clone of the current document. More...
 
const std::string WriteJsonString () const
 This method returns a string with the corresponding text to the equivalent *.json file. More...
 
const std::string PrettyPrintJsonString () const
 This method returns a string with the corresponding text to the equivalent *.json file (this version is prettier, and considers tabulations) More...
 
Parameters GetValue (const std::string &rEntry)
 This method returns the Parameter corresponding to a certain entry. More...
 
Parameters GetValue (const std::string &rEntry) const
 This method returns the Parameter corresponding to a certain entry (const version) More...
 
void SetValue (const std::string &rEntry, const Parameters &rOtherValue)
 This method sets an existing parameter with a given parameter. More...
 
void AddValue (const std::string &rEntry, const Parameters &rOtherValue)
 This method sets a non-existing parameter with a given parameter. More...
 
Parameters AddEmptyValue (const std::string &rEntry)
 This method adds an empty parameter. More...
 
bool RemoveValue (const std::string &rEntry)
 This method removes an entry of the Parameters given a certain key. More...
 
bool RemoveValues (const std::vector< std::string > &rEntries)
 This method removes several entries of the Parameters given a certain list of keys. More...
 
json_iteration_proxy items () noexcept
 This method returns the items of the current parameter. More...
 
json_const_iteration_proxy items () const noexcept
 This method returns the items of the current parameter (const) More...
 
bool Has (const std::string &rEntry) const
 This method checks if the Parameter contains a certain entry. More...
 
bool IsNull () const
 This method checks if the parameter is a null. More...
 
bool IsNumber () const
 This method checks if the parameter is a number. More...
 
bool IsDouble () const
 This method checks if the parameter is a double. More...
 
bool IsInt () const
 This method checks if the parameter is a integer. More...
 
bool IsBool () const
 This method checks if the parameter is a boolean. More...
 
bool IsString () const
 This method checks if the parameter is a string. More...
 
bool IsArray () const
 This method checks if the parameter is an array. More...
 
bool IsStringArray () const
 This method checks if the parameter is an array of strings. More...
 
bool IsVector () const
 This method checks if the parameter is a vector. More...
 
bool IsMatrix () const
 This method checks if the parameter is a matrix. More...
 
template<class TValue >
bool Is () const
 Templetized type checker for supported types. More...
 
bool IsSubParameter () const
 This method checks if the parameter is a subparameter. More...
 
double GetDouble () const
 This method returns the double contained in the current Parameter. More...
 
int GetInt () const
 This method returns the integer contained in the current Parameter. More...
 
bool GetBool () const
 This method returns the boolean contained in the current Parameter. More...
 
std::string GetString () const
 This method returns the string contained in the current Parameter. More...
 
std::vector< std::string > GetStringArray () const
 This method returns the array of strings in the current Parameter. More...
 
Vector GetVector () const
 This method returns the vector contained in the current Parameter. More...
 
Matrix GetMatrix () const
 This method returns the matrix contained in the current Parameter. More...
 
template<class TValue >
TValue Get () const
 Templetized getter for supported types. More...
 
void SetDouble (const double Value)
 This method sets the double contained in the current Parameter. More...
 
void SetInt (const int Value)
 This method sets the integer contained in the current Parameter. More...
 
void SetBool (const bool Value)
 This method sets the bool contained in the current Parameter. More...
 
void SetString (const std::string &rValue)
 This method sets the string contained in the current Parameter. More...
 
void SetStringArray (const std::vector< std::string > &rValue)
 This method sets the string array contained in the current Parameter. More...
 
void SetVector (const Vector &rValue)
 This method sets the vector contained in the current Parameter. More...
 
void SetMatrix (const Matrix &rValue)
 This method sets the matrix contained in the current Parameter. More...
 
template<class TValue >
void Set (const TValue &rValue)
 Templetized setter for supported types. More...
 
void AddDouble (const std::string &rEntry, const double Value)
 This method adds a new double Parameter. More...
 
void AddInt (const std::string &rEntry, const int Value)
 This method adds a new integer Parameter. More...
 
void AddBool (const std::string &rEntry, const bool Value)
 This method adds a new bool Parameter. More...
 
void AddString (const std::string &rEntry, const std::string &rValue)
 This method adds a new string Parameter. More...
 
void AddStringArray (const std::string &rEntry, const std::vector< std::string > &rValue)
 This method sets the string array contained in the current Parameter. More...
 
void AddVector (const std::string &rEntry, const Vector &rValue)
 This method adds a new vector Parameter. More...
 
void AddMatrix (const std::string &rEntry, const Matrix &rValue)
 This method adds a new matrix Parameter. More...
 
iterator begin ()
 This returns the begin iterator. More...
 
iterator end ()
 This returns the end iterator. More...
 
const_iterator begin () const
 This returns the constant begin iterator. More...
 
const_iterator end () const
 This returns the constant end iterator. More...
 
SizeType size () const
 This method returns the total size of the current array parameter. More...
 
void swap (Parameters &rOther) noexcept
 This method does a swap between two parameters. More...
 
void Reset () noexcept
 This method resets the whole parameter (it assigns an empty parameter) More...
 
Parameters GetArrayItem (const IndexType Index)
 This method returns an array item given an index. More...
 
Parameters GetArrayItem (const IndexType Index) const
 This method returns an array item given an index (const version) More...
 
void SetArrayItem (const IndexType Index, const Parameters &rOtherArrayItem)
 This method sets an array item given an index. More...
 
void AddEmptyArray (const std::string &rEntry)
 This method add a new entry with no value assigned. More...
 
void Append (const double Value)
 This method appends into an array a double value. More...
 
void Append (const int Value)
 This method appends into an array a integer value. More...
 
void Append (const bool Value)
 This method appends into an array a boolean value. More...
 
void Append (const std::string &rValue)
 This method appends into an array a string value. More...
 
void Append (const Vector &rValue)
 This method appends into an array a vector value. More...
 
void Append (const Matrix &rValue)
 This method appends into an array a matrix value. More...
 
void Append (const Parameters &rValue)
 This method appends into an array a Parameter value. More...
 
void CopyValuesFromExistingParameters (const Parameters OriginParameters, const std::vector< std::string > &rListParametersToCopy)
 This method can be used in order to copy the values from existing Parameters object. More...
 
void RecursivelyFindValue (const nlohmann::json &rBaseValue, const nlohmann::json &rValueToFind) const
 This method looks in a recursive way in the json structure. More...
 
bool IsEquivalentTo (Parameters &rParameters)
 Checks if the names and values are the same, no importance to the order. More...
 
bool HasSameKeysAndTypeOfValuesAs (Parameters &rParameters)
 Checks if the names and the type of values are the same, no importance to the order. More...
 
void ValidateAndAssignDefaults (const Parameters &rDefaultParameters)
 This function is designed to verify that the parameters under testing match the form prescribed by the rDefaultParameters. More...
 
void RecursivelyValidateAndAssignDefaults (const Parameters &rDefaultParameters)
 This function is designed to verify that the parameters under testing match the form prescribed by the defaults. More...
 
void AddMissingParameters (const Parameters &rDefaultParameters)
 This function is designed to verify that the parameters under testing contain at least all parameters prescribed by the rDefaultParameters. More...
 
void RecursivelyAddMissingParameters (const Parameters &rDefaultParameters)
 This function is designed to verify that the parameters under testing contain at least all parameters prescribed by the rDefaultParameters. More...
 
void ValidateDefaults (const Parameters &rDefaultParameters) const
 This function is designed to verify that the all parameteters in the parameters under testing have a matching parameter prescribed by the rDefaultParameters. More...
 
void RecursivelyValidateDefaults (const Parameters &rDefaultParameters) const
 This function is designed to verify that the all parameteters in the parameters under testing have a matching parameter prescribed by the rDefaultParameters. More...
 
Input and output
virtual std::string Info () const
 Turn back information as a string. More...
 
virtual void PrintInfo (std::ostream &rOStream) const
 Print information about this object. More...
 
virtual void PrintData (std::ostream &rOStream) const
 Print object's data. More...
 

Type Definitions

typedef std::size_t IndexType
 Index definition. More...
 
typedef std::size_t SizeType
 Size definition. More...
 
using iterator = iterator_adaptor
 Definition of the iterators. More...
 
using const_iterator = const_iterator_adaptor
 
typedef nlohmann::detail::iter_impl< nlohmann::json > json_iterator
 Iterators from nlohmann::json. More...
 
typedef nlohmann::detail::iter_impl< const nlohmann::json > json_const_iterator
 
typedef nlohmann::detail::iteration_proxy< json_iteratorjson_iteration_proxy
 
typedef nlohmann::detail::iteration_proxy< json_const_iteratorjson_const_iteration_proxy
 
 KRATOS_CLASS_POINTER_DEFINITION (Parameters)
 Pointer definition of MmgProcess. More...
 

Static Member Variables

class Serializer
 

Detailed Description

This class provides to Kratos a data structure for I/O based on the standard of JSON.

In computing, JavaScript Object Notation or JSON is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value). It is a very common data format used for asynchronous browser–server communication, including as a replacement for XML in some AJAX-style systems. More info: https://json.org/ This class uses nlohmann JSON header only library

Author
Riccardo Rossi
Vicente Mataix Ferrandiz

Member Typedef Documentation

◆ const_iterator

using Kratos::Parameters::const_iterator = const_iterator_adaptor

◆ IndexType

typedef std::size_t Kratos::Parameters::IndexType

Index definition.

◆ iterator

using Kratos::Parameters::iterator = iterator_adaptor

Definition of the iterators.

◆ json_const_iteration_proxy

typedef nlohmann::detail::iteration_proxy<json_const_iterator> Kratos::Parameters::json_const_iteration_proxy

◆ json_const_iterator

typedef nlohmann::detail::iter_impl<const nlohmann::json> Kratos::Parameters::json_const_iterator

◆ json_iteration_proxy

typedef nlohmann::detail::iteration_proxy<json_iterator> Kratos::Parameters::json_iteration_proxy

◆ json_iterator

typedef nlohmann::detail::iter_impl<nlohmann::json> Kratos::Parameters::json_iterator

Iterators from nlohmann::json.

◆ SizeType

typedef std::size_t Kratos::Parameters::SizeType

Size definition.

Constructor & Destructor Documentation

◆ Parameters() [1/5]

Kratos::Parameters::Parameters ( )

Default constructor.

It assigns null pointers to the member variables

◆ Parameters() [2/5]

Kratos::Parameters::Parameters ( const std::string &  rJsonString)

String constructor. It takes a string as input, which parses into a nlohmann::json class.

Parameters
rJsonStringThe string to be parsed into a nlohmann::json class

◆ Parameters() [3/5]

Kratos::Parameters::Parameters ( std::ifstream &  rStringStream)

File constructor. It takes a file stream as input, which parses into a nlohmann::json class.

Parameters
rStringStreamThe stream to the JSON file

◆ Parameters() [4/5]

Kratos::Parameters::Parameters ( Parameters const &  rOther)

Copy constructor.

◆ Parameters() [5/5]

Kratos::Parameters::Parameters ( Parameters &&  rOther)

Move constructor.

◆ ~Parameters()

virtual Kratos::Parameters::~Parameters ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ AddBool()

void Kratos::Parameters::AddBool ( const std::string &  rEntry,
const bool  Value 
)

This method adds a new bool Parameter.

Parameters
rEntryThe key identifier of the parameter
ValueThe bool value

◆ AddDouble()

void Kratos::Parameters::AddDouble ( const std::string &  rEntry,
const double  Value 
)

This method adds a new double Parameter.

Parameters
rEntryThe key identifier of the parameter
ValueThe double value

◆ AddEmptyArray()

void Kratos::Parameters::AddEmptyArray ( const std::string &  rEntry)

This method add a new entry with no value assigned.

Parameters
rEntryThe key identifier of the parameter

◆ AddEmptyValue()

Parameters Kratos::Parameters::AddEmptyValue ( const std::string &  rEntry)

This method adds an empty parameter.

Parameters
rEntryThe key identifier of the parameter

◆ AddInt()

void Kratos::Parameters::AddInt ( const std::string &  rEntry,
const int  Value 
)

This method adds a new integer Parameter.

Parameters
rEntryThe key identifier of the parameter
ValueThe integer value

◆ AddMatrix()

void Kratos::Parameters::AddMatrix ( const std::string &  rEntry,
const Matrix rValue 
)

This method adds a new matrix Parameter.

Parameters
rEntryThe key identifier of the parameter
ValueThe matrix value

◆ AddMissingParameters()

void Kratos::Parameters::AddMissingParameters ( const Parameters rDefaultParameters)

This function is designed to verify that the parameters under testing contain at least all parameters prescribed by the rDefaultParameters.

If a parameter is found in the rDefaultParameters but not in the Parameters been tested, it is copied to the parameters. This version of the function only walks one level, without descending in the branches

Parameters
rDefaultParametersParameters of reference which we use to check

◆ AddString()

void Kratos::Parameters::AddString ( const std::string &  rEntry,
const std::string &  rValue 
)

This method adds a new string Parameter.

Parameters
rEntryThe key identifier of the parameter
rValueThe string value

◆ AddStringArray()

void Kratos::Parameters::AddStringArray ( const std::string &  rEntry,
const std::vector< std::string > &  rValue 
)

This method sets the string array contained in the current Parameter.

Parameters
rEntryThe key identifier of the parameter
ValueThe string array

◆ AddValue()

void Kratos::Parameters::AddValue ( const std::string &  rEntry,
const Parameters rOtherValue 
)

This method sets a non-existing parameter with a given parameter.

Parameters
rEntryThe key identifier of the parameter
rOtherValueThe value to set

◆ AddVector()

void Kratos::Parameters::AddVector ( const std::string &  rEntry,
const Vector rValue 
)

This method adds a new vector Parameter.

Parameters
rEntryThe key identifier of the parameter
rValueThe vector value

◆ Append() [1/7]

void Kratos::Parameters::Append ( const bool  Value)

This method appends into an array a boolean value.

Parameters
ValueThe boolean value to append

◆ Append() [2/7]

void Kratos::Parameters::Append ( const double  Value)

This method appends into an array a double value.

Parameters
ValueThe double value to append

◆ Append() [3/7]

void Kratos::Parameters::Append ( const int  Value)

This method appends into an array a integer value.

Parameters
ValueThe integer value to append

◆ Append() [4/7]

void Kratos::Parameters::Append ( const Matrix rValue)

This method appends into an array a matrix value.

Parameters
rValueThe matrix value to append

◆ Append() [5/7]

void Kratos::Parameters::Append ( const Parameters rValue)

This method appends into an array a Parameter value.

Parameters
rValueThe Parameter value to append

◆ Append() [6/7]

void Kratos::Parameters::Append ( const std::string &  rValue)

This method appends into an array a string value.

Parameters
rValueThe string value to append

◆ Append() [7/7]

void Kratos::Parameters::Append ( const Vector rValue)

This method appends into an array a vector value.

Parameters
rValueThe vector value to append

◆ begin() [1/2]

Parameters::iterator Kratos::Parameters::begin ( )

This returns the begin iterator.

Returns
The begin iterator

◆ begin() [2/2]

Parameters::const_iterator Kratos::Parameters::begin ( ) const

This returns the constant begin iterator.

Returns
The constant begin iterator

◆ Clone()

Parameters Kratos::Parameters::Clone ( ) const

Generates a clone of the current document.

Returns
A clone of the given Parameters

◆ CopyValuesFromExistingParameters()

void Kratos::Parameters::CopyValuesFromExistingParameters ( const Parameters  OriginParameters,
const std::vector< std::string > &  rListParametersToCopy 
)

This method can be used in order to copy the values from existing Parameters object.

Parameters
OriginParametersThe Parameters to be copied
rListParametersToCopyThe list of Parameters to copy

◆ end() [1/2]

Parameters::iterator Kratos::Parameters::end ( )

This returns the end iterator.

Returns
The end iterator

◆ end() [2/2]

Parameters::const_iterator Kratos::Parameters::end ( ) const

This returns the constant end iterator.

Returns
The constant end iterator

◆ Get()

template<class TValue >
TValue Kratos::Parameters::Get ( ) const

Templetized getter for supported types.

Supported types: double, int, bool, std::string, Vector, Matrix.

Template Parameters
TValuetype of the value to parse and return.

◆ GetArrayItem() [1/2]

Parameters Kratos::Parameters::GetArrayItem ( const IndexType  Index)

This method returns an array item given an index.

Parameters
IndexThe index of the parameter to obtain
Returns
The parameter corresponding to the given index

◆ GetArrayItem() [2/2]

Parameters Kratos::Parameters::GetArrayItem ( const IndexType  Index) const

This method returns an array item given an index (const version)

Parameters
IndexThe index of the parameter to obtain
Returns
The parameter corresponding to the given index

◆ GetBool()

bool Kratos::Parameters::GetBool ( ) const

This method returns the boolean contained in the current Parameter.

Returns
The boolean value

◆ GetDouble()

double Kratos::Parameters::GetDouble ( ) const

This method returns the double contained in the current Parameter.

Returns
The double value

◆ GetInt()

int Kratos::Parameters::GetInt ( ) const

This method returns the integer contained in the current Parameter.

Returns
The integer value

◆ GetMatrix()

Matrix Kratos::Parameters::GetMatrix ( ) const

This method returns the matrix contained in the current Parameter.

Returns
The matrix value

◆ GetString()

std::string Kratos::Parameters::GetString ( ) const

This method returns the string contained in the current Parameter.

Returns
The string value

◆ GetStringArray()

std::vector< std::string > Kratos::Parameters::GetStringArray ( ) const

This method returns the array of strings in the current Parameter.

Returns
The array of strings

◆ GetValue() [1/2]

Parameters Kratos::Parameters::GetValue ( const std::string &  rEntry)

This method returns the Parameter corresponding to a certain entry.

Parameters
rEntryThe key identifier of the parameter
Returns
The corresponding parameter

◆ GetValue() [2/2]

Parameters Kratos::Parameters::GetValue ( const std::string &  rEntry) const

This method returns the Parameter corresponding to a certain entry (const version)

Parameters
rEntryThe key identifier of the parameter
Returns
The corresponding parameter

◆ GetVector()

Vector Kratos::Parameters::GetVector ( ) const

This method returns the vector contained in the current Parameter.

Returns
The vector value

◆ Has()

bool Kratos::Parameters::Has ( const std::string &  rEntry) const

This method checks if the Parameter contains a certain entry.

Parameters
rEntryThe key identifier of the parameter
Returns
True if it contains, false otherwise

◆ HasSameKeysAndTypeOfValuesAs()

bool Kratos::Parameters::HasSameKeysAndTypeOfValuesAs ( Parameters rParameters)

Checks if the names and the type of values are the same, no importance to the order.

Lists have to be ordered, though! Take into account that in Kratos some physical vectors are represented with a list.

Parameters
rParametersThe parameters to be checked
Returns
True if it has, false othersise

◆ Info()

virtual std::string Kratos::Parameters::Info ( ) const
inlinevirtual

Turn back information as a string.

◆ Is() [1/2]

template<class TValue >
bool Kratos::Parameters::Is ( ) const

Templetized type checker for supported types.

Supported types: double, int, bool, std::string, Vector, Matrix.

Template Parameters
TValuetype of the value to parse.

◆ Is() [2/2]

template<>
bool Kratos::Parameters::Is ( ) const

◆ IsArray()

bool Kratos::Parameters::IsArray ( ) const

This method checks if the parameter is an array.

Returns
True if it is an array, false otherwise

◆ IsBool()

bool Kratos::Parameters::IsBool ( ) const

This method checks if the parameter is a boolean.

Returns
True if it is a boolean, false otherwise

◆ IsDouble()

bool Kratos::Parameters::IsDouble ( ) const

This method checks if the parameter is a double.

Returns
True if it is a double, false otherwise

◆ IsEquivalentTo()

bool Kratos::Parameters::IsEquivalentTo ( Parameters rParameters)

Checks if the names and values are the same, no importance to the order.

Lists have to be ordered, though! Take into account that in Kratos some physical vectors are represented with a list.

Parameters
rParametersThe parameters to be checked
Returns
True if it has, false othersise

◆ IsInt()

bool Kratos::Parameters::IsInt ( ) const

This method checks if the parameter is a integer.

Returns
True if it is a integer, false otherwise

◆ IsMatrix()

bool Kratos::Parameters::IsMatrix ( ) const

This method checks if the parameter is a matrix.

Returns
True if it is a matrix, false otherwise

◆ IsNull()

bool Kratos::Parameters::IsNull ( ) const

This method checks if the parameter is a null.

Returns
True if it is null, false otherwise

◆ IsNumber()

bool Kratos::Parameters::IsNumber ( ) const

This method checks if the parameter is a number.

Returns
True if it is a number, false otherwise

◆ IsString()

bool Kratos::Parameters::IsString ( ) const

This method checks if the parameter is a string.

Returns
True if it is a string, false otherwise

◆ IsStringArray()

bool Kratos::Parameters::IsStringArray ( ) const

This method checks if the parameter is an array of strings.

Returns
True if it is a string array, false otherwise

◆ IsSubParameter()

bool Kratos::Parameters::IsSubParameter ( ) const

This method checks if the parameter is a subparameter.

Returns
True if it is a suparameter, false otherwise

◆ IsVector()

bool Kratos::Parameters::IsVector ( ) const

This method checks if the parameter is a vector.

Returns
True if it is a vector, false otherwise

◆ items() [1/2]

Parameters::json_const_iteration_proxy Kratos::Parameters::items ( ) const
noexcept

This method returns the items of the current parameter (const)

Returns
The items of the current Parameter (const)

◆ items() [2/2]

Parameters::json_iteration_proxy Kratos::Parameters::items ( )
noexcept

This method returns the items of the current parameter.

Returns
The items of the current Parameter

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::Parameters::KRATOS_CLASS_POINTER_DEFINITION ( Parameters  )

Pointer definition of MmgProcess.

◆ operator=() [1/2]

Parameters & Kratos::Parameters::operator= ( Parameters &&  rOther)

This is the move operator.

Parameters
rOtherThe other parameter to compute the move

◆ operator=() [2/2]

Parameters & Kratos::Parameters::operator= ( Parameters const &  rOther)

Assignment operator.

◆ operator[]() [1/4]

Parameters Kratos::Parameters::operator[] ( const IndexType  Index)

This method allows to access to an array item with the operator [].

Parameters
IndexThe index of the term of interest
Returns
The desired Parameter

◆ operator[]() [2/4]

Parameters Kratos::Parameters::operator[] ( const IndexType  Index) const

This method allows to access to an array item with the operator [] (const version)

Parameters
IndexThe index of the term of interest
Returns
The desired Parameter

◆ operator[]() [3/4]

Parameters Kratos::Parameters::operator[] ( const std::string &  rEntry)

This metrod returns the Parameter corresponding to a given key.

Parameters
rEntryThe key identifier of the parameter
Returns
The desired Parameter

◆ operator[]() [4/4]

Parameters Kratos::Parameters::operator[] ( const std::string &  rEntry) const

This metrod returns the Parameter corresponding to a given key (const version)

Parameters
rEntryThe key identifier of the parameter
Returns
The desired Parameter

◆ PrettyPrintJsonString()

const std::string Kratos::Parameters::PrettyPrintJsonString ( ) const

This method returns a string with the corresponding text to the equivalent *.json file (this version is prettier, and considers tabulations)

Returns
The corresponding text

◆ PrintData()

virtual void Kratos::Parameters::PrintData ( std::ostream &  rOStream) const
inlinevirtual

Print object's data.

◆ PrintInfo()

virtual void Kratos::Parameters::PrintInfo ( std::ostream &  rOStream) const
inlinevirtual

Print information about this object.

◆ RecursivelyAddMissingParameters()

void Kratos::Parameters::RecursivelyAddMissingParameters ( const Parameters rDefaultParameters)

This function is designed to verify that the parameters under testing contain at least all parameters prescribed by the rDefaultParameters.

If a parameter is found in the rDefaultParameters but not in the Parameters been tested, it is copied to the parameters. This version walks and validates the entire json tree below the point at which the function is called

Parameters
rDefaultParametersParameters of reference which we use to check

◆ RecursivelyFindValue()

void Kratos::Parameters::RecursivelyFindValue ( const nlohmann::json &  rBaseValue,
const nlohmann::json &  rValueToFind 
) const

This method looks in a recursive way in the json structure.

Parameters
rBaseValueThe value where to find
rValueToFindThe value to look

◆ RecursivelyValidateAndAssignDefaults()

void Kratos::Parameters::RecursivelyValidateAndAssignDefaults ( const Parameters rDefaultParameters)

This function is designed to verify that the parameters under testing match the form prescribed by the defaults.

If the parameters contain values that do not appear in the defaults, an error is thrown, whereas if a parameter is found in the defaults but not in the Parameters been tested, it is copied to the parameters. This version walks and validates the entire json tree below the point at which the function is called

Parameters
rDefaultParametersParameters of reference which we use to check

◆ RecursivelyValidateDefaults()

void Kratos::Parameters::RecursivelyValidateDefaults ( const Parameters rDefaultParameters) const

This function is designed to verify that the all parameteters in the parameters under testing have a matching parameter prescribed by the rDefaultParameters.

If the parameters contain values that do not appear in the defaults, an error is thrown. This version walks and validates the entire json tree below the point at which the function is called

Parameters
rDefaultParametersParameters of reference which we use to check

◆ RemoveValue()

bool Kratos::Parameters::RemoveValue ( const std::string &  rEntry)

This method removes an entry of the Parameters given a certain key.

Parameters
rEntryThe key identifier of the parameter
Returns
False if failed, true otherwise

◆ RemoveValues()

bool Kratos::Parameters::RemoveValues ( const std::vector< std::string > &  rEntries)

This method removes several entries of the Parameters given a certain list of keys.

Parameters
rEntriesThe keys identifier of the parameters
Returns
False if failed, true otherwise

◆ Reset()

void Kratos::Parameters::Reset ( )
noexcept

This method resets the whole parameter (it assigns an empty parameter)

◆ Set()

template<class TValue >
void Kratos::Parameters::Set ( const TValue &  rValue)

Templetized setter for supported types.

Supported types: double, int, bool, std::string, Vector, Matrix.

Template Parameters
TValuetype of the value to be set.
Parameters
rValuevalue to be written to the JSON.

◆ SetArrayItem()

void Kratos::Parameters::SetArrayItem ( const IndexType  Index,
const Parameters rOtherArrayItem 
)

This method sets an array item given an index.

Parameters
IndexThe index of the parameter to set
rOtherArrayItemThe parameter corresponding to the given index

◆ SetBool()

void Kratos::Parameters::SetBool ( const bool  Value)

This method sets the bool contained in the current Parameter.

Parameters
ValueThe bool value

◆ SetDouble()

void Kratos::Parameters::SetDouble ( const double  Value)

This method sets the double contained in the current Parameter.

Parameters
ValueThe double value

◆ SetInt()

void Kratos::Parameters::SetInt ( const int  Value)

This method sets the integer contained in the current Parameter.

Parameters
ValueThe integer value

◆ SetMatrix()

void Kratos::Parameters::SetMatrix ( const Matrix rValue)

This method sets the matrix contained in the current Parameter.

Parameters
ValueThe matrix value

◆ SetString()

void Kratos::Parameters::SetString ( const std::string &  rValue)

This method sets the string contained in the current Parameter.

Parameters
rValueThe string value

◆ SetStringArray()

void Kratos::Parameters::SetStringArray ( const std::vector< std::string > &  rValue)

This method sets the string array contained in the current Parameter.

Parameters
ValueThe string array

◆ SetValue()

void Kratos::Parameters::SetValue ( const std::string &  rEntry,
const Parameters rOtherValue 
)

This method sets an existing parameter with a given parameter.

Parameters
rEntryThe key identifier of the parameter
rOtherValueThe value to set

◆ SetVector()

void Kratos::Parameters::SetVector ( const Vector rValue)

This method sets the vector contained in the current Parameter.

Parameters
rValueThe vector value

◆ size()

Parameters::SizeType Kratos::Parameters::size ( ) const

This method returns the total size of the current array parameter.

Returns
The size of the current array parameter

◆ swap()

void Kratos::Parameters::swap ( Parameters rOther)
noexcept

This method does a swap between two parameters.

Parameters
rOtherThe other parameter to compute the swap

◆ ValidateAndAssignDefaults()

void Kratos::Parameters::ValidateAndAssignDefaults ( const Parameters rDefaultParameters)

This function is designed to verify that the parameters under testing match the form prescribed by the rDefaultParameters.

If the parameters contain values that do not appear in the rDefaultParameters, an error is thrown, whereas if a parameter is found in the rDefaultParameters but not in the Parameters been tested, it is copied to the parameters. This version of the function only walks one level, without descending in the branches

Parameters
rDefaultParametersParameters of reference which we use to check

◆ ValidateDefaults()

void Kratos::Parameters::ValidateDefaults ( const Parameters rDefaultParameters) const

This function is designed to verify that the all parameteters in the parameters under testing have a matching parameter prescribed by the rDefaultParameters.

If the parameters contain values that do not appear in the defaults, an error is thrown. This version of the function only walks one level, without descending in the branches

Parameters
rDefaultParametersParameters of reference which we use to check

◆ WriteJsonString()

const std::string Kratos::Parameters::WriteJsonString ( ) const

This method returns a string with the corresponding text to the equivalent *.json file.

Returns
The corresponding text

Friends And Related Function Documentation

◆ Serializer

friend class Serializer
friend

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