sidedPhaseInterface.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2021-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "phaseInterface.H"
27 #include "sidedPhaseInterface.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
35  (
37  separatorsToTypeName
38  ({
40  separator()
41  }).c_str(),
42  0
43  );
45 }
46 
47 
48 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 
51 (
52  const phaseInterface& interface,
53  bool strict
54 ) const
55 {
56  return
57  (!strict || isType<sidedPhaseInterface>(interface))
58  && (strict || isA<sidedPhaseInterface>(interface))
59  && &phase_
60  == &refCast<const sidedPhaseInterface>(interface).phase_
61  && phaseInterface::same(interface, false);
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
68 (
69  const phaseModel& phase,
70  const phaseModel& otherPhase
71 )
72 :
73  phaseInterface(phase, otherPhase),
74  phase_(phase)
75 {}
76 
77 
79 (
80  const phaseSystem& fluid,
81  const word& name
82 )
83 :
84  phaseInterface(fluid, name),
85  phase_(identifyPhases(fluid, name, {separator()}).second())
86 {
87  if (!contains(phase_))
88  {
90  << "Interface " << name << " is not valid. An interface cannot "
91  << "have a side that is not one of its own phases."
92  << exit(FatalError);
93  }
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
98 
100 {}
101 
102 
103 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
104 
106 {
107  return phaseInterface::name() + '_' + separator() + '_' + phase().name();
108 }
109 
110 
112 {
113  return phase_;
114 }
115 
116 
118 {
119  return phaseInterface::otherPhase(phase_);
120 }
121 
122 
125 {
126  wordList nameParts = phaseInterface::nameToNameParts(fluid(), name());
127 
128  const label i =
130 
131  nameParts[i+1] = otherPhase().name();
132 
133  return phaseInterface::New
134  (
135  fluid(),
136  phaseInterface::namePartsToName(fluid(), nameParts)
137  );
138 }
139 
140 
141 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Class to represent an interface between phases. Derivations can further specify the configuration of ...
const phaseModel & otherPhase(const phaseModel &phase) const
Return the other phase relative to the given phase.
static word separator()
Return the separator that delimits this interface's name.
virtual word name() const
Name.
static wordList nameToNameParts(const phaseSystem &fluid, const word &name)
Split an interface name and return all its parts.
virtual bool same(const phaseInterface &interface, bool strict) const
Return true if the phase interfaces are the same.
static word namePartsToName(const phaseSystem &fluid, const wordList &nameParts)
Convert interface name parts to an interface name.
static autoPtr< phaseInterface > New(const phaseSystem &fluid, const word &name)
Select given fluid and name.
Class to represent a system of phases.
Definition: phaseSystem.H:74
Class to represent a certain side of an interface between phases.
static word separator()
Return the separator that delimits this interface's name.
virtual ~sidedPhaseInterface()
Destructor.
virtual word name() const
Name.
const phaseModel & otherPhase() const
Phase on the other side of the interface.
autoPtr< phaseInterface > otherInterface() const
Interface on the other side of the interface.
virtual bool same(const phaseInterface &interface, bool strict) const
Return true if the phase interfaces are the same.
const phaseModel & phase() const
Phase on the this side of the interface.
sidedPhaseInterface(const phaseModel &phase, const phaseModel &otherPhase)
Construct from phases.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
defineTypeNameAndDebugWithName(dispersedDisplacedPhaseInterface, separatorsToTypeName({ dispersedPhaseInterface::separator(), displacedPhaseInterface::separator() }).c_str(), 0)
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
error FatalError