52 #define XMESH_TAG "xmesh"
53 #define YMESH_TAG "ymesh"
54 #define ZMESH_TAG "zmesh"
77 struct pdrMeshSpecLine
83 pdrMeshSpecLine() : knot(0),
ndiv(0), factor(0) {}
94 Istream&
operator>>(Istream& is, pdrMeshSpecLine& spec)
100 is.readBegin(
"pdrMeshSpecLine");
108 spec.ndiv = tok.labelToken();
120 is.readEnd(
"pdrMeshSpecLine");
128 Ostream&
operator<<(Ostream&
os,
const pdrMeshSpecLine& spec)
145 void read_spec(ISstream& is,
const direction cmpt, List<scalar>& gridPoint)
147 if (!gridPoint.empty())
150 <<
"Duplicate specification of "
156 List<pdrMeshSpecLine> specs(is);
158 if (specs.size() < 2)
162 <<
" is too small. Need at least two points!" <<
nl
166 specs.last().ndiv = 0;
169 DynamicList<scalar> knots;
170 DynamicList<label> divisions;
171 DynamicList<scalar> factors;
173 for (
const auto& spec : specs)
175 knots.append(spec.knot);
181 divisions.append(spec.ndiv);
182 factors.append(spec.factor);
186 for (
const label nDiv : divisions)
194 <<
"No cells defined for direction "
203 const label nSegments = divisions.size();
207 for (label segmenti=0; segmenti < nSegments; ++segmenti)
209 const label nDiv = divisions[segmenti];
210 const scalar factor = factors[segmenti];
212 SubList<scalar> subPoint(gridPoint, nDiv+1, start);
215 subPoint[0] = knots[segmenti];
216 subPoint[nDiv] = knots[segmenti+1];
218 const scalar dist = (subPoint.last() - subPoint.first());
220 if (
equal(factor, scalar(1)))
222 for (label i=1; i < nDiv; ++i)
224 subPoint[i] = (subPoint[0] + (dist * i)/nDiv);
229 scalar
delta = dist * (1.0 - factor) / (1.0 - ::
pow(factor, nDiv));
231 scalar xyz = subPoint[0];
233 for (label i=0; i < nDiv; ++i)
254 <<
" nCells: " << block.sizes() <<
nl
255 <<
" Box: " << block.bounds() <<
nl
265 Info<<
"Reading pdrMeshSpec (legacy format)" <<
nl;
267 bool processed =
false;
269 for (
const fileName dirName : {
"system",
"constant/polyMesh" })
273 casepath / dirName /
"pdrMeshSpec"
289 <<
"Did not process pdrMeshSpec" <<
nl
297 Vector<scalarList> grid;
306 if (line == XMESH_TAG)
308 Detail::read_spec(is, vector::X, grid.x());
310 else if (line == YMESH_TAG)
312 Detail::read_spec(is,
vector::Y, grid.y());
314 else if (line == ZMESH_TAG)
316 Detail::read_spec(is, vector::Z, grid.z());
320 for (
direction cmpt=0; cmpt < vector::nComponents; ++cmpt)
322 if (grid[cmpt].empty())
325 <<
"No specification for "
326 << vector::componentNames[cmpt]
332 block.reset(grid.x(), grid.y(), grid.z());