Go to the source code of this file.
◆ assemble_wave() [1/2]
void assemble_wave |
( |
EquationSystems & |
es, |
|
|
const std::string & |
libmesh_dbg_varsystem_name |
|
) |
| |
Definition at line 224 of file miscellaneous_ex1.C.
229 libmesh_assert_equal_to (system_name,
"Wave");
235 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
256 const FEType & fe_type = dof_map.variable_type(0);
261 std::unique_ptr<FEBase> fe (FEBase::build(
dim, fe_type));
264 std::unique_ptr<FEBase> inf_fe (FEBase::build_InfFE(
dim, fe_type));
270 fe->attach_quadrature_rule (&qrule);
277 inf_fe->attach_quadrature_rule (&qrule);
296 std::vector<dof_id_type> dof_indices;
307 dof_map.dof_indices (elem, dof_indices);
309 const unsigned int n_dofs =
310 cast_int<unsigned int>(dof_indices.size());
328 if (elem->infinite())
359 const std::vector<Real> & JxW = cfe->get_JxW();
362 const std::vector<std::vector<Real>> & phi = cfe->get_phi();
366 const std::vector<std::vector<RealGradient>> & dphi = cfe->get_dphi();
376 const std::vector<RealGradient> & dphase = cfe->get_dphase();
377 const std::vector<Real> &
weight = cfe->get_Sobolev_weight();
378 const std::vector<RealGradient> & dweight = cfe->get_Sobolev_dweight();
389 Ke.
resize (n_dofs, n_dofs);
390 Ce.
resize (n_dofs, n_dofs);
391 Me.
resize (n_dofs, n_dofs);
399 unsigned int max_qp = cfe->n_quadrature_points();
402 for (
unsigned int qp=0; qp<max_qp; qp++)
408 const unsigned int n_sf = cfe->n_shape_functions();
425 for (
unsigned int i=0; i<n_sf; i++)
426 for (
unsigned int j=0; j<n_sf; j++)
431 (dweight[qp] * phi[i][qp]
440 (dphase[qp] * dphi[j][qp])
443 (dweight[qp] * dphase[qp])
444 * phi[i][qp] * phi[j][qp]
446 (dphi[i][qp] * dphase[qp])
453 (1. - (dphase[qp] * dphase[qp]))
454 * phi[i][qp] * phi[j][qp] *
weight[qp]
463 Ke.
add(1./speed , Ce);
464 Ke.
add(1./(speed*speed), Me);
468 dof_map.constrain_element_matrix(Ke, dof_indices);
481 unsigned int dn = node->dof_number(0,0,0);
491 #endif //ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
References std::abs(), libMesh::MeshBase::active_local_element_ptr_range(), libMesh::DenseMatrix< T >::add(), libMesh::NumericVector< T >::add(), libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::FEGenericBase< OutputType >::build(), libMesh::FEGenericBase< OutputType >::build_InfFE(), dim, libMesh::Parameters::get(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::libmesh_ignore(), libMesh::MeshBase::local_node_ptr_range(), libMesh::ImplicitSystem::matrix, mesh, libMesh::MeshBase::mesh_dimension(), libMesh::EquationSystems::parameters, libMesh::Real, libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::ExplicitSystem::rhs, libMesh::SECOND, libMesh::TOLERANCE, and libMesh::MeshTools::weight().
◆ assemble_wave() [2/2]
void assemble_wave |
( |
EquationSystems & |
es, |
|
|
const std::string & |
system_name |
|
) |
| |
Definition at line 323 of file transient_ex2.C.
328 libmesh_assert_equal_to (system_name,
"Wave");
346 FEType fe_type = t_system.get_dof_map().variable_type(0);
372 std::unique_ptr<FEBase> fe (FEBase::build(
dim, fe_type));
378 fe->attach_quadrature_rule (&qrule);
381 const std::vector<Real> & JxW = fe->get_JxW();
384 const std::vector<std::vector<Real>> & phi = fe->get_phi();
388 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
393 const DofMap & dof_map = t_system.get_dof_map();
403 std::vector<dof_id_type> dof_indices;
429 const unsigned int n_dof_indices = dof_indices.size();
431 Ke.
resize (n_dof_indices, n_dof_indices);
432 Ce.
resize (n_dof_indices, n_dof_indices);
433 Me.
resize (n_dof_indices, n_dof_indices);
434 zero_matrix.
resize (n_dof_indices, n_dof_indices);
435 Fe.
resize (n_dof_indices);
440 for (
unsigned int qp=0; qp<qrule.n_points(); qp++)
445 for (std::size_t i=0; i<phi.size(); i++)
446 for (std::size_t j=0; j<phi.size(); j++)
448 Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
449 Me(i,j) += JxW[qp]*phi[i][qp]*phi[j][qp]
463 for (
auto side : elem->side_index_range())
469 std::unique_ptr<FEBase> fe_face (FEBase::build(
dim, fe_type));
478 fe_face->attach_quadrature_rule (&qface);
482 const std::vector<std::vector<Real>> & phi_face = fe_face->get_phi();
486 const std::vector<Real> & JxW_face = fe_face->get_JxW();
490 fe_face->reinit(elem, side);
494 const Real acc_n_value = 1.0;
497 for (
unsigned int qp=0; qp<qface.n_points(); qp++)
501 for (std::size_t i=0; i<phi_face.size(); i++)
503 Fe(i) += acc_n_value*rho
504 *phi_face[i][qp]*JxW_face[qp];
References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::FEGenericBase< OutputType >::build(), dim, libMesh::DofMap::dof_indices(), libMesh::Parameters::get(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::QBase::n_points(), libMesh::EquationSystems::parameters, libMesh::Real, libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), and libMesh::SECOND.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 84 of file miscellaneous_ex1.C.
90 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
91 libmesh_example_requires(
false,
"--enable-ifem");
95 libmesh_example_requires(3 <= LIBMESH_DIM,
"3D support");
98 libMesh::out <<
"Running ex6 with dim = 3" << std::endl << std::endl;
117 #ifdef LIBMESH_HAVE_EXODUS_API
137 builder.build_inf_elem(
true);
142 if (elem->infinite())
143 elem->subdomain_id() = 1;
150 #ifdef LIBMESH_HAVE_EXODUS_API
181 equation_systems.get_system(
"Wave").add_variable(
"p", fe_type);
185 equation_systems.get_system(
"Wave").attach_assemble_function (
assemble_wave);
190 equation_systems.parameters.set<
Real>(
"speed") = 1.;
191 equation_systems.parameters.set<
Real>(
"fluid density") = 1.;
194 equation_systems.init();
197 equation_systems.print_info();
200 equation_systems.get_system(
"Wave").solve();
212 equation_systems.write (
"eqn_sys.dat",
WRITE);
219 #endif // else part of ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
References libMesh::EquationSystems::add_system(), assemble_wave(), libMesh::MeshTools::Generation::build_cube(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::MeshBase::element_ptr_range(), libMesh::MeshBase::find_neighbors(), libMesh::FIRST, libMesh::EquationSystems::get_system(), libMesh::HEX8, libMesh::TriangleWrapper::init(), libMesh::EquationSystems::init(), mesh, libMesh::out, libMesh::EquationSystems::parameters, libMesh::EquationSystems::print_info(), libMesh::MeshBase::print_info(), libMesh::Real, libMesh::Parameters::set(), libMesh::WRITE, libMesh::ExodusII_IO::write(), and libMesh::EquationSystems::write().
virtual void add(const numeric_index_type i, const T value)=0
Adds value to each entry of the vector.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const MeshBase & get_mesh() const
NumericVector< Number > * rhs
The system matrix.
This class implements specific orders of Gauss quadrature.
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
This class contains a specific system class.
boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add(const T2 factor, const DenseMatrix< T3 > &mat)
Adds factor times mat to this matrix.
This class forms the foundation from which generic finite elements may be derived.
const T_sys & get_system(const std::string &name) const
static const Real TOLERANCE
void assemble_wave(EquationSystems &es, const std::string &system_name)
unsigned int mesh_dimension() const
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
void resize(const unsigned int new_m, const unsigned int new_n)
Resize the matrix.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
virtual SimpleRange< element_iterator > element_ptr_range()=0
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 is the MeshBase class.
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
void libmesh_ignore(const Args &...)
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
This class is used to build infinite elements on top of an existing mesh.
SparseMatrix< Number > * matrix
The system matrix.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
This is the EquationSystems class.
void resize(const unsigned int n)
Resize the vector.
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.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
This class handles the numbering of degrees of freedom on a mesh.
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the mesh.
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
const DofMap & get_dof_map() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
const T & get(const std::string &) const
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
Parameters parameters
Data structure holding arbitrary parameters.