2018-06-11 15:19:05 -04:00
|
|
|
/*
|
|
|
|
|
Copyright 2013--2018 James E. McClure, Virginia Polytechnic & State University
|
2020-10-12 06:08:29 -04:00
|
|
|
Copyright Equnior ASA
|
2018-06-11 15:19:05 -04:00
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2015-01-23 23:26:41 -05:00
|
|
|
// Header file for two-phase averaging class
|
2015-08-25 14:32:36 -04:00
|
|
|
#ifndef TwoPhase_INC
|
|
|
|
|
#define TwoPhase_INC
|
|
|
|
|
|
2019-03-18 09:42:44 -04:00
|
|
|
#include <memory>
|
2015-07-20 13:33:34 -04:00
|
|
|
#include <vector>
|
|
|
|
|
|
2018-01-24 10:01:29 -05:00
|
|
|
#include "analysis/pmmc.h"
|
2015-06-03 10:30:35 -04:00
|
|
|
#include "analysis/analysis.h"
|
2018-09-20 16:51:53 -04:00
|
|
|
#include "analysis/distance.h"
|
|
|
|
|
#include "analysis/Minkowski.h"
|
2019-03-18 09:42:44 -04:00
|
|
|
#include "common/Domain.h"
|
|
|
|
|
#include "common/Communication.h"
|
2015-07-20 13:33:34 -04:00
|
|
|
#include "common/Utilities.h"
|
2021-01-04 22:16:58 -05:00
|
|
|
#include "common/MPI.h"
|
2015-07-20 13:33:34 -04:00
|
|
|
#include "IO/MeshDatabase.h"
|
|
|
|
|
#include "IO/Reader.h"
|
|
|
|
|
#include "IO/Writer.h"
|
2015-03-22 21:13:17 -04:00
|
|
|
|
2015-01-23 23:26:41 -05:00
|
|
|
|
|
|
|
|
class TwoPhase{
|
|
|
|
|
|
|
|
|
|
//...........................................................................
|
|
|
|
|
int n_nw_pts,n_ns_pts,n_ws_pts,n_nws_pts,n_local_sol_pts,n_local_nws_pts;
|
|
|
|
|
int n_nw_tris,n_ns_tris,n_ws_tris,n_nws_seg,n_local_sol_tris;
|
|
|
|
|
//...........................................................................
|
|
|
|
|
int nc;
|
|
|
|
|
int kstart,kfinish;
|
|
|
|
|
|
|
|
|
|
double fluid_isovalue, solid_isovalue;
|
2015-01-26 21:38:58 -05:00
|
|
|
double Volume;
|
2015-01-23 23:26:41 -05:00
|
|
|
// initialize lists for vertices for surfaces, common line
|
|
|
|
|
DTMutableList<Point> nw_pts;
|
|
|
|
|
DTMutableList<Point> ns_pts;
|
|
|
|
|
DTMutableList<Point> ws_pts;
|
|
|
|
|
DTMutableList<Point> nws_pts;
|
|
|
|
|
DTMutableList<Point> local_sol_pts;
|
|
|
|
|
DTMutableList<Point> local_nws_pts;
|
|
|
|
|
DTMutableList<Point> tmp;
|
|
|
|
|
|
|
|
|
|
// initialize triangle lists for surfaces
|
|
|
|
|
IntArray nw_tris;
|
|
|
|
|
IntArray ns_tris;
|
|
|
|
|
IntArray ws_tris;
|
|
|
|
|
IntArray nws_seg;
|
|
|
|
|
IntArray local_sol_tris;
|
|
|
|
|
|
|
|
|
|
// Temporary storage arrays
|
|
|
|
|
DoubleArray CubeValues;
|
|
|
|
|
DoubleArray Values;
|
|
|
|
|
DoubleArray DistanceValues;
|
|
|
|
|
DoubleArray KGwns_values;
|
|
|
|
|
DoubleArray KNwns_values;
|
|
|
|
|
DoubleArray InterfaceSpeed;
|
|
|
|
|
DoubleArray NormalVector;
|
|
|
|
|
|
2015-07-13 11:24:51 -04:00
|
|
|
DoubleArray RecvBuffer;
|
|
|
|
|
|
2015-11-12 10:28:08 -05:00
|
|
|
char *TempID;
|
|
|
|
|
|
2015-01-28 09:26:33 -05:00
|
|
|
// CSV / text file where time history of averages is saved
|
|
|
|
|
FILE *TIMELOG;
|
2015-07-13 11:17:56 -04:00
|
|
|
FILE *NWPLOG;
|
|
|
|
|
FILE *WPLOG;
|
2015-01-28 09:26:33 -05:00
|
|
|
|
2015-01-23 23:26:41 -05:00
|
|
|
public:
|
2015-07-13 08:18:03 -04:00
|
|
|
//...........................................................................
|
2018-05-17 09:43:12 -04:00
|
|
|
std::shared_ptr <Domain> Dm;
|
2015-07-13 08:18:03 -04:00
|
|
|
int NumberComponents_WP,NumberComponents_NWP;
|
2015-01-23 23:26:41 -05:00
|
|
|
//...........................................................................
|
|
|
|
|
// Averaging variables
|
|
|
|
|
//...........................................................................
|
|
|
|
|
// local averages (to each MPI process)
|
|
|
|
|
double trimdist; // pixel distance to trim surface for specified averages
|
2015-01-26 21:38:58 -05:00
|
|
|
double porosity,poreVol;
|
|
|
|
|
double awn,ans,aws,lwns;
|
|
|
|
|
double wp_volume,nwp_volume;
|
2015-01-23 23:26:41 -05:00
|
|
|
double As, dummy;
|
|
|
|
|
double vol_w, vol_n; // volumes the exclude the interfacial region
|
|
|
|
|
double sat_w, sat_w_previous;
|
|
|
|
|
double pan,paw; // local phase averaged pressure
|
|
|
|
|
// Global averages (all processes)
|
|
|
|
|
double pan_global,paw_global; // local phase averaged pressure
|
|
|
|
|
double vol_w_global, vol_n_global; // volumes the exclude the interfacial region
|
|
|
|
|
double awn_global,ans_global,aws_global;
|
|
|
|
|
double lwns_global;
|
|
|
|
|
double efawns,efawns_global; // averaged contact angle
|
2015-09-08 16:21:26 -04:00
|
|
|
double euler,Kn,Jn,An;
|
|
|
|
|
double euler_global,Kn_global,Jn_global,An_global;
|
2018-10-24 13:26:37 -04:00
|
|
|
|
|
|
|
|
double rho_n, rho_w;
|
|
|
|
|
double nu_n, nu_w;
|
|
|
|
|
double gamma_wn;
|
|
|
|
|
double Fx, Fy, Fz;
|
2015-09-04 09:08:02 -04:00
|
|
|
|
2015-01-23 23:26:41 -05:00
|
|
|
double Jwn,Jwn_global; // average mean curavture - wn interface
|
|
|
|
|
double Kwn,Kwn_global; // average Gaussian curavture - wn interface
|
|
|
|
|
double KNwns,KNwns_global; // wns common curve normal curavture
|
|
|
|
|
double KGwns,KGwns_global; // wns common curve geodesic curavture
|
|
|
|
|
double trawn,trawn_global; // trimmed interfacial area
|
|
|
|
|
double trJwn,trJwn_global; // trimmed interfacial area
|
|
|
|
|
double trRwn,trRwn_global; // trimmed interfacial area
|
2015-01-26 21:38:58 -05:00
|
|
|
double nwp_volume_global; // volume for the non-wetting phase
|
|
|
|
|
double wp_volume_global; // volume for the wetting phase
|
2015-01-23 23:26:41 -05:00
|
|
|
double As_global;
|
2015-11-05 20:00:49 -05:00
|
|
|
double wwndnw, wwndnw_global;
|
2016-01-09 21:37:44 -05:00
|
|
|
double wwnsdnwn, wwnsdnwn_global;
|
|
|
|
|
double Jwnwwndnw, Jwnwwndnw_global;
|
2015-01-23 23:26:41 -05:00
|
|
|
double dEs,dAwn,dAns; // Global surface energy (calculated by rank=0)
|
|
|
|
|
DoubleArray van;
|
|
|
|
|
DoubleArray vaw;
|
|
|
|
|
DoubleArray vawn;
|
|
|
|
|
DoubleArray vawns;
|
|
|
|
|
DoubleArray Gwn;
|
|
|
|
|
DoubleArray Gns;
|
|
|
|
|
DoubleArray Gws;
|
|
|
|
|
DoubleArray van_global;
|
|
|
|
|
DoubleArray vaw_global;
|
|
|
|
|
DoubleArray vawn_global;
|
|
|
|
|
DoubleArray vawns_global;
|
|
|
|
|
DoubleArray Gwn_global;
|
|
|
|
|
DoubleArray Gns_global;
|
|
|
|
|
DoubleArray Gws_global;
|
|
|
|
|
//...........................................................................
|
|
|
|
|
//...........................................................................
|
2017-07-08 13:32:29 -04:00
|
|
|
int Nx,Ny,Nz;
|
2015-07-13 08:18:03 -04:00
|
|
|
IntArray PhaseID; // Phase ID array (solid=0, non-wetting=1, wetting=2)
|
2015-08-25 14:32:36 -04:00
|
|
|
BlobIDArray Label_WP; // Wetting phase label
|
|
|
|
|
BlobIDArray Label_NWP; // Non-wetting phase label index (0:nblobs-1)
|
|
|
|
|
std::vector<BlobIDType> Label_NWP_map; // Non-wetting phase label for each index
|
2015-01-23 23:26:41 -05:00
|
|
|
DoubleArray SDn;
|
|
|
|
|
DoubleArray SDs;
|
|
|
|
|
DoubleArray Phase;
|
|
|
|
|
DoubleArray Press;
|
|
|
|
|
DoubleArray dPdt;
|
|
|
|
|
DoubleArray MeanCurvature;
|
|
|
|
|
DoubleArray GaussCurvature;
|
|
|
|
|
DoubleArray SDs_x; // Gradient of the signed distance
|
|
|
|
|
DoubleArray SDs_y;
|
|
|
|
|
DoubleArray SDs_z;
|
2015-01-28 11:18:18 -05:00
|
|
|
DoubleArray SDn_x; // Gradient of the signed distance
|
|
|
|
|
DoubleArray SDn_y;
|
|
|
|
|
DoubleArray SDn_z;
|
|
|
|
|
DoubleArray DelPhi; // Magnitude of Gradient of the phase indicator field
|
2015-01-23 23:26:41 -05:00
|
|
|
DoubleArray Phase_tplus;
|
|
|
|
|
DoubleArray Phase_tminus;
|
2015-01-28 11:18:18 -05:00
|
|
|
DoubleArray Vel_x; // Velocity
|
2015-01-23 23:26:41 -05:00
|
|
|
DoubleArray Vel_y;
|
|
|
|
|
DoubleArray Vel_z;
|
2018-09-20 16:51:53 -04:00
|
|
|
DoubleArray PhaseDistance;
|
|
|
|
|
|
2018-09-28 17:58:46 -04:00
|
|
|
std::shared_ptr<Minkowski> wet_morph;
|
|
|
|
|
std::shared_ptr<Minkowski> nonwet_morph;
|
2018-09-20 16:51:53 -04:00
|
|
|
|
2015-07-13 08:18:03 -04:00
|
|
|
// Container for averages;
|
|
|
|
|
DoubleArray ComponentAverages_WP;
|
|
|
|
|
DoubleArray ComponentAverages_NWP;
|
2015-01-23 23:26:41 -05:00
|
|
|
//...........................................................................
|
2018-05-17 09:43:12 -04:00
|
|
|
TwoPhase(std::shared_ptr <Domain> Dm);
|
2015-08-25 14:32:36 -04:00
|
|
|
~TwoPhase();
|
2015-01-23 23:26:41 -05:00
|
|
|
void Initialize();
|
2015-07-13 09:42:44 -04:00
|
|
|
// void SetupCubes(Domain &Dm);
|
2015-01-28 10:03:15 -05:00
|
|
|
void UpdateMeshValues();
|
|
|
|
|
void UpdateSolid();
|
2015-01-28 11:18:18 -05:00
|
|
|
void ComputeDelPhi();
|
2015-06-16 21:50:29 -04:00
|
|
|
void ColorToSignedDistance(double Beta, DoubleArray &ColorData, DoubleArray &DistData);
|
2015-01-23 23:26:41 -05:00
|
|
|
void ComputeLocal();
|
2015-08-18 21:40:51 -04:00
|
|
|
void AssignComponentLabels();
|
2015-07-13 08:18:03 -04:00
|
|
|
void ComponentAverages();
|
2015-01-28 10:03:15 -05:00
|
|
|
void Reduce();
|
2015-01-26 21:38:58 -05:00
|
|
|
void NonDimensionalize(double D, double viscosity, double IFT);
|
2015-01-28 09:26:33 -05:00
|
|
|
void PrintAll(int timestep);
|
2015-07-13 08:18:03 -04:00
|
|
|
int GetCubeLabel(int i, int j, int k, IntArray &BlobLabel);
|
2015-04-13 16:56:03 -04:00
|
|
|
void SortBlobs();
|
2015-07-13 11:17:56 -04:00
|
|
|
void PrintComponents(int timestep);
|
2018-10-24 13:26:37 -04:00
|
|
|
void SetParams(double rhoA, double rhoB, double tauA, double tauB, double force_x, double force_y, double force_z, double alpha);
|
2018-11-02 16:01:09 -04:00
|
|
|
double Volume_w(){
|
|
|
|
|
return wp_volume_global;
|
|
|
|
|
}
|
|
|
|
|
double Volume_n(){
|
|
|
|
|
return nwp_volume_global;
|
|
|
|
|
}
|
2015-01-23 23:26:41 -05:00
|
|
|
};
|
|
|
|
|
|
2015-04-13 16:56:03 -04:00
|
|
|
|
2015-08-25 14:32:36 -04:00
|
|
|
#endif
|
2015-07-13 15:41:32 -04:00
|
|
|
|