59 if (fieldType ==
"CONSTANT")
61 if (fieldType ==
"FILE")
63 if (fieldType ==
"FUNCTION")
65 if (fieldType ==
"CPIECEWISE")
67 if (fieldType ==
"FPIECEWISE")
69 if (fieldType ==
"OPERATOR")
71 if (fieldType ==
"ALIAS")
75 "When adding object with label " << label << std::endl <<
76 " unrecognized type: " << fieldType << std::endl <<
77 " Valid types are : CONSTANT, FILE, FUNCTION, CPIECEWISE, FPIECEWISE, OPERATOR, ALIAS.\n" <<
97 "When adding constant field "<< label <<
" to the dictionary, incorrect number of values provided\n" <<
98 " Either 1, 3 or 9 values must be given, for scalars, vectors or tensors, respectively.\n" <<
110 CEPS_ABORT_IF(av.size()!=2 and av.size()!=4 and av.size()!=10,
111 "When initializing piecewise constant field " << label <<
",\n" <<
112 " wrong number of words in description <attribute> <value>.\n" <<
m_address
162 "When adding piecewise function " << label <<
" to dictionary, not enough parameters\n" <<
163 " given after attribute " << attrValue
184 if (not maps.empty())
186 else if (not mapv.empty())
204 "When initializing dictionary entry " << label <<
" with FILE labelword, \n" <<
205 " no file name was provided !"
210 if (ext==
"vtk" or ext==
"msh")
213 "When initializing dictionary entry " << label <<
" with FILE labelword, missing either\n" <<
215 " - SCALAR, VECTOR, or TENSOR labelword\n" <<
216 " - name of data array in file\n" <<
217 " - CELL or NODE location labelword\n" <<
227 "When initializing dictionary entry " << label <<
" with FILE labelword,\n" <<
228 " the last parameter should be either NODE or CELL.\n" <<
246 else if (dim==
"VECTOR")
248 else if (dim==
"TENSOR")
252 "When initializing dictionary entry " << label <<
" with FILE labelword,\n" <<
253 " the last parameter should be either NODE or CELL\n" <<
260 std::ifstream ifs(v[0]);
262 "Impossible to open file " << v[0] <<
" to create interpolation table"
267 std::getline(ifs,line);
272 return addInterpolationTable<9,CepsMathTensor>(label,ifs,v[0],time);
274 return addInterpolationTable<3,CepsMathVertex>(label,ifs,v[0],time);
275 return addInterpolationTable<1,CepsMathScalar>(label,ifs,v[0],time);
295 "When adding function " << label <<
" to the dictionary with keyword OPERATOR,\n" <<
296 " operator definition requires three arguments (func1 operator func2)\n" <<
315 "When adding function " << label <<
" to the dictionary with keyword OPERATOR,\n" <<
316 " " << lr[i] <<
"operand is neither an existing function of the dictionary\n" <<
317 " or a real constant. Got: " << str[i] <<
"\n" <<
m_address
320 str[i] = label +
"_" + lr[i];
328 auto tryToAdd = [&]<
class _SharedPtr> (_SharedPtr obj) -> void {
337 return tryToAdd(scalar[0]);
339 return tryToAdd(vector[0]);
341 return tryToAdd(tensor[0]);
357 "Cannot create alias to function " << params <<
" that is not in the dictionary"
431 "FunctionDictionary does not have any scalar entry " << std::quoted(LABEL)
441 "FunctionDictionary does not have any vector entry " << std::quoted(LABEL)
451 "FunctionDictionary does not have any tensor entry " << std::quoted(LABEL)
535 if (is[tag] and args[tag].size()>0)
536 fun[tag] =
getScalar(args[tag][0],
nullptr);
539 CEPS_ABORT_IF(not is[TIME] and not is[SPACE] and not is[UFUNC],
540 "When adding function to the dictionary, no keyword TIME, SPACE or UFUNC found"
556 for (
auto [tag1,obj1]: fun)
559 for (
auto [tag2,obj2] : fun)
563 res->setOwned(
true,
true);
574 checkParam(words,{
"START",
"END",
"DURATION",
"PERIOD",
"AMPLITUDE"});
577 if (profile ==
"SRECT" or profile ==
"SMOOTH_RECTANGLE")
580 return ceps::getNew<ExcitationTimeFunction>(
593 checkParam(words,{
"CENTER",
"DIAMETER",
"AMPLITUDE"},{3,1,1});
596 if (profile ==
"SRECT" or profile ==
"SMOOTH_RECTANGLE")
599 return ceps::getNew<ExcitationSpatialFunction>(
616 for(
CepsUInt i=0; i<keys.size(); i++)
621 CepsUInt n = nToRead.size()!=0 ? nToRead[i] : 1;
623 "When adding function into the dictionary, missing parameter(s)\n" <<
624 " after keyword " << keys[i] <<
"\n" <<
m_address
628 "When adding function into the dictionary, wrong parameter\n" <<
629 " after keyword " << keys[i] <<
", got: " << words[pos+1+j] <<
"\n" <<
m_address
@ Cell
Data is defined at cell centers.
@ Point
Data is defined on each point.
CepsFunctionFlag
Enum for CepsStandardArgs functions.
@ CellIndex
Use cell index to determine position.
@ NodeIndex
Use node index to determine position.
@ None
No dependance, constant functions.
#define CEPS_ABORT(message)
Stops the execution with a message. If testing is enabled, only throws a runtime_error.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
float CepsReal
Need single precision floating point.
CepsArray3< CepsReal > CepsReal3D
Three real scalars, used like this for compatibility in polynomials.
int32_t CepsInt
Need 32 bit integer.
CstPiecewiseSAFunc< _Result > * newCstPiecewiseSAFunc(const CepsMap< CepsAttribute, _Result > &map)
Direct way to build a CstPiecewiseSAFunc.
FctPiecewiseSAFunc< _Result > * newFctPiecewiseSAFunc(const CepsMap< CepsAttribute, SAFunc< _Result > * > &map)
Direct way to build a CstPiecewiseSAFunc.
OperatorSAFunc<' *', _Res1, _Res2 > * newProductSAFunc(SAFunc< _Res1 > *, SAFunc< _Res2 > *)
Get a new product object without having to look after return types of fn1 and fn2.
Functor that gets its result from an array.
Reader used to import point or cell data from files.
CepsBool hasArray(const CepsString &label, CepsInt dim=-1) const
Tells if file has data array, dim = 0 for scalars, 1 for vector, 2 for tensor.
A simple SA func that extracts time from arguments, will be added to the dictionary upon creation.
CepsReal eval(CepsStandardArgs) override
Returns args.t.
CepsEnum getFlags() const override
Time flags.
void addFromFile(const CepsString &label, const CepsString ¶ms, Geometry *geom, CepsBool neverMind=false)
Add a function read from data file, requires geometry. If the extension is compatible with CoeffReade...
void addConstant(const CepsString &label, const CepsString ¶ms)
Add a constant function through parameter string.
Map< CepsMathVertex > VectorMap
Typedef for the map of vector functions.
FunctionDictionary()
Constructor, adds some function by default.
CepsBool hasTensor(const CepsString &label) const
Tells if function "label" is registered.
void addFctPiecewise(const CepsString &label, const CepsString ¶ms)
Add a piecewise function, function on eacg.
ScalarEntry parseSpatialFunction(const CepsVector< CepsString > ¶ms)
Returns a pointer to a function deduced from the string parameters.
Map< CepsMathTensor > TensorMap
Typedef for the map of tensor functions.
void addOperator(const CepsString &label, const CepsString ¶ms)
Add an operation between already registered functions and/or real constants.
void addCstPiecewise(const CepsString &label, const CepsString ¶ms)
Add a piecewise function, constant on each region.
CepsSet< CepsString > m_doNotDelete
Functions that must not be deleted (created by alias)
~FunctionDictionary()
Destructor.
ScalarMap m_scalars
All scalar entries.
void deleteVector(const CepsString &label)
Delete a single vector entry. Be careful if the functor was created outside dictionary.
ScalarEntry parseTimeFunction(const CepsVector< CepsString > ¶ms)
Returns a pointer to a function deduced from the string parameters.
VectorMap m_vectors
All vector entries.
CepsBool hasScalar(const CepsString &label) const
Tells if function "label" is registered.
void addAlias(const CepsString &label, const CepsString ¶ms)
Adds a shortcut to an already existing function.
const TensorEntry getTensor(const CepsString &label) const
Get a single tensor entry, const version.
void checkParam(const CepsVector< CepsString > &words, const CepsVector< CepsString > &keys, const CepsVector< CepsUInt > &nToRead={}) const
Aborts if a function parameter is missing or not a number.
Map< CepsMathScalar > ScalarMap
Typedef for the map of scalar functions.
TensorMap m_tensors
All tensor entries.
void addInternal(const CepsString &label, Entry< _Result > func, Map< _Result > &map, const CepsString &name)
Internal adding method.
CepsBool hasVector(const CepsString &label) const
Tells if function "label" is registered.
const TensorMap & getTensors() const
Get all tensor entries, const version.
const VectorMap & getVectors() const
Get all vector entries, const version.
const VectorEntry getVector(const CepsString &label) const
Get a single vector entry, const version.
CepsString m_address
A string that is displayed in error messages.
const ScalarMap & getScalars() const
Get all scalar entries, const version.
void add(const CepsString &label, const CepsString ¶ms, Geometry *geom=nullptr)
Add an object from parameters.
void addFunction(const CepsString &label, const CepsString ¶ms)
Add a function deduced from tags only, works only with scalar return type.
void deleteScalar(const CepsString &label)
Delete a single scalar entry. Be careful if the functor was created outside dictionary.
const ScalarEntry getScalar(const CepsString &label) const
Get a single scalar entry, const version.
void addEntry(const CepsString &label, ScalarEntry func)
Ads an entry to the map of scalar functions.
void deleteTensor(const CepsString &label)
Delete a single tensor entry. Be careful if the functor was created outside dictionary.
ScalarEntry parseFunction(const CepsString ¶ms)
Returns a pointer to a function deduced from the string parameters.
Encapsulates all the geometrical data.
A SAFunc is a ceps::Function that uses CepsStandardArgs as argument of call operator (),...
CepsMathTensor toMathTensor(const CepsVector< CepsString > &vec)
Cast a CepsVector of CepsString to CepsMathTensor.
CepsString toKey(const CepsString &s)
Transform to key type a std::string, upper case and no spaces.
CepsBool isValidPtr(_Type *ptr)
Tells if pointer is not null.
CepsMap< CepsString, CepsVector< CepsString > > splitByKeyword(const CepsString &s, const CepsSet< CepsString > &tags)
Extract parameters in the CepsString given by tags. Builds a map of keywords and parameter words acco...
_Derived runtimeCast(_Base x)
Perform a runtime cast between base type and derived type if we can.
CepsInt argVector(const CepsVector< _Type, _Alloc > &vec, const _Type &value)
Get position of element in vector, -1 if not found.
CepsMathScalar toMathScalar(const CepsVector< CepsString > &vec)
Cast a CepsVector of CepsString to CepsMathScalar same effect as ceps::toReal(vec[0])
CepsString readParams(const CepsVector< CepsString > &scope, const CepsString &tag, const CepsString &def="", const CepsUInt &pad=1)
Read parameters into a map.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
CepsString getExtension(const CepsString &str)
Returns the extension of a file, if any.
CepsVector< CepsString > splitAtNthDelimiter(const CepsString &s, CepsUInt n, CepsString delimiters=CepsString(" \t"))
Split a string a the n-th delimeter. This ignores the doubled delimiter (eg multiple spaces count as ...
CepsVector< CepsString > split(const CepsString &s, const CepsString &delimiters=CepsString(" \t"))
Splits a string using mulitple delimiters in a single string.
CepsInt toInt(const CepsString &s)
Cast CepsString to CepsInt.
CepsString toUpper(const CepsString &s)
Switches all characters to upper case.
CepsBool isNumber(const CepsString &s)
Check if the string contains only digit numbers.
CepsMathVertex toMathVertex(const CepsVector< CepsString > &vec)
Cast a CepsVector of CepsString to CepsMathVertex.
CepsVector< CepsString > splitUntilNthDelimiter(const CepsString &s, const CepsUInt &n, CepsString delimiters=CepsString(" \t"))
Split a string for the first n delimeters.
void destroyObject(_Type &)
Destroy[delete] any type.
CepsReal toReal(const CepsString &s)
Cast CepsString to CepsReal.
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...