27 #include "libmesh/mesh_base.h" 28 #include "libmesh/node.h" 29 #include "libmesh/numeric_vector.h" 35 const std::set<unsigned int>& dv_dof_ids):
36 _level_set_system (sys),
38 _level_set_fe_size (0.),
39 _dv_dof_ids (dv_dof_ids) {
41 libmesh_assert_greater(radius, 0.);
54 libMesh::NumericVector<Real>& output)
const {
56 libmesh_assert_equal_to(input.size(),
_filter_map.size());
57 libmesh_assert_equal_to(output.size(),
_filter_map.size());
61 std::vector<Real> input_vals(input.size(), 0.);
62 input.localize(input_vals);
64 std::map<unsigned int, std::vector<std::pair<unsigned int, Real>>>::const_iterator
68 for ( ; map_it != map_end; map_it++) {
70 std::vector<std::pair<unsigned int, Real>>::const_iterator
71 vec_it = map_it->second.begin(),
72 vec_end = map_it->second.end();
74 for ( ; vec_it != vec_end; vec_it++) {
75 if (map_it->first >= input.first_local_index() &&
76 map_it->first < input.last_local_index()) {
79 output.add(map_it->first, input_vals[vec_it->first] * vec_it->second);
81 output.set(map_it->first, input_vals[map_it->first]);
94 std::vector<Real>& output)
const {
96 libmesh_assert_equal_to(input.size(),
_filter_map.size());
97 libmesh_assert_equal_to(output.size(),
_filter_map.size());
99 std::fill(output.begin(), output.end(), 0.);
101 std::map<unsigned int, std::vector<std::pair<unsigned int, Real>>>::const_iterator
105 for ( ; map_it != map_end; map_it++) {
107 std::vector<std::pair<unsigned int, Real>>::const_iterator
108 vec_it = map_it->second.begin(),
109 vec_end = map_it->second.end();
111 for ( ; vec_it != vec_end; vec_it++) {
113 output[map_it->first] += input[vec_it->first] * vec_it->second;
115 output[map_it->first] += input[map_it->first];
124 const libMesh::Node& level_set_node)
const {
133 for (
unsigned int i=0; i<elem.n_nodes(); i++) {
135 pt -= level_set_node;
159 libmesh_assert(mesh.is_replicated());
162 libMesh::MeshBase::const_node_iterator
163 node_it_1 = mesh.nodes_begin(),
164 node_it_2 = mesh.nodes_begin(),
165 node_end = mesh.nodes_end();
178 for ( ; node_it_1 != node_end; node_it_1++) {
182 node_it_2 = mesh.nodes_begin();
185 for ( ; node_it_2 != node_end; node_it_2++) {
188 d = (**node_it_1) - (**node_it_2);
201 libmesh_assert_greater(sum, 0.);
205 std::vector<std::pair<unsigned int, Real>>& vec =
_filter_map[dof_1];
206 for (
unsigned int i=0; i<vec.size(); i++) {
208 vec[i].second /= sum;
209 libmesh_assert_less_equal(vec[i].second, 1.);
214 libMesh::MeshBase::const_element_iterator
215 e_it = mesh.elements_begin(),
216 e_end = mesh.elements_end();
218 for ( ; e_it != e_end; e_it++) {
219 const libMesh::Elem* e = *e_it;
231 o <<
"Filter radius: " <<
_radius << std::endl;
234 << std::setw(20) <<
"Filtered ID" 235 << std::setw(20) <<
"Dependent Vars" << std::endl;
237 std::map<unsigned int, std::vector<std::pair<unsigned int, Real>>>::const_iterator
241 for ( ; map_it != map_end; map_it++) {
244 << std::setw(20) << map_it->first;
246 std::vector<std::pair<unsigned int, Real>>::const_iterator
247 vec_it = map_it->second.begin(),
248 vec_end = map_it->second.end();
250 for ( ; vec_it != vec_end; vec_it++) {
254 <<
" : " << std::setw(8) << vec_it->first
255 <<
" (" << std::setw(8) << vec_it->second <<
" )";
257 libMesh::out <<
" : " << map_it->first;
259 libMesh::out << std::endl;
virtual void print(std::ostream &o) const
prints the filter data.
libMesh::System & _level_set_system
system on which the level set discrete function is defined
std::map< unsigned int, std::vector< std::pair< unsigned int, Real > > > _filter_map
Algebraic relation between filtered level set values and the design variables .
bool if_elem_in_domain_of_influence(const libMesh::Elem &elem, const libMesh::Node &level_set_node) const
function identifies if the given element is within the domain of influence of this specified level se...
Real _level_set_fe_size
largest element size in the level set mesh
const std::set< unsigned int > & _dv_dof_ids
dof ids that are design variables.
Real _radius
radius of the filter.
void compute_filtered_values(const libMesh::NumericVector< Real > &input, libMesh::NumericVector< Real > &output) const
computes the filtered output from the provided input.
void _init()
initializes the algebraic data structures
FilterBase(libMesh::System &sys, const Real radius, const std::set< unsigned int > &dv_dof_ids)