Go to the documentation of this file.
54 scalar Amin(VGREAT), LsqMax(0.0);
64 (p1.
x() - p0.
x()) * (p2.
y() - p0.
y()) -
65 (p2.
x() - p0.
x()) * (p1.
y() - p0.
y())
69 Info <<
"Triangle " << triI <<
" area " << Atri <<
endl;
89 if( Amin < SMALL * LsqMax )
110 (p1.
x() - p0.
x()) * (p2.
y() - p0.
y()) -
111 (p2.
x() - p0.
x()) * (p1.
y() - p0.
y())
114 const scalar stab =
sqrt(
sqr(Atri) +
K);
117 Info <<
"Triangle " << triI <<
" area " << Atri <<
endl;
126 const scalar Astab =
Foam::max(VSMALL, 0.5 * (Atri + stab));
127 func += LSqrTri / Astab;
145 gradGradLt.
xx() = 4.0;
146 gradGradLt.
yy() = 4.0;
150 const point& p0 = pts_[trias_[triI][0]];
151 const point& p1 = pts_[trias_[triI][1]];
152 const point& p2 = pts_[trias_[triI][2]];
154 if(
magSqr(p1 - p2) < VSMALL )
continue;
165 (p1.
x() - p0.
x()) * (p2.
y() - p0.
y()) -
166 (p2.
x() - p0.
x()) * (p1.
y() - p0.
y())
169 const scalar stab =
sqrt(
sqr(Atri) +
K);
171 const scalar Astab =
Foam::max(ROOTVSMALL, 0.5 * (Atri + stab));
175 0.5 * (p1.
y() - p2.
y()),
176 0.5 * (p2.
x() - p1.
x()),
180 const vector gradAstab = 0.5 * (gradAtri + Atri * gradAtri / stab);
182 const tensor gradGradAstab =
185 (gradAtri * gradAtri) / stab -
186 sqr(Atri) * (gradAtri * gradAtri) /
pow(stab, 3)
189 const vector gradLt(4.0 * p0 - 2.0 * p1 - 2.0 * p2);
192 const scalar sqrAstab =
sqr(Astab);
193 gradF += gradLt / Astab - (LSqrTri * gradAstab) / sqrAstab;
198 twoSymm(gradLt * gradAstab) / sqrAstab -
199 gradGradAstab * LSqrTri / sqrAstab +
200 2.0 * LSqrTri * (gradAstab * gradAstab) / (sqrAstab * Astab);
204 if(
mag(gradGradF.
xx()) < VSMALL ) gradGradF.
xx() = VSMALL;
205 if(
mag(gradGradF.
yy()) < VSMALL ) gradGradF.
yy() = VSMALL;
213 point currCentre = pOpt;
225 funcBefore = funcAfter;
230 for(
label i=0;i<4;++i)
232 pOpt.
x() = currCentre.
x() + 0.5 *
dirVecs[i].
x() * dx;
233 pOpt.
y() = currCentre.
y() + 0.5 *
dirVecs[i].
y() * dy;
238 if(
func < funcAfter )
247 currCentre = minCentre;
255 const scalar t =
mag(funcAfter - funcBefore) / funcAfter;
258 Info <<
"Point position " << pOpt <<
endl;
259 Info <<
"Func before " << funcBefore <<
endl;
260 Info <<
"Func after " << funcAfter <<
endl;
261 Info <<
"Normalised difference " << t <<
endl;
266 }
while( ++iter < 100 );
291 funcBefore = funcAfter;
297 mat[0][0] = gradGradF.
xx();
298 mat[0][1] = gradGradF.
xy();
299 mat[1][0] = gradGradF.
yx();
300 mat[1][1] = gradGradF.
yy();
302 source[0] = gradF.
x();
303 source[1] = gradF.
y();
317 if(
mag(disp) > 0.2 * avgEdge )
321 disp = dir * 0.2 * avgEdge;
326 Info <<
"Second gradient " << gradGradF <<
endl;
327 Info <<
"Gradient " << gradF <<
endl;
328 Info <<
"Displacement " << disp <<
endl;
337 if(
mag(funcAfter - funcBefore) / funcBefore < tol )
341 Info <<
"New coordinates " << pOpt <<
endl;
344 }
while( ++nIterations < 100 );
362 pMin_ = pts_[trias_[0][1]];
369 for(
label i=1;i<3;++i)
393 const point newPoint = pOpt;
397 if( funcSteepest > funcDivide )
DynList< point > & pts_
reference to the simplex points
scalar determinant()
return matrix determinant
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
point optimizePoint(const scalar tol=0.1)
optimizes position of a central point in the simplex
#define forAll(list, i)
Loop across all elements in list.
scalar solveSecond(const FixedList< scalar, 2 > &source)
return the second component of the solution vector
scalar evaluateFunc(const scalar &K) const
evaluate the functional
Template functions to aid in the implementation of demand driven data.
scalar solveFirst(const FixedList< scalar, 2 > &source)
return the first component of the solution vector
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
CGAL::Exact_predicates_exact_constructions_kernel K
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static const vector dirVecs[4]
direction vectors for divide and conquer algorithm
void func(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
point pMin_
min position of the bnd box
scalar evaluateStabilisationFactor() const
evaluate stabilisation factor
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const DynList< triFace > & trias_
reference to the triangles forming a simplex
A triangular face using a FixedList of labels corresponding to mesh vertices.
dimensionedScalar sqrt(const dimensionedScalar &ds)
A 1D vector of objects of type <T> with a fixed size <Size>.
scalar optimiseSteepestDescent(const scalar tol)
optimise point position via the steepest descent method
point pMax_
max position of the bnd box
dimensionedScalar det(const dimensionedSphericalTensor &dt)
surfaceOptimizer(const surfaceOptimizer &)
Disallow default bitwise copy construct.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void evaluateGradients(const scalar &, vector &, tensor &) const
evaluate gradients needed for optimisation
scalar optimiseDivideAndConquer(const scalar tol)
optimise point position using the divide and conquer technique