libMesh
Functions
transient_ex2.C File Reference

Go to the source code of this file.

Functions

void assemble_wave (EquationSystems &es, const std::string &system_name)
 
void apply_initial (EquationSystems &es, const std::string &system_name)
 
void fill_dirichlet_bc (EquationSystems &es, const std::string &system_name)
 
int main (int argc, char **argv)
 

Function Documentation

void apply_initial ( EquationSystems es,
const std::string &  system_name 
)

Definition at line 540 of file transient_ex2.C.

References libMesh::EquationSystems::get_system(), libMesh::System::get_vector(), and libMesh::NumericVector< T >::zero().

Referenced by main().

542 {
543  // Get a reference to our system, as before
544  NewmarkSystem & t_system = es.get_system<NewmarkSystem> (system_name);
545 
546  // Numeric vectors for the pressure, velocity and acceleration
547  // values.
548  NumericVector<Number> & pres_vec = t_system.get_vector("displacement");
549  NumericVector<Number> & vel_vec = t_system.get_vector("velocity");
550  NumericVector<Number> & acc_vec = t_system.get_vector("acceleration");
551 
552  // Assume our fluid to be at rest, which would
553  // also be the default conditions in class NewmarkSystem,
554  // but let us do it explicitly here.
555  pres_vec.zero();
556  vel_vec.zero();
557  acc_vec.zero();
558 }
virtual void zero()=0
Set all entries to zero.
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:794
This class contains a specific system class.
const T_sys & get_system(const std::string &name) const
void assemble_wave ( EquationSystems es,
const std::string &  system_name 
)

Definition at line 322 of file transient_ex2.C.

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(), libMesh::SECOND, and side.

Referenced by main().

324 {
325  // It is a good idea to make sure we are assembling
326  // the proper system.
327  libmesh_assert_equal_to (system_name, "Wave");
328 
329  // Get a constant reference to the mesh object.
330  const MeshBase & mesh = es.get_mesh();
331 
332  // The dimension that we are running.
333  const unsigned int dim = mesh.mesh_dimension();
334 
335  // Copy the speed of sound and fluid density
336  // to a local variable.
337  const Real speed = es.parameters.get<Real>("speed");
338  const Real rho = es.parameters.get<Real>("fluid density");
339 
340  // Get a reference to our system, as before.
341  NewmarkSystem & t_system = es.get_system<NewmarkSystem> (system_name);
342 
343  // Get a constant reference to the Finite Element type
344  // for the first (and only) variable in the system.
345  FEType fe_type = t_system.get_dof_map().variable_type(0);
346 
347  // In here, we will add the element matrices to the
348  // @e additional matrices "stiffness_mass" and "damping"
349  // and the additional vector "force", not to the members
350  // "matrix" and "rhs". Therefore, get writable
351  // references to them.
352  SparseMatrix<Number> & stiffness = t_system.get_matrix("stiffness");
353  SparseMatrix<Number> & damping = t_system.get_matrix("damping");
354  SparseMatrix<Number> & mass = t_system.get_matrix("mass");
355  NumericVector<Number> & force = t_system.get_vector("force");
356 
357  // Some solver packages (PETSc) are especially picky about
358  // allocating sparsity structure and truly assigning values
359  // to this structure. Namely, matrix additions, as performed
360  // later, exhibit acceptable performance only for identical
361  // sparsity structures. Therefore, explicitly zero the
362  // values in the collective matrix, so that matrix additions
363  // encounter identical sparsity structures.
364  SparseMatrix<Number> & matrix = *t_system.matrix;
365  DenseMatrix<Number> zero_matrix;
366 
367  // Build a Finite Element object of the specified type. Since the
368  // FEBase::build() member dynamically creates memory we will
369  // store the object as a UniquePtr<FEBase>. This can be thought
370  // of as a pointer that will clean up after itself.
371  UniquePtr<FEBase> fe (FEBase::build(dim, fe_type));
372 
373  // A 2nd order Gauss quadrature rule for numerical integration.
374  QGauss qrule (dim, SECOND);
375 
376  // Tell the finite element object to use our quadrature rule.
377  fe->attach_quadrature_rule (&qrule);
378 
379  // The element Jacobian * quadrature weight at each integration point.
380  const std::vector<Real> & JxW = fe->get_JxW();
381 
382  // The element shape functions evaluated at the quadrature points.
383  const std::vector<std::vector<Real>> & phi = fe->get_phi();
384 
385  // The element shape function gradients evaluated at the quadrature
386  // points.
387  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
388 
389  // A reference to the DofMap object for this system. The DofMap
390  // object handles the index translation from node and element numbers
391  // to degree of freedom numbers.
392  const DofMap & dof_map = t_system.get_dof_map();
393 
394  // The element mass, damping and stiffness matrices
395  // and the element contribution to the rhs.
396  DenseMatrix<Number> Ke, Ce, Me;
398 
399  // This vector will hold the degree of freedom indices for
400  // the element. These define where in the global system
401  // the element degrees of freedom get mapped.
402  std::vector<dof_id_type> dof_indices;
403 
404  // Now we will loop over all the elements in the mesh.
405  // We will compute the element matrix and right-hand-side
406  // contribution.
407  for (const auto & elem : mesh.active_local_element_ptr_range())
408  {
409  // Get the degree of freedom indices for the
410  // current element. These define where in the global
411  // matrix and right-hand-side this element will
412  // contribute to.
413  dof_map.dof_indices (elem, dof_indices);
414 
415  // Compute the element-specific data for the current
416  // element. This involves computing the location of the
417  // quadrature points (q_point) and the shape functions
418  // (phi, dphi) for the current element.
419  fe->reinit (elem);
420 
421  // Zero the element matrices and rhs before
422  // summing them. We use the resize member here because
423  // the number of degrees of freedom might have changed from
424  // the last element. Note that this will be the case if the
425  // element type is different (i.e. the last element was HEX8
426  // and now have a PRISM6).
427  {
428  const unsigned int n_dof_indices = dof_indices.size();
429 
430  Ke.resize (n_dof_indices, n_dof_indices);
431  Ce.resize (n_dof_indices, n_dof_indices);
432  Me.resize (n_dof_indices, n_dof_indices);
433  zero_matrix.resize (n_dof_indices, n_dof_indices);
434  Fe.resize (n_dof_indices);
435  }
436 
437  // Now loop over the quadrature points. This handles
438  // the numeric integration.
439  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
440  {
441  // Now we will build the element matrix. This involves
442  // a double loop to integrate the test functions (i) against
443  // the trial functions (j).
444  for (std::size_t i=0; i<phi.size(); i++)
445  for (std::size_t j=0; j<phi.size(); j++)
446  {
447  Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
448  Me(i,j) += JxW[qp]*phi[i][qp]*phi[j][qp]
449  *1./(speed*speed);
450  } // end of the matrix summation loop
451  } // end of quadrature point loop
452 
453  // Now compute the contribution to the element matrix and the
454  // right-hand-side vector if the current element lies on the
455  // boundary.
456  {
457  // In this example no natural boundary conditions will
458  // be considered. The code is left here so it can easily
459  // be extended.
460  //
461  // don't do this for any side
462  for (auto side : elem->side_index_range())
463  if (!true)
464  // if (elem->neighbor_ptr(side) == libmesh_nullptr)
465  {
466  // Declare a special finite element object for
467  // boundary integration.
468  UniquePtr<FEBase> fe_face (FEBase::build(dim, fe_type));
469 
470  // Boundary integration requires one quadrature rule,
471  // with dimensionality one less than the dimensionality
472  // of the element.
473  QGauss qface(dim-1, SECOND);
474 
475  // Tell the finite element object to use our
476  // quadrature rule.
477  fe_face->attach_quadrature_rule (&qface);
478 
479  // The value of the shape functions at the quadrature
480  // points.
481  const std::vector<std::vector<Real>> & phi_face = fe_face->get_phi();
482 
483  // The Jacobian * Quadrature Weight at the quadrature
484  // points on the face.
485  const std::vector<Real> & JxW_face = fe_face->get_JxW();
486 
487  // Compute the shape function values on the element
488  // face.
489  fe_face->reinit(elem, side);
490 
491  // Here we consider a normal acceleration acc_n=1 applied to
492  // the whole boundary of our mesh.
493  const Real acc_n_value = 1.0;
494 
495  // Loop over the face quadrature points for integration.
496  for (unsigned int qp=0; qp<qface.n_points(); qp++)
497  {
498  // Right-hand-side contribution due to prescribed
499  // normal acceleration.
500  for (std::size_t i=0; i<phi_face.size(); i++)
501  {
502  Fe(i) += acc_n_value*rho
503  *phi_face[i][qp]*JxW_face[qp];
504  }
505  } // end face quadrature point loop
506  } // end if (elem->neighbor_ptr(side) == libmesh_nullptr)
507 
508  // In this example the Dirichlet boundary conditions will be
509  // imposed via penalty method after the
510  // system is assembled.
511 
512  } // end boundary condition section
513 
514  // If this assembly program were to be used on an adaptive mesh,
515  // we would have to apply any hanging node constraint equations
516  // by uncommenting the following lines:
517  // std::vector<unsigned int> dof_indicesC = dof_indices;
518  // std::vector<unsigned int> dof_indicesM = dof_indices;
519  // dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
520  // dof_map.constrain_element_matrix (Ce, dof_indicesC);
521  // dof_map.constrain_element_matrix (Me, dof_indicesM);
522 
523  // Finally, simply add the contributions to the additional
524  // matrices and vector.
525  stiffness.add_matrix (Ke, dof_indices);
526  damping.add_matrix (Ce, dof_indices);
527  mass.add_matrix (Me, dof_indices);
528 
529  force.add_vector (Fe, dof_indices);
530 
531  // For the overall matrix, explicitly zero the entries where
532  // we added values in the other ones, so that we have
533  // identical sparsity footprints.
534  matrix.add_matrix(zero_matrix, dof_indices);
535 
536  } // end of element loop
537 }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
unsigned int dim
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:350
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]...
unsigned short int side
Definition: xdr_io.C:49
MeshBase & mesh
const T & get(const std::string &) const
Definition: parameters.h:430
This is the MeshBase class.
Definition: mesh_base.h:68
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int mesh_dimension() const
Definition: mesh_base.C:148
void resize(const unsigned int new_m, const unsigned int new_n)
Resize the matrix.
Definition: dense_matrix.h:776
This class contains a specific system class.
This class implements specific orders of Gauss quadrature.
Parameters parameters
Data structure holding arbitrary parameters.
const MeshBase & get_mesh() const
const T_sys & get_system(const std::string &name) const
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.
Definition: dof_map.C:1917
void fill_dirichlet_bc ( EquationSystems es,
const std::string &  system_name 
)

Definition at line 561 of file transient_ex2.C.

References std::abs(), libMesh::NumericVector< T >::add(), libMesh::DofObject::dof_number(), libMesh::Parameters::get(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::ImplicitSystem::matrix, mesh, n_nodes, libMesh::MeshBase::n_nodes(), libMesh::MeshBase::node_ref(), libMesh::EquationSystems::parameters, libMesh::pi, libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::System::time, and libMesh::TOLERANCE.

Referenced by main().

563 {
564  // It is a good idea to make sure we are assembling
565  // the proper system.
566  libmesh_assert_equal_to (system_name, "Wave");
567 
568  // Get a reference to our system, as before.
569  NewmarkSystem & t_system = es.get_system<NewmarkSystem> (system_name);
570 
571  // Get writable references to the overall matrix and vector.
572  SparseMatrix<Number> & matrix = *t_system.matrix;
573  NumericVector<Number> & rhs = *t_system.rhs;
574 
575  // Get a constant reference to the mesh object.
576  const MeshBase & mesh = es.get_mesh();
577 
578  // Get libMesh's pi
579  const Real pi = libMesh::pi;
580 
581  // Ask the EquationSystems flag whether
582  // we should do this also for the matrix
583  const bool do_for_matrix =
584  es.parameters.get<bool>("Newmark set BC for Matrix");
585 
586  // Number of nodes in the mesh.
587  unsigned int n_nodes = mesh.n_nodes();
588 
589  for (unsigned int n_cnt=0; n_cnt<n_nodes; n_cnt++)
590  {
591  // Get a reference to the current node.
592  const Node & curr_node = mesh.node_ref(n_cnt);
593 
594  // Check if Dirichlet BCs should be applied to this node.
595  // Use the TOLERANCE from mesh_common.h as tolerance.
596  // Here a pressure value is applied if the z-coord.
597  // is equal to 4, which corresponds to one end of the
598  // pipe-mesh in this directory.
599  const Real z_coo = 4.;
600 
601  if (std::abs(curr_node(2)-z_coo) < TOLERANCE)
602  {
603  // The global number of the respective degree of freedom.
604  unsigned int dn = curr_node.dof_number(0, 0, 0);
605 
606  // The penalty parameter.
607  const Real penalty = 1.e10;
608 
609  // Here we apply sinusoidal pressure values for 0<t<0.002
610  // at one end of the pipe-mesh.
611  Real p_value;
612  if (t_system.time < .002)
613  p_value = sin(2*pi*t_system.time/.002);
614  else
615  p_value = .0;
616 
617  // Now add the contributions to the matrix and the rhs.
618  rhs.add(dn, p_value*penalty);
619 
620  // Add the penalty parameter to the global matrix
621  // if desired.
622  if (do_for_matrix)
623  matrix.add(dn, dn, penalty);
624  }
625  } // loop n_cnt
626 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1545
double abs(double a)
A Node is like a Point, but with more information.
Definition: node.h:52
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:420
MeshBase & mesh
NumericVector< Number > * rhs
The system matrix.
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:810
const T & get(const std::string &) const
Definition: parameters.h:430
static const Real TOLERANCE
This is the MeshBase class.
Definition: mesh_base.h:68
const dof_id_type n_nodes
Definition: tecplot_io.C:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
The system matrix.
This class contains a specific system class.
Parameters parameters
Data structure holding arbitrary parameters.
const MeshBase & get_mesh() const
const T_sys & get_system(const std::string &name) const
virtual void add(const numeric_index_type i, const T value)=0
Adds value to each entry of the vector.
virtual dof_id_type n_nodes() const =0
const Real pi
.
Definition: libmesh.h:172
int main ( int  argc,
char **  argv 
)

Definition at line 99 of file transient_ex2.C.

References libMesh::EquationSystems::add_system(), libMesh::System::add_variable(), apply_initial(), assemble_wave(), libMesh::LibMeshInit::comm(), libMesh::default_solver_package(), libMesh::DofObject::dof_number(), libMesh::EIGEN_SOLVERS, fill_dirichlet_bc(), libMesh::FIRST, libMesh::EquationSystems::get_system(), libMesh::TriangleWrapper::init(), libMesh::EquationSystems::init(), libMesh::INVALID_SOLVER_PACKAGE, libMesh::NumericVector< T >::localize(), mesh, libMesh::MeshBase::node_ref(), libMesh::out, libMesh::EquationSystems::parameters, libMesh::PETSC_SOLVERS, libMesh::EquationSystems::print_info(), libMesh::MeshBase::print_info(), libMesh::MeshBase::read(), libMesh::Real, libMesh::Parameters::set(), libMesh::NumericVector< T >::size(), and libMesh::MeshOutput< MT >::write_equation_systems().

100 {
101  // Initialize libraries, like in example 2.
102  LibMeshInit init (argc, argv);
103 
104  // This example requires a linear solver package.
105  libmesh_example_requires(libMesh::default_solver_package() != INVALID_SOLVER_PACKAGE,
106  "--enable-petsc, --enable-trilinos, or --enable-eigen");
107 
108  // Check for proper usage.
109  if (argc < 2)
110  libmesh_error_msg("Usage: " << argv[0] << " [meshfile]");
111 
112  // Tell the user what we are doing.
113  else
114  {
115  libMesh::out << "Running " << argv[0];
116 
117  for (int i=1; i<argc; i++)
118  libMesh::out << " " << argv[i];
119 
120  libMesh::out << std::endl << std::endl;
121 
122  }
123 
124  // LasPack solvers don't work so well for this example, Trilinos doesn't work at all.
125  // PETSc and Eigen both work...
126  libmesh_example_requires(libMesh::default_solver_package() == PETSC_SOLVERS || \
127  libMesh::default_solver_package() == EIGEN_SOLVERS, "--enable-petsc");
128 
129  // Get the name of the mesh file
130  // from the command line.
131  std::string mesh_file = argv[1];
132  libMesh::out << "Mesh file is: " << mesh_file << std::endl;
133 
134  // Skip this 3D example if libMesh was compiled as 1D or 2D-only.
135  libmesh_example_requires(3 <= LIBMESH_DIM, "3D support");
136 
137  // Create a mesh.
138  // This example directly references all mesh nodes and is
139  // incompatible with DistributedMesh use.
140  //
141  // Create a ReplicatedMesh object, with dimension to be overridden
142  // later, distributed across the default MPI communicator.
143  ReplicatedMesh mesh(init.comm());
144 
145  // Read the meshfile specified on the command line.
146  mesh.read(mesh_file);
147 
148  // Print information about the mesh to the screen.
149  mesh.print_info();
150 
151  // The node that should be monitored.
152  const unsigned int result_node = 274;
153 
154 
155  // Time stepping issues
156  //
157  // Note that the total current time is stored as a parameter
158  // in the \pEquationSystems object.
159  //
160  // the time step size
161  const Real delta_t = .0000625;
162 
163  // The number of time steps.
164  unsigned int n_time_steps = 300;
165 
166  // Create an equation systems object.
167  EquationSystems equation_systems (mesh);
168 
169  // Declare the system and its variables.
170  // Create a NewmarkSystem named "Wave"
171  equation_systems.add_system<NewmarkSystem> ("Wave");
172 
173  // Use a handy reference to this system
174  NewmarkSystem & t_system = equation_systems.get_system<NewmarkSystem> ("Wave");
175 
176  // Add the variable "p" to "Wave". "p"
177  // will be approximated using first-order approximation.
178  t_system.add_variable("p", FIRST);
179 
180  // Give the system a pointer to the matrix assembly
181  // function and the initial condition function defined
182  // below.
183  t_system.attach_assemble_function (assemble_wave);
184  t_system.attach_init_function (apply_initial);
185 
186  // Set the time step size, and optionally the
187  // Newmark parameters, so that NewmarkSystem can
188  // compute integration constants. Here we simply use
189  // pass only the time step and use default values
190  // for alpha=.25 and delta=.5.
191  t_system.set_newmark_parameters(delta_t);
192 
193  // Set the speed of sound and fluid density
194  // as EquationSystems parameter,
195  // so that assemble_wave() can access it.
196  equation_systems.parameters.set<Real>("speed") = 1000.;
197  equation_systems.parameters.set<Real>("fluid density") = 1000.;
198 
199  // Start time integration from t=0
200  t_system.time = 0.;
201 
202  // Initialize the data structures for the equation system.
203  equation_systems.init();
204 
205  // Prints information about the system to the screen.
206  equation_systems.print_info();
207 
208  // A file to store the results at certain nodes.
209  std::ofstream res_out("pressure_node.res");
210 
211  // get the dof_numbers for the nodes that
212  // should be monitored.
213  const unsigned int res_node_no = result_node;
214  const Node & res_node = mesh.node_ref(res_node_no-1);
215  unsigned int dof_no = res_node.dof_number(0, 0, 0);
216 
217  // Assemble the time independent system matrices and rhs.
218  // This function will also compute the effective system matrix
219  // K~=K+a_0*M+a_1*C and apply user specified initial
220  // conditions.
221  t_system.assemble();
222 
223  // Now solve for each time step.
224  // For convenience, use a local buffer of the
225  // current time. But once this time is updated,
226  // also update the EquationSystems parameter
227  // Start with t_time = 0 and write a short header
228  // to the nodal result file
229  res_out << "# pressure at node " << res_node_no << "\n"
230  << "# time\tpressure\n"
231  << t_system.time << "\t" << 0 << std::endl;
232 
233 
234  for (unsigned int time_step=0; time_step<n_time_steps; time_step++)
235  {
236  // Update the time. Both here and in the
237  // EquationSystems object
238  t_system.time += delta_t;
239 
240  // Update the rhs.
241  t_system.update_rhs();
242 
243  // Impose essential boundary conditions.
244  // Not that since the matrix is only assembled once,
245  // the penalty parameter should be added to the matrix
246  // only in the first time step. The applied
247  // boundary conditions may be time-dependent and hence
248  // the rhs vector is considered in each time step.
249  if (time_step == 0)
250  {
251  // The local function fill_dirichlet_bc()
252  // may also set Dirichlet boundary conditions for the
253  // matrix. When you set the flag as shown below,
254  // the flag will return true. If you want it to return
255  // false, simply do not set it.
256  equation_systems.parameters.set<bool>("Newmark set BC for Matrix") = true;
257 
258  fill_dirichlet_bc(equation_systems, "Wave");
259 
260  // unset the flag, so that it returns false
261  equation_systems.parameters.set<bool>("Newmark set BC for Matrix") = false;
262  }
263  else
264  fill_dirichlet_bc(equation_systems, "Wave");
265 
266  // Solve the system "Wave".
267  t_system.solve();
268 
269  // After solving the system, write the solution
270  // to a GMV-formatted plot file.
271  // Do only for a few time steps.
272  if (time_step == 30 || time_step == 60 ||
273  time_step == 90 || time_step == 120)
274  {
275  std::ostringstream file_name;
276 
277 #ifdef LIBMESH_HAVE_VTK
278  file_name << "out_"
279  << std::setw(3)
280  << std::setfill('0')
281  << std::right
282  << time_step
283  << ".pvtu";
284 
285  VTKIO(mesh).write_equation_systems (file_name.str(), equation_systems);
286 #else
287 
288  file_name << "out."
289  << std::setw(3)
290  << std::setfill('0')
291  << std::right
292  << time_step
293  << ".gmv";
294 
295  GMVIO(mesh).write_equation_systems (file_name.str(), equation_systems);
296 #endif
297  }
298 
299  // Update the p, v and a.
300  t_system.update_u_v_a();
301 
302  // dof_no may not be local in parallel runs, so we may need a
303  // global displacement vector
304  NumericVector<Number> & displacement = t_system.get_vector("displacement");
305  std::vector<Number> global_displacement(displacement.size());
306  displacement.localize(global_displacement);
307 
308  // Write nodal results to file. The results can then
309  // be viewed with e.g. gnuplot (run gnuplot and type
310  // 'plot "pressure_node.res" with lines' in the command line)
311  res_out << t_system.time << "\t"
312  << global_displacement[dof_no]
313  << std::endl;
314  }
315 
316  // All done.
317  return 0;
318 }
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
A Node is like a Point, but with more information.
Definition: node.h:52
virtual numeric_index_type size() const =0
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:420
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1101
MeshBase & mesh
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Definition: dof_object.h:810
void apply_initial(EquationSystems &es, const std::string &system_name)
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:62
This class implements writing meshes in the GMV format.
Definition: gmv_io.h:46
This class implements reading and writing meshes in the VTK format.
Definition: vtk_io.h:59
SolverPackage default_solver_package()
Definition: libmesh.C:995
void init(triangulateio &t)
Initializes the fields of t to NULL/0 as necessary.
void fill_dirichlet_bc(EquationSystems &es, const std::string &system_name)
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition: mesh_output.C:31
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
This class contains a specific system class.
void assemble_wave(EquationSystems &es, const std::string &system_name)
virtual void read(const std::string &name, void *mesh_data=libmesh_nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the mesh.
Definition: mesh_base.C:448
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.