dfnTrans
Code for Particle Tracking simulations in 3D DFN
|
#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>
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 tempout * | tempdata |
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().
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().
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().
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().
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().
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().
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().
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().
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().
void FinalPosition | ( | ) |
Function calculates particles final position at out-flow boundary
Definition at line 2634 of file TrackingPart.c.
Referenced by ParticleTrack().
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().
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().
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().
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.
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().
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().
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().
void ParticleTrack | ( | ) |
The main driving function of particles tracking procedure.
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().
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().
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().
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().
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().
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().
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().
unsigned int all_out = 0 |
Definition at line 29 of file TrackingPart.c.
Referenced by ParticleTrack().
unsigned int avs_o = 0 |
Definition at line 30 of file TrackingPart.c.
Referenced by ParticleOutput(), and ParticleTrack().
unsigned int curv_o = 0 |
Definition at line 30 of file TrackingPart.c.
Referenced by ParticleOutput(), and ParticleTrack().
unsigned int disp_o = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by ParticleTrack().
unsigned int FLAG_OUT = 0 |
Definition at line 29 of file TrackingPart.c.
Referenced by CalculateWeights(), and ParticleTrack().
unsigned int frac_o = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by ParticleTrack().
struct lagrangian lagvariable |
Definition at line 1 of file TrackingPart.c.
Referenced by ParticleTrack().
unsigned int marfa = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by OutputMarPlumDisp(), and ParticleTrack().
unsigned int mixing_rule = 1 |
Definition at line 30 of file TrackingPart.c.
Referenced by AcrossIntersection(), CheckDistance(), and ParticleTrack().
unsigned int no_out = 0 |
Definition at line 30 of file TrackingPart.c.
Referenced by CheckDistance(), ParticleOutput(), and ParticleTrack().
unsigned int nodeID = 0 |
Definition at line 30 of file TrackingPart.c.
Referenced by ParticleOutput(), and ParticleTrack().
unsigned int np |
index of current particle, idex in particle's loop
Definition at line 30 of file TrackingPart.c.
Referenced by AcrossIntersection(), CalculateCurrentDT(), CalculateLagrangian(), CalculatePosition3D(), CalculateWeights(), CheckDistance(), CorrectorStep(), FlowInWeight(), InitParticles_flux(), InOutFlowCell(), InsideCell(), Moving2NextCell(), Moving2NextCellBound(), NeighborCells(), ParticleOutput(), ParticleTrack(), PredictorStep(), SearchNeighborCells(), and TimeDomainRW().
unsigned int plumec = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by OutputMarPlumDisp(), and ParticleTrack().
unsigned int t |
Definition at line 30 of file TrackingPart.c.
Referenced by CheckDistance(), ParticleOutput(), and ParticleTrack().
double t_adv = 0.0 |
Definition at line 32 of file TrackingPart.c.
Referenced by CheckDistance(), and ParticleTrack().
double t_adv0 = 0.0 |
Definition at line 32 of file TrackingPart.c.
Referenced by CheckDistance(), and ParticleTrack().
unsigned int tdrw = 0 |
Definition at line 30 of file TrackingPart.c.
Referenced by CheckDistance(), and ParticleTrack().
double tdrw_diffcoeff = 0.0 |
Definition at line 32 of file TrackingPart.c.
Referenced by ParticleTrack(), and TimeDomainRW().
double tdrw_lambda = 0.0 |
Definition at line 32 of file TrackingPart.c.
Referenced by ParticleTrack(), and TimeDomainRW().
unsigned int tdrw_limited = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by ParticleTrack(), and TimeDomainRW().
unsigned int tdrw_o = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by CheckDistance(), and ParticleTrack().
double tdrw_porosity = 0.0 |
Definition at line 32 of file TrackingPart.c.
Referenced by ParticleTrack(), and TimeDomainRW().
struct tempout* tempdata |
Definition at line 56 of file TrackingPart.c.
Referenced by ParticleOutput(), and ParticleTrack().
unsigned int tfile = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by ParticleOutput(), and ParticleTrack().
unsigned int timecounter = 0 |
Definition at line 31 of file TrackingPart.c.
Referenced by ParticleOutput(), and ParticleTrack().
double timediff = 0.0 |
Definition at line 32 of file TrackingPart.c.
Referenced by CheckDistance(), ParticleTrack(), and TimeDomainRW().
unsigned int traj_o = 0 |
Definition at line 30 of file TrackingPart.c.
Referenced by OutputMarPlumDisp(), ParticleOutput(), and ParticleTrack().