| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2020 - 2025 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
#ifndef dealii_vector_tools_point_value_h |
| 16 |
#define dealii_vector_tools_point_value_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/template_constraints.h> |
| 22 |
|
| 23 |
|
| 24 |
DEAL_II_NAMESPACE_OPEN |
| 25 |
|
| 26 |
template <int dim, int spacedim> |
| 27 |
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>)) |
| 28 |
class DoFHandler; |
| 29 |
|
| 30 |
template <int dim, typename Number> |
| 31 |
class Function; |
| 32 |
template <int dim, int spacedim> |
| 33 |
class Mapping; |
| 34 |
|
| 35 |
template <int dim, typename Number> |
| 36 |
DEAL_II_CXX20_REQUIRES(dim >= 0) |
| 37 |
class Point; |
| 38 |
|
| 39 |
template <typename Number> |
| 40 |
class Vector; |
| 41 |
namespace hp |
| 42 |
{ |
| 43 |
template <int dim, int spacedim> |
| 44 |
class MappingCollection; |
| 45 |
} // namespace hp |
| 46 |
|
| 47 |
namespace VectorTools |
| 48 |
{ |
| 49 |
/** |
| 50 |
* @name Assembling of right hand sides |
| 51 |
*/ |
| 52 |
/** @{ */ |
| 53 |
|
| 54 |
/** |
| 55 |
* Create a right hand side vector for a point source at point @p p. In |
| 56 |
* other words, it creates a vector $F$ so that $F_i = \int_\Omega |
| 57 |
* \delta(x-p) \varphi_i(x) dx$ where $\varphi_i$ are the shape functions |
| 58 |
* described by @p dof_handler and @p p is the point at which the delta |
| 59 |
* function is located. Prior content of the given @p rhs_vector |
| 60 |
* vector is deleted. This function is for the case of a scalar finite |
| 61 |
* element. |
| 62 |
* |
| 63 |
* This function is typically used in one of these two contexts: |
| 64 |
* - Let's say you want to solve the same kind of problems many times |
| 65 |
* over, with different values for right hand sides or coefficients, |
| 66 |
* and then evaluate the solution at the same point every time. You |
| 67 |
* could do this by calling VectorTools::point_value() after each |
| 68 |
* solve, or you could realize that to evaluate the solution $u_h$ |
| 69 |
* at a point $p$, you could rearrange operations like this: |
| 70 |
* @f{align*}{ |
| 71 |
* u_h(p) &= \sum_j U_j \varphi_j(p) = \sum_j U_j F_j |
| 72 |
* \\ &= U \cdot F |
| 73 |
* @f} |
| 74 |
* with the vector as defined above. In other words, point evaluation |
| 75 |
* can be achieved with just a single vector-vector product, and the |
| 76 |
* vector $F$ can be computed once and for all and reused |
| 77 |
* for each solve, without having to go through the mesh every time |
| 78 |
* to find out which cell (and where in the cell) the point $p$ is |
| 79 |
* located. |
| 80 |
* - This function is also useful if you wanted to compute the Green's |
| 81 |
* function for the problem you are solving. This is because the |
| 82 |
* Green's function $G(x,p)$ is defined by |
| 83 |
* @f{align*}{ |
| 84 |
* L G(x,p) &= \delta(x-p) |
| 85 |
* @f} |
| 86 |
* where $L$ is the differential operator of your problem. The discrete |
| 87 |
* version then requires computing the right hand side vector |
| 88 |
* $F_i = \int_\Omega \varphi_i(x) \delta(x-p)$, which is exactly |
| 89 |
* the vector computed by the current function. |
| 90 |
* |
| 91 |
* While maybe not relevant for documenting <i>what</i> this |
| 92 |
* function does, it may be interesting to note that delta functions |
| 93 |
* do not exist in reality, and consequently, using this function |
| 94 |
* does not model any real situation. This is, because no real |
| 95 |
* object is able to focus an infinite force density at an |
| 96 |
* infinitesimally small part of the domain (rather, all real |
| 97 |
* devices will spread out the force over a finite area); nor is it |
| 98 |
* possible to measure values at individual points (but all |
| 99 |
* measurements will somehow be averaged over small areas). Only if |
| 100 |
* this area is so small that it cannot be resolved by any mesh does |
| 101 |
* it make sense to model the situation in a way that uses a delta |
| 102 |
* function with the same overall force or sensitivity. On the other |
| 103 |
* hand, a situation that is probably more fruitfully simulated with |
| 104 |
* a delta function is the electric potential of a point source; in |
| 105 |
* this case, the solution is known to have a logarithmic |
| 106 |
* singularity (in 2d) or a $\frac{1}{r}$ singularity (in 3d), |
| 107 |
* neither of which is bounded. |
| 108 |
* |
| 109 |
* Mathematically, the use of delta functions typically leads to exact |
| 110 |
* solutions to which the numerically obtained, approximate solution does |
| 111 |
* not converge. This is because, taking the Laplace equation as an example, |
| 112 |
* the error between exact and numerical solution can be bounded by the |
| 113 |
* expression |
| 114 |
* @f{align*}{ |
| 115 |
* \| u-u_h \|_{L_2} \le C h \| \nabla u \|_{L_2} |
| 116 |
* @f} |
| 117 |
* but when using a delta function on the right hand side, the term |
| 118 |
* $\| \nabla u \|_{L_2} = |u|_{H^1}$ is not finite. This can be seen |
| 119 |
* by using the a-priori bound for solutions of the Laplace equation |
| 120 |
* $-\Delta u = f$ that states that $|u|_{H^1} \le \|f\|_{H^{-1}}$. |
| 121 |
* When using a delta function as right hand side, $f(x)=\delta(x-p)$, |
| 122 |
* one would need to take the $H^{-1}$ norm of a delta function, which |
| 123 |
* however is not finite because $\delta(\cdot-p) \not\in H^{-1}$. |
| 124 |
* |
| 125 |
* The consequence of all of this is that the exact solution of the |
| 126 |
* Laplace equation with a delta function on the right hand side -- |
| 127 |
* i.e., the <i>Green's function</i> -- has a singularity at $p$ that |
| 128 |
* is so strong that it cannot be resolved by a finite element |
| 129 |
* solution, and consequently finite element approximations do not |
| 130 |
* converge towards the exact solution in any of the usual norms. |
| 131 |
* |
| 132 |
* All of this is also the case for all of the other usual second-order |
| 133 |
* partial differential equations in dimensions two or higher. (Because |
| 134 |
* in dimension two and higher, $H^1$ functions are not necessarily |
| 135 |
* continuous, and consequently the delta function is not in the dual |
| 136 |
* space $H^{-1}$.) |
| 137 |
*/ |
| 138 |
template <int dim, int spacedim> |
| 139 |
void |
| 140 |
create_point_source_vector(const Mapping<dim, spacedim> &mapping, |
| 141 |
const DoFHandler<dim, spacedim> &dof_handler, |
| 142 |
const Point<spacedim, double> &p, |
| 143 |
Vector<double> &rhs_vector); |
| 144 |
|
| 145 |
/** |
| 146 |
* Like the previous function, but for hp-objects. |
| 147 |
*/ |
| 148 |
template <int dim, int spacedim> |
| 149 |
void |
| 150 |
create_point_source_vector( |
| 151 |
const hp::MappingCollection<dim, spacedim> &mapping, |
| 152 |
const DoFHandler<dim, spacedim> &dof_handler, |
| 153 |
const Point<spacedim, double> &p, |
| 154 |
Vector<double> &rhs_vector); |
| 155 |
|
| 156 |
/** |
| 157 |
* Call the create_point_source_vector() function, see above, with |
| 158 |
* an implied default $Q_1$ mapping object. |
| 159 |
* |
| 160 |
* Note that if your DoFHandler uses any active FE index other than zero, then |
| 161 |
* you need to call the function above that provides a mapping object for each |
| 162 |
* active FE index. |
| 163 |
*/ |
| 164 |
template <int dim, int spacedim> |
| 165 |
void |
| 166 |
create_point_source_vector(const DoFHandler<dim, spacedim> &dof_handler, |
| 167 |
const Point<spacedim, double> &p, |
| 168 |
Vector<double> &rhs_vector); |
| 169 |
|
| 170 |
/** |
| 171 |
* Create a right hand side vector for a point source at point @p p. This |
| 172 |
* variation of the function is meant for vector-valued problems with |
| 173 |
* exactly dim components (it will also work for problems with more than dim |
| 174 |
* components, and in this case simply consider only the first dim |
| 175 |
* components of the shape functions). It computes a right hand side that |
| 176 |
* corresponds to a forcing function that is equal to a delta function times |
| 177 |
* a given direction. In other words, it creates a vector $F$ so that $F_i = |
| 178 |
* \int_\Omega [\mathbf d \delta(x-p)] \cdot \varphi_i(x) dx$. Note here that |
| 179 |
* $\varphi_i$ is a vector-valued function. $\mathbf d$ is the given direction |
| 180 |
* of the source term $\mathbf d \delta(x-p)$ and corresponds to the @p |
| 181 |
* direction argument to be passed to this function. |
| 182 |
* |
| 183 |
* Prior content of the given @p rhs_vector vector is deleted. |
| 184 |
* |
| 185 |
* See the discussion of the first create_point_source_vector() variant for |
| 186 |
* more on the use of delta functions. |
| 187 |
*/ |
| 188 |
template <int dim, int spacedim> |
| 189 |
void |
| 190 |
create_point_source_vector(const Mapping<dim, spacedim> &mapping, |
| 191 |
const DoFHandler<dim, spacedim> &dof_handler, |
| 192 |
const Point<spacedim, double> &p, |
| 193 |
const Point<dim, double> &direction, |
| 194 |
Vector<double> &rhs_vector); |
| 195 |
|
| 196 |
/** |
| 197 |
* Like the previous function, but for hp-objects. |
| 198 |
*/ |
| 199 |
template <int dim, int spacedim> |
| 200 |
void |
| 201 |
create_point_source_vector( |
| 202 |
const hp::MappingCollection<dim, spacedim> &mapping, |
| 203 |
const DoFHandler<dim, spacedim> &dof_handler, |
| 204 |
const Point<spacedim, double> &p, |
| 205 |
const Point<dim, double> &direction, |
| 206 |
Vector<double> &rhs_vector); |
| 207 |
|
| 208 |
/** |
| 209 |
* Call the create_point_source_vector() function for vector-valued finite |
| 210 |
* elements, see above, with an implied default $Q_1$ mapping object. |
| 211 |
* |
| 212 |
* Note that if your DoFHandler uses any active FE index other than zero, then |
| 213 |
* you need to call the function above that provides a mapping object for each |
| 214 |
* active FE index. |
| 215 |
*/ |
| 216 |
template <int dim, int spacedim> |
| 217 |
void |
| 218 |
create_point_source_vector(const DoFHandler<dim, spacedim> &dof_handler, |
| 219 |
const Point<spacedim, double> &p, |
| 220 |
const Point<dim, double> &direction, |
| 221 |
Vector<double> &rhs_vector); |
| 222 |
/** @} */ |
| 223 |
|
| 224 |
/** |
| 225 |
* @name Evaluation of functions and errors |
| 226 |
*/ |
| 227 |
/** @{ */ |
| 228 |
|
| 229 |
/** |
| 230 |
* Point error evaluation. Find the first cell containing the given point |
| 231 |
* and compute the difference of a (possibly vector-valued) finite element |
| 232 |
* function and a continuous function (with as many vector components as the |
| 233 |
* finite element) at this point. |
| 234 |
* |
| 235 |
* This is a wrapper function using a Q1-mapping for cell boundaries to call |
| 236 |
* the other point_difference() function. |
| 237 |
* |
| 238 |
* @note If the cell in which the point is found is not locally owned, an |
| 239 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 240 |
* |
| 241 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 242 |
*/ |
| 243 |
template <int dim, typename VectorType, int spacedim> |
| 244 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 245 |
void point_difference( |
| 246 |
const DoFHandler<dim, spacedim> &dof, |
| 247 |
const VectorType &fe_function, |
| 248 |
const Function<spacedim, typename VectorType::value_type> &exact_solution, |
| 249 |
Vector<typename VectorType::value_type> &difference, |
| 250 |
const Point<spacedim, double> &point); |
| 251 |
|
| 252 |
/** |
| 253 |
* Point error evaluation. Find the first cell containing the given point |
| 254 |
* and compute the difference of a (possibly vector-valued) finite element |
| 255 |
* function and a continuous function (with as many vector components as the |
| 256 |
* finite element) at this point. |
| 257 |
* |
| 258 |
* Compared with the other function of the same name, this function uses an |
| 259 |
* arbitrary mapping to evaluate the difference. |
| 260 |
* |
| 261 |
* @note If the cell in which the point is found is not locally owned, an |
| 262 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 263 |
* |
| 264 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 265 |
*/ |
| 266 |
template <int dim, typename VectorType, int spacedim> |
| 267 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 268 |
void point_difference( |
| 269 |
const Mapping<dim, spacedim> &mapping, |
| 270 |
const DoFHandler<dim, spacedim> &dof, |
| 271 |
const VectorType &fe_function, |
| 272 |
const Function<spacedim, typename VectorType::value_type> &exact_solution, |
| 273 |
Vector<typename VectorType::value_type> &difference, |
| 274 |
const Point<spacedim, double> &point); |
| 275 |
|
| 276 |
/** |
| 277 |
* Evaluate a possibly vector-valued finite element function defined by the |
| 278 |
* given DoFHandler and nodal vector @p fe_function at the given point @p |
| 279 |
* point, and return the (vector) value of this function through the last |
| 280 |
* argument. |
| 281 |
* |
| 282 |
* This function uses a $Q_1$-mapping for the cell the point is evaluated |
| 283 |
* in. If you need to evaluate using a different mapping (for example when |
| 284 |
* using curved boundaries), use the point_difference() function that takes |
| 285 |
* a mapping. |
| 286 |
* |
| 287 |
* This function is not particularly cheap. This is because it first |
| 288 |
* needs to find which cell a given point is in, then find the point |
| 289 |
* on the reference cell that matches the given evaluation point, |
| 290 |
* and then evaluate the shape functions there. You probably do not |
| 291 |
* want to use this function to evaluate the solution at <i>many</i> |
| 292 |
* points. For this kind of application, the FEFieldFunction class |
| 293 |
* offers at least some optimizations. On the other hand, if you |
| 294 |
* want to evaluate <i>many solutions</i> at the same point, you may |
| 295 |
* want to look at the VectorTools::create_point_source_vector() |
| 296 |
* function. |
| 297 |
* |
| 298 |
* @note If the cell in which the point is found is not locally owned, an |
| 299 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 300 |
* |
| 301 |
* @note This function needs to find the cell within which a point lies, |
| 302 |
* and this can only be done up to a certain numerical tolerance of course. |
| 303 |
* Consequently, for points that are on, or close to, the boundary of |
| 304 |
* a cell, you may get the value of the finite element field either |
| 305 |
* here or there, depending on which cell the point is found in. This |
| 306 |
* does not matter (to within the same tolerance) if the finite element |
| 307 |
* field is continuous. On the other hand, if the finite element in use |
| 308 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 309 |
* points on or close to the boundary of the cell, as one would expect |
| 310 |
* when trying to evaluate point values of discontinuous functions. |
| 311 |
* |
| 312 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 313 |
*/ |
| 314 |
template <int dim, typename VectorType, int spacedim> |
| 315 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 316 |
void point_value(const DoFHandler<dim, spacedim> &dof, |
| 317 |
const VectorType &fe_function, |
| 318 |
const Point<spacedim, double> &point, |
| 319 |
Vector<typename VectorType::value_type> &value); |
| 320 |
|
| 321 |
/** |
| 322 |
* Same as above for hp. |
| 323 |
* |
| 324 |
* @note If the cell in which the point is found is not locally owned, an |
| 325 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 326 |
* |
| 327 |
* @note This function needs to find the cell within which a point lies, |
| 328 |
* and this can only be done up to a certain numerical tolerance of course. |
| 329 |
* Consequently, for points that are on, or close to, the boundary of |
| 330 |
* a cell, you may get the value of the finite element field either |
| 331 |
* here or there, depending on which cell the point is found in. This |
| 332 |
* does not matter (to within the same tolerance) if the finite element |
| 333 |
* field is continuous. On the other hand, if the finite element in use |
| 334 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 335 |
* points on or close to the boundary of the cell, as one would expect |
| 336 |
* when trying to evaluate point values of discontinuous functions. |
| 337 |
* |
| 338 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 339 |
*/ |
| 340 |
template <int dim, typename VectorType, int spacedim> |
| 341 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 342 |
void point_value(const DoFHandler<dim, spacedim> &dof, |
| 343 |
const VectorType &fe_function, |
| 344 |
const Point<spacedim, double> &point, |
| 345 |
Vector<typename VectorType::value_type> &value); |
| 346 |
|
| 347 |
/** |
| 348 |
* Evaluate a scalar finite element function defined by the given DoFHandler |
| 349 |
* and nodal vector @p fe_function at the given point @p point, and return |
| 350 |
* the value of this function. |
| 351 |
* |
| 352 |
* This function uses a Q1-mapping for the cell the point is evaluated |
| 353 |
* in. If you need to evaluate using a different mapping (for example when |
| 354 |
* using curved boundaries), use the point_difference() function that takes |
| 355 |
* a mapping. |
| 356 |
* |
| 357 |
* This function is not particularly cheap. This is because it first |
| 358 |
* needs to find which cell a given point is in, then find the point |
| 359 |
* on the reference cell that matches the given evaluation point, |
| 360 |
* and then evaluate the shape functions there. You probably do not |
| 361 |
* want to use this function to evaluate the solution at <i>many</i> |
| 362 |
* points. For this kind of application, the FEFieldFunction class |
| 363 |
* offers at least some optimizations. On the other hand, if you |
| 364 |
* want to evaluate <i>many solutions</i> at the same point, you may |
| 365 |
* want to look at the VectorTools::create_point_source_vector() |
| 366 |
* function. |
| 367 |
* |
| 368 |
* This function is used in the "Possibilities for extensions" part of the |
| 369 |
* results section of |
| 370 |
* @ref step_3 "step-3". |
| 371 |
* |
| 372 |
* @note If the cell in which the point is found is not locally owned, an |
| 373 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 374 |
* |
| 375 |
* @note This function needs to find the cell within which a point lies, |
| 376 |
* and this can only be done up to a certain numerical tolerance of course. |
| 377 |
* Consequently, for points that are on, or close to, the boundary of |
| 378 |
* a cell, you may get the value of the finite element field either |
| 379 |
* here or there, depending on which cell the point is found in. This |
| 380 |
* does not matter (to within the same tolerance) if the finite element |
| 381 |
* field is continuous. On the other hand, if the finite element in use |
| 382 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 383 |
* points on or close to the boundary of the cell, as one would expect |
| 384 |
* when trying to evaluate point values of discontinuous functions. |
| 385 |
* |
| 386 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 387 |
*/ |
| 388 |
template <int dim, typename VectorType, int spacedim> |
| 389 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 390 |
typename VectorType::value_type |
| 391 |
point_value(const DoFHandler<dim, spacedim> &dof, |
| 392 |
const VectorType &fe_function, |
| 393 |
const Point<spacedim, double> &point); |
| 394 |
|
| 395 |
/** |
| 396 |
* Same as above for hp. |
| 397 |
* |
| 398 |
* @note If the cell in which the point is found is not locally owned, an |
| 399 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 400 |
* |
| 401 |
* @note This function needs to find the cell within which a point lies, |
| 402 |
* and this can only be done up to a certain numerical tolerance of course. |
| 403 |
* Consequently, for points that are on, or close to, the boundary of |
| 404 |
* a cell, you may get the value of the finite element field either |
| 405 |
* here or there, depending on which cell the point is found in. This |
| 406 |
* does not matter (to within the same tolerance) if the finite element |
| 407 |
* field is continuous. On the other hand, if the finite element in use |
| 408 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 409 |
* points on or close to the boundary of the cell, as one would expect |
| 410 |
* when trying to evaluate point values of discontinuous functions. |
| 411 |
* |
| 412 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 413 |
*/ |
| 414 |
template <int dim, typename VectorType, int spacedim> |
| 415 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 416 |
typename VectorType::value_type |
| 417 |
point_value(const DoFHandler<dim, spacedim> &dof, |
| 418 |
const VectorType &fe_function, |
| 419 |
const Point<spacedim, double> &point); |
| 420 |
|
| 421 |
/** |
| 422 |
* Evaluate a possibly vector-valued finite element function defined by the |
| 423 |
* given DoFHandler and nodal vector @p fe_function at the given point @p |
| 424 |
* point, and return the (vector) value of this function through the last |
| 425 |
* argument. |
| 426 |
* |
| 427 |
* Compared with the other function of the same name, this function uses an |
| 428 |
* arbitrary mapping to evaluate the point value. |
| 429 |
* |
| 430 |
* This function is not particularly cheap. This is because it first |
| 431 |
* needs to find which cell a given point is in, then find the point |
| 432 |
* on the reference cell that matches the given evaluation point, |
| 433 |
* and then evaluate the shape functions there. You probably do not |
| 434 |
* want to use this function to evaluate the solution at <i>many</i> |
| 435 |
* points. For this kind of application, the FEFieldFunction class |
| 436 |
* offers at least some optimizations. On the other hand, if you |
| 437 |
* want to evaluate <i>many solutions</i> at the same point, you may |
| 438 |
* want to look at the VectorTools::create_point_source_vector() |
| 439 |
* function. |
| 440 |
* |
| 441 |
* @note If the cell in which the point is found is not locally owned, an |
| 442 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 443 |
* |
| 444 |
* @note This function needs to find the cell within which a point lies, |
| 445 |
* and this can only be done up to a certain numerical tolerance of course. |
| 446 |
* Consequently, for points that are on, or close to, the boundary of |
| 447 |
* a cell, you may get the value of the finite element field either |
| 448 |
* here or there, depending on which cell the point is found in. This |
| 449 |
* does not matter (to within the same tolerance) if the finite element |
| 450 |
* field is continuous. On the other hand, if the finite element in use |
| 451 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 452 |
* points on or close to the boundary of the cell, as one would expect |
| 453 |
* when trying to evaluate point values of discontinuous functions. |
| 454 |
* |
| 455 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 456 |
*/ |
| 457 |
template <int dim, typename VectorType, int spacedim> |
| 458 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 459 |
void point_value(const Mapping<dim, spacedim> &mapping, |
| 460 |
const DoFHandler<dim, spacedim> &dof, |
| 461 |
const VectorType &fe_function, |
| 462 |
const Point<spacedim, double> &point, |
| 463 |
Vector<typename VectorType::value_type> &value); |
| 464 |
|
| 465 |
/** |
| 466 |
* Same as above for hp. |
| 467 |
* |
| 468 |
* @note If the cell in which the point is found is not locally owned, an |
| 469 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 470 |
* |
| 471 |
* @note This function needs to find the cell within which a point lies, |
| 472 |
* and this can only be done up to a certain numerical tolerance of course. |
| 473 |
* Consequently, for points that are on, or close to, the boundary of |
| 474 |
* a cell, you may get the value of the finite element field either |
| 475 |
* here or there, depending on which cell the point is found in. This |
| 476 |
* does not matter (to within the same tolerance) if the finite element |
| 477 |
* field is continuous. On the other hand, if the finite element in use |
| 478 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 479 |
* points on or close to the boundary of the cell, as one would expect |
| 480 |
* when trying to evaluate point values of discontinuous functions. |
| 481 |
* |
| 482 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 483 |
*/ |
| 484 |
template <int dim, typename VectorType, int spacedim> |
| 485 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 486 |
void point_value(const hp::MappingCollection<dim, spacedim> &mapping, |
| 487 |
const DoFHandler<dim, spacedim> &dof, |
| 488 |
const VectorType &fe_function, |
| 489 |
const Point<spacedim, double> &point, |
| 490 |
Vector<typename VectorType::value_type> &value); |
| 491 |
|
| 492 |
/** |
| 493 |
* Evaluate a scalar finite element function defined by the given DoFHandler |
| 494 |
* and nodal vector @p fe_function at the given point @p point, and return |
| 495 |
* the value of this function. |
| 496 |
* |
| 497 |
* Compared with the other function of the same name, this function uses an |
| 498 |
* arbitrary mapping to evaluate the difference. |
| 499 |
* |
| 500 |
* This function is not particularly cheap. This is because it first |
| 501 |
* needs to find which cell a given point is in, then find the point |
| 502 |
* on the reference cell that matches the given evaluation point, |
| 503 |
* and then evaluate the shape functions there. You probably do not |
| 504 |
* want to use this function to evaluate the solution at <i>many</i> |
| 505 |
* points. For this kind of application, the FEFieldFunction class |
| 506 |
* offers at least some optimizations. On the other hand, if you |
| 507 |
* want to evaluate <i>many solutions</i> at the same point, you may |
| 508 |
* want to look at the VectorTools::create_point_source_vector() |
| 509 |
* function. |
| 510 |
* |
| 511 |
* @note If the cell in which the point is found is not locally owned, an |
| 512 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 513 |
* |
| 514 |
* @note This function needs to find the cell within which a point lies, |
| 515 |
* and this can only be done up to a certain numerical tolerance of course. |
| 516 |
* Consequently, for points that are on, or close to, the boundary of |
| 517 |
* a cell, you may get the value of the finite element field either |
| 518 |
* here or there, depending on which cell the point is found in. This |
| 519 |
* does not matter (to within the same tolerance) if the finite element |
| 520 |
* field is continuous. On the other hand, if the finite element in use |
| 521 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 522 |
* points on or close to the boundary of the cell, as one would expect |
| 523 |
* when trying to evaluate point values of discontinuous functions. |
| 524 |
* |
| 525 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 526 |
*/ |
| 527 |
template <int dim, typename VectorType, int spacedim> |
| 528 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 529 |
typename VectorType::value_type |
| 530 |
point_value(const Mapping<dim, spacedim> &mapping, |
| 531 |
const DoFHandler<dim, spacedim> &dof, |
| 532 |
const VectorType &fe_function, |
| 533 |
const Point<spacedim, double> &point); |
| 534 |
|
| 535 |
/** |
| 536 |
* Same as above for hp. |
| 537 |
* |
| 538 |
* @note If the cell in which the point is found is not locally owned, an |
| 539 |
* exception of type VectorTools::ExcPointNotAvailableHere is thrown. |
| 540 |
* |
| 541 |
* @note This function needs to find the cell within which a point lies, |
| 542 |
* and this can only be done up to a certain numerical tolerance of course. |
| 543 |
* Consequently, for points that are on, or close to, the boundary of |
| 544 |
* a cell, you may get the value of the finite element field either |
| 545 |
* here or there, depending on which cell the point is found in. This |
| 546 |
* does not matter (to within the same tolerance) if the finite element |
| 547 |
* field is continuous. On the other hand, if the finite element in use |
| 548 |
* is <i>not</i> continuous, then you will get unpredictable values for |
| 549 |
* points on or close to the boundary of the cell, as one would expect |
| 550 |
* when trying to evaluate point values of discontinuous functions. |
| 551 |
* |
| 552 |
* @dealiiConceptRequires{concepts::is_dealii_vector_type<VectorType>} |
| 553 |
*/ |
| 554 |
template <int dim, typename VectorType, int spacedim> |
| 555 |
DEAL_II_CXX20_REQUIRES(concepts::is_dealii_vector_type<VectorType>) |
| 556 |
typename VectorType::value_type |
| 557 |
point_value(const hp::MappingCollection<dim, spacedim> &mapping, |
| 558 |
const DoFHandler<dim, spacedim> &dof, |
| 559 |
const VectorType &fe_function, |
| 560 |
const Point<spacedim, double> &point); |
| 561 |
/** @} */ |
| 562 |
} // namespace VectorTools |
| 563 |
|
| 564 |
DEAL_II_NAMESPACE_CLOSE |
| 565 |
|
| 566 |
#endif // dealii_vector_tools_point_value_h |