blasius.c (4bb93ecc821f655e71cae2a68ccc76985e5f378e) blasius.c (38690fecfcf11bfdf51c3082dadeac248fcdcecf)
1// Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors.
2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3//
4// SPDX-License-Identifier: BSD-2-Clause
5//
6// This file is part of CEED: http://github.com/ceed
7
8/// @file

--- 105 unchanged lines hidden (view full) ---

114 PetscFunctionReturn(PETSC_SUCCESS);
115}
116
117static PetscErrorCode GetYNodeLocs(const MPI_Comm comm, const char path[PETSC_MAX_PATH_LEN], PetscReal **pynodes, PetscInt *nynodes) {
118 int ndims, dims[2];
119 FILE *fp;
120 const PetscInt char_array_len = 512;
121 char line[char_array_len];
1// Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors.
2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3//
4// SPDX-License-Identifier: BSD-2-Clause
5//
6// This file is part of CEED: http://github.com/ceed
7
8/// @file

--- 105 unchanged lines hidden (view full) ---

114 PetscFunctionReturn(PETSC_SUCCESS);
115}
116
117static PetscErrorCode GetYNodeLocs(const MPI_Comm comm, const char path[PETSC_MAX_PATH_LEN], PetscReal **pynodes, PetscInt *nynodes) {
118 int ndims, dims[2];
119 FILE *fp;
120 const PetscInt char_array_len = 512;
121 char line[char_array_len];
122 char **array;
123 PetscReal *node_locs;
124
125 PetscFunctionBeginUser;
126 PetscCall(PetscFOpen(comm, path, "r", &fp));
127 PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
122 PetscReal *node_locs;
123
124 PetscFunctionBeginUser;
125 PetscCall(PetscFOpen(comm, path, "r", &fp));
126 PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
128 PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
129
127
130 for (PetscInt i = 0; i < ndims; i++) dims[i] = atoi(array[i]);
128 {
129 char **array;
130
131 PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
132 for (PetscInt i = 0; i < ndims; i++) dims[i] = atoi(array[i]);
133 PetscCall(PetscStrToArrayDestroy(ndims, array));
134 }
131 if (ndims < 2) dims[1] = 1; // Assume 1 column of data is not otherwise specified
132 *nynodes = dims[0];
133 PetscCall(PetscMalloc1(*nynodes, &node_locs));
134
135 for (PetscInt i = 0; i < dims[0]; i++) {
135 if (ndims < 2) dims[1] = 1; // Assume 1 column of data is not otherwise specified
136 *nynodes = dims[0];
137 PetscCall(PetscMalloc1(*nynodes, &node_locs));
138
139 for (PetscInt i = 0; i < dims[0]; i++) {
140 char **array;
141
136 PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
137 PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
138 PetscCheck(ndims == dims[1], comm, PETSC_ERR_FILE_UNEXPECTED,
139 "Line %" PetscInt_FMT " of %s does not contain correct number of columns (%d instead of %d)", i, path, ndims, dims[1]);
140
141 node_locs[i] = (PetscReal)atof(array[0]);
142 PetscCall(PetscSynchronizedFGets(comm, fp, char_array_len, line));
143 PetscCall(PetscStrToArray(line, ' ', &ndims, &array));
144 PetscCheck(ndims == dims[1], comm, PETSC_ERR_FILE_UNEXPECTED,
145 "Line %" PetscInt_FMT " of %s does not contain correct number of columns (%d instead of %d)", i, path, ndims, dims[1]);
146
147 node_locs[i] = (PetscReal)atof(array[0]);
148 PetscCall(PetscStrToArrayDestroy(ndims, array));
142 }
143 PetscCall(PetscFClose(comm, fp));
144 *pynodes = node_locs;
145 PetscFunctionReturn(PETSC_SUCCESS);
146}
147
148/* \brief Modify the domain and mesh for blasius
149 *

--- 217 unchanged lines hidden ---
149 }
150 PetscCall(PetscFClose(comm, fp));
151 *pynodes = node_locs;
152 PetscFunctionReturn(PETSC_SUCCESS);
153}
154
155/* \brief Modify the domain and mesh for blasius
156 *

--- 217 unchanged lines hidden ---