46 bool 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());
105 void Foam::abaqusMeshSet::calcSamples
107 DynamicList<point>& samplingPts,
108 DynamicList<label>& samplingCells,
109 DynamicList<label>& samplingFaces,
110 DynamicList<label>& samplingSegments,
111 DynamicList<scalar>& samplingCurveDist
115 <<
"abaqusMeshSet : sampling " << sampleCoords_.size() <<
" points" 118 List<bool>
found(sampleCoords_.size(),
false);
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);
139 DynamicList<label> lost;
142 if (!
found[samplei]) lost.append(samplei);
145 const label nFound = sampleCoords_.size() - lost.size();
146 label nOutOfBounds = 0;
150 typedef Tuple2<label, Tuple2<label, scalar>> procCellDist;
151 List<procCellDist> pcd(lost.size(), procCellDist(-1, {-1, GREAT}));
154 const label samplei = lost[i];
155 const vector& pt0 = sampleCoords_[samplei];
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];
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" 258 void Foam::abaqusMeshSet::genSamples()
261 DynamicList<point> samplingPts;
262 DynamicList<label> samplingCells;
263 DynamicList<label> samplingFaces;
264 DynamicList<label> samplingSegments;
265 DynamicList<scalar> samplingCurveDist;
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,
305 const dictionary&
dict 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))
339 <<
"Number of sample points: " << sampleCoords_.
size() <<
nl 340 <<
"Sample points bounds: " << boundBox(sampleCoords_) <<
endl;
Foam::SubStrings< StringType > split(const StringType &str, const char delim, std::string::size_type pos=0, const bool keepEmpty=false)
Split string into sub-strings at the delimiter character.
void size(const label n)
Older name for setAddressableSize.
Input/output streams with (internal or external) character storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label findNearestCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find nearest cell in terms of cell centre.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Macros for easy insertion into run-time selection tables.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
#define forAll(list, i)
Loop across all elements in list.
dimensionedScalar pos(const dimensionedScalar &ds)
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
void inplaceTrimRight(std::string &s)
Trim trailing whitespace inplace.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
label findCell(const point &location, const label seedCelli=-1, const bool useTreeSearch=true) const
Find cell containing location.
#define DebugInFunction
Report an information message using Foam::Info.
abaqusMeshSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Construct from dictionary.
static void listCombineAllGather(List< T > &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Same as Pstream::listCombineReduce.
const vectorField & cellCentres() const
errorManip< error > abort(error &err)
#define DebugInfo
Report an information message using Foam::Info.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
const dimensionedScalar c
Speed of light in a vacuum.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
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))
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...