37 namespace implicitFunctions
43 composedFunctionImplicitFunction,
53 Foam::implicitFunctions::composedFunctionImplicitFunction::modeType
55Foam::implicitFunctions::composedFunctionImplicitFunction::modeTypeNames
57 { modeType::ADD,
"add" },
58 { modeType::SUBTRACT,
"subtract" },
59 { modeType::MINDIST,
"minDist" },
60 { modeType::INTERSECT,
"intersect" },
65Foam::implicitFunctions::composedFunctionImplicitFunction::selectFunction
67 const scalarField& values
72 case modeType::MINDIST:
81 case modeType::SUBTRACT:
84 const label idx =
findMin(values, 1);
86 if (values[idx] < values[0] &&
pos(values[0]))
95 case modeType::INTERSECT:
102 <<
"This mode is not supported only " <<
nl
103 <<
"Supported modes are: " <<
nl
115Foam::implicitFunctions::composedFunctionImplicitFunction::
116composedFunctionImplicitFunction
118 const dictionary&
dict
122 mode_(modeTypeNames.
get(
"mode",
dict)),
125 const dictionary& funcDict =
dict.subDict(
"composedFunction");
127 functions_.resize(funcDict.size());
128 values_.resize(funcDict.size(), Zero);
132 for (
const entry& dEntry : funcDict)
134 const word&
key = dEntry.keyword();
136 if (!dEntry.isDict())
139 <<
"Entry " <<
key <<
" is not a dictionary" <<
endl
140 <<
exit(FatalIOError);
143 const dictionary& subdict = dEntry.dict();
148 implicitFunction::New(subdict.get<word>(
"type"), subdict)
165 values_[i] = functions_[i].value(
p);
168 const label idx = selectFunction(values_);
181 values_[i] =
mag(functions_[i].value(
p));
184 const label minIdx =
findMin(values_);
186 return functions_[minIdx].grad(
p);
198 values_[i] =
mag(functions_[i].value(
p));
201 const label minIdx =
findMin(values_);
203 return functions_[minIdx].distanceToSurfaces(
p);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Computes the gradient of an input field.
virtual scalar distanceToSurfaces(const vector &p) const
virtual scalar value(const vector &p) const
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
dimensionedScalar pos(const dimensionedScalar &ds)
label findMin(const ListType &input, label start=0)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
label findMax(const ListType &input, label start=0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.