deal.II version GIT relicensing-2250-g88cb8ba3cb 2024-12-13 12:20:00+00:00
|
#include <deal.II/grid/manifold_lib.h>
Public Types | |
using | FaceVertexNormals = std::array< Tensor< 1, spacedim >, GeometryInfo< dim >::vertices_per_face > |
Static Public Member Functions | |
static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Private Types | |
using | map_value_type = decltype(counter_map)::value_type |
using | map_iterator = decltype(counter_map)::iterator |
Private Member Functions | |
void | check_no_subscribers () const noexcept |
Private Attributes | |
const FunctionParser< spacedim >::ConstMap | const_map |
ObserverPointer< const Function< chartdim >, FunctionManifold< dim, spacedim, chartdim > > | push_forward_function |
ObserverPointer< const Function< spacedim >, FunctionManifold< dim, spacedim, chartdim > > | pull_back_function |
const double | tolerance |
bool | owns_pointers |
const std::string | push_forward_expression |
const std::string | pull_back_expression |
const std::string | chart_vars |
const std::string | space_vars |
const double | finite_difference_step |
const FlatManifold< chartdim, chartdim > | sub_manifold |
std::atomic< unsigned int > | counter |
std::map< std::string, unsigned int > | counter_map |
std::vector< std::atomic< bool > * > | validity_pointers |
const std::type_info * | object_info |
Static Private Attributes | |
static std::mutex | mutex |
Manifold description derived from ChartManifold, based on explicit Function<spacedim> and Function<chartdim> objects describing the push_forward() and pull_back() functions.
You can use this Manifold object to describe any arbitrary shape domain, as long as you can express it in terms of an invertible map, for which you provide both the forward expression, and the inverse expression.
In debug mode, a check is performed to verify that the transformations are actually one the inverse of the other.
Definition at line 668 of file manifold_lib.h.
|
inherited |
Type keeping information about the normals at the vertices of a face of a cell. Thus, there are GeometryInfo<dim>::vertices_per_face
normal vectors, that define the tangent spaces of the boundary at the vertices. Note that the vectors stored in this object are not required to be normalized, nor to actually point outward, as one often will only want to check for orthogonality to define the tangent plane; if a function requires the normals to be normalized, then it must do so itself.
For obvious reasons, this type is not useful in 1d.
Definition at line 305 of file manifold.h.
|
privateinherited |
The data type used in counter_map.
Definition at line 238 of file enable_observer_pointer.h.
|
privateinherited |
The iterator type used in counter_map.
Definition at line 243 of file enable_observer_pointer.h.
FunctionManifold< dim, spacedim, chartdim >::FunctionManifold | ( | const Function< chartdim > & | push_forward_function, |
const Function< spacedim > & | pull_back_function, | ||
const Tensor< 1, chartdim > & | periodicity = Tensor<1, chartdim>() , |
||
const double | tolerance = 1e-10 |
||
) |
Explicit functions constructor. Takes a push_forward function of spacedim components, and a pull_back function of chartdim
components. See the documentation of the base class ChartManifold for the meaning of the optional periodicity
argument.
The tolerance argument is used in debug mode to actually check that the two functions are one the inverse of the other.
Note: the object constructed in this way stores pointers to the push_forward and pull_back functions. Therefore, one must guarantee that the function objects are destroyed only after the constructed manifold.
Definition at line 1337 of file manifold_lib.cc.
FunctionManifold< dim, spacedim, chartdim >::FunctionManifold | ( | std::unique_ptr< Function< chartdim > > | push_forward, |
std::unique_ptr< Function< spacedim > > | pull_back, | ||
const Tensor< 1, chartdim > & | periodicity = Tensor<1, chartdim>() , |
||
const double | tolerance = 1e-10 |
||
) |
Same as previous, except this constructor takes ownership of the Function objects passed as first and second argument, and is ultimately in charge of deleting the pointers when the FunctionManifold object is destroyed.
This constructor is useful because it allows creating function objects at the place of calling the constructor without having to name and later delete these objects. This allows the following idiom: FunctionManifold<dim> manifold(std::make_unique<MyPushForward>(...), std::make_unique<MyPullBack>(...));
Definition at line 1357 of file manifold_lib.cc.
FunctionManifold< dim, spacedim, chartdim >::FunctionManifold | ( | const std::string | push_forward_expression, |
const std::string | pull_back_expression, | ||
const Tensor< 1, chartdim > & | periodicity = Tensor<1, chartdim>() , |
||
const typename FunctionParser< spacedim >::ConstMap | const_map = typename FunctionParser<spacedim>::ConstMap() , |
||
const std::string | chart_vars = FunctionParser<chartdim>::default_variable_names() , |
||
const std::string | space_vars = FunctionParser<spacedim>::default_variable_names() , |
||
const double | tolerance = 1e-10 , |
||
const double | h = 1e-8 |
||
) |
Expressions constructor. Takes the expressions of the push_forward function of spacedim components, and of the pull_back function of chartdim
components. See the documentation of the base class ChartManifold for the meaning of the optional periodicity
argument.
The strings should be the readable by the default constructor of the FunctionParser classes. You can specify custom variable expressions with the last two optional arguments. If you don't, the default names are used, i.e., "x,y,z".
The tolerance argument is used in debug mode to actually check that the two functions are one the inverse of the other.
Definition at line 1377 of file manifold_lib.cc.
|
overridevirtual |
If needed, we delete the pointers we own.
Definition at line 1407 of file manifold_lib.cc.
|
overridevirtual |
Make a clone of this Manifold object.
Implements Manifold< dim, spacedim >.
Definition at line 1425 of file manifold_lib.cc.
|
overridevirtual |
Given a point in the chartdim
coordinate system, uses the push_forward_function to compute the push_forward of points in chartdim
space dimensions to spacedim
space dimensions.
Implements ChartManifold< dim, spacedim, chartdim >.
Definition at line 1465 of file manifold_lib.cc.
|
overridevirtual |
Given a point in the chartdim dimensional Euclidean space, this method returns the derivatives of the function \(F\) that maps from the sub_manifold coordinate system to the Euclidean coordinate system. In other words, it is a matrix of size \(\text{spacedim}\times\text{chartdim}\).
This function is used in the computations required by the get_tangent_vector() function. The default implementation calls the get_gradient() method of the FunctionManifold::push_forward_function() member class. If you construct this object using the constructor that takes two string expression, then the default implementation of this method uses a finite difference scheme to compute the gradients(see the
AutoDerivativeFunction() class for details), and you can specify the size of the spatial step size at construction time with the h
parameter.
Refer to the general documentation of this class for more information.
Reimplemented from ChartManifold< dim, spacedim, chartdim >.
Definition at line 1493 of file manifold_lib.cc.
|
overridevirtual |
Given a point in the spacedim coordinate system, uses the pull_back_function to compute the pull_back of points in spacedim
space dimensions to chartdim
space dimensions.
Implements ChartManifold< dim, spacedim, chartdim >.
Definition at line 1510 of file manifold_lib.cc.
|
overridevirtualinherited |
Refer to the general documentation of this class and the documentation of the base class for more information.
Reimplemented from Manifold< dim, spacedim >.
Definition at line 1013 of file manifold.cc.
|
overridevirtualinherited |
Refer to the general documentation of this class and the documentation of the base class for more information.
Reimplemented from Manifold< dim, spacedim >.
Reimplemented in CylindricalManifold< dim, spacedim >.
Definition at line 1027 of file manifold.cc.
|
overridevirtualinherited |
Compute a new set of points that interpolate between the given points surrounding_points
. weights
is a table with as many columns as surrounding_points.size()
. The number of rows in weights
must match the length of new_points
.
The implementation of this function first transforms the surrounding_points
to the chart space by calling pull_back(). Then, new points are computed on the chart by usual interpolation according to the given weights
, which are finally transformed to the image space by push_forward().
This implementation can be much more efficient for computing multiple new points from the same surrounding points than separate calls to get_new_point() in case the pull_back() operation is expensive. This is because pull_back() is only called once for the surrounding points and the interpolation is done for all given weights using this set of points. Often, pull_back() is also more expensive than push_forward() because the former might involve some kind of Newton iteration in non-trivial manifolds.
Reimplemented from Manifold< dim, spacedim >.
Definition at line 1048 of file manifold.cc.
|
overridevirtualinherited |
Return a vector that, at \(\mathbf x_1\), is tangential to the geodesic that connects two points \(\mathbf x_1,\mathbf x_2\). See the documentation of the Manifold class and of Manifold::get_tangent_vector() for a more detailed description.
For the current class, we assume that this geodesic is the image under the push_forward() operation of a straight line of the pre-images of x1
and x2
(where pre-images are computed by pulling back the locations x1
and x2
). In other words, if these preimages are \(\xi_1=F^{-1}(\mathbf x_1), \xi_2=F^{-1}(\mathbf x_2)\), then the geodesic in preimage (the chartdim-dimensional Euclidean) space is
\begin{align*} \zeta(t) &= \xi_1 + t (\xi_2-\xi_1) \\ &= F^{-1}(\mathbf x_1) + t\left[F^{-1}(\mathbf x_2) -F^{-1}(\mathbf x_1)\right] \end{align*}
In image space, i.e., in the space in which we operate, this leads to the curve
\begin{align*} \mathbf s(t) &= F(\zeta(t)) \\ &= F(\xi_1 + t (\xi_2-\xi_1)) \\ &= F\left(F^{-1}(\mathbf x_1) + t\left[F^{-1}(\mathbf x_2) -F^{-1}(\mathbf x_1)\right]\right). \end{align*}
What the current function is supposed to return is \(\mathbf s'(0)\). By the chain rule, this is equal to
\begin{align*} \mathbf s'(0) &= \frac{d}{dt}\left. F\left(F^{-1}(\mathbf x_1) + t\left[F^{-1}(\mathbf x_2) -F^{-1}(\mathbf x_1)\right]\right) \right|_{t=0} \\ &= \nabla_\xi F\left(F^{-1}(\mathbf x_1)\right) \left[F^{-1}(\mathbf x_2) -F^{-1}(\mathbf x_1)\right]. \end{align*}
This formula may then have to be slightly modified by considering any periodicity that was assumed in the call to the constructor.
Thus, the computation of tangent vectors also requires the implementation of derivatives \(\nabla_\xi F(\xi)\) of the push-forward mapping. Here, \(F^{-1}(\mathbf x_2)-F^{-1}(\mathbf x_1)\) is a chartdim-dimensional vector, and \(\nabla_\xi F\left(F^{-1}(\mathbf x_1)\right) = \nabla_\xi F\left(\xi_1\right)\) is a spacedim-times-chartdim-dimensional matrix. Consequently, and as desired, the operation results in a spacedim-dimensional vector.
x1 | The first point that describes the geodesic, and the one at which the "direction" is to be evaluated. |
x2 | The second point that describes the geodesic. |
Reimplemented from Manifold< dim, spacedim >.
Definition at line 1087 of file manifold.cc.
|
inherited |
Return the periodicity associated with the submanifold.
Definition at line 1119 of file manifold.cc.
|
virtualinherited |
Given a point which lies close to the given manifold, it modifies it and projects it to manifold itself.
This class is used by the default implementation of the function get_new_point() and should be implemented by derived classes. The default implementation simply throws an exception if called.
If your manifold is simple, you could implement this function only, and the default behavior should work out of the box.
Reimplemented in FlatManifold< dim, spacedim >, FlatManifold< chartdim, chartdim >, FlatManifold< dim, dim >, FlatManifold< dim, spacedim >, OpenCASCADE::NormalProjectionManifold< dim, spacedim >, OpenCASCADE::DirectionalProjectionManifold< dim, spacedim >, and OpenCASCADE::NormalToMeshProjectionManifold< dim, spacedim >.
|
virtualinherited |
Backward compatibility interface. Return the point which shall become the new middle vertex of the two children of a regular line. In 2d, this line is a line at the boundary, while in 3d, it is bounding a face at the boundary (the lines therefore is also on the boundary).
The default implementation of this function passes its argument to the Manifolds::get_default_points_and_weights() function, and then calls the Manifold<dim,spacedim>::get_new_point() function. User derived classes can overload Manifold<dim,spacedim>::get_new_point() or Manifold<dim,spacedim>::project_to_manifold(), which is called by the default implementation of Manifold<dim,spacedim>::get_new_point().
|
virtualinherited |
Backward compatibility interface. Return the point which shall become the common point of the four children of a quad at the boundary in three or more spatial dimensions. This function therefore is only useful in at least three dimensions and should not be called for lower dimensions.
This function is called after the four lines bounding the given quad
are refined, so you may want to use the information provided by quad->line(i)->child(j)
, i=0...3
, j=0,1
.
The default implementation of this function passes its argument to the Manifolds::get_default_points_and_weights() function, and then calls the Manifold<dim,spacedim>::get_new_point() function. User derived classes can overload Manifold<dim,spacedim>::get_new_point() or Manifold<dim,spacedim>::project_to_manifold(), which is called by the default implementation of Manifold<dim,spacedim>::get_new_point().
|
virtualinherited |
Backward compatibility interface. Return the point which shall become the common point of the eight children of a hex in three or spatial dimensions. This function therefore is only useful in at least three dimensions and should not be called for lower dimensions.
This function is called after the all the bounding objects of the given hex
are refined, so you may want to use the information provided by hex->quad(i)->line(j)->child(k)
, i=0...5
, j=0...3
, k=0,1
.
The default implementation of this function passes its argument to the Manifolds::get_default_points_and_weights() function, and then calls the Manifold<dim,spacedim>::get_new_point() function. User derived classes can overload Manifold<dim,spacedim>::get_new_point() or Manifold<dim,spacedim>::project_to_manifold(), which is called by the default implementation of Manifold<dim,spacedim>::get_new_point().
|
inherited |
Backward compatibility interface. Depending on dim=2
or dim=3
this function calls the get_new_point_on_line or the get_new_point_on_quad function. It throws an exception for dim=1
. This wrapper allows dimension independent programming.
|
inherited |
Backward compatibility interface. Depending on dim=1
, dim=2
or dim=3
this function calls the get_new_point_on_line, get_new_point_on_quad or the get_new_point_on_hex function. This wrapper allows dimension independent programming.
|
virtualinherited |
Return the normal vector to a face embedded in this manifold, at the point p. It is not required that the normals actually point outward from the domain even if the face iterator given points to a face on the boundary of the domain. If p is not in fact on the surface, but only close-by, try to return something reasonable, for example the normal vector at the surface point closest to p. (The point p will in fact not normally lie on the actual surface, but rather be a quadrature point mapped by some polynomial mapping; the mapped surface, however, will not usually coincide with the actual surface.)
This function only makes sense if dim==spacedim because otherwise there is no unique normal vector but in fact a (spacedim-dim+1)-dimensional tangent space of vectors that are all both normal to the face and normal to the dim-dimensional surface that lives in spacedim-dimensional space. For example, think of a two-dimensional mesh that covers a two-dimensional surface in three-dimensional space. In that case, each face (edge) is one-dimensional, and there are two linearly independent vectors that are both normal to the edge: one is normal to the edge and tangent to the surface (intuitively, that would be the one that points from the current cell to the neighboring one, if the surface was locally flat), and the other one is rooted in the edge but points perpendicular to the surface (which is also perpendicular to the edge that lives within the surface). Thus, because there are no obviously correct semantics for this function if spacedim is greater than dim, the function will simply throw an error in that situation.
The face iterator gives an indication which face this function is supposed to compute the normal vector for. This is useful if the boundary of the domain is composed of different nondifferential pieces (for example when using the FlatManifold class to approximate a geometry that is completely described by the coarse mesh, with piecewise (bi-)linear components between the vertices, but where the boundary may have a kink at the vertices itself).
Reimplemented in FlatManifold< dim, spacedim >, FlatManifold< chartdim, chartdim >, FlatManifold< dim, dim >, FlatManifold< dim, spacedim >, PolarManifold< dim, spacedim >, and SphericalManifold< dim, spacedim >.
|
virtualinherited |
Compute the normal vectors to the boundary at each vertex of the given face embedded in the Manifold. It is not required that the normal vectors be normed somehow. Neither is it required that the normals actually point outward.
This function is needed to compute data for C1 mappings. The default implementation calls normal_vector() on each vertex.
Note that when computing normal vectors at a vertex where the boundary is not differentiable, you have to make sure that you compute the one-sided limits, i.e. limit with respect to points inside the given face.
|
inherited |
Subscribes a user of the object by storing the pointer validity
. The subscriber may be identified by text supplied as identifier
.
Definition at line 131 of file enable_observer_pointer.cc.
|
inherited |
Unsubscribes a user from the object.
identifier
and the validity
pointer must be the same as the one supplied to subscribe(). Definition at line 151 of file enable_observer_pointer.cc.
|
inlineinherited |
Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.
Definition at line 322 of file enable_observer_pointer.h.
|
inlineinherited |
List the subscribers to the input stream
.
Definition at line 339 of file enable_observer_pointer.h.
|
inherited |
List the subscribers to deallog
.
Definition at line 199 of file enable_observer_pointer.cc.
Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.
This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.
Definition at line 331 of file enable_observer_pointer.h.
|
privatenoexceptinherited |
Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.
Definition at line 53 of file enable_observer_pointer.cc.
|
private |
Constants for the FunctionParser classes.
Definition at line 788 of file manifold_lib.h.
|
private |
Pointer to the push_forward function.
Definition at line 795 of file manifold_lib.h.
|
private |
Pointer to the pull_back function.
Definition at line 802 of file manifold_lib.h.
|
private |
Relative tolerance. In debug mode, we check that the two functions provided at construction time are actually one the inverse of the other. This value is used as relative tolerance in this check.
Definition at line 809 of file manifold_lib.h.
|
private |
Check ownership of the smart pointers. Indicates whether this class is the owner of the objects pointed to by the previous two member variables. This value is set in the constructor of the class. If true
, then the destructor will delete the function objects pointed to be the two pointers.
Definition at line 818 of file manifold_lib.h.
|
private |
The expression used to construct the push_forward function.
Definition at line 823 of file manifold_lib.h.
|
private |
The expression used to construct the pull_back function.
Definition at line 828 of file manifold_lib.h.
|
private |
Variable names in the chart domain.
Definition at line 833 of file manifold_lib.h.
|
private |
Variable names in the space domain.
Definition at line 838 of file manifold_lib.h.
|
private |
The finite difference step to use internally.
Definition at line 843 of file manifold_lib.h.
|
privateinherited |
The sub_manifold object is used to compute the average of the points in the chart coordinates system.
In an ideal world, it would have type FlatManifold<dim,chartdim>. However, this would instantiate cases where dim>spacedim, which leads to invalid situations. We instead use <chartdim,chartdim>, which is (i) always valid, and (ii) does not matter at all since the first (dim) argument of manifolds is, in fact, ignored as far as manifold functionality is concerned.
Definition at line 1093 of file manifold.h.
|
mutableprivateinherited |
Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).
The creator (and owner) of an object is counted in the map below if HE manages to supply identification.
We use the mutable
keyword in order to allow subscription to constant objects also.
This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic
class template.
Definition at line 227 of file enable_observer_pointer.h.
|
mutableprivateinherited |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 233 of file enable_observer_pointer.h.
|
mutableprivateinherited |
In this vector, we store pointers to the validity bool in the ObserverPointer objects that subscribe to this class.
Definition at line 249 of file enable_observer_pointer.h.
|
mutableprivateinherited |
Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.
Definition at line 257 of file enable_observer_pointer.h.
|
staticprivateinherited |
A mutex used to ensure data consistency when accessing the mutable
members of this class. This lock is used in the subscribe() and unsubscribe() functions, as well as in list_subscribers()
.
Definition at line 280 of file enable_observer_pointer.h.