Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
vector_selector.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2009 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_mesh_worker_vector_selector_h
17#define dealii_mesh_worker_vector_selector_h
18
19#include <deal.II/base/config.h>
20
23
26#include <deal.II/base/tensor.h>
27
29
30// Forward declaration
31#ifndef DOXYGEN
32template <int, int>
33class FEValuesBase;
34#endif
35
36namespace MeshWorker
37{
52 {
53 public:
62 void
63 add(const std::string &name,
64 const bool values = true,
65 const bool gradients = false,
66 const bool hessians = false);
67
72 // void add(const std::string& name,
73 // const unsigned int selected_block,
74 // bool values = true,
75 // bool gradients = false,
76 // bool hessians = false);
77
87 void
88 initialize(const AnyData &);
89
93 bool
94 empty() const;
95
99 bool
100 has_values() const;
101
105 bool
106 has_gradients() const;
107
111 bool
112 has_hessians() const;
113
117 unsigned int
118 n_values() const;
119
123 unsigned int
124 n_gradients() const;
125
129 unsigned int
130 n_hessians() const;
131
135 unsigned int
136 value_index(const unsigned int i) const;
137
141 unsigned int
142 gradient_index(const unsigned int i) const;
143
147 unsigned int
148 hessian_index(const unsigned int i) const;
149
153 template <class StreamType, typename DATA>
154 void
155 print(StreamType &s, const AnyData &v) const;
156
160 template <class StreamType>
161 void
162 print(StreamType &s) const;
163
167 std::size_t
168 memory_consumption() const;
169
170 protected:
175
180
185 };
186
193 template <int dim, int spacedim = dim, typename Number = double>
195 {
196 public:
200 VectorDataBase() = default;
201
206
214 void
216
220 virtual ~VectorDataBase() override = default;
221
260 virtual void
261 fill(std::vector<std::vector<std::vector<Number>>> &values,
262 std::vector<std::vector<std::vector<Tensor<1, spacedim, Number>>>>
263 &gradients,
264 std::vector<std::vector<std::vector<Tensor<2, spacedim, Number>>>>
265 & hessians,
267 const std::vector<types::global_dof_index> &index,
268 const unsigned int component,
269 const unsigned int n_comp,
270 const unsigned int start,
271 const unsigned int size) const;
272
279 virtual void
280 mg_fill(std::vector<std::vector<std::vector<Number>>> &values,
281 std::vector<std::vector<std::vector<Tensor<1, spacedim, Number>>>>
282 &gradients,
283 std::vector<std::vector<std::vector<Tensor<2, spacedim, Number>>>>
284 & hessians,
286 const unsigned int level,
287 const std::vector<types::global_dof_index> &index,
288 const unsigned int component,
289 const unsigned int n_comp,
290 const unsigned int start,
291 const unsigned int size) const;
292
293 protected:
295 };
296
297
305 template <typename VectorType, int dim, int spacedim = dim>
307 : public VectorDataBase<dim, spacedim, typename VectorType::value_type>
308 {
309 public:
313 VectorData() = default;
314
319
323 void
325
333 void
334 initialize(const VectorType *, const std::string &name);
335
336 virtual void
337 fill(std::vector<std::vector<std::vector<typename VectorType::value_type>>>
338 &values,
339 std::vector<std::vector<
341 &gradients,
342 std::vector<std::vector<
344 & hessians,
346 const std::vector<types::global_dof_index> &index,
347 const unsigned int component,
348 const unsigned int n_comp,
349 const unsigned int start,
350 const unsigned int size) const override;
351
352 virtual void
354 std::vector<std::vector<std::vector<typename VectorType::value_type>>>
355 &values,
356 std::vector<std::vector<
358 &gradients,
359 std::vector<std::vector<
361 & hessians,
363 const unsigned int level,
364 const std::vector<types::global_dof_index> &index,
365 const unsigned int component,
366 const unsigned int n_comp,
367 const unsigned int start,
368 const unsigned int size) const override;
369
373 std::size_t
375 };
376
377
385 template <typename VectorType, int dim, int spacedim = dim>
386 class MGVectorData : public VectorData<VectorType, dim, spacedim>
387 {
388 public:
392 MGVectorData() = default;
393
398
402 void
404
412 void
413 initialize(const MGLevelObject<VectorType> *, const std::string &name);
414 };
415
416
417 //----------------------------------------------------------------------//
418
419 inline void
420 VectorSelector::add(const std::string &name,
421 const bool values,
422 const bool gradients,
423 const bool hessians)
424 {
425 if (values)
426 value_selection.add(name);
427 if (gradients)
429 if (hessians)
431 }
432
433
434 // inline void
435 // VectorSelector::add(const std::string& name,
436 // const unsigned int block,
437 // bool values, bool gradients, bool hessians)
438 //{
439 // if (values) value_selection.add(name, block);
440 // if (gradients) gradient_selection.add(name, block);
441 // if (hessians) hessian_selection.add(name, block);
442 //}
443
444
445 inline void
447 {
451 }
452
453 inline bool
455 {
456 return (value_selection.size() == 0 && gradient_selection.size() == 0 &&
457 hessian_selection.size() == 0);
458 }
459
460
461 inline bool
463 {
464 return value_selection.size() != 0;
465 }
466
467
468 inline bool
470 {
471 return gradient_selection.size() != 0;
472 }
473
474
475 inline bool
477 {
478 return hessian_selection.size() != 0;
479 }
480
481
482 inline unsigned int
484 {
485 return value_selection.size();
486 }
487
488
489 inline unsigned int
491 {
492 return gradient_selection.size();
493 }
494
495
496 inline unsigned int
498 {
499 return hessian_selection.size();
500 }
501
502
503 inline unsigned int
504 VectorSelector::value_index(const unsigned int i) const
505 {
506 return value_selection(i);
507 }
508
509
510 inline unsigned int
511 VectorSelector::gradient_index(const unsigned int i) const
512 {
513 return gradient_selection(i);
514 }
515
516
517 inline unsigned int
518 VectorSelector::hessian_index(const unsigned int i) const
519 {
520 return hessian_selection(i);
521 }
522
523
524 template <class StreamType>
525 inline void
526 VectorSelector::print(StreamType &s) const
527 {
528 s << "values: " << n_values() << " gradients: " << n_gradients()
529 << " hessians: " << n_hessians() << std::endl;
530 }
531
532
533 template <class StreamType, typename DATA>
534 inline void
535 VectorSelector::print(StreamType &s, const AnyData &v) const
536 {
537 s << "values: ";
538 for (unsigned int i = 0; i < n_values(); ++i)
539 s << " '" << v.name(value_selection(i)) << '\'';
540 s << std::endl << "gradients:";
541 for (unsigned int i = 0; i < n_gradients(); ++i)
542 s << " '" << v.name(gradient_selection(i)) << '\'';
543 s << std::endl << "hessians: ";
544 for (unsigned int i = 0; i < n_hessians(); ++i)
545 s << " '" << v.name(hessian_selection(i)) << '\'';
546 s << std::endl;
547 }
548
549
550 inline std::size_t
552 {
553 return sizeof(*this);
554 }
555} // namespace MeshWorker
556
557
559
560#endif
const std::string & name(const unsigned int i) const
Name of object at index.
Definition any_data.h:311
void initialize(const AnyData &)
MGVectorData(const VectorSelector &)
void initialize(const MGLevelObject< VectorType > *, const std::string &name)
virtual void mg_fill(std::vector< std::vector< std::vector< Number > > > &values, std::vector< std::vector< std::vector< Tensor< 1, spacedim, Number > > > > &gradients, std::vector< std::vector< std::vector< Tensor< 2, spacedim, Number > > > > &hessians, const FEValuesBase< dim, spacedim > &fe, const unsigned int level, const std::vector< types::global_dof_index > &index, const unsigned int component, const unsigned int n_comp, const unsigned int start, const unsigned int size) const
void initialize(const AnyData &)
virtual ~VectorDataBase() override=default
VectorDataBase(const VectorSelector &)
virtual void fill(std::vector< std::vector< std::vector< Number > > > &values, std::vector< std::vector< std::vector< Tensor< 1, spacedim, Number > > > > &gradients, std::vector< std::vector< std::vector< Tensor< 2, spacedim, Number > > > > &hessians, const FEValuesBase< dim, spacedim > &fe, const std::vector< types::global_dof_index > &index, const unsigned int component, const unsigned int n_comp, const unsigned int start, const unsigned int size) const
void initialize(const VectorType *, const std::string &name)
virtual void fill(std::vector< std::vector< std::vector< typename VectorType::value_type > > > &values, std::vector< std::vector< std::vector< Tensor< 1, spacedim, typename VectorType::value_type > > > > &gradients, std::vector< std::vector< std::vector< Tensor< 2, spacedim, typename VectorType::value_type > > > > &hessians, const FEValuesBase< dim, spacedim > &fe, const std::vector< types::global_dof_index > &index, const unsigned int component, const unsigned int n_comp, const unsigned int start, const unsigned int size) const override
VectorData(const VectorSelector &)
virtual void mg_fill(std::vector< std::vector< std::vector< typename VectorType::value_type > > > &values, std::vector< std::vector< std::vector< Tensor< 1, spacedim, typename VectorType::value_type > > > > &gradients, std::vector< std::vector< std::vector< Tensor< 2, spacedim, typename VectorType::value_type > > > > &hessians, const FEValuesBase< dim, spacedim > &fe, const unsigned int level, const std::vector< types::global_dof_index > &index, const unsigned int component, const unsigned int n_comp, const unsigned int start, const unsigned int size) const override
std::size_t memory_consumption() const
void initialize(const AnyData &)
std::size_t memory_consumption() const
unsigned int n_values() const
unsigned int n_gradients() const
unsigned int value_index(const unsigned int i) const
void print(StreamType &s, const AnyData &v) const
void initialize(const AnyData &)
unsigned int n_hessians() const
unsigned int hessian_index(const unsigned int i) const
void add(const std::string &name, const bool values=true, const bool gradients=false, const bool hessians=false)
unsigned int gradient_index(const unsigned int i) const
void initialize(const AnyData &data)
void add(const std::string &name)
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
unsigned int level
Definition grid_out.cc:4618