46bool Foam::abaqusMeshSet::readCoord(ISstream& is,
vector& coord)
const
56 const auto elems = buffer.find(
"*ELEMENT");
58 if (elems != std::string::npos)
65 const auto pos = buffer.find(
'*');
66 if (
pos != std::string::npos)
72 while (buffer.empty() && is.good());
81 if (strings.size() != 4)
84 <<
"Read error: expected format int, float, float, float"
85 <<
" but read buffer " << buffer
89 for (
int i = 0; i <= 2; ++i)
92 const auto&
s = strings[i+1].str();
93 ISpanStream buf(
s.data(),
s.length());
105void Foam::abaqusMeshSet::calcSamples
115 <<
"abaqusMeshSet : sampling " << sampleCoords_.size() <<
" points"
120 forAll(sampleCoords_, samplei)
122 const vector& pt = sampleCoords_[samplei];
124 label celli = searchEngine().findCell(pt);
127 found[samplei] =
true;
129 samplingPts.append(pt);
130 samplingCells.append(celli);
131 samplingFaces.append(-1);
132 samplingSegments.append(0);
133 samplingCurveDist.append(1.0*samplei);
145 const label nFound = sampleCoords_.size() - lost.size();
146 label nOutOfBounds = 0;
154 const label samplei = lost[i];
155 const vector& pt0 = sampleCoords_[samplei];
156 const label celli = searchEngine().findNearestCell(pt0);
158 const scalar distSqr =
magSqr(pt1 - pt0);
165 [](procCellDist&
x,
const procCellDist&
y)
168 if (
y.second().second() <
x.second().second())
177 const label samplei = lost[i];
179 if (pcd[i].second().second() < maxDistSqr_)
183 const label celli = pcd[i].second().first();
187 samplingCells.append(celli);
188 samplingFaces.append(-1);
189 samplingSegments.append(0);
190 samplingCurveDist.append(1.0*samplei);
198 samplingPts.append(sampleCoords_[samplei]);
199 samplingCells.append(-1);
200 samplingFaces.append(-1);
201 samplingSegments.append(0);
202 samplingCurveDist.append(1.0*samplei);
214 const label samplei = lost[i];
215 const vector& pt0 = sampleCoords_[samplei];
216 const label celli = searchEngine().findNearestCell(pt0);
218 const scalar distSqr =
magSqr(pt1 - pt0);
220 if (distSqr < maxDistSqr_)
222 samplingPts.append(pt1);
223 samplingCells.append(celli);
224 samplingFaces.append(-1);
225 samplingSegments.append(0);
226 samplingCurveDist.append(1.0*samplei);
231 samplingPts.append(sampleCoords_[samplei]);
232 samplingCells.append(-1);
233 samplingFaces.append(-1);
234 samplingSegments.append(0);
235 samplingCurveDist.append(1.0*samplei);
242 <<
"Sample size : " << sampleCoords_.size() <<
nl
243 <<
"Lost samples : " << nOutOfBounds <<
nl
244 <<
"Recovered samples : "
245 << (sampleCoords_.size() - nOutOfBounds - nFound) <<
nl
252 <<
"Identified " << nOutOfBounds <<
" out-of-bounds points"
258void Foam::abaqusMeshSet::genSamples()
276 samplingPts.shrink();
277 samplingCells.shrink();
278 samplingFaces.shrink();
279 samplingSegments.shrink();
280 samplingCurveDist.shrink();
284 std::move(samplingPts),
285 std::move(samplingCells),
286 std::move(samplingFaces),
287 std::move(samplingSegments),
288 std::move(samplingCurveDist)
303 const polyMesh&
mesh,
304 const meshSearch& searchEngine,
309 scale_(
dict.getOrDefault<scalar>(
"scale", 1)),
311 maxDistSqr_(
sqr(
dict.getOrDefault<scalar>(
"maxDist", 0)))
315 const fileName inputFile(
dict.get<fileName>(
"file").expand());
316 IFstream pointsFile(inputFile);
318 if (!pointsFile.good())
321 <<
"Unable to find file " << pointsFile.name()
326 DynamicList<point> coords;
328 while (readCoord(pointsFile, c))
333 sampleCoords_.transfer(coords);
339 <<
"Number of sample points: " << sampleCoords_.size() <<
nl
340 <<
"Sample points bounds: " << boundBox(sampleCoords_) <<
endl;
Input/output streams with (internal or external) character storage.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
virtual const fileName & name() const override
Read/write access to the name of the stream.
bool good() const noexcept
True if next operation might succeed.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &val)
Append an element at the end of the list.
static void listCombineAllGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Same as Pstream::listCombineReduce.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
@ broadcast
broadcast [MPI]
Generates sample positions from points specified in a file as Abaqus mesh points.
abaqusMeshSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
A bounding box defined in terms of min/max extrema points.
const word & name() const noexcept
The coord-set name.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Mesh consisting of general polyhedral cells.
const vectorField & cellCentres() const
Holds list of sampling points which is filled at construction time. Various implementations of this b...
const meshSearch & searchEngine() const noexcept
sampledSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const coordSet::coordFormat axisType)
Construct from components.
const polyMesh & mesh() const noexcept
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for handling debugging switches.
Foam::SubStrings split(const std::string &str, const char delim, std::string::size_type pos=0, const bool keepEmpty=false)
Split string into sub-strings at the delimiter character.
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
dimensionedScalar pos(const dimensionedScalar &ds)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.