Go to the source code of this file.
 | 
| void  | assemble_cd (EquationSystems &es, const std::string &system_name) | 
|   | 
| void  | init_cd (EquationSystems &es, const std::string &system_name) | 
|   | 
| Real  | exact_solution (const Real x, const Real y, const Real t) | 
|   | This is the exact solution that we are trying to obtain.  More...
  | 
|   | 
| Number  | exact_value (const Point &p, const Parameters ¶meters, const std::string &, const std::string &) | 
|   | 
| int  | main (int argc, char **argv) | 
|   | 
| void  | init_cd (EquationSystems &es, const std::string &libmesh_dbg_var(system_name)) | 
|   | 
| void  | assemble_cd (EquationSystems &es, const std::string &libmesh_dbg_var(system_name)) | 
|   | 
◆ assemble_cd() [1/2]
      
        
          | void assemble_cd  | 
          ( | 
          EquationSystems &  | 
          es,  | 
        
        
           | 
           | 
          const std::string &  | 
          libmesh_dbg_varsystem_name  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 487 of file adaptivity_ex2.C.
  492   libmesh_assert_equal_to (system_name, 
"Convection-Diffusion");
 
  506   FEType fe_type = system.variable_type(0);
 
  512   std::unique_ptr<FEBase> fe      (FEBase::build(
dim, fe_type));
 
  513   std::unique_ptr<FEBase> fe_face (FEBase::build(
dim, fe_type));
 
  517   QGauss qrule (
dim,   fe_type.default_quadrature_order());
 
  518   QGauss qface (
dim-1, fe_type.default_quadrature_order());
 
  521   fe->attach_quadrature_rule      (&qrule);
 
  522   fe_face->attach_quadrature_rule (&qface);
 
  527   const std::vector<Real> & JxW      = fe->get_JxW();
 
  528   const std::vector<Real> & JxW_face = fe_face->get_JxW();
 
  531   const std::vector<std::vector<Real>> & phi = fe->get_phi();
 
  532   const std::vector<std::vector<Real>> & psi = fe_face->get_phi();
 
  536   const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
 
  539   const std::vector<Point> & qface_points = fe_face->get_xyz();
 
  545   const DofMap & dof_map = system.get_dof_map();
 
  557   std::vector<dof_id_type> dof_indices;
 
  564   const Real diffusivity =
 
  588       const unsigned int n_dofs =
 
  589         cast_int<unsigned int>(dof_indices.size());
 
  590       libmesh_assert_equal_to (n_dofs, phi.size());
 
  598       Ke.
resize (n_dofs, n_dofs);
 
  608       for (
unsigned int qp=0; qp<qrule.n_points(); qp++)
 
  615           for (
unsigned int l=0; l != n_dofs; l++)
 
  617               u_old += phi[l][qp]*system.
old_solution (dof_indices[l]);
 
  626           for (
unsigned int i=0; i != n_dofs; i++)
 
  636                                         (grad_u_old*velocity)*phi[i][qp] +
 
  639                                         diffusivity*(grad_u_old*dphi[i][qp]))
 
  642               for (
unsigned int j=0; j != n_dofs; j++)
 
  647                                       phi[i][qp]*phi[j][qp] +
 
  650                                              (velocity*dphi[j][qp])*phi[i][qp] +
 
  652                                              diffusivity*(dphi[i][qp]*dphi[j][qp]))
 
  669         const Real penalty = 1.e10;
 
  674         for (
auto s : elem->side_index_range())
 
  675           if (elem->neighbor_ptr(s) == 
nullptr)
 
  677               fe_face->reinit(elem, s);
 
  679               libmesh_assert_equal_to (n_dofs, psi.size());
 
  681               for (
unsigned int qp=0; qp<qface.n_points(); qp++)
 
  688                   for (
unsigned int i=0; i != n_dofs; i++)
 
  689                     Fe(i) += penalty*JxW_face[qp]*
value*psi[i][qp];
 
  692                   for (
unsigned int i=0; i != n_dofs; i++)
 
  693                     for (
unsigned int j=0; j != n_dofs; j++)
 
  694                       Ke(i,j) += penalty*JxW_face[qp]*psi[i][qp]*psi[j][qp];
 
  714       system.matrix->add_matrix (Ke, dof_indices);
 
  715       system.rhs->add_vector    (Fe, dof_indices);
 
 
References libMesh::MeshBase::active_local_element_ptr_range(), libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::DofMap::constrain_element_matrix_and_vector(), dim, libMesh::DofMap::dof_indices(), exact_solution(), libMesh::Parameters::get(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::TransientSystem< Base >::old_solution(), libMesh::EquationSystems::parameters, libMesh::Real, libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), and value.
 
 
◆ assemble_cd() [2/2]
Definition at line 293 of file transient_ex1.C.
  299 #ifdef LIBMESH_ENABLE_AMR 
  302   libmesh_assert_equal_to (system_name, 
"Convection-Diffusion");
 
  316   FEType fe_type = system.variable_type(0);
 
  322   std::unique_ptr<FEBase> fe      (FEBase::build(
dim, fe_type));
 
  323   std::unique_ptr<FEBase> fe_face (FEBase::build(
dim, fe_type));
 
  327   QGauss qrule (
dim,   fe_type.default_quadrature_order());
 
  328   QGauss qface (
dim-1, fe_type.default_quadrature_order());
 
  331   fe->attach_quadrature_rule      (&qrule);
 
  332   fe_face->attach_quadrature_rule (&qface);
 
  337   const std::vector<Real> & JxW      = fe->get_JxW();
 
  338   const std::vector<Real> & JxW_face = fe_face->get_JxW();
 
  341   const std::vector<std::vector<Real>> & phi = fe->get_phi();
 
  342   const std::vector<std::vector<Real>> & psi = fe_face->get_phi();
 
  346   const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
 
  349   const std::vector<Point> & qface_points = fe_face->get_xyz();
 
  355   const DofMap & dof_map = system.get_dof_map();
 
  367   std::vector<dof_id_type> dof_indices;
 
  401       Ke.
resize (dof_indices.size(),
 
  404       Fe.
resize (dof_indices.size());
 
  412       for (
unsigned int qp=0; qp<qrule.n_points(); qp++)
 
  419           for (std::size_t l=0; l<phi.size(); l++)
 
  421               u_old += phi[l][qp]*system.
old_solution  (dof_indices[l]);
 
  430           for (std::size_t i=0; i<phi.size(); i++)
 
  440                                         (grad_u_old*velocity)*phi[i][qp] +
 
  443                                         0.01*(grad_u_old*dphi[i][qp]))
 
  446               for (std::size_t j=0; j<phi.size(); j++)
 
  451                                       phi[i][qp]*phi[j][qp] +
 
  455                                              (velocity*dphi[j][qp])*phi[i][qp] +
 
  458                                              0.01*(dphi[i][qp]*dphi[j][qp]))
 
  475         const Real penalty = 1.e10;
 
  480         for (
auto s : elem->side_index_range())
 
  481           if (elem->neighbor_ptr(s) == 
nullptr)
 
  483               fe_face->reinit(elem, s);
 
  485               for (
unsigned int qp=0; qp<qface.n_points(); qp++)
 
  492                   for (std::size_t i=0; i<psi.size(); i++)
 
  493                     Fe(i) += penalty*JxW_face[qp]*
value*psi[i][qp];
 
  496                   for (std::size_t i=0; i<psi.size(); i++)
 
  497                     for (std::size_t j=0; j<psi.size(); j++)
 
  498                       Ke(i,j) += penalty*JxW_face[qp]*psi[i][qp]*psi[j][qp];
 
  511       system.matrix->add_matrix (Ke, dof_indices);
 
  512       system.rhs->add_vector    (Fe, dof_indices);
 
  516 #endif // #ifdef LIBMESH_ENABLE_AMR 
 
Referenced by main().
 
 
◆ exact_solution()
      
        
          | Real exact_solution  | 
          ( | 
          const Real  | 
          x,  | 
        
        
           | 
           | 
          const Real  | 
          y,  | 
        
        
           | 
           | 
          const Real  | 
          z = 0.  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
This is the exact solution that we are trying to obtain. 
We will solve
and take a finite difference approximation using this function to get f. This is the well-known "method of
manufactured solutions". 
Definition at line 43 of file exact_solution.C.
   47   static const Real pi = acos(-1.);
 
   49   return cos(.5*
pi*x)*sin(.5*
pi*y)*cos(.5*
pi*z);
 
 
Referenced by assemble_cd(), and exact_value().
 
 
◆ exact_value()
      
        
          | Number exact_value  | 
          ( | 
          const Point &  | 
          p,  | 
        
        
           | 
           | 
          const Parameters &  | 
          parameters,  | 
        
        
           | 
           | 
          const std::string &  | 
          ,  | 
        
        
           | 
           | 
          const std::string &  | 
            | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ init_cd() [1/2]
      
        
          | void init_cd  | 
          ( | 
          EquationSystems &  | 
          es,  | 
        
        
           | 
           | 
          const std::string &  | 
          libmesh_dbg_varsystem_name  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ init_cd() [2/2]
◆ main()
      
        
          | int main  | 
          ( | 
          int  | 
          argc,  | 
        
        
           | 
           | 
          char **  | 
          argv  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 119 of file adaptivity_ex2.C.
  126                            "--enable-petsc, --enable-trilinos, or --enable-eigen");
 
  128 #ifndef LIBMESH_ENABLE_AMR 
  129   libmesh_example_requires(
false, 
"--enable-amr");
 
  142                <<
"\t " << argv[0] << 
" -init_timestep 0 -n_timesteps 25 [-n_refinements 5]\n" 
  144                <<
"\t " << argv[0] << 
" -read_solution -init_timestep 26 -n_timesteps 25\n" 
  149   for (
int i=1; i<argc; i++)
 
  155   GetPot command_line (argc, argv);
 
  164   const bool read_solution = command_line.search(
"-read_solution");
 
  171   unsigned int init_timestep = 0;
 
  175   if (command_line.search(
"-init_timestep"))
 
  176     init_timestep = command_line.next(0);
 
  181       libmesh_error_msg(
"ERROR: Initial timestep not specified!");
 
  186   unsigned int n_timesteps = 0;
 
  189   if (command_line.search(
"-n_timesteps"))
 
  190     n_timesteps = command_line.next(0);
 
  192     libmesh_error_msg(
"ERROR: Number of timesteps not specified");
 
  196   libmesh_example_requires(2 <= LIBMESH_DIM, 
"2D support");
 
  214       unsigned int n_refinements = 5;
 
  215       if (command_line.search(
"-n_refinements"))
 
  216         n_refinements = command_line.next(0);
 
  220         mesh_refinement.uniformly_refine (n_refinements);
 
  233       system.add_variable (
"u", 
FIRST);
 
  238       system.attach_init_function (
init_cd);
 
  241       equation_systems.init ();
 
  253       equation_systems.read(
"saved_solution.xda", 
READ);
 
  271       libMesh::out << 
"Initial H1 norm = " << H1norm << std::endl << std::endl;
 
  275   equation_systems.print_info();
 
  277   equation_systems.parameters.set<
unsigned int>(
"linear solver maximum iterations") = 250;
 
  278   equation_systems.parameters.set<
Real>(
"linear solver tolerance") = 
TOLERANCE;
 
  296   equation_systems.parameters.set<
Real>(
"diffusivity") = 0.01;
 
  310   const Real dt = 0.025;
 
  311   system.time = init_timestep*dt;
 
  315   for (
unsigned int t_step=init_timestep; t_step<(init_timestep+n_timesteps); t_step++)
 
  321       equation_systems.parameters.set<
Real> (
"time") = system.time;
 
  322       equation_systems.parameters.set<
Real> (
"dt")   = dt;
 
  329         std::ostringstream 
out;
 
  337             << std::setprecision(3)
 
  351       *system.old_local_solution = *system.current_local_solution;
 
  354       const unsigned int max_r_steps = 2;
 
  357       for (
unsigned int r_step=0; r_step<max_r_steps; r_step++)
 
  368           if (r_step+1 != max_r_steps)
 
  403               mesh_refinement.refine_fraction() = 0.80;
 
  404               mesh_refinement.coarsen_fraction() = 0.07;
 
  405               mesh_refinement.max_h_level() = 5;
 
  406               mesh_refinement.flag_elements_by_error_fraction (error);
 
  410               mesh_refinement.refine_and_coarsen_elements();
 
  417               equation_systems.reinit ();
 
  422       unsigned int output_freq = 10;
 
  423       if (command_line.search(
"-output_freq"))
 
  424         output_freq = command_line.next(0);
 
  427       if ((t_step+1)%output_freq == 0)
 
  429           std::ostringstream file_name;
 
  431           file_name << 
"out.gmv." 
  447       libMesh::out << 
"Final H1 norm = " << H1norm << std::endl << std::endl;
 
  450       equation_systems.write(
"saved_solution.xda", 
WRITE);
 
  454 #endif // #ifndef LIBMESH_ENABLE_AMR 
 
References assemble_cd(), libMesh::MeshRefinement::coarsen_fraction(), libMesh::default_solver_package(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::FIRST, libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::H1, libMesh::TriangleWrapper::init(), init_cd(), libMesh::INVALID_SOLVER_PACKAGE, libMesh::MeshRefinement::max_h_level(), mesh, libMesh::out, libMesh::MeshBase::print_info(), libMesh::READ, libMesh::MeshBase::read(), libMesh::Real, libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_fraction(), libMesh::TOLERANCE, libMesh::TRILINOS_SOLVERS, libMesh::MeshRefinement::uniformly_refine(), libMesh::JumpErrorEstimator::use_unweighted_quadrature_rules, libMesh::WRITE, libMesh::MeshBase::write(), and libMesh::MeshOutput< MT >::write_equation_systems().
 
 
 
Real exact_solution(const Real x, const Real y, const Real t)
This is the exact solution that we are trying to obtain.
 
const MeshBase & get_mesh() const
 
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
 
Manages storage and variables for transient systems.
 
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 void estimate_error(const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) override
This function uses the derived class's jump error estimate formula to estimate the error on each cell...
 
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
 
virtual void write(const std::string &name)=0
 
const T_sys & get_system(const std::string &name) const
 
static const Real TOLERANCE
 
SolverPackage default_solver_package()
 
unsigned int mesh_dimension() const
 
This class implements writing meshes in the GMV format.
 
void init_cd(EquationSystems &es, const std::string &system_name)
 
void resize(const unsigned int new_m, const unsigned int new_n)
Resize the matrix.
 
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
 
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
 
Implements (adaptive) mesh refinement algorithms for a MeshBase.
 
This class implements the Kelly error indicator which is based on the flux jumps between elements.
 
This is the MeshBase class.
 
void libmesh_ignore(const Args &...)
 
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
 
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
 
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
 
This is the EquationSystems class.
 
T & set(const std::string &)
 
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
 
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
 
void resize(const unsigned int n)
Resize the vector.
 
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.
 
Number old_solution(const dof_id_type global_dof_number) const
 
bool use_unweighted_quadrature_rules
This boolean flag allows you to use "unweighted" quadrature rules (sized to exactly integrate unweigh...
 
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
 
void assemble_cd(EquationSystems &es, const std::string &system_name)
 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
 
Real exact_solution(const Real x, const Real y, const Real t)
This is the exact solution that we are trying to obtain.
 
const T & get(const std::string &) const
 
Number exact_value(const Point &p, const Parameters ¶meters, const std::string &, const std::string &)
 
Parameters parameters
Data structure holding arbitrary parameters.