42#include "libmesh/exodusII_io.h"
43#include "libmesh/libmesh.h"
44#include "libmesh/mesh.h"
45#include "libmesh/mesh_generation.h"
46#include "libmesh/linear_implicit_system.h"
47#include "libmesh/equation_systems.h"
48#include "libmesh/enum_xdr_mode.h"
49#include "libmesh/getpot.h"
50#include "libmesh/mesh_refinement.h"
53#include "libmesh/fe.h"
54#include "libmesh/inf_fe.h"
55#include "libmesh/inf_elem_builder.h"
58#include "libmesh/quadrature_gauss.h"
62#include "libmesh/sparse_matrix.h"
63#include "libmesh/numeric_vector.h"
64#include "libmesh/dense_matrix.h"
65#include "libmesh/dense_vector.h"
69#include "libmesh/dof_map.h"
72#include "libmesh/node.h"
75#include "libmesh/elem.h"
83 const std::string & system_name);
86int main (
int argc,
char ** argv)
92#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
93 libmesh_example_requires(
false,
"--enable-ifem");
97 libmesh_example_requires(3 <= LIBMESH_DIM,
"3D support");
104 GetPot input(argc, argv);
106 const unsigned int nx = input(
"nx", 4),
123#ifdef LIBMESH_HAVE_EXODUS_API
147 for (
auto & elem :
mesh.element_ptr_range())
148 if (elem->infinite())
149 elem->subdomain_id() = 1;
156#ifdef LIBMESH_HAVE_EXODUS_API
187 equation_systems.
get_system(
"Wave").add_variable(
"p", fe_type);
200 equation_systems.
init();
202#ifdef LIBMESH_ENABLE_AMR
204 const unsigned int nr = input(
"nr", 0);
209 equation_systems.
reinit();
227 equation_systems.
write (
"eqn_sys.dat",
WRITE);
240 const std::string & libmesh_dbg_var(system_name))
244 libmesh_assert_equal_to (system_name,
"Wave");
250#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
271 const FEType & fe_type = dof_map.variable_type(0);
285 fe->attach_quadrature_rule (&qrule);
292 inf_fe->attach_quadrature_rule (&qrule);
311 std::vector<dof_id_type> dof_indices;
319 for (
const auto & elem :
mesh.active_local_element_ptr_range())
325 dof_map.dof_indices (elem, dof_indices);
327 const unsigned int n_dofs =
328 cast_int<unsigned int>(dof_indices.size());
346 if (elem->infinite())
409 const std::vector<RealGradient> & dphase = cfe->
get_dphase();
422 Ke.
resize (n_dofs, n_dofs);
423 Ce.
resize (n_dofs, n_dofs);
424 Me.
resize (n_dofs, n_dofs);
435 for (
unsigned int qp=0; qp<max_qp; qp++)
441 const unsigned int n_sf =
459 for (
unsigned int i=0; i<n_sf; i++)
460 for (
unsigned int j=0; j<n_sf; j++)
465 (dweight[qp] * phi[i][qp]
467 dphi[i][qp] * weight[qp]
474 (dphase[qp] * dphi[j][qp])
475 * weight[qp] * phi[i][qp]
477 (dweight[qp] * dphase[qp])
478 * phi[i][qp] * phi[j][qp]
480 (dphi[i][qp] * dphase[qp])
481 * weight[qp] * phi[j][qp]
487 (1. - (dphase[qp] * dphase[qp]))
488 * phi[i][qp] * phi[j][qp] * weight[qp]
497 Ke.
add(1./speed , Ce);
498 Ke.
add(1./(speed*speed), Me);
502 dof_map.constrain_element_matrix(Ke, dof_indices);
509 for (
const auto & node :
mesh.local_node_ptr_range())
515 unsigned int dn = node->dof_number(0,0,0);
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().
std::enable_if< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
Adds factor times mat to this matrix.
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
This class handles the numbering of degrees of freedom on a mesh.
This is the EquationSystems class.
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
void write(std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
const MeshBase & get_mesh() const
Parameters parameters
Data structure holding arbitrary parameters.
virtual void init()
Initialize all the systems.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
const T_sys & get_system(std::string_view name) const
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
NumericVector< Number > * rhs
The system matrix.
virtual unsigned int n_quadrature_points() const
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)=0
This is at the core of this class.
FEType get_fe_type() const
virtual const std::vector< Real > & get_JxWxdecay_sq() const
This function is the variant of get_JxW() for InfFE.
This class forms the foundation from which generic finite elements may be derived.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
static std::unique_ptr< FEGenericBase > build_InfFE(const unsigned int dim, const FEType &type)
Builds a specific infinite element type.
const std::vector< OutputGradient > & get_dphase() const
virtual const std::vector< Real > & get_Sobolev_weightxR_sq() const
virtual const std::vector< std::vector< OutputGradient > > & get_dphi_over_decayxR() const
virtual const std::vector< std::vector< OutputShape > > & get_phi_over_decayxR() const
virtual const std::vector< RealGradient > & get_Sobolev_dweightxR_sq() const
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
const SparseMatrix< Number > & get_system_matrix() const
This class is used to build infinite elements on top of an existing mesh.
const Point build_inf_elem(const bool be_verbose=false)
Build infinite elements atop a volume-based mesh, determine origin automatically.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
This is the MeshBase class.
unsigned int mesh_dimension() const
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true)=0
Locate element face (edge in 2D) neighbors.
Implements (adaptive) mesh refinement algorithms for a MeshBase.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
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].
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
T & set(const std::string &)
const T & get(std::string_view) const
This class implements specific orders of Gauss quadrature.
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
void assemble_wave(EquationSystems &es, const std::string &system_name)
The libMesh namespace provides an interface to certain functionality in the library.
void libmesh_ignore(const Args &...)
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real