55 PetscFunctionBeginUser;
57 PetscCall(PetscPrintf(PETSC_COMM_WORLD,
"==> Running %s (%zu tests)\n", suite_name, case_count));
58 for (
size_t i = 0; i < case_count; ++i) {
59 PetscCall(PetscPrintf(PETSC_COMM_WORLD,
" -> %s\n", cases[i].name));
60 PetscCall(cases[i].fn());
61 PetscCall(PetscPrintf(PETSC_COMM_WORLD,
" [PASS] %s\n", cases[i].name));
64 PetscCall(PetscPrintf(PETSC_COMM_WORLD,
"==> %s complete\n", suite_name));
65 PetscFunctionReturn(0);
105 PetscFunctionBeginUser;
106 if (!simCtx_out || !user_out) {
107 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"Output pointers cannot be NULL.");
110 PetscCall(PetscCalloc1(1, &simCtx));
111 PetscCall(PetscCalloc1(1, &user));
113 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &simCtx->
rank));
139 PetscCall(DMDACreate3d(PETSC_COMM_WORLD,
140 DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE,
143 PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,
147 PetscCall(DMSetUp(user->
da));
148 PetscCall(DMDASetUniformCoordinates(user->
da, 0.0, (PetscReal)(mx - 1), 0.0, (PetscReal)(my - 1), 0.0, (PetscReal)(mz - 1)));
150 PetscCall(DMDACreate3d(PETSC_COMM_WORLD,
151 DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE,
154 PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,
158 PetscCall(DMSetUp(user->
fda));
159 PetscCall(DMDASetUniformCoordinates(user->
fda, 0.0, (PetscReal)(mx - 1), 0.0, (PetscReal)(my - 1), 0.0, (PetscReal)(mz - 1)));
160 PetscCall(DMDAGetLocalInfo(user->
fda, &user->
info));
162 PetscCall(DMCreateGlobalVector(user->
da, &user->
P));
163 PetscCall(DMCreateLocalVector(user->
da, &user->
lP));
164 PetscCall(DMCreateGlobalVector(user->
da, &user->
Nvert));
165 PetscCall(DMCreateLocalVector(user->
da, &user->
lNvert));
168 PetscCall(DMCreateGlobalVector(user->
da, &user->
Psi));
169 PetscCall(DMCreateLocalVector(user->
da, &user->
lPsi));
170 PetscCall(DMCreateGlobalVector(user->
da, &user->
Qcrit));
171 PetscCall(DMCreateGlobalVector(user->
da, &user->
P_nodal));
172 PetscCall(DMCreateGlobalVector(user->
da, &user->
Psi_nodal));
174 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Ucat));
175 PetscCall(DMCreateLocalVector(user->
fda, &user->
lUcat));
176 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Ucont));
177 PetscCall(DMCreateLocalVector(user->
fda, &user->
lUcont));
178 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Csi));
179 PetscCall(DMCreateLocalVector(user->
fda, &user->
lCsi));
180 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Eta));
181 PetscCall(DMCreateLocalVector(user->
fda, &user->
lEta));
182 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Zet));
183 PetscCall(DMCreateLocalVector(user->
fda, &user->
lZet));
184 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Cent));
185 PetscCall(DMCreateLocalVector(user->
fda, &user->
lCent));
186 PetscCall(DMCreateGlobalVector(user->
fda, &user->
Ucat_nodal));
188 PetscCall(VecZeroEntries(user->
P));
189 PetscCall(VecZeroEntries(user->
Nvert));
191 PetscCall(VecZeroEntries(user->
Psi));
192 PetscCall(VecZeroEntries(user->
Ucat));
193 PetscCall(VecZeroEntries(user->
Ucont));
194 PetscCall(VecZeroEntries(user->
Cent));
198 *simCtx_out = simCtx;
200 PetscFunctionReturn(0);
212 PetscFunctionBeginUser;
213 PetscCall(DMDAVecGetArray(user->
fda, user->
Csi, &csi));
214 PetscCall(DMDAVecGetArray(user->
fda, user->
Eta, &eta));
215 PetscCall(DMDAVecGetArray(user->
fda, user->
Zet, &zet));
217 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
218 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
219 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
220 csi[k][j][i].
x = 1.0; csi[k][j][i].
y = 0.0; csi[k][j][i].
z = 0.0;
221 eta[k][j][i].
x = 0.0; eta[k][j][i].
y = 1.0; eta[k][j][i].
z = 0.0;
222 zet[k][j][i].
x = 0.0; zet[k][j][i].
y = 0.0; zet[k][j][i].
z = 1.0;
227 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Csi, &csi));
228 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Eta, &eta));
229 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Zet, &zet));
231 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Csi, INSERT_VALUES, user->
lCsi));
232 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Csi, INSERT_VALUES, user->
lCsi));
233 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Eta, INSERT_VALUES, user->
lEta));
234 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Eta, INSERT_VALUES, user->
lEta));
235 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Zet, INSERT_VALUES, user->
lZet));
236 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Zet, INSERT_VALUES, user->
lZet));
237 PetscCall(DMGlobalToLocalBegin(user->
da, user->
Nvert, INSERT_VALUES, user->
lNvert));
238 PetscCall(DMGlobalToLocalEnd(user->
da, user->
Nvert, INSERT_VALUES, user->
lNvert));
239 PetscCall(DMGlobalToLocalBegin(user->
da, user->
P, INSERT_VALUES, user->
lP));
240 PetscCall(DMGlobalToLocalEnd(user->
da, user->
P, INSERT_VALUES, user->
lP));
241 PetscCall(DMGlobalToLocalBegin(user->
da, user->
Psi, INSERT_VALUES, user->
lPsi));
242 PetscCall(DMGlobalToLocalEnd(user->
da, user->
Psi, INSERT_VALUES, user->
lPsi));
243 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Ucat, INSERT_VALUES, user->
lUcat));
244 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Ucat, INSERT_VALUES, user->
lUcat));
245 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Ucont, INSERT_VALUES, user->
lUcont));
246 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Ucont, INSERT_VALUES, user->
lUcont));
247 PetscCall(DMGlobalToLocalBegin(user->
fda, user->
Cent, INSERT_VALUES, user->
lCent));
248 PetscCall(DMGlobalToLocalEnd(user->
fda, user->
Cent, INSERT_VALUES, user->
lCent));
249 PetscFunctionReturn(0);
257 PetscFunctionBeginUser;
259 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"UserCtx cannot be NULL.");
262 PetscCall(DMCreate(PETSC_COMM_WORLD, &user->
swarm));
263 PetscCall(DMSetType(user->
swarm, DMSWARM));
264 PetscCall(DMSetDimension(user->
swarm, 3));
265 PetscCall(DMSwarmSetType(user->
swarm, DMSWARM_BASIC));
266 PetscCall(DMSwarmSetCellDM(user->
swarm, user->
da));
271 PetscCall(DMSwarmFinalizeFieldRegister(user->
swarm));
272 PetscCall(DMSwarmSetLocalSizes(user->
swarm, nlocal, 0));
274 PetscCall(DMCreate(PETSC_COMM_WORLD, &user->
post_swarm));
275 PetscCall(DMSetType(user->
post_swarm, DMSWARM));
276 PetscCall(DMSetDimension(user->
post_swarm, 3));
277 PetscCall(DMSwarmSetType(user->
post_swarm, DMSWARM_BASIC));
278 PetscCall(DMSwarmSetCellDM(user->
post_swarm, user->
da));
280 PetscCall(DMSwarmFinalizeFieldRegister(user->
post_swarm));
281 PetscCall(DMSwarmSetLocalSizes(user->
post_swarm, nlocal, 0));
282 PetscFunctionReturn(0);
429 PetscReal vmin = 0.0;
430 PetscReal vmax = 0.0;
432 PetscFunctionBeginUser;
433 PetscCall(VecMin(vec, NULL, &vmin));
434 PetscCall(VecMax(vec, NULL, &vmax));
437 PetscFunctionReturn(0);