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]);
135int main(
int argc,
char *argv[])
139 "Smooth a surface using lambda/mu smoothing.\n"
140 "For laplacian smoothing, set lambda to the relaxation factor"
144 argList::noParallel();
145 argList::validOptions.clear();
146 argList::addArgument(
"input",
"The input surface file");
147 argList::addArgument(
"lambda",
"On the interval [0,1]");
148 argList::addArgument(
"mu",
"On the interval [0,1]");
149 argList::addArgument(
"iterations",
"The number of iterations to perform");
150 argList::addArgument(
"output",
"The output surface file");
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);
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
Extract command arguments and options from the supplied argc and argv parameters.
T get(const label index) const
Get a value from the argument at index.
bool found(const word &optName) const
Return true if the named option is found.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
A bounding box defined in terms of min/max extrema points.
Mesh data needed to do the Finite Area discretisation.
const pointField & points() const noexcept
Return points.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling file names.
A class for managing temporary objects.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const volScalarField & mu
#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))
Determine correspondence between points. See below.
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
loopControl iters(runTime, aMesh.solutionDict(), "solution")
Foam::argList args(argc, argv)
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define forAll(list, i)
Loop across all elements in list.