2016-05-26 12:42:51 -04:00
|
|
|
#ifndef Analysis_H_INC
|
|
|
|
|
#define Analysis_H_INC
|
2015-04-28 11:34:57 -04:00
|
|
|
|
|
|
|
|
#include "common/Array.h"
|
|
|
|
|
#include "common/Communication.h"
|
|
|
|
|
|
2015-07-16 22:08:43 -04:00
|
|
|
#include <set>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2015-04-28 11:34:57 -04:00
|
|
|
|
2015-08-25 14:32:36 -04:00
|
|
|
// Define types to use for blob ids
|
|
|
|
|
typedef int32_t BlobIDType;
|
|
|
|
|
typedef Array<BlobIDType> BlobIDArray;
|
|
|
|
|
|
|
|
|
|
|
2015-04-28 11:34:57 -04:00
|
|
|
/*!
|
|
|
|
|
* @brief Compute the blob
|
|
|
|
|
* @details Compute the blob (F>vf|S>vs) starting from (i,j,k) - oil blob
|
|
|
|
|
* @return Returns the number of cubes in the blob
|
|
|
|
|
* @param[in] Phase Phase
|
|
|
|
|
* @param[in] SignDist SignDist
|
|
|
|
|
* @param[in] vF vF
|
|
|
|
|
* @param[in] vS vS
|
|
|
|
|
* @param[in] S S
|
|
|
|
|
* @param[out] LocalBlobID The ids of the blobs
|
|
|
|
|
* @return Returns the number of blobs
|
|
|
|
|
*/
|
|
|
|
|
int ComputeLocalBlobIDs( const DoubleArray& Phase, const DoubleArray& SignDist,
|
2015-08-25 14:32:36 -04:00
|
|
|
double vF, double vS, BlobIDArray& LocalBlobID, bool periodic=true );
|
2015-04-28 11:34:57 -04:00
|
|
|
|
2015-07-11 22:24:43 -04:00
|
|
|
/*!
|
|
|
|
|
* @brief Compute blob of an arbitrary phase
|
|
|
|
|
* @details Compute the connected components for Phase(i,j,k)=VALUE
|
|
|
|
|
* @return the number of connected components of the phase
|
|
|
|
|
* @param[in] PhaseID
|
|
|
|
|
* @param[in] VALUE
|
|
|
|
|
* @param[out] ComponentLabel
|
|
|
|
|
* @param[in] periodic
|
|
|
|
|
*/
|
2015-08-30 14:47:07 -04:00
|
|
|
int ComputeLocalPhaseComponent( const IntArray &PhaseID, int &VALUE, IntArray &ComponentLabel, bool periodic );
|
2015-04-28 11:34:57 -04:00
|
|
|
|
2015-07-16 22:08:43 -04:00
|
|
|
|
2015-04-28 11:34:57 -04:00
|
|
|
/*!
|
|
|
|
|
* @brief Compute the blob
|
|
|
|
|
* @details Compute the blob (F>vf|S>vs) starting from (i,j,k) - oil blob
|
|
|
|
|
* @return Returns the number of cubes in the blob
|
|
|
|
|
* @param[in] nx Number of elements in the x-direction
|
|
|
|
|
* @param[in] ny Number of elements in the y-direction
|
|
|
|
|
* @param[in] nz Number of elements in the z-direction
|
|
|
|
|
* @param[in] Phase Phase
|
|
|
|
|
* @param[in] SignDist SignDist
|
|
|
|
|
* @param[in] vF vF
|
|
|
|
|
* @param[in] vS vS
|
|
|
|
|
* @param[in] S S
|
|
|
|
|
* @param[out] LocalBlobID The ids of the blobs
|
|
|
|
|
* @return Returns the number of blobs
|
|
|
|
|
*/
|
2015-07-17 11:08:33 -04:00
|
|
|
int ComputeGlobalBlobIDs( int nx, int ny, int nz, const RankInfoStruct& rank_info,
|
2015-04-28 11:34:57 -04:00
|
|
|
const DoubleArray& Phase, const DoubleArray& SignDist, double vF, double vS,
|
2015-09-04 13:06:36 -04:00
|
|
|
BlobIDArray& GlobalBlobID, MPI_Comm comm );
|
2015-04-28 11:34:57 -04:00
|
|
|
|
2015-07-16 22:08:43 -04:00
|
|
|
|
2015-07-13 08:18:03 -04:00
|
|
|
/*!
|
|
|
|
|
* @brief Compute component of the specified phase
|
|
|
|
|
* @details Compute component of specified phase PhaseID=VALUE
|
2015-07-16 22:08:43 -04:00
|
|
|
* @return Returns the number of cubes in the blob
|
2015-07-13 08:18:03 -04:00
|
|
|
* @param[in] nx Number of elements in the x-direction
|
|
|
|
|
* @param[in] ny Number of elements in the y-direction
|
|
|
|
|
* @param[in] nz Number of elements in the z-direction
|
|
|
|
|
* @param[in] rank_in MPI communication info
|
|
|
|
|
* @param[in] PhaseID Array that identifies the phases
|
|
|
|
|
* @param[in] VALUE Identifier for the phase to decompose
|
|
|
|
|
* @param[out] GlobalBlobID The ids of the blobs for the phase
|
|
|
|
|
* @return Return the number of components in the specified phase
|
|
|
|
|
*/
|
2015-07-17 11:08:33 -04:00
|
|
|
int ComputeGlobalPhaseComponent( int nx, int ny, int nz, const RankInfoStruct& rank_info,
|
2015-09-04 13:06:36 -04:00
|
|
|
const IntArray &PhaseID, int &VALUE, BlobIDArray &GlobalBlobID, MPI_Comm comm );
|
2015-04-28 11:34:57 -04:00
|
|
|
|
2015-07-16 22:08:43 -04:00
|
|
|
|
2015-04-28 11:34:57 -04:00
|
|
|
/*!
|
|
|
|
|
* @brief Reorder the blobs
|
|
|
|
|
* @details Reorder the blobs based on the number of cells they contain
|
|
|
|
|
* largest first.
|
|
|
|
|
* @param[in] nx Number of elements in the x-direction
|
|
|
|
|
* @param[in] ny Number of elements in the y-direction
|
|
|
|
|
* @param[in] nz Number of elements in the z-direction
|
|
|
|
|
* @param[in/out] ID The ids of the blobs
|
|
|
|
|
*/
|
2015-09-04 13:06:36 -04:00
|
|
|
void ReorderBlobIDs( BlobIDArray& ID, MPI_Comm comm );
|
2015-04-28 11:34:57 -04:00
|
|
|
|
|
|
|
|
|
2015-08-25 14:32:36 -04:00
|
|
|
typedef std::pair<BlobIDType,std::vector<BlobIDType> > BlobIDSplitStruct;
|
|
|
|
|
typedef std::pair<std::vector<BlobIDType>,BlobIDType> BlobIDMergeStruct;
|
|
|
|
|
typedef std::pair<std::vector<BlobIDType>,std::vector<BlobIDType> > BlobIDMergeSplitStruct;
|
2015-10-02 10:38:44 -04:00
|
|
|
typedef std::pair<BlobIDType,BlobIDType> OverlapID;
|
2015-07-16 22:08:43 -04:00
|
|
|
struct ID_map_struct {
|
2015-10-02 10:38:44 -04:00
|
|
|
std::vector<BlobIDType> created; // list of new blobs that were created
|
|
|
|
|
std::vector<BlobIDType> destroyed; // list of blobs that disappeared
|
2015-08-25 14:32:36 -04:00
|
|
|
std::vector<std::pair<BlobIDType,BlobIDType> > src_dst; // one-one mapping of blobs (first,second timestep id)
|
2015-07-16 22:08:43 -04:00
|
|
|
std::vector<BlobIDSplitStruct> split; // list of blobs that split
|
|
|
|
|
std::vector<BlobIDMergeStruct> merge; // list of blobs that merged
|
|
|
|
|
std::vector<BlobIDMergeSplitStruct> merge_split; // list of blobs that both merged and split
|
2015-10-02 10:38:44 -04:00
|
|
|
std::map<OverlapID,int64_t> overlap; // for ids that are not a 1-1 mapping, this is a list of the overlaps <src,dst>
|
2015-08-25 14:32:36 -04:00
|
|
|
//! Empty constructor
|
|
|
|
|
ID_map_struct() {}
|
|
|
|
|
//! Create initial map from N blobs (ordered 1:N-1)
|
|
|
|
|
ID_map_struct( int N ) {
|
|
|
|
|
created.resize(N);
|
|
|
|
|
for (int i=0; i<N; i++) { created[i]=i; }
|
|
|
|
|
}
|
2015-07-16 22:08:43 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Get the mapping of blob ids between iterations
|
|
|
|
|
* @details This functions computes the map of blob ids between iterations
|
|
|
|
|
* @return Returns the map of the blob ids. Each final blob may have no source
|
|
|
|
|
* ids, one parent, or multiple parents. Each src id may be a parent for multiple blobs.
|
|
|
|
|
* @param[in] ID1 The blob ids at the first timestep
|
|
|
|
|
* @param[in] ID2 The blob ids at the second timestep
|
|
|
|
|
*/
|
2015-10-02 10:38:44 -04:00
|
|
|
ID_map_struct computeIDMap( int nx, int ny, int nz, const BlobIDArray& ID1, const BlobIDArray& ID2, MPI_Comm comm );
|
2015-08-25 14:32:36 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Compute the new global ids based on the map
|
|
|
|
|
* @details This functions computes the time-consistent global ids for the
|
|
|
|
|
* current global id index
|
|
|
|
|
* @param[in/out] map The timestep mapping for the ids
|
|
|
|
|
* @param[in] id_max The globally largest id used previously
|
|
|
|
|
* @param[out] new_ids The newly renumbered blob ids (0:ids.max())
|
|
|
|
|
*/
|
|
|
|
|
void getNewIDs( ID_map_struct& map, BlobIDType& id_max, std::vector<BlobIDType>& new_ids );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Update the blob ids based on mapping
|
|
|
|
|
* @details This functions computes the map of blob ids between iterations.
|
|
|
|
|
* Note: we also update the map to reflect the new ids
|
|
|
|
|
* @param[out] new_ids The newly renumbered blob ids (0:ids.max())
|
|
|
|
|
* @param[in/out] IDs The blob ids to renumber
|
|
|
|
|
*/
|
|
|
|
|
void renumberIDs( const std::vector<BlobIDType>& new_id_list, BlobIDArray& IDs );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Write the ID map
|
|
|
|
|
* @details This functions writes the id map fo an iteration.
|
|
|
|
|
* If no ids changed, then nothing will be written
|
|
|
|
|
* Note: only rank 0 writes, and the file is created on timestep 0.
|
|
|
|
|
* @param[in] map The timestep mapping for the ids
|
|
|
|
|
* @param[in] timestep The current timestep (timestep 0 creates the file)
|
|
|
|
|
* @param[in] filename The filename to write/append
|
|
|
|
|
*/
|
|
|
|
|
void writeIDMap( const ID_map_struct& map, long long int timestep, const std::string& filename );
|
|
|
|
|
|
2015-07-16 22:08:43 -04:00
|
|
|
|
2015-04-28 11:34:57 -04:00
|
|
|
|
|
|
|
|
#endif
|