28 #include "surfaceTensionModel.H" 37 bool phaseInterfaceAddedHeadSeparator =
40 HashTable<word> phaseInterface::oldSeparatorToSeparator_ =
61 const phaseModel& phase1,
62 const phaseModel& phase2
65 return phase1.
index() < phase2.index() ? phase1 : phase2;
71 const phaseModel& phase1,
72 const phaseModel& phase2
75 return phase1.
index() < phase2.index() ? phase2 : phase1;
81 if (
findIndex(headSeparators_, separator) == -1)
83 headSeparators_.append(separator);
95 const word& oldSeparator,
99 return oldSeparatorToSeparator_.insert(oldSeparator, separator);
105 const phaseSystem& fluid,
112 <<
"Could not parse interface name \"" 121 label nPhaseNameParts = 0;
128 const word& phaseName =
129 fluid.phases()[
phasei].name();
132 phaseNamePart.size() < phaseName.size()
133 && name.size() - i >= phaseName.size()
134 &&
name(i, phaseName.size()) == phaseName
138 phaseNamePart = phaseName;
144 nameParts.append(phaseNamePart);
145 i += phaseNamePart.size();
148 if (i == name.size())
break;
154 if (name[i] !=
'_') error();
159 if (nPhaseNameParts == 0) error();
162 if (i == name.size())
break;
166 if (j == word::npos) error();
167 nameParts.last() =
name(i, j - i);
171 if (name[i] !=
'_') error();
181 const phaseSystem& fluid,
185 const wordList nameParts = nameToNameParts(fluid, name);
187 wordList separators(nameParts.size()/2);
188 forAll(separators, separatori)
190 separators[separatori] = nameParts[2*separatori + 1];
203 wordList separators(separatorsUnsorted);
206 SubList<word> tailSeparators(separators, separators.size() - 1, 1);
210 static const word phaseName =
"<phase>";
211 word typeName = phaseName;
212 forAll(separators, separatori)
217 + separators[separatori]
218 + (separators[separatori].empty() ?
"" :
"_")
229 const phaseSystem& fluid,
233 return separatorsToTypeName(nameToSeparators(fluid, name));
239 const phaseSystem& fluid,
249 name.append(nameParts[i] +
"_");
253 return name(name.size() - 1);
259 const phaseSystem& fluid,
268 if (fluid.phases().found(oldNameParts[i]))
270 name.append(oldNameParts[i] +
"_");
276 const word& oldSeparator = oldNameParts[i];
277 const word& separator = oldSeparatorToSeparator_[oldSeparator];
281 name.append(separator +
"_");
286 return name(name.size() - 1);
293 const phaseSystem& fluid,
298 const wordList nameParts = nameToNameParts(fluid, name);
300 label nameParti = -1;
301 bool multiple =
false;
302 for (
label namePartj = 1; namePartj < nameParts.size() - 1; namePartj += 2)
304 forAll(separators, separatori)
306 if (nameParts[namePartj] == separators[separatori])
308 multiple = multiple || nameParti != -1;
309 nameParti = namePartj;
317 <<
"No matches identified in \"" << name
324 <<
"Multiple matches identified in \"" << name
329 Tuple2<const phaseModel&, const phaseModel&>
331 fluid.phases()[nameParts[nameParti - 1]],
332 fluid.phases()[nameParts[nameParti + 1]]
341 const phaseModel& phase1,
342 const phaseModel& phase2
345 phase1_(getPhase1(phase1, phase2)),
346 phase2_(getPhase2(phase1, phase2)),
353 const Tuple2<const phaseModel&, const phaseModel&>&
phases 362 const phaseSystem& fluid,
372 const phaseSystem& fluid,
373 const phaseInterfaceKey& key
396 const phaseSystem& fluid,
400 wordConstructorTable::iterator cstrIter =
403 if (cstrIter == wordConstructorTablePtr_->end())
406 <<
"Unknown phaseInterface type " 408 <<
"Valid phaseInterface types are : " <<
endl 409 << wordConstructorTablePtr_->sortedToc()
423 const phaseSystem& fluid = interface1.fluid();
428 <<
"Could not combine interfaces " << interface1.name()
437 const Pair<word> headNames1(nameParts1[0], nameParts1[2]);
438 const Pair<word> headNames2(nameParts2[0], nameParts2[2]);
439 const word& headSeparator1 = nameParts1[1];
440 const word& headSeparator2 = nameParts2[1];
442 const bool haveBothHeadSeparators =
446 (headNamesCompare == 0)
447 || (haveBothHeadSeparators && headSeparator1 != headSeparator2)
448 || (haveBothHeadSeparators && headNamesCompare != 1)
459 headSeparator1 !=
word::null ? nameParts1 : nameParts2,
465 for (
label i1 = 3; i1 < nameParts1.size(); i1 += 2)
467 nameParts.append(nameParts1[i1]);
468 nameParts.append(nameParts1[i1 + 1]);
472 for (
label i2 = 3; i2 < nameParts2.size(); i2 += 2)
475 for (
label i1 = 3; i1 < nameParts1.size(); i1 += 2)
477 if (nameParts1[i1] == nameParts2[i2])
479 if (nameParts1[i1 + 1] != nameParts2[i2 + 1]) error();
485 nameParts.append(nameParts2[i2]);
486 nameParts.append(nameParts2[i2 + 1]);
labelList first(const UList< labelPair > &p)
label index() const
Return the index of the phase.
#define forAll(list, i)
Loop across all elements in list.
static autoPtr< phaseInterface > New(const phaseSystem &fluid, const word &name)
Select given fluid and name.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UniformDimensionedField< vector > uniformDimensionedVectorField
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
tmp< volScalarField > rho() const
Average density.
static int compare(const Pair< Type > &a, const Pair< Type > &b)
Compare Pairs.
phaseInterface(const phaseModel &phase1, const phaseModel &phase2)
Construct from phases.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual tmp< volScalarField > rho() const =0
Return the density field.
const word & name() const
static word nameToTypeName(const phaseSystem &fluid, const word &name)
Convert an interface name into a type name. Essentially just.
virtual word name() const
Name.
const phaseModel & phase1() const
Return phase 1.
static bool addOldSeparatorToSeparator(const word &oldSeparator, const word &separator)
Add a old separator to separator to the table.
Macros for easy insertion into run-time selection tables.
static bool addHeadSeparator(const word &separator)
Add a head separator to the list.
virtual autoPtr< phaseInterface > clone() const
Clone function.
static wordList nameToNameParts(const phaseSystem &fluid, const word &name)
Split an interface name and return all its parts.
static Tuple2< const phaseModel &, const phaseModel & > identifyPhases(const phaseSystem &fluid, const word &name, const wordList &separators)
Return references to the phases associated with a given name, and a.
A class for handling words, derived from string.
static const word null
An empty word.
An STL-conforming hash table.
graph_traits< Graph >::vertices_size_type size_type
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
static word namePartsToName(const phaseSystem &fluid, const wordList &nameParts)
Convert interface name parts to an interface name.
static word oldNamePartsToName(const phaseSystem &fluid, const wordList &oldNameParts)
Convert old-format interface name parts to an interface name. Used.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
const phaseModel & phase2() const
Return phase 2.
tmp< volScalarField > magUr() const
Relative velocity magnitude.
word name(const complex &)
Return a string representation of a complex.
tmp< volScalarField > sigma(const phaseInterfaceKey &key) const
Return the surface tension coefficient for an interface.
labelList second(const UList< labelPair > &p)
const phaseSystem & fluid() const
Return the phase system.
List< word > wordList
A List of words.
phaseSystem::phaseModelList & phases
dimensioned< scalar > mag(const dimensioned< Type > &)
static const phaseModel & getPhase2(const phaseModel &phase1, const phaseModel &phase2)
Get a reference to phase2 after sorting the phases by index.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
static word separatorsToTypeName(const wordList &separators)
Convert a list of separators into a type name.
tmp< volScalarField > sigma() const
Surface tension coefficient.
A class for managing temporary objects.
virtual ~phaseInterface()
Destructor.
Single incompressible phase derived from the phase-fraction. Used as part of the multiPhaseMixture fo...
#define defineTypeNameAndDebugWithName(Type, Name, DebugSwitch)
Define the typeName and debug information, lookup as Name.
static const phaseModel & getPhase1(const phaseModel &phase1, const phaseModel &phase2)
Get a reference to phase1 after sorting the phases by index.
static wordList nameToSeparators(const phaseSystem &fluid, const word &name)
Split an interface name and return its separators.
virtual word name() const
Name.