66 auto& avg = tavg.
ref();
70 vector& avgPos = avg[vertI];
72 if (fixedPoints.
test(vertI))
74 avgPos =
s.localPoints()[vertI];
78 const labelList& pEdges = pointEdges[vertI];
82 const edge&
e =
s.edges()[pEdges[myEdgeI]];
84 label otherVertI =
e.otherVertex(vertI);
86 avgPos +=
s.localPoints()[otherVertI];
89 avgPos /= pEdges.
size();
119 <<
"Did not match all feature points to points on the surface" 125 if (from0To1[fpI] != -1)
127 fixedPoints.
set(from0To1[fpI]);
135 int main(
int argc,
char *argv[])
139 "Smooth a surface using lambda/mu smoothing.\n" 140 "For laplacian smoothing, set lambda to the relaxation factor" 155 "Fix points from a file containing feature points and edges" 165 if (lambda < 0 || lambda > 1)
169 <<
"0: no change 1: move vertices to average of neighbours" 172 if (mu < 0 || mu > 1)
176 <<
"0: no change 1: move vertices to average of neighbours" 181 <<
"mu : " <<
mu <<
nl 183 <<
"Reading surface from " << surfFileName <<
" ..." <<
endl;
187 Info<<
"Faces : " << surf1.size() <<
nl 188 <<
"Vertices : " << surf1.nPoints() <<
nl 189 <<
"Bounding Box: " <<
boundBox(surf1.localPoints()) <<
endl;
191 bitSet fixedPoints(surf1.localPoints().size(),
false);
196 Info<<
"Reading features from " << featureFileName <<
" ..." <<
endl;
200 getFixedPoints(feMesh, surf1.localPoints(), fixedPoints);
202 Info<<
"Number of fixed points on surface = " << fixedPoints.
count()
206 for (label iter = 0; iter <
iters; iter++)
212 (1 -
lambda)*surf1.localPoints()
213 +
lambda*avg(surf1, fixedPoints)
220 surf1.movePoints(newPoints);
228 (1 +
mu)*surf1.localPoints()
229 -
mu*avg(surf1, fixedPoints)
236 surf1.movePoints(newPoints);
240 Info<<
"Writing surface to " << outFileName <<
" ..." <<
endl;
241 surf1.
write(outFileName);
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
unsigned int count(const bool on=true) const
Count number of bits set.
void set(const bitSet &bitset)
Set specified bits from another bitset.
A class for handling file names.
const pointField & points() const noexcept
Return points.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void noParallel()
Remove the parallel options.
A bounding box defined in terms of min/max extrema points.
Determine correspondence between points. See below.
#define forAll(list, i)
Loop across all elements in list.
bool matchPoints(const UList< point > &pts0, const UList< point > &pts1, const UList< scalar > &matchDistance, const bool verbose, labelList &from0To1, const point &origin=point::zero)
Determine correspondence between pointFields. Gets passed.
const dimensionedScalar e
Elementary charge.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
Extract command arguments and options from the supplied argc and argv parameters. ...
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Mesh data needed to do the Finite Area discretisation.
const dimensionedScalar mu
Atomic mass unit.
T get(const label index) const
Get a value from the argument at index.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
loopControl iters(runTime, aMesh.solutionDict(), "solution")
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A class for managing temporary objects.
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))
Foam::argList args(argc, argv)
static HashTable< string > validOptions
A list of valid options.
bool found(const word &optName) const
Return true if the named option is found.
static constexpr const zero Zero
Global zero (0)