libMesh
Public Member Functions | Private Attributes | List of all members
DofObjectTest< DerivedClass > Class Template Reference

#include <dof_object_test.h>

Public Member Functions

void setUp (DerivedClass *derived_instance)
 
void testSetId ()
 
void testValidId ()
 
void testInvalidateId ()
 
void testSetProcId ()
 
void testValidProcId ()
 
void testInvalidateProcId ()
 
void testSetNSystems ()
 
void testSetNVariableGroups ()
 
void testManualDofCalculation ()
 
void testJensEftangBug ()
 

Private Attributes

DerivedClass * instance
 

Detailed Description

template<class DerivedClass>
class DofObjectTest< DerivedClass >

Definition at line 22 of file dof_object_test.h.

Member Function Documentation

template<class DerivedClass>
void DofObjectTest< DerivedClass >::setUp ( DerivedClass *  derived_instance)

Definition at line 28 of file dof_object_test.h.

Referenced by NodeTest::setUp().

29  {
30  instance=derived_instance;
31  }
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testInvalidateId ( )

Definition at line 52 of file dof_object_test.h.

53  {
54  DofObject aobject(*instance);
55 
56  aobject.set_id(1);
57  aobject.invalidate_id();
58 
59  CPPUNIT_ASSERT( !aobject.valid_id() );
60  }
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testInvalidateProcId ( )

Definition at line 81 of file dof_object_test.h.

82  {
83  DofObject aobject(*instance);
84 
85  aobject.processor_id(libMesh::global_processor_id());
86  aobject.invalidate_processor_id();
87 
88  CPPUNIT_ASSERT( !aobject.valid_processor_id() );
89  }
processor_id_type global_processor_id()
Definition: libmesh_base.h:114
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testJensEftangBug ( )

Definition at line 167 of file dof_object_test.h.

168  {
169  // For more information on this bug, see the following email thread:
170  // https://sourceforge.net/p/libmesh/mailman/libmesh-users/thread/50C8EE7C.8090405@gmail.com/
171  DofObject aobject(*instance);
172  dof_id_type buf0[] = {2, 8, 257, 0, 257, 96, 257, 192, 257, 0};
173  aobject.set_buffer(std::vector<dof_id_type>(buf0, buf0+10));
174 
175  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(0,0,0), static_cast<dof_id_type>( 0));
176  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(0,1,0), static_cast<dof_id_type>( 96));
177  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(0,2,0), static_cast<dof_id_type>(192));
178  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(1,0,0), static_cast<dof_id_type>( 0));
179 
180  dof_id_type buf1[] = {2, 8, 257, 1, 257, 97, 257, 193, 257, 1};
181  aobject.set_buffer(std::vector<dof_id_type>(buf1, buf1+10));
182 
183  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(0,0,0), static_cast<dof_id_type>( 1));
184  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(0,1,0), static_cast<dof_id_type>( 97));
185  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(0,2,0), static_cast<dof_id_type>(193));
186  CPPUNIT_ASSERT_EQUAL (aobject.dof_number(1,0,0), static_cast<dof_id_type>( 1));
187  }
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
uint8_t dof_id_type
Definition: id_types.h:64
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testManualDofCalculation ( )

Definition at line 125 of file dof_object_test.h.

126  {
127  DofObject aobject(*instance);
128 
129  aobject.set_n_systems (2);
130 
131  std::vector<unsigned int> nvpg;
132 
133  nvpg.push_back(2);
134  nvpg.push_back(3);
135 
136  aobject.set_n_vars_per_group (0, nvpg);
137  aobject.set_n_vars_per_group (1, nvpg);
138 
139  aobject.set_n_comp_group (0, 0, 1);
140  aobject.set_n_comp_group (0, 1, 3);
141 
142  aobject.set_n_comp_group (1, 0, 2);
143  aobject.set_n_comp_group (1, 1, 1);
144 
145  aobject.set_vg_dof_base(0, 0, 0);
146  aobject.set_vg_dof_base(0, 1, 120);
147 
148  aobject.set_vg_dof_base(1, 0, 20);
149  aobject.set_vg_dof_base(1, 1, 220);
150 
151  // Make sure the first dof is sane
152  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(0), aobject.dof_number(0, 0, 0));
153 
154  // Check that we can manually index dofs of variables based on the first dof in a variable group
155  // Using: id = base + var_in_vg*ncomp + comp
156  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(aobject.vg_dof_base(0, 0) + 1*1 + 0), aobject.dof_number(0, 1, 0));
157 
158  // Another Check that we can manually index dofs of variables based on the first dof in a variable group
159  // Using: id = base + var_in_vg*ncomp + comp
160  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(aobject.vg_dof_base(0, 1) + 2*3 + 2), aobject.dof_number(0, 4, 2));
161 
162  // One More Check that we can manually index dofs of variables based on the first dof in a variable group
163  // Using: id = base + var_in_vg*ncomp + comp
164  CPPUNIT_ASSERT_EQUAL(static_cast<dof_id_type>(aobject.vg_dof_base(1, 1) + 0*3 + 0), aobject.dof_number(1, 2, 0));
165  }
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testSetId ( )

Definition at line 33 of file dof_object_test.h.

34  {
35  DofObject aobject(*instance);
36 
37  aobject.set_id(1);
38  CPPUNIT_ASSERT_EQUAL( static_cast<dof_id_type>(1) , aobject.id() );
39  }
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testSetNSystems ( )

Definition at line 91 of file dof_object_test.h.

92  {
93  DofObject aobject(*instance);
94 
95  aobject.set_n_systems (10);
96 
97  CPPUNIT_ASSERT_EQUAL( (unsigned int) 10, aobject.n_systems() );
98  }
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testSetNVariableGroups ( )

Definition at line 100 of file dof_object_test.h.

101  {
102  DofObject aobject(*instance);
103 
104  aobject.set_n_systems (2);
105 
106  std::vector<unsigned int> nvpg;
107 
108  nvpg.push_back(10);
109  nvpg.push_back(20);
110  nvpg.push_back(30);
111 
112  aobject.set_n_vars_per_group (0, nvpg);
113  aobject.set_n_vars_per_group (1, nvpg);
114 
115  for (unsigned int s=0; s<2; s++)
116  {
117  CPPUNIT_ASSERT_EQUAL( (unsigned int) 60, aobject.n_vars(s) );
118  CPPUNIT_ASSERT_EQUAL( (unsigned int) 3, aobject.n_var_groups(s) );
119 
120  for (unsigned int vg=0; vg<3; vg++)
121  CPPUNIT_ASSERT_EQUAL( nvpg[vg], aobject.n_vars(s,vg) );
122  }
123  }
const char * s
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testSetProcId ( )

Definition at line 62 of file dof_object_test.h.

63  {
64  DofObject aobject(*instance);
65 
66  aobject.processor_id(libMesh::global_processor_id());
67  CPPUNIT_ASSERT_EQUAL( (processor_id_type)libMesh::global_processor_id() , aobject.processor_id() );
68  }
uint8_t processor_id_type
Definition: id_types.h:99
processor_id_type global_processor_id()
Definition: libmesh_base.h:114
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testValidId ( )

Definition at line 41 of file dof_object_test.h.

42  {
43  DofObject aobject(*instance);
44 
45  aobject.set_id(1);
46  CPPUNIT_ASSERT( aobject.valid_id() );
47 
48  aobject.set_id(DofObject::invalid_id);
49  CPPUNIT_ASSERT( !aobject.valid_id() );
50  }
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance
template<class DerivedClass>
void DofObjectTest< DerivedClass >::testValidProcId ( )

Definition at line 70 of file dof_object_test.h.

71  {
72  DofObject aobject(*instance);
73 
74  aobject.processor_id(libMesh::global_processor_id());
75  CPPUNIT_ASSERT(aobject.valid_processor_id());
76 
77  aobject.processor_id(DofObject::invalid_processor_id);
78  CPPUNIT_ASSERT(!aobject.valid_processor_id());
79  }
processor_id_type global_processor_id()
Definition: libmesh_base.h:114
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
DerivedClass * instance

Member Data Documentation

template<class DerivedClass>
DerivedClass* DofObjectTest< DerivedClass >::instance
private

Definition at line 25 of file dof_object_test.h.


The documentation for this class was generated from the following file: