Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Backofen, Rainer
amdis
Commits
cf83fce1
Commit
cf83fce1
authored
Aug 07, 2012
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converting routines for phasefields and signed distance functions
parent
49bb4f10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
41 deletions
+90
-41
extensions/PhaseFieldConvert.h
extensions/PhaseFieldConvert.h
+90
-41
No files found.
extensions/PhaseFieldConvert.h
View file @
cf83fce1
...
...
@@ -5,6 +5,10 @@
using
namespace
AMDiS
;
/// \brief
/// Converts an AbstractFunction <i>dist</i>, that describes a signed distance function, to
/// a phasefield function <i>p</i>, by \f$ \frac{1}{2}(1 - tanh(s \cdot dist(x) / \epsilon))\f$
///
struct
SignedDistFctToPhaseField
:
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
SignedDistFctToPhaseField
(
double
epsilon_
,
...
...
@@ -27,6 +31,67 @@ private:
double
scalingFactor
;
};
/// \brief
/// Converts a DOFVector, that describes a signed distance function, to
/// a phasefield function <i>p</i>, by \f$ \frac{1}{2}(1 - tanh(s \cdot dist / \epsilon))\f$.
/// You have to use <i>transformDOF</i> to apply this function to the DOFVector <i>dist</i>.
///
struct
SignedDistToPhaseField
:
AbstractFunction
<
double
,
double
>
{
SignedDistToPhaseField
(
double
epsilon_
=
-
1.0
,
double
scalingFactor_
=
1.0
/
sqrt
(
2.0
))
:
AbstractFunction
<
double
,
double
>
(
6
),
epsilon
(
epsilon_
),
scalingFactor
(
scalingFactor_
)
{
if
(
epsilon
<
0.0
)
Parameters
::
get
(
"mesh->refinement->epsilon"
,
epsilon
);
}
double
operator
()(
const
double
&
dist
)
const
{
return
0.5
*
(
1.0
-
tanh
(
scalingFactor
*
dist
/
epsilon
));
}
private:
double
epsilon
;
double
scalingFactor
;
};
/// \brief
/// Converts a DOFVector, that describes a signed distance function, to
/// a phasefield function <i>p</i> with values in [-1,1], by \f$ - tanh(s \cdot dist / \epsilon)\f$.
/// You have to use <i>transformDOF</i> to apply this function to the DOFVector <i>dist</i>.
///
struct
SignedDistToCh
:
AbstractFunction
<
double
,
double
>
{
SignedDistToCh
(
double
epsilon_
=
-
1.0
,
double
scalingFactor_
=
1.0
/
sqrt
(
2.0
))
:
AbstractFunction
<
double
,
double
>
(
6
),
epsilon
(
epsilon_
),
scalingFactor
(
scalingFactor_
)
{
if
(
epsilon
<
0.0
)
Parameters
::
get
(
"mesh->refinement->epsilon"
,
epsilon
);
}
double
operator
()(
const
double
&
dist
)
const
{
return
-
tanh
(
scalingFactor
*
dist
/
epsilon
);
}
private:
double
epsilon
;
double
scalingFactor
;
};
/// \brief
/// Converts a vector of AbstractFunctions <i>{dist_i}</i>, that describe signed distance functions, to
/// a phasefield function <i>p</i>, by \f$ \frac{1}{2}(1 - tanh(s \cdot \min_i(dist_i(x)) / \epsilon))\f$.
/// The minimum of all distance function describes the union of the areas of negative values, of the
/// distance functions.
///
struct
SignedDistFctListToPhaseField
:
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
SignedDistFctListToPhaseField
(
double
epsilon_
,
...
...
@@ -54,6 +119,10 @@ private:
};
/// \brief
/// Calculates the maximum of vector of distance function. This describes the intersections of the areas
/// of negative values, of the distance functions.
///
struct
SignedDistList
:
AbstractFunction
<
double
,
WorldVector
<
double
>
>
{
SignedDistList
(
std
::
vector
<
AbstractFunction
<
double
,
WorldVector
<
double
>
>*>
dist_
)
...
...
@@ -89,6 +158,14 @@ private:
std
::
vector
<
AbstractFunction
<
double
,
WorldVector
<
double
>
>*>
dist
;
};
/// \brief
/// Converts a DOFVector, that describes a phasefield function <i>phi</i>, to
/// a signed distance function <i>dist</i>, by \f$ atanh(-\phi)\cdot\epsilon/s \f$.
/// You have to use <i>transformDOF</i> to apply this function to the DOFVector <i>phi</i>.
/// the phasefield values are cutted to allow the atanh calculation, by
/// \f$ \phi:=\max(-1 + 10^{-10}, min(1-10^{-10}, \phi) ) \f$
///
struct
PhaseFieldToSignedDist
:
AbstractFunction
<
double
,
double
>
{
PhaseFieldToSignedDist
(
double
epsilon_
=
-
1.0
,
double
scalingFactor_
=
1.0
/
sqrt
(
2.0
))
...
...
@@ -111,48 +188,13 @@ private:
double
scalingFactor
;
};
struct
SignedDistToPhaseField
:
AbstractFunction
<
double
,
double
>
{
SignedDistToPhaseField
(
double
epsilon_
=
-
1.0
,
double
scalingFactor_
=
1.0
/
sqrt
(
2.0
))
:
AbstractFunction
<
double
,
double
>
(
6
),
epsilon
(
epsilon_
),
scalingFactor
(
scalingFactor_
)
{
if
(
epsilon
<
0.0
)
Parameters
::
get
(
"mesh->refinement->epsilon"
,
epsilon
);
}
double
operator
()(
const
double
&
dist
)
const
{
return
0.5
*
(
1.0
-
tanh
(
scalingFactor
*
dist
/
epsilon
));
}
private:
double
epsilon
;
double
scalingFactor
;
};
struct
SignedDistToCh
:
AbstractFunction
<
double
,
double
>
{
SignedDistToCh
(
double
epsilon_
=
-
1.0
,
double
scalingFactor_
=
1.0
/
sqrt
(
2.0
))
:
AbstractFunction
<
double
,
double
>
(
6
),
epsilon
(
epsilon_
),
scalingFactor
(
scalingFactor_
)
{
if
(
epsilon
<
0.0
)
Parameters
::
get
(
"mesh->refinement->epsilon"
,
epsilon
);
}
double
operator
()(
const
double
&
dist
)
const
{
return
-
tanh
(
scalingFactor
*
dist
/
epsilon
);
}
private:
double
epsilon
;
double
scalingFactor
;
};
/// \brief
/// Converts a DOFVector, that describes a phasefield function <i>c</i> with
/// values in [-1, 1], to a phasefield function with values in [0,1], by
/// \f$ \frac{1}{2}(c + 1) \f$.
/// You have to use <i>transformDOF</i> to apply this function to the DOFVector <i>phi</i>.
///
struct
ChToPhaseField
:
AbstractFunction
<
double
,
double
>
{
ChToPhaseField
()
:
AbstractFunction
<
double
,
double
>
(
1
)
{};
...
...
@@ -162,6 +204,13 @@ struct ChToPhaseField : AbstractFunction<double, double>
}
};
/// \brief
/// Converts a DOFVector, that describes a phasefield function <i>phi</i> with
/// values in [0, 1], to a phasefield function with values in [-1,1], by
/// \f$ 2\cdot\phi-1 \f$.
/// You have to use <i>transformDOF</i> to apply this function to the DOFVector <i>phi</i>.
///
struct
PhaseFieldToCh
:
AbstractFunction
<
double
,
double
>
{
PhaseFieldToCh
()
:
AbstractFunction
<
double
,
double
>
(
1
)
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment