14 #include <stk_mesh/base/Selector.hpp> 15 #include <stk_mesh/base/Bucket.hpp> 16 #include <stk_mesh/base/MetaData.hpp> 17 #include <stk_mesh/base/BulkData.hpp> 18 #include <stk_mesh/base/Types.hpp> 24 : m_mesh_meta_data(0), m_op()
31 : m_mesh_meta_data( &
MetaData::get(p) ) , m_op()
38 m_op.insert( m_op.begin(), OpType( 0, 0, m_op.size()+1 ) );
44 bool singlePart = (m_op.size() == 1);
45 bool fullCompoundPart = (m_op[0].m_count == m_op.size());
47 if ( !(singlePart || fullCompoundPart) ) {
59 std::pair<const unsigned *, const unsigned *> part_ords(&part_ord, &part_ord+1);
60 return apply(part_ords, PartOrdLess());
78 if (m_mesh_meta_data == 0) {
79 m_mesh_meta_data = B.m_mesh_meta_data;
82 m_op.insert( m_op.end() , B.m_op.begin() , B.m_op.end() );
89 if (m_mesh_meta_data == 0) {
90 m_mesh_meta_data = B.m_mesh_meta_data;
95 const size_t original_size = m_op.size();
97 if ( 1 == original_size &&
98 m_op.front().m_count == 1 &&
99 m_op.front().m_unary == 0 ) {
104 else if ( m_op.front().m_count == original_size &&
105 m_op.front().m_unary != 0 ) {
118 m_op.front().m_count = m_op.size();
125 const unsigned finalSize = 1 + m_op.size() + notB.m_op.size();
133 OpType( 0 , 1 , finalSize ) );
147 Selector operator & (
const Part & A ,
const Selector & B )
154 Selector operator & (
const Selector & A,
const Part & B )
161 Selector operator & (
const Selector & A,
const Selector & B )
209 out << selector.printExpression(selector.m_op.begin(),selector.m_op.end());
213 std::string Selector::printExpression(
214 const std::vector<OpType>::const_iterator start,
215 const std::vector<OpType>::const_iterator finish
218 std::ostringstream outS;
220 std::vector<OpType>::const_iterator start_it = start;
221 std::vector<OpType>::const_iterator finish_it = finish;
223 const OpType & op = *start_it;
224 if (op.m_count > 0) {
225 if (op.m_unary != 0) {
229 if (op.m_count == 1) {
233 finish_it = start_it;
234 for (
int i=0 ; i < op.m_count ; ++i) {
238 outS << printExpression(start_it,finish_it) <<
")";
239 start_it = finish_it;
244 if (m_mesh_meta_data != NULL) {
245 Part & part = m_mesh_meta_data->
get_part(op.m_part_id);
246 if (op.m_unary != 0) {
253 if (start_it != finish) {
254 outS <<
" AND " << printExpression(start_it,finish);
263 if (union_part_vector.size() > 0) {
264 selector = *union_part_vector[0];
265 for (
unsigned i = 1 ; i < union_part_vector.size() ; ++i) {
266 selector |= *union_part_vector[i];
276 if (intersection_part_vector.size() > 0) {
277 selector = *intersection_part_vector[0];
278 for (
unsigned i = 1 ; i < intersection_part_vector.size() ; ++i) {
279 selector &= *intersection_part_vector[i];
288 const MetaData& meta = MetaData::get(field);
289 const FieldRestrictionVector& rvec = field.restrictions();
291 for(
size_t i=0; i<rvec.size(); ++i) {
292 selector |= meta.
get_part(rvec[i].part_ordinal());
295 const FieldRestrictionVector& sel_rvec = field.selector_restrictions();
296 for(
size_t i=0; i<sel_rvec.size(); ++i) {
297 selector |= sel_rvec[i].selector();
Field base class with an anonymous data type and anonymous multi-dimension.
Selector & operator&=(const Selector &selector)
Intersection: this = this INTERSECT ( expression )
Selector & complement()
Complement: this = !(this) Postcondition: this is a compound expression.
Bucket & bucket() const
The bucket which holds this mesh entity's field data.
This is a class for selecting buckets based on a set of meshparts and set logic.
std::pair< const unsigned *, const unsigned * > superset_part_ordinals() const
Selector()
A default Selector selects nothing.
An application-defined subset of a problem domain.
std::ostream & operator<<(std::ostream &s, const Bucket &k)
Print the part names for which this bucket is a subset.
const std::string & name() const
Application-defined text name of this part.
unsigned mesh_meta_data_ordinal() const
Internally generated ordinal of this part that is unique within the owning meta data manager...
Selector & operator|=(const Selector &selector)
Union: this = this UNION ( expression )
A fundamental unit within the discretization of a problem domain, including but not limited to nodes...
bool apply(const std::pair< PartIterator, PartIterator > &part_range, Compare comp) const
Is the intersection of the 'part_ords' parts a member of the set defined by the selector expression...
void compoundAll()
Turn the entire expression into a compound.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
A container for the field data of a homogeneous collection of entities.
bool operator()(const Part &part) const
Is this part a member of the set defined by the selector expression.