Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_FieldPattern.cpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
12
13namespace panzer {
14
16
18 const panzer::FieldPattern& right)
19{
20 return left.equals(right);
21}
22
24 const panzer::FieldPattern& right)
25{
26 return !left.equals(right);
27}
28
30{
31 int count = 0;
32 int dim = getDimension();
33
34 // compute number of IDs
35 for(int i=0;i<dim+1;i++) {
36 for(int sc=0;sc<getSubcellCount(i);sc++)
37 count += getSubcellIndices(i,sc).size();
38 }
39
40 return count;
41}
42
43void FieldPattern::print(std::ostream & os) const
44{
45 int dim = getDimension()+1;
46 os << "FieldPattern: " << dim << " Subcell types" << std::endl;
47 for(int i=0;i<dim;i++) {
48 int subcells = getSubcellCount(i);
49 os << "FieldPattern: " << subcells << " subcells of type " << i << std::endl;
50
51 for(int j=0;j<subcells;j++) {
52 const std::vector<int> & indices = getSubcellIndices(i,j);
53 os << "FieldPattern: subcell " << j << " = [ ";
54 for(std::size_t k=0;k<indices.size();k++)
55 os << indices[k] << " ";
56 os << "]" << std::endl;
57 }
58 }
59}
60
62{
63 bool equal = true;
64
65 // test same dimension
66 std::size_t dim = getDimension();
67 equal &= (dim==(std::size_t) fp.getDimension());
68
69 // check sub cells
70 for(std::size_t d=0;d<dim;d++)
71 equal &= getSubcellCount(d)==fp.getSubcellCount(d);
72
73 return equal;
74}
75
77{
78 bool consistent = true;
79
80 std::size_t dim = getDimension();
81 for(std::size_t d=0;d<dim+1;d++) {
82 int numSC = getSubcellCount(d);
83 std::size_t sz = getSubcellIndices(d,0).size();
84 for(int i=1;i<numSC;i++) {
85 consistent &= (sz==getSubcellIndices(d,i).size());
86 }
87 }
88
89 return consistent;
90}
91
92bool FieldPattern::equals(const FieldPattern & fp) const
93{
94 // same geometry is required
95 if(not this->sameGeometry(fp))
96 return false;
97
98 // check to make sure subcell indices are equal
99 int dimension = this->getDimension();
100 for(int d=0;d<dimension+1;d++) {
101 for(int sc=0;sc<this->getSubcellCount(d);sc++) {
102 const std::vector<int> & myVector = this->getSubcellIndices(d,sc);
103 const std::vector<int> & argVector = fp.getSubcellIndices(d,sc);
104
105 // check size of vectors
106 if(myVector.size()!=argVector.size())
107 return false;
108
109 // check content of vectors
110 bool eq = std::equal(myVector.begin(),myVector.end(),argVector.begin());
111 if(not eq)
112 return false;
113 }
114 }
115
116 return true;
117}
118
119std::ostream & operator<<(std::ostream & os,const FieldPattern & fp)
120{
121 fp.print(os);
122 return os;
123}
124
125}
virtual ~FieldPattern()=0
Do nothing destructor.
virtual int getDimension() const =0
virtual void print(std::ostream &os) const
virtual int getSubcellCount(int dim) const =0
virtual int numberIds() const
virtual const std::vector< int > & getSubcellIndices(int dim, int cellIndex) const =0
virtual bool consistentSubcells() const
virtual bool equals(const FieldPattern &fp) const
virtual bool sameGeometry(const FieldPattern &fp) const
std::ostream & operator<<(std::ostream &os, const AssemblyEngineInArgs &in)
bool operator==(const panzer::BasisDescriptor &left, const panzer::BasisDescriptor &right)
bool operator!=(const panzer::FieldPattern &left, const panzer::FieldPattern &right)