60 const bitSet& fixedPoints
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]);
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"
155 "Fix points from a file containing feature points and edges"
161 const auto mu =
args.get<scalar>(3);
169 <<
"0: no change 1: move vertices to average of neighbours"
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);
193 if (
args.found(
"featureFile"))
195 const auto featureFileName =
args.get<
fileName>(
"featureFile");
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);
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.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void noParallel()
Remove the parallel options.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static HashTable< string > validOptions
A list of valid options.
static void addNote(const string ¬e)
Add extra notes for the usage information.
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 for True 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 vertex labels. This can correspond to a directed graph edge or an edge on a ...
A class for handling file names.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#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.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
static constexpr const zero Zero
Global zero (0).
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.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
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.