libMesh
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
PeriodicBCTest Class Reference
Inheritance diagram for PeriodicBCTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (PeriodicBCTest)
 
 CPPUNIT_TEST (testPeriodicLagrange2)
 
 CPPUNIT_TEST_SUITE_END ()
 

Private Member Functions

void testPeriodicBC (FEType fe_type)
 
void testPeriodicLagrange2 ()
 

Detailed Description

Definition at line 161 of file periodic_bc_test.C.

Member Function Documentation

◆ CPPUNIT_TEST()

PeriodicBCTest::CPPUNIT_TEST ( testPeriodicLagrange2  )

◆ CPPUNIT_TEST_SUITE_END()

PeriodicBCTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

PeriodicBCTest::LIBMESH_CPPUNIT_TEST_SUITE ( PeriodicBCTest  )

◆ testPeriodicBC()

void PeriodicBCTest::testPeriodicBC ( FEType  fe_type)
inlineprivate

Definition at line 175 of file periodic_bc_test.C.

176 {
177 Mesh mesh(*TestCommWorld);
178 BoundaryInfo & boundary = mesh.get_boundary_info();
179
182 es.add_system<LinearImplicitSystem> ("PBCSys");
183
184 // We need to change around BCIDs and set up the periodic BC first
186
187 mesh.read("meshes/shark_tooth_tri6.xda.gz");
188
189 // Add some BCIDs on top and bottom for our periodic boundary
190 for (const Elem * elem : mesh.active_element_ptr_range())
191 {
192 for (unsigned int s=0; s != 3; ++s)
193 if (!elem->neighbor_ptr(s))
194 {
195 unsigned v2 = (s+1)%3;
196 // Left-running edges are on bottom, because this xda
197 // has a flipped mesh
198 if (elem->point(s)(0) - elem->point(v2)(0) < -.1)
199 boundary.add_side(elem, s, top_id);
200
201 // Right-running edges are on top
202 else if (elem->point(s)(0) - elem->point(v2)(0) > .1)
203 boundary.add_side(elem, s, bottom_id);
204
205 // Vertical edges are Dirichlet
206 else
207 boundary.add_side(elem, s, side_id);
208 }
209 }
210
211 PeriodicBoundary vert(RealVectorValue(0., 4.0));
212 vert.myboundary = bottom_id;
213 vert.pairedboundary = top_id;
215
216 // Okay, *now* the mesh knows to save periodic neighbors
219
220 const unsigned int u_var = sys.add_variable("u", fe_type);
222
223 std::set<boundary_id_type> side_bdy { side_id };
224 std::vector<unsigned int> all_vars (1, u_var);
226 DirichletBoundary exact_bc(side_bdy, all_vars, exact_val);
227 sys.get_dof_map().add_dirichlet_boundary(exact_bc);
228
229 es.init();
230
231 sys.solve();
232
233 ExodusII_IO(mesh).write_equation_systems("periodic.e", es);
234
235 Parameters params;
236
237 for (Real x = 0.1; x < 10; x += 0.2)
238 for (Real ya = -2.9; ya < 1; ya += 0.2)
239 {
240 // Integrate the sharktooth shape
241 const Real offset = 1-std::abs(std::fmod(x,2)-1);
242 const Real y = ya + offset;
243 Point p{x,y};
244 const Number exact = quadratic_solution(p,params,"","");
245 const Number approx = sys.point_value(0,p);
246 LIBMESH_ASSERT_NUMBERS_EQUAL(exact, approx,
248 }
249 }
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
void add_periodic_boundary(const PeriodicBoundaryBase &periodic_boundary)
Adds a copy of the specified periodic boundary to the system.
This is the base class from which all geometric element types are derived.
Definition elem.h:96
This is the EquationSystems class.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition exodusII_io.h:53
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
virtual void solve() override
Assembles & solves the linear system A*x=b.
void allow_remote_element_removal(bool allow)
If false is passed in then this mesh will no longer have remote elements deleted when being prepared ...
Definition mesh_base.h:1378
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
Definition mesh_base.C:824
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
The definition of a periodic boundary.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition system.C:2219
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in assembling the system matrix and RHS.
Definition system.C:1959
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition system.C:1344
const DofMap & get_dof_map() const
Definition system.h:2417
Wrap a libMesh-style function pointer into a FunctionBase object.
MeshBase & mesh
VectorValue< Real > RealVectorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Number quadratic_solution(const Point &p, const Parameters &, const std::string &, const std::string &)
void periodic_bc_test_poisson(EquationSystems &es, const std::string &)
const boundary_id_type side_id
const boundary_id_type top_id
const boundary_id_type bottom_id

References libMesh::DofMap::add_dirichlet_boundary(), libMesh::DofMap::add_periodic_boundary(), libMesh::BoundaryInfo::add_side(), libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), libMesh::MeshBase::allow_remote_element_removal(), libMesh::System::attach_assemble_function(), bottom_id, libMesh::MeshBase::get_boundary_info(), libMesh::System::get_dof_map(), libMesh::EquationSystems::init(), mesh, libMesh::PeriodicBoundaryBase::myboundary, libMesh::PeriodicBoundaryBase::pairedboundary, periodic_bc_test_poisson(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), quadratic_solution(), libMesh::MeshBase::read(), libMesh::Real, side_id, libMesh::LinearImplicitSystem::solve(), TestCommWorld, libMesh::TOLERANCE, top_id, and libMesh::ExodusII_IO::write_equation_systems().

Referenced by testPeriodicLagrange2().

◆ testPeriodicLagrange2()

void PeriodicBCTest::testPeriodicLagrange2 ( )
inlineprivate

Definition at line 252 of file periodic_bc_test.C.

252{ LOG_UNIT_TEST; testPeriodicBC(FEType(SECOND, LAGRANGE)); }
void testPeriodicBC(FEType fe_type)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197

References libMesh::LAGRANGE, libMesh::SECOND, and testPeriodicBC().


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