[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
ffd_parameterization.cpp
1 #include "ffd_parameterization.hpp"
2 
3 namespace PHiLiP {
4 
5 template<int dim>
7  std::shared_ptr<HighOrderGrid<dim,double>> _high_order_grid,
8  const FreeFormDeformation<dim> &_ffd,
9  std::vector< std::pair< unsigned int, unsigned int > > &_ffd_design_variables_indices_dim)
10  : BaseParameterization<dim>(_high_order_grid)
11  , ffd(_ffd)
12  , ffd_design_variables_indices_dim(_ffd_design_variables_indices_dim)
13  {}
14 
15 template<int dim>
17  VectorType &ffd_des_var)
18 {
19  const unsigned int n_design_variables = ffd_design_variables_indices_dim.size();
20  const dealii::IndexSet row_part = dealii::Utilities::MPI::create_evenly_distributed_partitioning(MPI_COMM_WORLD,n_design_variables);
21  dealii::IndexSet ghost_row_part(n_design_variables);
22  ghost_row_part.add_range(0,n_design_variables);
23  ffd_des_var.reinit(row_part, ghost_row_part, MPI_COMM_WORLD);
24 
25  ffd.get_design_variables(ffd_design_variables_indices_dim, ffd_des_var);
26 
27  initial_ffd_des_var = ffd_des_var;
28  initial_ffd_des_var.update_ghost_values();
29 }
30 
31 template<int dim>
33 {
34  ffd.get_dXvdXp(*(this->high_order_grid), ffd_design_variables_indices_dim, dXv_dXp);
35 }
36 
37 template<int dim>
39  const MatrixType &dXv_dXp,
40  const VectorType &ffd_des_var)
41 {
42  AssertDimension(ffd_des_var.size(), initial_ffd_des_var.size());
43  VectorType current_ffd_des_var = ffd_des_var;
44  ffd.get_design_variables( ffd_design_variables_indices_dim, current_ffd_des_var);
45 
46  bool design_variable_has_changed = this->has_design_variable_been_updated(current_ffd_des_var, ffd_des_var);
47 
48  bool mesh_updated;
49  if(!design_variable_has_changed)
50  {
51  mesh_updated = false;
52  return mesh_updated;
53  }
54 
55  ffd.set_design_variables( ffd_design_variables_indices_dim, ffd_des_var);
56 
57  VectorType dXp = ffd_des_var;
58  dXp -= initial_ffd_des_var;
59  dXp.update_ghost_values();
60  VectorType dXv = this->high_order_grid->volume_nodes;
61  dXv_dXp.vmult(dXv, dXp);
62  dXv.update_ghost_values();
63  this->high_order_grid->volume_nodes = this->high_order_grid->initial_volume_nodes;
64  this->high_order_grid->volume_nodes += dXv;
65  this->high_order_grid->volume_nodes.update_ghost_values();
66  mesh_updated = true;
67  return mesh_updated;
68 }
69 
70 template<int dim>
72 {
73  ffd.output_ffd_vtu(iteration_no);
74 }
75 
76 template<int dim>
78 {
80 }
81 
83 } // PHiLiP namespace
void compute_dXv_dXp(MatrixType &dXv_dXp) const override
Computes the derivative of volume nodes w.r.t. FFD design parameters. Overrides the virtual function ...
void output_design_variables(const unsigned int iteration_no) const override
Outputs design variables of FFD.
bool has_design_variable_been_updated(const VectorType &current_design_var, const VectorType &updated_design_var) const
Checks if the design variable has changed.
VectorType initial_ffd_des_var
Initial design variable. Value is set in initialize_design_variables().
Files for the baseline physics.
Definition: ADTypes.hpp:10
FFD design parameterization. Holds an object of FreeFormDeformation and uses it to update the mesh wh...
Free form deformation class from Sederberg 1986.
dealii::TrilinosWrappers::SparseMatrix MatrixType
Alias for dealii::TrilinosWrappers::SparseMatrix.
Abstract class for design parameterization. Objective function and the constraints take this class&#39;s ...
unsigned int get_number_of_design_variables() const override
Returns the number of FFD design variables.
FreeFormDeformationParameterization(std::shared_ptr< HighOrderGrid< dim, double >> _high_order_grid, const FreeFormDeformation< dim > &_ffd, std::vector< std::pair< unsigned int, unsigned int > > &_ffd_design_variables_indices_dim)
Constructor.
bool update_mesh_from_design_variables(const MatrixType &dXv_dXp, const VectorType &ffd_des_var) override
Checks if the design variables have changed and updates volume nodes based on the parameterization...
const std::vector< std::pair< unsigned int, unsigned int > > ffd_design_variables_indices_dim
List of FFD design variables and axes.
FreeFormDeformation< dim > ffd
Free-form deformation used to parametrize the geometry.
void initialize_design_variables(VectorType &ffd_des_var) override
Initializes FFD design variables and set locally owned and ghost indices. Overrides the virtual funct...
std::shared_ptr< HighOrderGrid< dim, double > > high_order_grid
Pointer to high order grid.
dealii::LinearAlgebra::distributed::Vector< double > VectorType
Alias for dealii&#39;s parallel distributed vector.