-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsmooth_border.c
More file actions
193 lines (154 loc) · 5.88 KB
/
smooth_border.c
File metadata and controls
193 lines (154 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
File Name: smooth_border.c
Program Name: grav_parallel
Subroutine Name(s): smooth(double *param, PARAMETER P)
create_grid(double *param, double **GRID, PARAMETER P)
Release Date: April 1, 2020
Release Version: 1.0
VERSION/REVISION HISTORY
Date: April 1, 2020, Author: Laura Connor
Initial Release, Version 1.0
DISCLAIMER/NOTICE
This computer code/material was prepared as an account of work
performed by the Center for Nuclear Waste Regulatory Analyses (CNWRA)
for the Division of Waste Management of the Nuclear Regulatory
Commission (NRC), an independent agency of the United States
Government. The developer(s) of the code nor any of their sponsors
make any warranty, expressed or implied, or assume any legal
liability or responsibility for the accuracy, completeness, or
usefulness of any information, apparatus, product or process
disclosed, or represent that its use would not infringe on
privately-owned rights.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE SPONSORS
OR THOSE WHO HAVE WRITTEN OR MODIFIED THIS CODE, BE LIABLE FOR
DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH OTHER PROGRAMS) THE PROGRAM,
EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES,
OR FOR ANY CLAIM BY ANY OTHER PARTY.
PURPOSE:
The purpose of each subroutine in this file is described above each
individual routine.
PROGRAMMING LANGUAGE: ANSI C
GLOBAL VARIABLES:
REFERENCES:
PROGRAM FLOW:
*/
#include "parameters.h"
#include "common_structures.h"
/******************************************************************
FUNCTION: smooth
DESCRIPTION: This function smooths the border cells of the grid
by giving the outer cells the same value as their
inner neighboring cells.
INPUTS: (IN/OUT) double *param : the array of prism parameters being optimized
(IN) PARAMETER P : structure of model parameters
RETURN: none
****************************************************************
void smooth(double *param, PARAMETER P, FILE *logfile) {
int parm, ct, index1, index2;
Now smooth the border cells
parm = DEPTH_TO_BOT;
for (ct = 1; ct < P.col - 2; ct++) {
fprintf(log_file, "ct=%d ", ct);
index1 = ct;
index2 = ct + P.col;
param[parm+index1] = param[parm+index2];
fprintf(logfile, "1=%d 2=%d ", index1, index2);
index1 = (P.row - 1) * P.col + ct;
index2 = (P.row - 2) * P.col + ct;
param[parm+index1] = param[parm+index2];
fprintf(logfile, "1=%d 2=%d ", index1, index2);
}
for (ct = 0; ct < P.row - 1; ct++) {
fprintf(log_file, "ct=%d ", ct);
index1 = ct * P.col;
index2 = ct * P.col + 1;
param[parm+index1] = param[parm+index2];
fprintf(logfile, "1=%d 2=%d ", index1, index2);
index1 = ct * P.col + P.col - 1;
index2 = ct * P.col + P.col - 2;
param[parm+index1] = param[parm+index2];
fprintf(logfile, "1=%d 2=%d ", index1, index2);
}
}
*/
/******************************************************************
FUNCTION: create_grid
DESCRIPTION: This function fills in the interior of the grid with
the optimized parameters.
INPUTS: (IN/OUT) double *param : the array of prism parameters being optimized
(IN) PARAMETER P : structure of model parameters
(IN/OUT) double **GRID : 2-D array of grid cells
RETURN: none
*****************************************************************/
void create_grid(double *param, double **GRID, PARAMETER P) {
int x, y, i;
int parm = DEPTH_TO_BOT;
/* Fill in the interior of the grid with the optimized parameters */
for (y=1; y < P.row-1; y++)
for (x=1; x < P.col-1; x++)
GRID[y][x] = param[parm++];
/* Now calculate the border cells.
based on the interior neighbor */
/* NORTH/SOUTH
GRID[1][0] = (GRID[1][1] + GRID[2][1])/2.0;
GRID[P.col-2][0] = (GRID[P.col-3][1] + GRID[P.col-2][1])/2.0;
GRID[1][P.row-1] = (GRID[1][P.row-2] + GRID[2][P.row-2])/2.0;
GRID[P.col-2][P.row-1] = (GRID[P.col-3][P.row-2] + GRID[P.col-2][P.row-2])/2.0;
GRID[1][0] = GRID[P.col-2][0] = GRID[1][P.row-1] = GRID[P.col-2][P.row-1] = param[SURF_TO_BOT];
*/
i=0;
while (i < 2) {
if ( !i ) {
y = 0;
for (x = 1; x < P.col-1; x++)
/*GRID[y][x] = GRID[y+1][x];*/
GRID[y][x] = P.depth_to_top;
}
else {
y = P.row-1;
for (x = 1; x < P.col-1; x++)
/* GRID[y][x] = GRID[y-1][x]; */
GRID[y][x] = P.depth_to_top;
}
/* if (x > 1 && x < P.col-2)
GRID[x][y-1] = (GRID[x-1][y] + GRID[x][y] + GRID[x-1][y])/3.0; */
i++;
}
/* EAST/WEST
GRID[0][1] = (GRID[1][1] + GRID[2][1])/2.0;
GRID[0][P.row-2] = (GRID[P.col-3][1] + GRID[P.col-2][1])/2.0;
GRID[P.col-1][1] = (GRID[1][P.row-2] + GRID[2][P.row-2])/2.0;
GRID[P.col-1][P.row-2] = (GRID[P.col-3][P.row-2] + GRID[P.col-2][P.row-2])/2.0;
GRID[0][1] = GRID[0][P.row-2] = GRID[P.col-1][1] = GRID[P.col-1][P.row-2] = param[SURF_TO_BOT];
*/
i=0;
while (i < 2) {
if (!i){
x = 0;
for (y = 1; y < P.row-1; y++)
/* GRID[y][x] = GRID[y][x+1]; */
GRID[y][x] = P.depth_to_top;
}
else {
x = P.col-1;
for (y = 1; y < P.row-1; y++)
/* GRID[y][x] = GRID[y][x-1]; */
GRID[y][x] = P.depth_to_top;
}
i++;
}
/* 4 CORNERS
GRID[0][0] = GRID[1][1];
GRID[P.row-1][0] = GRID[P.row-2][1];
GRID[0][P.col-1] = GRID[1][P.col-2];
GRID[P.row-1][P.col-1] = GRID[P.row-2][P.col-2];
*/
GRID[0][0] = P.depth_to_top;
GRID[P.row-1][0] = P.depth_to_top;
GRID[0][P.col-1] = P.depth_to_top;
GRID[P.row-1][P.col-1] = P.depth_to_top;
}