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-2023 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const phaseModel& phase,
53  const phaseModel& otherPhase
54 )
55 :
56  phaseInterface(phase, otherPhase),
57  phase_(phase)
58 {}
59 
60 
62 (
63  const phaseSystem& fluid,
64  const word& name
65 )
66 :
67  phaseInterface(fluid, name),
68  phase_(identifyPhases(fluid, name, {separator()}).second())
69 {
70  if (!contains(phase_))
71  {
73  << "Interface " << name << " is not valid. An interface cannot "
74  << "have a side that is not one of its own phases."
75  << exit(FatalError);
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
83 {}
84 
85 
86 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
87 
89 {
90  return phaseInterface::name() + '_' + separator() + '_' + phase().name();
91 }
92 
93 
95 {
96  return phase_;
97 }
98 
99 
101 {
102  return phaseInterface::otherPhase(phase_);
103 }
104 
105 
108 {
109  wordList nameParts = phaseInterface::nameToNameParts(fluid(), name());
110 
111  const label i =
113 
114  nameParts[i+1] = otherPhase().name();
115 
116  return phaseInterface::New
117  (
118  fluid(),
119  phaseInterface::namePartsToName(fluid(), nameParts)
120  );
121 }
122 
123 
124 // ************************************************************************* //
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.
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 and model interfacial transfers between them.
Definition: phaseSystem.H:73
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.
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:306
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
defineTypeNameAndDebugWithName(dispersedDisplacedPhaseInterface, separatorsToTypeName({ dispersedPhaseInterface::separator(), displacedPhaseInterface::separator() }).c_str(), 0)
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
error FatalError
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)