41 namespace functionObjects
68 const scalar kappaNorm
83 Log <<
"Computing wave numbers" <<
endl;
88 kappa[kappai] = kappai*kappaNorm;
91 Log <<
"Computing energy spectrum" <<
endl;
97 label i = round((Cc.x() - 0.5*deltaC.x())/(deltaC.x())*(
N.
x() - 1));
98 label j = round((Cc.y() - 0.5*deltaC.y())/(deltaC.y())*(
N.
y() - 1));
99 label
k = round((Cc.z() - 0.5*deltaC.z())/(deltaC.z())*(
N.
z() - 1));
100 label kappai = round(
Foam::sqrt(scalar(i*i + j*j +
k*
k)));
102 E[kappai] += Ec[celli];
107 Log <<
"Writing spectrum" <<
endl;
108 autoPtr<OFstream> osPtr = newFileAtTime(
name(), time_.value());
109 OFstream&
os = osPtr.ref();
129 writeFile(mesh_,
name),
130 cellAddr_(mesh_.nCells()),
148 dict.readIfPresent(
"U", UName_);
166 vector cellDx(cellBb.span());
167 vector expectedMax(N_.x()*cellDx.x(), N_.y()*cellDx.y(), N_.z()*cellDx.z());
171 if (
mag(relativeSize[i] - 1) > 1
e-3)
174 <<
name() <<
" function object is only appropriate for " 175 <<
"isotropic structured IJK meshes. Mesh extents: " <<
L 176 <<
", computed IJK mesh extents: " << expectedMax
180 Log <<
"Mesh extents (deltax,deltay,deltaz): " <<
L <<
endl;
181 Log <<
"Number of cells (Nx,Ny,Nz): " << N_ <<
endl;
191 label i = round((
C[celli].
x() - c0_.x())/(deltaC_.x())*(N_.x() - 1));
192 label j = round((
C[celli].
y() - c0_.y())/(deltaC_.y())*(N_.y() - 1));
193 label
k = round((
C[celli].z() - c0_.z())/(deltaC_.z())*(N_.z() - 1));
195 cellAddr_[celli] =
k + j*N_.y() + i*N_.y()*N_.z();
222 toMaster << Uc <<
C << cellAddr_;
225 pBufs.finishedGathers();
239 fromProc >> Up >>
Cp >> cellAddrp;
244 calcAndWriteSpectrum(Uijk, Cijk, c0_, deltaC_, N_, kappaNorm_);
253 calcAndWriteSpectrum(Uijk, Cijk, c0_, deltaC_, N_, kappaNorm_);
virtual bool read(const dictionary &)
Read the field min/max data.
Graphite solid properties.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
defineTypeNameAndDebug(ObukhovLength, 0)
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
virtual void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const vector L(dict.get< vector >("L"))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
virtual bool execute()
Execute, currently does nothing.
constexpr char tab
The tab '\t' character(0x09)
A bounding box defined in terms of min/max extrema points.
const Cmpt & y() const noexcept
Access to the vector y component.
label k
Boltzmann constant.
Abstract base-class for Time/database function objects.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
void calcAndWriteSpectrum(const vectorField &U, const vectorField &C, const vector &c0, const vector &deltaC, const Vector< int > &N, const scalar kappaNorm)
Calculate and write the spectrum.
bool read(const char *buf, int32_t &val)
Same as readInt32.
#define forAll(list, i)
Loop across all elements in list.
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer...
virtual void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
const dimensionedScalar e
Elementary charge.
virtual bool write()
Write the energySpectrum.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr scalar twoPi(2 *M_PI)
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
Calculates the energy spectrum for a structured IJK mesh.
autoPtr< surfaceVectorField > Uf
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const Cmpt & x() const noexcept
Access to the vector x component.
const volScalarField & Cp
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
static tmp< complexField > forwardTransform(const tmp< complexField > &field, const UList< int > &nn)
virtual bool read(const dictionary &dict)
Read.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual void writeFileHeader(Ostream &os)
Output file header information.
const Vector< label > N(dict.get< Vector< label >>("N"))
const Cmpt & z() const noexcept
Access to the vector z component.
vector point
Point is a vector.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
static bool master(const label communicator=worldComm)
Am I the master rank.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
virtual bool read(const dictionary &dict)
Read optional controls.
Field< vector > vectorField
Specialisation of Field<T> for vector.
complexField ReComplexField(const UList< scalar > &re)
Create complex field from a list of real (using imag == 0)
energySpectrum(const energySpectrum &)=delete
No copy construct.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
static constexpr const zero Zero
Global zero (0)