dfnTrans
Code for Particle Tracking simulations in 3D DFN
TrackingPart.c File Reference
#include <stdio.h>
#include <search.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "FuncDef.h"
#include <unistd.h>
#include <time.h>
#include <sys/stat.h>
#include <stdbool.h>
Include dependency graph for TrackingPart.c:

Go to the source code of this file.

Data Structures

struct  inpfile
 
struct  lagrangian
 
struct  intcoef
 
struct  posit3d
 
struct  tempout
 

Functions

void ParticleTrack ()
 
void CheckNewCell ()
 
struct intcoef CalculateWeights (int nn1, int nn2, int nn3)
 
void SearchNeighborCells (int nn1, int nn2, int nn3)
 
int InsideCell (unsigned int numc)
 
void PredictorStep ()
 
void CorrectorStep ()
 
void NeighborCells (int k)
 
void DefineTimeStep ()
 
int CheckDistance ()
 
double InOutFlowCell (int indcell, int int1, double nposx, double nposy)
 
void AcrossIntersection (int prevcell, int int1, int int2, int mixing_rule)
 
int StreamlineRandomSampling (double products[4], double speedsq[4], int indj, int int1, int indk, int neighborcellind[4], int neighborfracind[4], int prevfrac, int prevcell)
 
int CompleteMixingRandomSampling (double products[4], double speedsq[4], int indj, int int1, int indk)
 
void Moving2Center (int nnp, int cellnumber)
 
int Moving2NextCell (int stuck, int k)
 
double CalculateCurrentDT ()
 
int Xindex (int nodenum, int nnp)
 
int Yindex (int nodenum, int nnp)
 
void Moving2NextCellBound (int prevcell)
 
void ParticleOutput (int currentt, int fract_p)
 
void FinalPosition ()
 
struct lagrangian CalculateLagrangian (double xcurrent, double ycurrent, double zcurrent, double xprev, double yprev, double zprev)
 
double TimeDomainRW (double time_advect)
 

Variables

struct lagrangian lagvariable
 
unsigned int FLAG_OUT = 0
 
unsigned int all_out = 0
 
unsigned int np
 
unsigned int t
 
unsigned int nodeID = 0
 
unsigned int avs_o = 0
 
unsigned int traj_o = 0
 
unsigned int curv_o = 0
 
unsigned int no_out = 0
 
unsigned int tdrw = 0
 
unsigned int mixing_rule = 1
 
unsigned int marfa = 0
 
unsigned int plumec = 0
 
unsigned int disp_o = 0
 
unsigned int timecounter = 0
 
unsigned int frac_o = 0
 
unsigned int tfile = 0
 
unsigned int tdrw_o = 0
 
unsigned int tdrw_limited = 0
 
double tdrw_porosity = 0.0
 
double tdrw_diffcoeff = 0.0
 
double t_adv0 = 0.0
 
double t_adv = 0.0
 
double timediff = 0.0
 
double tdrw_lambda = 0.0
 
struct tempouttempdata
 

Function Documentation

◆ AcrossIntersection()

void AcrossIntersection ( int  prevcell,
int  int1,
int  int2,
int  mixing_rule 
)

Particle is moving through intersection line

Definition at line 1784 of file TrackingPart.c.

References CalculateWeights(), cell, vertex::cells, ChangeFracture(), CompleteMixingRandomSampling(), vertex::coord_xy, vertex::fracture, element::fracture, contam::intcell, mixing_rule, node, element::node_ind, np, particle, contam::position, contam::prev_pos, StreamlineRandomSampling(), element::veloc_ind, vertex::velocity, intcoef::weights, XindexC(), and YindexC().

Referenced by CheckDistance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateCurrentDT()

double CalculateCurrentDT ( )

Functions returns particle instanteneous time step

Definition at line 2239 of file TrackingPart.c.

References contam::cell, cell, node, element::node_ind, np, particle, vertex::timestep, element::veloc_ind, and contam::weight.

Referenced by CalculateWeights(), CheckDistance(), CorrectorStep(), and PredictorStep().

Here is the caller graph for this function:

◆ CalculateLagrangian()

struct lagrangian CalculateLagrangian ( double  xcurrent,
double  ycurrent,
double  zcurrent,
double  xprev,
double  yprev,
double  zprev 
)

Function calculates Lagrangian variables: tau and beta.

Definition at line 2634 of file TrackingPart.c.

References contam::cell, cell, vertex::cells, vertex::coord_xy, vertex::indnodes, node, element::node_ind, np, vertex::numneighb, particle, contam::position, contam::prev_pos, contam::time, Xindex(), and Yindex().

Referenced by ParticleTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalculateWeights()

struct intcoef CalculateWeights ( int  nn1,
int  nn2,
int  nn3 
)

Function calculates interpolation weights for velocity instanteneous particles velocity and time step.

Definition at line 1111 of file TrackingPart.c.

References CalculateCurrentDT(), CalculateWeights(), contam::cell, cell, FLAG_OUT, contam::fracture, node, element::node_ind, np, vertex::numneighb, particle, contam::position, contam::prev_pos, SearchNeighborCells(), contam::velocity, contam::weight, and intcoef::weights.

Referenced by AcrossIntersection(), CalculateWeights(), InOutFlowCell(), and InsideCell().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckDistance()

int CheckDistance ( )

Function checks the distance from particle to intersection line when particles is located at the intersection triangular cell

Definition at line 1474 of file TrackingPart.c.

References AcrossIntersection(), CalculateCurrentDT(), contam::cell, cell, vertex::cells, CheckNewCell(), vertex::coord_xy, vertex::fracture, fracture, vertex::indnodes, InOutFlowCell(), mixing_rule, no_out, node, element::node_ind, np, vertex::numneighb, particle, ParticleOutput(), contam::position, PredictorStep(), contam::prev_pos, t, t_adv, t_adv0, contam::t_adv_diff, contam::t_diff, tdrw, tdrw_o, contam::time, timediff, TimeDomainRW(), Xindex(), and Yindex().

Referenced by ParticleTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckNewCell()

void CheckNewCell ( )

Function performs a check, did particle move to a new triangular cell during last time step or stayed at the same cell

Definition at line 1111 of file TrackingPart.c.

Referenced by CheckDistance(), and ParticleTrack().

Here is the caller graph for this function:

◆ CompleteMixingRandomSampling()

int CompleteMixingRandomSampling ( double  products[4],
double  speedsq[4],
int  indj,
int  int1,
int  indk 
)

Particle motion at a fracture intersection is determined by the streamline routing rule Arg 1: Cross product to define outgoing and incoming cells. Vector contains value for each cell at the intersection Arg 2: Vector of the speed squared for each cell at the intersection Arg 3: index of current cell in int1 node list Arg 4: int1 is the index of the node of the incoming cell that lies on the intersection Arg 5: indk gives the position in the list of the 4 intersection cells that is previous cell Return: The Exit cell at the intersection

Definition at line 2089 of file TrackingPart.c.

References vertex::cells, and node.

Referenced by AcrossIntersection().

Here is the caller graph for this function:

◆ CorrectorStep()

void CorrectorStep ( )

Corrector step in Predictor-Corrector technique. Function calculates new particle position using calculated velocity in Predictor step.

Definition at line 1408 of file TrackingPart.c.

References CalculateCurrentDT(), contam::cell, cell, element::node_ind, np, particle, contam::position, contam::prev_pos, element::veloc_ind, and contam::velocity.

Referenced by ParticleTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefineTimeStep()

void DefineTimeStep ( )

Function performs a loop through all the nodes in the mesh and defines a time step at each node. The time step of particles will be interpolated from time steps defined at each node.

Definition at line 1447 of file TrackingPart.c.

References nnodes, node, vertex::timestep, and vertex::velocity.

Referenced by main().

Here is the caller graph for this function:

◆ FinalPosition()

void FinalPosition ( )

Function calculates particles final position at out-flow boundary

Definition at line 2634 of file TrackingPart.c.

Referenced by ParticleTrack().

Here is the caller graph for this function:

◆ InOutFlowCell()

double InOutFlowCell ( int  indcell,
int  int1,
double  nposx,
double  nposy 
)

Function defines if velocities on cell vertices pointing in or out of intersection line

Definition at line 1730 of file TrackingPart.c.

References CalculateWeights(), contam::cell, cell, ChangeFracture(), vertex::coord_xy, contam::fracture, node, element::node_ind, np, particle, contam::position, element::veloc_ind, vertex::velocity, intcoef::weights, XindexC(), and YindexC().

Referenced by CheckDistance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsideCell()

int InsideCell ( unsigned int  numc)

Function checks if particle is in the cell (numc is cell ID)

Definition at line 1324 of file TrackingPart.c.

References CalculateWeights(), contam::cell, cell, contam::intcell, node, element::node_ind, np, particle, contam::weight, and intcoef::weights.

Referenced by InitCell(), InitPos(), Moving2Center(), and NeighborCells().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Moving2Center()

void Moving2Center ( int  nnp,
int  cellnumber 
)

Function moves particle to the center of the same cell

Definition at line 2175 of file TrackingPart.c.

References cell, vertex::coord_xy, InsideCell(), node, element::node_ind, particle, contam::position, Xindex(), and Yindex().

Referenced by InitPos(), Moving2NextCell(), and Moving2NextCellBound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Moving2NextCell()

int Moving2NextCell ( int  stuck,
int  k 
)

Functions performs the movement of particle from one cell to the center of neighbouring cell.

Definition at line 2198 of file TrackingPart.c.

References contam::cell, cell, vertex::cells, fracture, Moving2Center(), node, np, and particle.

Here is the call graph for this function:

◆ Moving2NextCellBound()

void Moving2NextCellBound ( int  prevcell)

In the pathological rare case, when particle is out of fracture, the function is called and it's moving particle to internal cell

Definition at line 2286 of file TrackingPart.c.

References contam::cell, cell, vertex::cells, fracture, Moving2Center(), node, element::node_ind, np, and particle.

Referenced by ParticleTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NeighborCells()

void NeighborCells ( int  k)

Function checks neighboring cells to find a particle

Definition at line 1426 of file TrackingPart.c.

References vertex::cells, fracture, InsideCell(), node, np, and particle.

Referenced by SearchNeighborCells().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParticleOutput()

void ParticleOutput ( int  currentt,
int  fract_p 
)

The function of particles trajectories outputs. Function is called at every intersection and outputs to file at each segment of particles trajectory: from intersection to intersection. The curvature of the trajectory is defined and dictate number of time steps for outputs (unless user requested every time step output).

Definition at line 2367 of file TrackingPart.c.

References vertex::aperture, avs_o, tempout::betap, CalculatePosition3D(), CalculateVelocity3D(), contam::cell, cell, tempout::cellp, posit3d::cord3, curv_o, DefineAngle(), contam::fracture, fracture, tempout::fracturep, tempout::length_t, maindir, no_out, node, element::node_ind, nodeID, np, OpenFile(), particle, pi, contam::position, tempout::position2d, tempout::position3d, contam::pressure, tempout::pressure, t, tempdata, tfile, contam::time, timecounter, tempout::timep, tempout::times, traj_o, and tempout::velocity3d.

Referenced by CheckDistance(), and ParticleTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParticleTrack()

void ParticleTrack ( )

The main driving function of particles tracking procedure.

  1. The all necessary options for particle tracking and for the outputs are read from input control file.
  2. The subroutine for particle initial positions is called.
  3. External loop on paticles is organised. One particle at a time.
  4. Internal loop on time steps, where particles are mobing through fracture network. 4.1 Predictor -corrector technique is used for particles to move through fractures. 4.2 Complete mixing or streamline routing rule (defined by user) are used on intersections. 4.3 Particles data outputs.

Definition at line 66 of file TrackingPart.c.

References all_out, vertex::aperture, avs_o, tempout::betap, lagrangian::betta, CalculateLagrangian(), CalculatePosition3D(), CalculateVelocity3D(), contam::cell, cell, tempout::cellp, CheckDistance(), CheckNewCell(), Control_File(), Control_File_Optional(), Control_Param(), vertex::coord, posit3d::cord3, CorrectorStep(), curv_o, disp_o, inpfile::filename, FinalPosition(), contam::fl_weight, inpfile::flag, FLAG_OUT, flag_w, FlowInWeight(), frac_o, vertex::fracture, contam::fracture, fracture, tempout::fracturep, InitCell(), InitPos(), lagrangian::initx, lagrangian::inity, lagrangian::initz, lagvariable, tempout::length_t, maindir, marfa, mixing_rule, Moving2NextCellBound(), nfract, no_out, node, element::node_ind, nodeID, nodezonein, nodezoneout, np, OpenFile(), OutputMarPlumDisp(), inpfile::param, particle, ParticleOutput(), plumec, contam::position, tempout::position2d, tempout::position3d, PredictorStep(), contam::pressure, tempout::pressure, String_Compare(), t, t_adv, t_adv0, contam::t_adv_diff, contam::t_diff, lagrangian::tau, tdrw, tdrw_diffcoeff, tdrw_lambda, tdrw_limited, tdrw_o, tdrw_porosity, tempdata, tfile, contam::time, timecounter, timediff, TimeDomainRW(), tempout::timep, tempout::times, timesteps, timeunit, traj_o, and tempout::velocity3d.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PredictorStep()

void PredictorStep ( )

Predictor step in Predictor-Corrector technique. Function calculates new velocities and new particle position.

Definition at line 1383 of file TrackingPart.c.

References CalculateCurrentDT(), contam::cell, cell, node, element::node_ind, np, particle, contam::position, vertex::pressure, contam::pressure, contam::prev_pos, element::veloc_ind, contam::velocity, vertex::velocity, and contam::weight.

Referenced by CheckDistance(), and ParticleTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SearchNeighborCells()

void SearchNeighborCells ( int  nn1,
int  nn2,
int  nn3 
)

Function performs a search of neighbouring cells of current particles position.

Definition at line 1285 of file TrackingPart.c.

References cell, NeighborCells(), np, and particle.

Referenced by CalculateWeights().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StreamlineRandomSampling()

int StreamlineRandomSampling ( double  products[4],
double  speedsq[4],
int  indj,
int  int1,
int  indk,
int  neighborcellind[4],
int  neighborfracind[4],
int  prevfrac,
int  prevcell 
)

Particle motion at a fracture intersection is determined by the streamline routing rule Arg 1: Cross product to define outgoing and incoming cells. Vector contains value for each cell at the intersection Arg 2: Vector of the speed squared for each cell at the intersection Arg 3: index of current cell in int1 node list Arg 4: int1 is the index of the node of the incoming cell that lies on the intersection Arg 5: indk gives the position in the list of the 4 intersection cells that is previous cell Arg 6: Vector of the indicies for the 4 neighboring cells Arg 7: Vector of the fracture index for the 4 neighboring cells Arg 8: Fracture a particle is coming from Arg 9: Cell index a particle is coming from Return: The Exit cell at the intersection

Definition at line 1901 of file TrackingPart.c.

References cell, vertex::cells, fracture, and node.

Referenced by AcrossIntersection().

Here is the caller graph for this function:

◆ TimeDomainRW()

double TimeDomainRW ( double  time_advect)

Time Domain Random Walk (TDRW) procedure to account for matrix diffusion. Returns a diffusion time of particle per fracture. This function is called at each intersection.

Details on the method can be found in

Hyman, Jeffrey D., Harihar Rajaram, Shriram Srinivasan, Nataliia Makedonska, Satish Karra, Hari Viswanathan, and Gowri Srinivasan. "Matrix Diffusion in Fractured Media: New Insights Into Power Law Scaling of Breakthrough Curves." Geophysical Research Letters 46, no. 23 (2019): 13785-13795.

Definition at line 2769 of file TrackingPart.c.

References vertex::aperture, contam::cell, cell, material::firstnode, contam::fracture, fracture, node, element::node_ind, np, particle, pi, tdrw_diffcoeff, tdrw_lambda, tdrw_limited, tdrw_porosity, and timediff.

Referenced by CheckDistance(), and ParticleTrack().

Here is the caller graph for this function:

◆ Xindex()

int Xindex ( int  nodenum,
int  nnp 
)

Functions returns the index of X coordination of intersection node

Definition at line 2254 of file TrackingPart.c.

References fracture, node, and particle.

Referenced by CalculateLagrangian(), CheckDistance(), and Moving2Center().

Here is the caller graph for this function:

◆ Yindex()

int Yindex ( int  nodenum,
int  nnp 
)

Functions returns the index of Y coordination of intersection node

Definition at line 2270 of file TrackingPart.c.

References fracture, node, and particle.

Referenced by CalculateLagrangian(), CheckDistance(), and Moving2Center().

Here is the caller graph for this function:

Variable Documentation

◆ all_out

unsigned int all_out = 0

Definition at line 29 of file TrackingPart.c.

Referenced by ParticleTrack().

◆ avs_o

unsigned int avs_o = 0

Definition at line 30 of file TrackingPart.c.

Referenced by ParticleOutput(), and ParticleTrack().

◆ curv_o

unsigned int curv_o = 0

Definition at line 30 of file TrackingPart.c.

Referenced by ParticleOutput(), and ParticleTrack().

◆ disp_o

unsigned int disp_o = 0

Definition at line 31 of file TrackingPart.c.

Referenced by ParticleTrack().

◆ FLAG_OUT

unsigned int FLAG_OUT = 0

Definition at line 29 of file TrackingPart.c.

Referenced by CalculateWeights(), and ParticleTrack().

◆ frac_o

unsigned int frac_o = 0

Definition at line 31 of file TrackingPart.c.

Referenced by ParticleTrack().

◆ lagvariable

struct lagrangian lagvariable

Definition at line 1 of file TrackingPart.c.

Referenced by ParticleTrack().

◆ marfa

unsigned int marfa = 0

Definition at line 31 of file TrackingPart.c.

Referenced by OutputMarPlumDisp(), and ParticleTrack().

◆ mixing_rule

unsigned int mixing_rule = 1

Definition at line 30 of file TrackingPart.c.

Referenced by AcrossIntersection(), CheckDistance(), and ParticleTrack().

◆ no_out

unsigned int no_out = 0

Definition at line 30 of file TrackingPart.c.

Referenced by CheckDistance(), ParticleOutput(), and ParticleTrack().

◆ nodeID

unsigned int nodeID = 0

Definition at line 30 of file TrackingPart.c.

Referenced by ParticleOutput(), and ParticleTrack().

◆ np

◆ plumec

unsigned int plumec = 0

Definition at line 31 of file TrackingPart.c.

Referenced by OutputMarPlumDisp(), and ParticleTrack().

◆ t

unsigned int t

Definition at line 30 of file TrackingPart.c.

Referenced by CheckDistance(), ParticleOutput(), and ParticleTrack().

◆ t_adv

double t_adv = 0.0

Definition at line 32 of file TrackingPart.c.

Referenced by CheckDistance(), and ParticleTrack().

◆ t_adv0

double t_adv0 = 0.0

Definition at line 32 of file TrackingPart.c.

Referenced by CheckDistance(), and ParticleTrack().

◆ tdrw

unsigned int tdrw = 0

Definition at line 30 of file TrackingPart.c.

Referenced by CheckDistance(), and ParticleTrack().

◆ tdrw_diffcoeff

double tdrw_diffcoeff = 0.0

Definition at line 32 of file TrackingPart.c.

Referenced by ParticleTrack(), and TimeDomainRW().

◆ tdrw_lambda

double tdrw_lambda = 0.0

Definition at line 32 of file TrackingPart.c.

Referenced by ParticleTrack(), and TimeDomainRW().

◆ tdrw_limited

unsigned int tdrw_limited = 0

Definition at line 31 of file TrackingPart.c.

Referenced by ParticleTrack(), and TimeDomainRW().

◆ tdrw_o

unsigned int tdrw_o = 0

Definition at line 31 of file TrackingPart.c.

Referenced by CheckDistance(), and ParticleTrack().

◆ tdrw_porosity

double tdrw_porosity = 0.0

Definition at line 32 of file TrackingPart.c.

Referenced by ParticleTrack(), and TimeDomainRW().

◆ tempdata

struct tempout* tempdata

Definition at line 56 of file TrackingPart.c.

Referenced by ParticleOutput(), and ParticleTrack().

◆ tfile

unsigned int tfile = 0

Definition at line 31 of file TrackingPart.c.

Referenced by ParticleOutput(), and ParticleTrack().

◆ timecounter

unsigned int timecounter = 0

Definition at line 31 of file TrackingPart.c.

Referenced by ParticleOutput(), and ParticleTrack().

◆ timediff

double timediff = 0.0

Definition at line 32 of file TrackingPart.c.

Referenced by CheckDistance(), ParticleTrack(), and TimeDomainRW().

◆ traj_o

unsigned int traj_o = 0

Definition at line 30 of file TrackingPart.c.

Referenced by OutputMarPlumDisp(), ParticleOutput(), and ParticleTrack().