52#define XMESH_TAG "xmesh"
53#define YMESH_TAG "ymesh"
54#define ZMESH_TAG "zmesh"
83 pdrMeshSpecLine() : knot(0),
ndiv(0), factor(0) {}
94Istream&
operator>>(Istream& is, pdrMeshSpecLine& spec)
108 spec.ndiv = tok.labelToken();
120 is.readEnd(
"pdrMeshSpecLine");
128Ostream&
operator<<(Ostream&
os,
const pdrMeshSpecLine& spec)
130 os << token::BEGIN_LIST << spec.knot;
134 os << token::SPACE << spec.ndiv
135 << token::SPACE << spec.factor;
138 os << token::END_LIST;
145void read_spec(ISstream& is,
const direction cmpt, List<scalar>& gridPoint)
147 if (!gridPoint.empty())
150 <<
"Duplicate specification of "
151 << vector::componentNames[cmpt]
156 List<pdrMeshSpecLine> specs(is);
158 if (specs.size() < 2)
161 <<
"Grid specification for " << vector::componentNames[cmpt]
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 "
195 << vector::componentNames[cmpt] <<
nl
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;
304 stringOps::inplaceTrim(line);
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());
322 if (grid[cmpt].empty())
325 <<
"No specification for "
332 block.reset(grid.x(), grid.y(), grid.z());
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
static const char *const componentNames[]
static constexpr direction nComponents
Number of components in bool is 1.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
void read_mesh_spec(const fileName &casepath, PDRblock &pdrBlock)
void print_info(const PDRblock &block)
Ostream & operator<<(Ostream &os, const interfaceEntry &entry)
tmp< GeometricField< Type, faPatchField, areaMesh > > ndiv(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
bool operator!=(const eddy &a, const eddy &b)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Istream & operator>>(Istream &, directionInfo &)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)