@@ -69,15 +69,17 @@ Foam::functionObjects::disengagement::disengagement
6969 logFiles (obr_ ,name ),
7070 phases_ (mesh_ .lookupObject < phaseSystem > ("phaseProperties" ).phases ()),
7171 phaseName_ (dict .lookup < word > ("phase" )),
72+ inletPhaseName_ (dict .lookup < word > ("inletPhase" )),
7273 inletPatch_ (dict .lookup < word > ("inlet" )),
7374 tolerance_ (dict .lookup < scalar > ("tolerance" )),
7475 nsamples_ (dict .lookup < label > ("nsamples" )),
75- disengage_ (dict .lookup ("disengage" )),
76- holdup_ (2 * nsamples_ ,{0. ,-1. }),
76+ direction_ (dict .lookup < vector > ("direction" )),
77+ disengage_ (dict .lookup < bool > ("disengage" )),
78+ phase_com_ (2 * nsamples_ ,{0. ,-1. }),
7779 disengaged_ (false)
7880{
7981 //- Check that U has fixedValue
80- volVectorField & U = const_cast < volVectorField & > (mesh_ .lookupObject < volVectorField > ("U." + phaseName_ ));
82+ volVectorField & U = const_cast < volVectorField & > (mesh_ .lookupObject < volVectorField > ("U." + inletPhaseName_ ));
8183 label patchI = mesh_ .boundaryMesh ().findPatchID (inletPatch_ );
8284 volVectorField ::Boundary & UBf = const_cast < volVectorField ::Boundary & > (U .boundaryFieldRef ());
8385
@@ -106,9 +108,9 @@ void Foam::functionObjects::disengagement::writeFileHeader(const label i)
106108{
107109 if (Pstream ::master ())
108110 {
109- writeHeader (file (), "holdup " );
111+ writeHeader (file (), "phase_com " );
110112 writeCommented (file (), "time" );
111- writeTabbed (file (), "holdup " );
113+ writeTabbed (file (), "phase_com " );
112114 writeTabbed (file (), "disengaged" );
113115
114116 file () << endl ;
@@ -119,13 +121,14 @@ bool Foam::functionObjects::disengagement::execute()
119121{
120122 const volScalarField & alpha = mesh_ .lookupObject < volScalarField > ("alpha." + phaseName_ );
121123
122- //- Compute holdup
123- scalar volume = gSum (mesh_ .V ());
124- scalar holdup = gSum (fvc ::volumeIntegrate (alpha ))/volume ;
125- Pair < scalar > holddata (mesh_ .time ().value (), holdup );
124+ //- Compute phase_com
125+ scalar volume = gSum (fvc ::volumeIntegrate (alpha ));
126+ volScalarField hcoord = mesh_ .C ()& direction_ ;
127+ scalar phase_com = gSum (fvc ::volumeIntegrate (hcoord * alpha ))/volume ;
128+ Pair < scalar > holddata (mesh_ .time ().value (), phase_com );
126129
127130 //- See function at the beginning of file
128- add_to_list_like_static_queue (holdup_ ,holddata );
131+ add_to_list_like_static_queue (phase_com_ ,holddata );
129132
130133 //- Skip rest if no disengagement is required
131134 if (!disengage_ ) return true;
@@ -134,35 +137,35 @@ bool Foam::functionObjects::disengagement::execute()
134137 if (disengaged_ ) return true;
135138
136139 //- Do the check only if the list is complete
137- if (holdup_ [0 ].second () > 0. )
140+ if (phase_com_ [0 ].second () > 0. )
138141 {
139- scalar holdup_mean_long (0. );
140- scalar holdup_mean_short (0. );
141- scalar t0_long (holdup_ [0 ].first ());
142+ scalar phase_com_mean_long (0. );
143+ scalar phase_com_mean_short (0. );
144+ scalar t0_long (phase_com_ [0 ].first ());
142145 scalar deltat_long (0. );
143146 scalar deltat_short (0. );
144147
145148 //- The first (oldest) sample is skipped to have a well-defined dt
146149 for (int i = 1 ; i < 2 * nsamples_ ; i ++ )
147150 {
148- scalar dt = holdup_ [i ].first () - t0_long ;
149- t0_long = holdup_ [i ].first ();
150- holdup_mean_long += dt * holdup_ [i ].second ();
151+ scalar dt = phase_com_ [i ].first () - t0_long ;
152+ t0_long = phase_com_ [i ].first ();
153+ phase_com_mean_long += dt * phase_com_ [i ].second ();
151154 deltat_long += dt ;
152155
153156 //- Compute average on the most recent samples
154157 if (i >= nsamples_ )
155158 {
156- holdup_mean_short += dt * holdup_ [i ].second ();
159+ phase_com_mean_short += dt * phase_com_ [i ].second ();
157160 deltat_short += dt ;
158161 }
159162
160163 }
161164
162- holdup_mean_long /= deltat_long ;
163- holdup_mean_short /= deltat_short ;
165+ phase_com_mean_long /= deltat_long ;
166+ phase_com_mean_short /= deltat_short ;
164167
165- if (mag (holdup_mean_long - holdup_mean_short ) < tolerance_ )
168+ if (mag (phase_com_mean_long - phase_com_mean_short ) < tolerance_ )
166169 {
167170 if (!disengaged_ )
168171 {
@@ -172,7 +175,7 @@ bool Foam::functionObjects::disengagement::execute()
172175 disengaged_ = true;
173176
174177 //- Get boundary condition
175- volVectorField & U = const_cast < volVectorField & > (mesh_ .lookupObject < volVectorField > ("U." + phaseName_ ));
178+ volVectorField & U = const_cast < volVectorField & > (mesh_ .lookupObject < volVectorField > ("U." + inletPhaseName_ ));
176179
177180 label patchI = mesh_ .boundaryMesh ().findPatchID (inletPatch_ );
178181
@@ -199,9 +202,9 @@ bool Foam::functionObjects::disengagement::write()
199202
200203 if (Pstream ::master ())
201204 {
202- file () << holdup_ [2 * nsamples_ - 1 ].first ();
205+ file () << phase_com_ [2 * nsamples_ - 1 ].first ();
203206 file () << tab ;
204- file () << holdup_ [2 * nsamples_ - 1 ].second ();
207+ file () << phase_com_ [2 * nsamples_ - 1 ].second ();
205208 file () << tab ;
206209 file () << dis ;
207210 file () << endl ;
0 commit comments