1 #include "inner_vol_parameterization.hpp" 2 #include <deal.II/dofs/dof_tools.h> 3 #include <deal.II/lac/dynamic_sparsity_pattern.h> 4 #include <deal.II/lac/sparsity_tools.h> 20 unsigned int n_surf_nodes = this->
high_order_grid->surface_nodes.size();
23 dealii::LinearAlgebra::distributed::Vector<int> is_a_surface_node;
27 const dealii::IndexSet &volume_range = this->
high_order_grid->volume_nodes.get_partitioner()->locally_owned_range();
28 const dealii::IndexSet &surface_range = this->
high_order_grid->surface_nodes.get_partitioner()->locally_owned_range();
32 for(
unsigned int i_surf = 0; i_surf<n_surf_nodes; ++i_surf)
34 if(!(surface_range.is_element(i_surf)))
continue;
36 const unsigned int vol_index = this->
high_order_grid->surface_to_volume_indices(i_surf);
37 Assert(volume_range.is_element(vol_index),
38 dealii::ExcMessage(
"Surface index is in range, so vol index is expected to be in the range of this processor."));
39 is_a_surface_node(vol_index) = 1;
41 is_a_surface_node.update_ghost_values();
45 unsigned int n_elements_this_mpi = volume_range.n_elements() - surface_range.n_elements();
46 std::vector<unsigned int> n_elements_per_mpi(this->
n_mpi);
47 MPI_Allgather(&n_elements_this_mpi, 1, MPI_UNSIGNED, &(n_elements_per_mpi[0]), 1, MPI_UNSIGNED, this->
mpi_communicator);
50 unsigned int lower_index = 0, higher_index = 0;
51 for(
int i_mpi = 0; i_mpi < this->
mpi_rank; ++i_mpi)
53 lower_index += n_elements_per_mpi[i_mpi];
55 higher_index = lower_index + n_elements_this_mpi;
63 unsigned int count1 = lower_index;
64 for(
unsigned int i_vol = 0; i_vol < n_vol_nodes; ++i_vol)
66 if(!volume_range.is_element(i_vol))
continue;
68 if(is_a_surface_node(i_vol))
continue;
72 AssertDimension(count1, higher_index);
89 design_var.update_ghost_values();
96 const dealii::IndexSet &volume_range = this->
high_order_grid->volume_nodes.get_partitioner()->locally_owned_range();
97 const unsigned int n_vol_nodes = this->
high_order_grid->volume_nodes.size();
99 dealii::DynamicSparsityPattern dsp(n_vol_nodes,
n_inner_nodes, volume_range);
108 dealii::IndexSet locally_relevant_dofs;
109 dealii::DoFTools::extract_locally_relevant_dofs(this->
high_order_grid->dof_handler_grid, locally_relevant_dofs);
111 dealii::SparsityTools::distribute_sparsity_pattern(dsp, volume_range, this->
mpi_communicator, locally_relevant_dofs);
122 dXv_dXp.compress(dealii::VectorOperation::insert);
130 AssertDimension(dXv_dXp.n(), design_var.size());
135 if(!(design_variable_has_changed))
137 mesh_updated =
false;
144 dXv_dXp.vmult_add(this->
high_order_grid->volume_nodes, change_in_des_var);
int n_mpi
Total no. of processors.
InnerVolParameterization(std::shared_ptr< HighOrderGrid< dim, double >> _high_order_grid)
Constructor.
int mpi_rank
Processor# of current processor.
void compute_dXv_dXp(MatrixType &dXv_dXp) const override
Computes the derivative of volume nodes w.r.t. inner volume nodes. Overrides the virtual function in ...
void compute_inner_vol_index_to_vol_index()
Computes inner_vol_range IndexSet on each processor, along with n_inner_nodes and inner_vol_index_to_...
bool has_design_variable_been_updated(const VectorType ¤t_design_var, const VectorType &updated_design_var) const
Checks if the design variable has changed.
dealii::IndexSet inner_vol_range
Local indices of inner volume nodes.
Files for the baseline physics.
dealii::TrilinosWrappers::SparseMatrix MatrixType
Alias for dealii::TrilinosWrappers::SparseMatrix.
void initialize_design_variables(VectorType &design_var) override
Initializes design variables with inner volume nodes and set locally owned and ghost indices...
VectorType current_design_var
Current design variable. Stored to prevent recomputing if it is unchanged.
Abstract class for design parameterization. Objective function and the constraints take this class's ...
unsigned int n_inner_nodes
No. of inner volume nodes.
MPI_Comm mpi_communicator
Alias for MPI_COMM_WORLD.
std::shared_ptr< HighOrderGrid< dim, double > > high_order_grid
Pointer to high order grid.
dealii::LinearAlgebra::distributed::Vector< int > inner_vol_index_to_vol_index
Converts inner volume index to global index of volume nodes.
unsigned int get_number_of_design_variables() const override
Returns the number of design variables (i.e. no. of inner volume nodes).
dealii::LinearAlgebra::distributed::Vector< double > VectorType
Alias for dealii's parallel distributed vector.
bool update_mesh_from_design_variables(const MatrixType &dXv_dXp, const VectorType &design_var) override
Checks if the design variables have changed and updates inner volume nodes of high order grid...
Design parameterization w.r.t. inner volume nodes (i.e. volume nodes excluding those on the boundary)...