ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Macros | Functions
read_input_tool.h File Reference
#include <string>
#include <vector>
#include <stdexcept>
#include "source_base/parallel_common.h"
Include dependency graph for read_input_tool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define strvalue   item.str_values[0]
 
#define intvalue   std::stoi(item.str_values[0])
 
#define doublevalue   std::stod(item.str_values[0])
 
#define boolvalue   assume_as_boolean(item.str_values[0])
 
#define add_double_bcast(PARAMETER)
 
#define add_int_bcast(PARAMETER)
 
#define add_bool_bcast(PARAMETER)
 
#define add_string_bcast(PARAMETER)
 
#define add_doublevec_bcast(PARAMETER, N, FILL)
 
#define add_intvec_bcast(PARAMETER, N, FILL)
 
#define add_stringvec_bcast(PARAMETER, N, FILL)
 
#define sync_string(PARAMETER)
 
#define sync_int(PARAMETER)
 
#define sync_double(PARAMETER)
 
#define sync_bool(PARAMETER)
 
#define sync_doublevec(PARAMETER, N, FILL)
 
#define sync_intvec(PARAMETER, N, FILL)
 
#define sync_stringvec(PARAMETER, N, FILL)
 
#define read_sync_string(PARAMETER)
 
#define read_sync_int(PARAMETER)
 
#define read_sync_double(PARAMETER)
 
#define read_sync_bool(PARAMETER)
 

Functions

template<typename T >
void parse_expression (const std::vector< std::string > &expressions, std::vector< T > &result)
 To parse input parameters as expressions into vectors.
 
template<typename T >
void reset_vector (std::vector< T > &vec, int size, T default_value)
 

Macro Definition Documentation

◆ add_bool_bcast

#define add_bool_bcast (   PARAMETER)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_bool(para.PARAMETER); }); \
}
Definition parameter.h:13
void bcast_bool(bool &object)
Definition parallel_common.cpp:64

◆ add_double_bcast

#define add_double_bcast (   PARAMETER)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_double(para.PARAMETER); }); \
}
void bcast_double(double *object, const int n)
Definition parallel_common.cpp:49

◆ add_doublevec_bcast

#define add_doublevec_bcast (   PARAMETER,
  N,
  FILL 
)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { \
int _vec_size = N; \
Parallel_Common::bcast_int(_vec_size); \
if (para.PARAMETER.size() != _vec_size) \
para.PARAMETER.resize(_vec_size, FILL); \
Parallel_Common::bcast_double(para.PARAMETER.data(), _vec_size); \
}); \
}
#define N
Definition exp.cpp:24

◆ add_int_bcast

#define add_int_bcast (   PARAMETER)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_int(para.PARAMETER); }); \
}
void bcast_int(int *object, const int n)
Definition parallel_common.cpp:59

◆ add_intvec_bcast

#define add_intvec_bcast (   PARAMETER,
  N,
  FILL 
)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { \
int _vec_size = N; \
Parallel_Common::bcast_int(_vec_size); \
if (para.PARAMETER.size() != _vec_size) \
para.PARAMETER.resize(_vec_size, FILL); \
Parallel_Common::bcast_int(para.PARAMETER.data(), _vec_size); \
}); \
}

◆ add_string_bcast

#define add_string_bcast (   PARAMETER)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_string(para.PARAMETER); }); \
}
void bcast_string(std::string *object, const int n)
Definition parallel_common.cpp:27

◆ add_stringvec_bcast

#define add_stringvec_bcast (   PARAMETER,
  N,
  FILL 
)
Value:
{ \
bcastfuncs.push_back([](Parameter& para) { \
int _vec_size = N; \
Parallel_Common::bcast_int(_vec_size); \
if (para.PARAMETER.size() != _vec_size) \
para.PARAMETER.resize(_vec_size, FILL); \
Parallel_Common::bcast_string(para.PARAMETER.data(), _vec_size); \
}); \
}

◆ boolvalue

#define boolvalue   assume_as_boolean(item.str_values[0])

◆ doublevalue

#define doublevalue   std::stod(item.str_values[0])

◆ intvalue

#define intvalue   std::stoi(item.str_values[0])

◆ read_sync_bool

#define read_sync_bool (   PARAMETER)
Value:
{ \
item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = boolvalue; }; \
sync_bool(PARAMETER); \
}
#define boolvalue
Definition read_input_tool.h:11

◆ read_sync_double

#define read_sync_double (   PARAMETER)
Value:
{ \
item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = doublevalue; }; \
sync_double(PARAMETER); \
}
#define doublevalue
Definition read_input_tool.h:10

◆ read_sync_int

#define read_sync_int (   PARAMETER)
Value:
{ \
item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = intvalue; }; \
sync_int(PARAMETER); \
}
#define intvalue
Definition read_input_tool.h:9

◆ read_sync_string

#define read_sync_string (   PARAMETER)
Value:
{ \
item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = strvalue; }; \
sync_string(PARAMETER); \
}
#define strvalue
Definition read_input_tool.h:8

◆ strvalue

#define strvalue   item.str_values[0]

◆ sync_bool

#define sync_bool (   PARAMETER)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \
add_bool_bcast(PARAMETER); \
}

◆ sync_double

#define sync_double (   PARAMETER)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \
add_double_bcast(PARAMETER); \
}

◆ sync_doublevec

#define sync_doublevec (   PARAMETER,
  N,
  FILL 
)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { \
for (int i = 0; i < N; i++) \
{ \
item.final_value << para.PARAMETER[i] << " "; \
} \
}; \
add_doublevec_bcast(PARAMETER, N, FILL); \
}

◆ sync_int

#define sync_int (   PARAMETER)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \
add_int_bcast(PARAMETER); \
}

◆ sync_intvec

#define sync_intvec (   PARAMETER,
  N,
  FILL 
)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { \
for (int i = 0; i < N; i++) \
{ \
item.final_value << para.PARAMETER[i] << " "; \
} \
}; \
add_intvec_bcast(PARAMETER, N, FILL); \
}

◆ sync_string

#define sync_string (   PARAMETER)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \
add_string_bcast(PARAMETER); \
}

◆ sync_stringvec

#define sync_stringvec (   PARAMETER,
  N,
  FILL 
)
Value:
{ \
item.get_final_value = [](Input_Item& item, const Parameter& para) { \
for (int i = 0; i < N; i++) \
{ \
item.final_value << para.PARAMETER[i] << " "; \
} \
}; \
add_stringvec_bcast(PARAMETER, N, FILL); \
}

Function Documentation

◆ parse_expression()

template<typename T >
void parse_expression ( const std::vector< std::string > &  expressions,
std::vector< T > &  result 
)

To parse input parameters as expressions into vectors.

Template Parameters
T
Parameters
expressions(vector<string>): expressions such as "3*1 0 2*0.5 3*0"
result(vector): stores parsing results, for example, "3*1 0 2*0.5 1*1.5" can be parsed as [1, 1, 1, 0, 0.5, 0.5, 1.5]
Here is the caller graph for this function:

◆ reset_vector()

template<typename T >
void reset_vector ( std::vector< T > &  vec,
int  size,
T  default_value 
)
Here is the caller graph for this function: