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

Go to the source code of this file.

Classes

class  DisjointNeighborTest
 

Functions

Number heat_exact (const Point &p, const Parameters &, const std::string &, const std::string &)
 
Number left_solution_fn (const Point &, const Parameters &, const std::string &, const std::string &)
 
Number right_solution_fn (const Point &, const Parameters &params, const std::string &, const std::string &)
 
void assemble_temperature_jump (EquationSystems &es, const std::string &)
 
 CPPUNIT_TEST_SUITE_REGISTRATION (DisjointNeighborTest)
 

Variables

static const Real b = 1.0
 
static const Real Cgap = 1.0
 
static const boundary_id_type left_id = 3
 
static const boundary_id_type right_id = 1
 
static const boundary_id_type interface_left_id = 5
 
static const boundary_id_type interface_right_id = 6
 
static const boundary_id_type interface1_left_id = 5
 
static const boundary_id_type interface1_right_id = 6
 
static const boundary_id_type interface2_left_id = 7
 
static const boundary_id_type interface2_right_id = 8
 
static const boundary_id_type interface3_left_id = 9
 
static const boundary_id_type interface3_right_id = 10
 
static const int Nx = 2
 
static const int Ny = 2
 

Function Documentation

◆ assemble_temperature_jump()

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

Definition at line 69 of file disjoint_neighbor_test.C.

71 {
72 const MeshBase &mesh = es.get_mesh();
74 const DofMap &dof_map = system.get_dof_map();
75 FEType fe_type = dof_map.variable_type(0);
76
77 // FE objects for volume and face integration
78 auto fe = FEBase::build(mesh.mesh_dimension(), fe_type);
79 auto fe_face_L = FEBase::build(mesh.mesh_dimension(), fe_type);
80 auto fe_face_R = FEBase::build(mesh.mesh_dimension(), fe_type);
81
82 // Quadrature rules
84 QGauss qface(mesh.mesh_dimension() - 1, fe_type.default_quadrature_order());
85 fe->attach_quadrature_rule(&qrule);
86 fe_face_L->attach_quadrature_rule(&qface);
87 fe_face_R->attach_quadrature_rule(&qface);
88
89 const auto &JxW_vol = fe->get_JxW();
90 const auto &dphi_vol = fe->get_dphi();
91 const auto &phi_L = fe_face_L->get_phi();
92 const auto &phi_R = fe_face_R->get_phi();
93 const auto &JxW_face = fe_face_L->get_JxW();
94
97 std::vector<dof_id_type> dof_indices;
98
99 const BoundaryInfo &boundary = mesh.get_boundary_info();
100 const double conductance = Cgap * b; // interface conductance
101
102 for (const Elem *elem : mesh.active_local_element_ptr_range())
103 {
104 dof_map.dof_indices(elem, dof_indices);
105 const unsigned int n_dofs = dof_indices.size();
106
107 Ke.resize(n_dofs, n_dofs);
108 Fe.resize(n_dofs);
109 Ke.zero();
110 Fe.zero();
111
112 // --- Volume contribution ---
113 fe->reinit(elem);
114 for (unsigned int qp = 0; qp < qrule.n_points(); qp++)
115 for (unsigned int i = 0; i < n_dofs; i++)
116 for (unsigned int j = 0; j < n_dofs; j++)
117 Ke(i, j) += conductance * JxW_vol[qp] * (dphi_vol[i][qp] * dphi_vol[j][qp]);
118
119 // --- Left-side interface ---
120 unsigned int side = boundary.side_with_boundary_id(elem, interface_left_id);
121 if (side != libMesh::invalid_uint)
122 {
123 fe_face_L->reinit(elem, side);
124 const Elem *neighbor = elem->neighbor_ptr(side);
125 libmesh_assert(neighbor);
126 unsigned int n_side = neighbor->which_neighbor_am_i(elem);
127 fe_face_R->reinit(neighbor, n_side);
128
129 std::vector<dof_id_type> dofs_L, dofs_R;
130 dof_map.dof_indices(elem, dofs_L);
131 dof_map.dof_indices(neighbor, dofs_R);
132
133 DenseMatrix<Number> Ke_ll(n_dofs, n_dofs);
134 DenseMatrix<Number> Ke_lr(n_dofs, dofs_R.size());
135
136 for (unsigned int qp = 0; qp < qface.n_points(); qp++)
137 {
138 for (unsigned int i = 0; i < n_dofs; i++)
139 for (unsigned int j = 0; j < n_dofs; j++)
140 Ke_ll(i, j) += Cgap * phi_L[i][qp] * phi_L[j][qp] * JxW_face[qp];
141
142 for (unsigned int i = 0; i < n_dofs; i++)
143 for (unsigned int j = 0; j < dofs_R.size(); j++)
144 Ke_lr(i, j) += -Cgap * phi_L[i][qp] * phi_R[j][qp] * JxW_face[qp];
145 }
146
147 Ke += Ke_ll;
148 system.matrix->add_matrix(Ke_lr, dofs_L, dofs_R);
149 }
150
151 // --- Right-side interface ---
152 side = boundary.side_with_boundary_id(elem, interface_right_id);
153 if (side != libMesh::invalid_uint)
154 {
155 fe_face_R->reinit(elem, side);
156 const Elem *neighbor = elem->neighbor_ptr(side);
157 libmesh_assert(neighbor);
158 unsigned int n_side = neighbor->which_neighbor_am_i(elem);
159 fe_face_L->reinit(neighbor, n_side);
160
161 std::vector<dof_id_type> dofs_R, dofs_L;
162 dof_map.dof_indices(elem, dofs_R);
163 dof_map.dof_indices(neighbor, dofs_L);
164
165 DenseMatrix<Number> Ke_rr(n_dofs, n_dofs);
166 DenseMatrix<Number> Ke_rl(n_dofs, dofs_L.size());
167
168 for (unsigned int qp = 0; qp < qface.n_points(); qp++)
169 {
170 for (unsigned int i = 0; i < n_dofs; i++)
171 for (unsigned int j = 0; j < n_dofs; j++)
172 Ke_rr(i, j) += Cgap * phi_R[i][qp] * phi_R[j][qp] * JxW_face[qp];
173
174 for (unsigned int i = 0; i < n_dofs; i++)
175 for (unsigned int j = 0; j < dofs_L.size(); j++)
176 Ke_rl(i, j) += -Cgap * phi_R[i][qp] * phi_L[j][qp] * JxW_face[qp];
177 }
178
179 Ke += Ke_rr;
180 system.matrix->add_matrix(Ke_rl, dofs_R, dofs_L);
181 }
182
183 // Apply constraints and add local contributions
184 dof_map.heterogenously_constrain_element_matrix_and_vector(Ke, Fe, dof_indices);
185 system.matrix->add_matrix(Ke, dof_indices);
186 system.rhs->add_vector(Fe, dof_indices);
187 }
188
189 system.matrix->close();
190 system.rhs->close();
191 }
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
unsigned int side_with_boundary_id(const Elem *const elem, const boundary_id_type boundary_id) const
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().
virtual void zero() override final
Sets all elements of the matrix to 0 and resets any decomposition flag which may have been previously...
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
virtual void zero() override final
Set every element in the vector to 0.
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
unsigned int which_neighbor_am_i(const Elem *e) const
This function tells you which neighbor e is.
Definition elem.h:2936
const Elem * neighbor_ptr(unsigned int i) const
Definition elem.h:2615
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
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
unsigned int mesh_dimension() const
Definition mesh_base.C:430
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].
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:2417
static const Real Cgap
static const boundary_id_type interface_left_id
static const boundary_id_type interface_right_id
static const Real b
MeshBase & mesh
libmesh_assert(ctx)
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303

References libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), b, libMesh::FEGenericBase< OutputType >::build(), Cgap, libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::FEType::default_quadrature_order(), libMesh::MeshBase::get_boundary_info(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), interface_left_id, interface_right_id, libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::ImplicitSystem::matrix, mesh, libMesh::MeshBase::mesh_dimension(), libMesh::QBase::n_points(), libMesh::Elem::neighbor_ptr(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::ExplicitSystem::rhs, libMesh::BoundaryInfo::side_with_boundary_id(), libMesh::Elem::which_neighbor_am_i(), libMesh::DenseMatrix< T >::zero(), and libMesh::DenseVector< T >::zero().

Referenced by DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ CPPUNIT_TEST_SUITE_REGISTRATION()

CPPUNIT_TEST_SUITE_REGISTRATION ( DisjointNeighborTest  )

◆ heat_exact()

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

Definition at line 43 of file disjoint_neighbor_test.C.

47{
48 return (p(0) < 0.5) ? p(0) : p(0) + b;
49}

References b.

Referenced by DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ left_solution_fn()

Number left_solution_fn ( const Point ,
const Parameters ,
const std::string &  ,
const std::string &   
)

Definition at line 51 of file disjoint_neighbor_test.C.

55{
56 return 0.0;
57}

Referenced by DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

◆ right_solution_fn()

Number right_solution_fn ( const Point ,
const Parameters params,
const std::string &  ,
const std::string &   
)

Definition at line 59 of file disjoint_neighbor_test.C.

63{
64 const Real b = params.get<Real>("b");
65 return 1.0 + b;
66}
const T & get(std::string_view) const
Definition parameters.h:451
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References b, libMesh::Parameters::get(), and libMesh::Real.

Referenced by DisjointNeighborTest::testTempJump(), and DisjointNeighborTest::testTempJumpRefine().

Variable Documentation

◆ b

const Real b = 1.0
static

Definition at line 24 of file disjoint_neighbor_test.C.

Referenced by libMesh::DenseMatrix< T >::_cholesky_back_substitute(), libMesh::DenseMatrix< T >::_lu_back_substitute(), libMesh::DenseMatrix< T >::_lu_back_substitute_lapack(), assemble_elasticity(), assemble_shell(), assemble_temperature_jump(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::System::boundary_project_solution(), libMesh::System::boundary_project_solution(), libMesh::System::boundary_project_vector(), libMesh::System::boundary_project_vector(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), NonlinearNeoHookeCurrentConfig::calculate_stress(), libMesh::ExodusII_IO_Helper::check_existing_vars(), libMesh::DenseMatrix< T >::cholesky_solve(), libMesh::DistributedVector< T >::close(), libMesh::VariationalSmootherConstraint::constrain_node_to_line(), ContainsPointTest::containsPointTri3Helper(), libMesh::cross_norm(), libMesh::cross_norm_sq(), DMCreateDomainDecomposition_libMesh(), DMlibMeshCreateDomainDecompositionDM(), libMesh::QGauss::dunavant_rule2(), libMesh::VariationalSmootherSystem::element_time_derivative(), libMesh::ThreadBufferedSyncbuf::emit_from_thread_local_buffer(), libMesh::DofMap::get_variable_array(), libMesh::Edge3::has_invertible_map(), libMesh::Edge4::has_invertible_map(), libMesh::Utility::hashword(), libMesh::Utility::hashword(), libMesh::Utility::hashword2(), heat_exact(), libMesh::QGauss::init_2D(), libMesh::QGauss::init_3D(), libMesh::TensorTools::inner_product(), libMesh::TensorTools::inner_product(), libMesh::TensorTools::inner_product(), libMesh::TensorTools::inner_product(), libMesh::Poly2TriTriangulator::insert_refinement_points(), libMesh::TypeNTensor< N, T >::int_pow(), libMesh::intersect_constraints(), libMesh::TypeTensor< T >::inverse(), libMesh::QGauss::keast_rule(), libMesh::Parallel::Histogram< KeyType, IdxType >::make_histogram(), libMesh::PetscVector< T >::map_global_to_local_index(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::PeriodicBoundaries::neighbor(), std::plus< boost::multiprecision::float128 >::operator()(), std::multiplies< boost::multiprecision::float128 >::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::CompareDofObjectsByID::operator()(), libMesh::CompareDofObjectsByPIDAndThenID::operator()(), libMesh::CompareElemIdsByLevel::operator()(), libMesh::Utility::CompareUnderlying::operator()(), libMesh::Utility::CompareUnderlying::operator()(), libMesh::Utility::CompareUnderlying::operator()(), libMesh::Utility::ReverseBytes::operator()(), libMesh::operator*(), libMesh::DenseMatrix< T >::outer_product(), libMesh::outer_product(), libMesh::outer_product(), libMesh::outer_product(), libMesh::RadialBasisInterpolation< KDDim, RBF >::prepare_for_use(), libMesh::Face::quasicircumcenter(), right_solution_fn(), libMesh::VTKIO::set_compression(), set_system_parameters(), libMesh::SIGN(), libMesh::TypeTensor< T >::solve(), libMesh::UnstructuredMesh::stitching_helper(), AllTriTest::test_helper_c0polyhedron(), ContainsPointTest::testContainsPointTri3(), InfFERadialTest::testInfQuants(), DenseMatrixTest::testOuterProduct(), TypeTensorTest::testOuterProduct(), DisjointNeighborTest::testPreserveDisjointNeighborPairsAfterStitch(), DisjointNeighborTest::testStitchCrossMesh(), DisjointNeighborTest::testTempJump(), DisjointNeighborTest::testTempJumpRefine(), MeshSmootherTest::testVariationalSmoother(), triangulate_domain(), libMesh::triple_product(), libMesh::Tet4::volume(), and libMesh::Edge3::volume().

◆ Cgap

const Real Cgap = 1.0
static

Definition at line 25 of file disjoint_neighbor_test.C.

Referenced by assemble_temperature_jump().

◆ interface1_left_id

const boundary_id_type interface1_left_id = 5
static

◆ interface1_right_id

const boundary_id_type interface1_right_id = 6
static

◆ interface2_left_id

const boundary_id_type interface2_left_id = 7
static

◆ interface2_right_id

const boundary_id_type interface2_right_id = 8
static

◆ interface3_left_id

const boundary_id_type interface3_left_id = 9
static

◆ interface3_right_id

const boundary_id_type interface3_right_id = 10
static

◆ interface_left_id

const boundary_id_type interface_left_id = 5
static

◆ interface_right_id

const boundary_id_type interface_right_id = 6
static

◆ left_id

const boundary_id_type left_id = 3
static

◆ Nx

const int Nx = 2
static

◆ Ny

const int Ny = 2
static

◆ right_id

const boundary_id_type right_id = 1
static