41 PetscFunctionBeginUser;
47 if (drivenDirection ==
' ') {
48 PetscFunctionReturn(0);
53 if (PetscAbsReal(bulkVelocityCorrection) < 1.0e-12) {
54 PetscFunctionReturn(0);
58 simCtx->
rank, user->
_this, drivenDirection);
62 DMDALocalInfo info = user->
info;
64 PetscInt lxs = (info.xs == 0) ? 1 : info.xs;
65 PetscInt lys = (info.ys == 0) ? 1 : info.ys;
66 PetscInt lzs = (info.zs == 0) ? 1 : info.zs;
67 PetscInt lxe = (info.xs + info.xm == info.mx) ? info.mx - 1 : info.xs + info.xm;
68 PetscInt lye = (info.ys + info.ym == info.my) ? info.my - 1 : info.ys + info.ym;
69 PetscInt lze = (info.zs + info.zm == info.mz) ? info.mz - 1 : info.zs + info.zm;
71 Cmpnts ***rct, ***csi, ***eta, ***zet;
73 ierr = DMDAVecGetArray(user->
fda, Rct, &rct); CHKERRQ(ierr);
74 ierr = DMDAVecGetArrayRead(user->
fda, user->
lCsi, (
const Cmpnts***)&csi); CHKERRQ(ierr);
75 ierr = DMDAVecGetArrayRead(user->
fda, user->
lEta, (
const Cmpnts***)&eta); CHKERRQ(ierr);
76 ierr = DMDAVecGetArrayRead(user->
fda, user->
lZet, (
const Cmpnts***)&zet); CHKERRQ(ierr);
77 ierr = DMDAVecGetArrayRead(user->
da, user->
lNvert, (
const PetscReal***)&nvert); CHKERRQ(ierr);
93 PetscReal drivingForceMagnitude;
108 PetscBool hasLoggedApplication = PETSC_FALSE;
110 for (k = lzs; k < lze; k++) {
111 for (j = lys; j < lye; j++) {
112 for (i = lxs; i < lxe; i++) {
113 if (nvert[k][j][i] < 0.1) {
114 PetscReal faceArea = 0.0;
115 PetscReal momentumSource = 0.0;
117 switch (drivenDirection) {
119 faceArea = sqrt(csi[k][j][i].x * csi[k][j][i].x + csi[k][j][i].y * csi[k][j][i].y + csi[k][j][i].z * csi[k][j][i].z);
120 momentumSource = drivingForceMagnitude * forceScalingFactor * faceArea;
121 rct[k][j][i].
x += momentumSource;
124 if (!hasLoggedApplication) {
126 hasLoggedApplication = PETSC_TRUE;
130 faceArea = sqrt(eta[k][j][i].x * eta[k][j][i].x + eta[k][j][i].y * eta[k][j][i].y + eta[k][j][i].z * eta[k][j][i].z);
131 momentumSource = drivingForceMagnitude * forceScalingFactor * faceArea;
132 rct[k][j][i].
y += momentumSource;
135 if (!hasLoggedApplication) {
137 hasLoggedApplication = PETSC_TRUE;
141 faceArea = sqrt(zet[k][j][i].x * zet[k][j][i].x + zet[k][j][i].y * zet[k][j][i].y + zet[k][j][i].z * zet[k][j][i].z);
142 momentumSource = drivingForceMagnitude * forceScalingFactor * faceArea;
143 rct[k][j][i].
z += momentumSource;
146 if (!hasLoggedApplication) {
148 hasLoggedApplication = PETSC_TRUE;
158 ierr = DMDAVecRestoreArray(user->
fda, Rct, &rct); CHKERRQ(ierr);
159 ierr = DMDAVecRestoreArrayRead(user->
fda, user->
lCsi, (
const Cmpnts***)&csi); CHKERRQ(ierr);
160 ierr = DMDAVecRestoreArrayRead(user->
fda, user->
lEta, (
const Cmpnts***)&eta); CHKERRQ(ierr);
161 ierr = DMDAVecRestoreArrayRead(user->
fda, user->
lZet, (
const Cmpnts***)&zet); CHKERRQ(ierr);
162 ierr = DMDAVecRestoreArrayRead(user->
da, user->
lNvert, (
const PetscReal***)&nvert); CHKERRQ(ierr);
164 PetscFunctionReturn(0);
PetscErrorCode LogDrivenFlowDiagnostics(UserCtx *user)
Implementation of LogDrivenFlowDiagnostics().
PetscErrorCode ComputeDrivenChannelFlowSource(UserCtx *user, Vec Rct)
Internal helper implementation: ComputeDrivenChannelFlowSource().
static char DrivenFlowDirection(const UserCtx *user)
The axis a driven periodic handler drives, or ' ' when none is configured.
Momentum source terms added to the contravariant RHS.