libMesh
Loading...
Searching...
No Matches
Classes | Functions | Variables
periodic_bc_test.C File Reference

Go to the source code of this file.

Classes

struct  PeriodicQuadFunction
 
class  RowPartitioner
 
class  PeriodicBCTest
 

Functions

Number quadratic_solution (const Point &p, const Parameters &, const std::string &, const std::string &)
 
void periodic_bc_test_poisson (EquationSystems &es, const std::string &)
 
 CPPUNIT_TEST_SUITE_REGISTRATION (PeriodicBCTest)
 

Variables

const boundary_id_type top_id = 50
 
const boundary_id_type bottom_id = 60
 
const boundary_id_type side_id = 70
 

Function Documentation

◆ CPPUNIT_TEST_SUITE_REGISTRATION()

CPPUNIT_TEST_SUITE_REGISTRATION ( PeriodicBCTest  )

◆ periodic_bc_test_poisson()

void periodic_bc_test_poisson ( EquationSystems &  es,
const std::string &   
)

Definition at line 78 of file periodic_bc_test.C.

80{
81 const MeshBase& mesh = es.get_mesh();
83 const DofMap& dof_map = system.get_dof_map();
84
85 // Interior FE to integrate smooth part of poisson problem
86 FEType fe_type = dof_map.variable_type(0);
87 std::unique_ptr<FEBase> fe (FEBase::build(2, fe_type));
88 QGauss qrule (2, fe_type.default_quadrature_order());
89 fe->attach_quadrature_rule(&qrule);
90
91 const std::vector<Real> & JxW = fe->get_JxW();
92 const std::vector<std::vector<Real>> & phi = fe->get_phi();
93 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
94
95 // Face FE to integrate delta function part of forcing
96 std::unique_ptr<FEBase> fe_face (FEBase::build(2, fe_type));
97 QGauss qface (1, fe_type.default_quadrature_order());
98 fe_face->attach_quadrature_rule(&qface);
99
100 const std::vector<Real> & JxW_face = fe_face->get_JxW();
101 const std::vector<std::vector<Real>> & phi_face = fe_face->get_phi();
102 std::unique_ptr<const Elem> elem_side;
103
106
107 std::vector<dof_id_type> dof_indices;
108
109 for (const Elem * elem : mesh.active_local_element_ptr_range())
110 {
111 dof_map.dof_indices (elem, dof_indices);
112 const unsigned int n_dofs = dof_indices.size();
113
114 Ke.resize (n_dofs, n_dofs);
115 Fe.resize (n_dofs);
116
117 fe->reinit (elem);
118
119 // Integrate the poisson problem over the element interior, where we have
120 // a nice f=2 forcing function aside from the discontinuity
121 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
122 {
123 for (unsigned int i=0; i != n_dofs; i++)
124 {
125 for (unsigned int j=0; j != n_dofs; j++)
126 Ke(i,j) += -JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
127
128 Fe(i) += JxW[qp]*phi[i][qp]*2;
129 }
130 }
131
132 for(unsigned int s=0; s != elem->n_sides(); ++s)
133 {
134 elem->build_side_ptr(elem_side, s);
135 Point centroid = elem_side->vertex_average();
136 if (std::abs(centroid(1) - 1) < TOLERANCE)
137 {
138 fe_face->reinit(elem, s);
139
140 for (unsigned int qp=0; qp<qface.n_points(); qp++)
141 {
142 // delta function divided by 2 since we hit it from
143 // both sides
144 for (unsigned int i=0; i != n_dofs; i++)
145 Fe(i) += JxW_face[qp]*phi_face[i][qp]*(-4);
146 }
147 }
148 }
149
150 dof_map.heterogenously_constrain_element_matrix_and_vector(Ke, Fe, dof_indices);
151 system.matrix->add_matrix (Ke, dof_indices);
152 system.rhs->add_vector (Fe, dof_indices);
153 }
154
155 system.rhs->close();
156 system.matrix->close();
157}
Defines a dense matrix for use in Finite Element-type computations.
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
virtual unsigned int size() const override final
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
This is the base class from which all geometric element types are derived.
Definition elem.h:96
const MeshBase & get_mesh() const
const T_sys & get_system(std::string_view name) const
NumericVector< Number > * rhs
The system matrix.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
Order default_quadrature_order() const
Definition fe_type.h:415
SparseMatrix< Number > * matrix
The system matrix.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This is the MeshBase class.
Definition mesh_base.h:81
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i].
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
This class implements specific orders of Gauss quadrature.
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
const DofMap & get_dof_map() const
Definition system.h:2448
MeshBase & mesh
static constexpr Real TOLERANCE

References libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::FEType::default_quadrature_order(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::ImplicitSystem::matrix, mesh, libMesh::QBase::n_points(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::ExplicitSystem::rhs, libMesh::DenseVector< T >::size(), and libMesh::TOLERANCE.

Referenced by PeriodicBCTest::testPeriodicBC().

◆ quadratic_solution()

Number quadratic_solution ( const Point &  p,
const Parameters &  ,
const std::string &  ,
const std::string &   
)

Definition at line 27 of file periodic_bc_test.C.

31{
32 const Real & y = LIBMESH_DIM > 1 ? p(1) : 0;
33
34 // Discontinuity at y=1 from the forcing function there.
35 // Periodic on -3 < y < 2
36 return (y > 1) ? (y-3)*(y-3) : (y+1)*(y+1);
37}
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::Real.

Referenced by PeriodicQuadFunction::component(), PeriodicQuadFunction::operator()(), and PeriodicBCTest::testPeriodicBC().

Variable Documentation

◆ bottom_id

const boundary_id_type bottom_id = 60

◆ side_id

const boundary_id_type side_id = 70

◆ top_id

const boundary_id_type top_id = 50