libMesh
Loading...
Searching...
No Matches
miscellaneous_ex2.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19
20
21// <h1>Miscellaneous Example 2 - Complex Numbers and the "FrequencySystem"</h1>
22// \author Steffen Petersen
23// \date 2003
24//
25// This example program introduces complex numbers and the
26// FrequencySystem class to solve a simple Helmholtz equation,
27// Laplacian(p) + (omega/c)^2*p = 0,
28// for multiple frequencies rather efficiently.
29//
30// The FrequencySystem class offers two solution styles:
31// 1.) Solve large systems once, and
32// 2.) Solve moderately-sized systems for multiple frequencies.
33// The latter approach is implemented here.
34//
35// This example uses an L-shaped domain and nodal boundary data given
36// in the files lshape.unv and lshape_data.unv. For this example, the
37// library has to be compiled with complex numbers enabled.
38
39// C++ include files that we need
40#include <iostream>
41#include <algorithm>
42#include <stdio.h>
43
44// Basic include files needed for overall functionality.
45#include "libmesh/libmesh.h"
46#include "libmesh/libmesh_logging.h"
47#include "libmesh/mesh.h"
48#include "libmesh/mesh_generation.h"
49#include "libmesh/exodusII_io.h"
50#include "libmesh/unv_io.h"
51#include "libmesh/equation_systems.h"
52#include "libmesh/elem.h"
53#include "libmesh/enum_xdr_mode.h"
54
55// Include FrequencySystem. This class offers added functionality for
56// the solution of frequency-dependent systems.
57#include "libmesh/frequency_system.h"
58
59// Define the FE object.
60#include "libmesh/fe.h"
61
62// Define the QGauss quadrature rule objects.
63#include "libmesh/quadrature_gauss.h"
64
65// Useful datatypes for finite element assembly.
66#include "libmesh/dense_matrix.h"
67#include "libmesh/dense_vector.h"
68
69// Sparse matrix and vector data types for parallel linear algebra.
70#include "libmesh/sparse_matrix.h"
71#include "libmesh/numeric_vector.h"
72
73// Define the DofMap, which handles degree of freedom indexing.
74#include "libmesh/dof_map.h"
75
76// Bring in everything from the libMesh namespace
77using namespace libMesh;
78
79// This problem is only defined on complex-valued fields, for
80// which libMesh must be configured with Number == Complex.
81#ifdef LIBMESH_USE_COMPLEX_NUMBERS
82
83// Function prototype. This is the function that will assemble
84// the mass, damping and stiffness matrices. It will not
85// form an overall system matrix ready for solution.
87 const std::string & system_name);
88
89// Function prototype. This is the function that will combine
90// the previously-assembled mass, damping and stiffness matrices
91// to the overall matrix, which then renders ready for solution.
93 const std::string & system_name);
94#endif
95
96// This example only works correctly if libmesh has been configured
97// with --enable-complex. If you wish to use PETSc, you must also
98// build PETSc with complex number support by configuring with
99// --with-scalar-type=complex --with-clanguage=cxx, and using the same
100// C++ compiler to build both PETSc and libmesh. This example also
101// works with the Eigen sparse linear solvers which are provided in
102// libmesh's contrib directory.
103int main (int argc, char ** argv)
104{
105 // The libMeshInit object initializes MPI, PETSc, etc, and must be
106 // constructed before all other objects.
107 LibMeshInit init (argc, argv);
108
109 // This example is designed for complex numbers.
110#ifndef LIBMESH_USE_COMPLEX_NUMBERS
111 libmesh_example_requires(false, "--enable-complex");
112#else
113
114 // This example requires at least 2D support.
115 libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
116
117 // Check for proper usage. frequency has two terms:
118 libmesh_error_msg_if(argc < 4, "Usage: " << argv[0] << " -f [real_frequency imag_frequency]");
119
120 if (init.comm().size() > 1)
121 {
122 if (init.comm().rank() == 0)
123 {
124 libMesh::err << "TODO: This example should be able to run in parallel."
125 << std::endl;
126 }
127 return 0;
128 }
129
130 // Tell the user what we are doing.
131 else
132 {
133 libMesh::out << "Running " << argv[0];
134
135 for (int i=1; i<argc; i++)
136 libMesh::out << " " << argv[i];
137
138 libMesh::out << std::endl << std::endl;
139 }
140
141 // Get the frequency from argv[2] as a float, solve for 1/3rd, 2/3rd
142 // and 1/1th of the given frequency.
143
144 const Number frequency_in (atof(argv[2]), atof(argv[3]));
145
146 // this must work as well, but is deprecated.
147 // const Real frequency_in = atof(argv[2]);
148
149 const unsigned int n_frequencies = 3;
150
151 // Create a mesh, with dimension to be overridden later, distributed
152 // across the default MPI communicator.
153 Mesh mesh(init.comm());
154
155 // Read the mesh file. Here the file lshape.unv contains
156 // an L-shaped domain in .unv format.
157 UNVIO unvio(mesh);
158 unvio.read("lshape.unv");
159
160 // Manually prepare the mesh for use, this is not done automatically
161 // by the UNVIO reader, so we have to do it here. Note that calling
162 // this function renumbers the nodes and elements of the Mesh, but
163 // the original numbering is still stored in the UNVIO object for
164 // correctly mapping dataset values (see below) to the correct nodes.
166
167 // Read the dataset accompanying this problem. The load on the
168 // boundary of the domain is stored in the .unv data file
169 // lshape_data.unv. The data are given as complex-valued normal
170 // velocities.
171 unvio.read_dataset("lshape_data.unv");
172
173 // Print information about the mesh to the screen.
175
176 // Create an EquationSystems object.
177 EquationSystems equation_systems (mesh);
178
179 // Create a FrequencySystem named "Helmholtz" and store a
180 // reference to it.
181 FrequencySystem & f_system =
182 equation_systems.add_system<FrequencySystem> ("Helmholtz");
183
184 // Add the variable "p" to the "Helmholtz" system. "p"
185 // will be approximated using second-order approximation.
186 f_system.add_variable("p", SECOND);
187
188 // The FrequencySystem requires two user-provided functions: one for
189 // assembling the different operators and another that specifies how
190 // to combine them before the solve.
193
194 // To enable the fast solution scheme, additional sparse matrices
195 // and one vector have to be added. The FrequencySystem object
196 // takes care of sizing the additional objects. The user should
197 // still set the sparsity structure of the f_system.matrix, so that
198 // the fast matrix addition method can be used. The procedure for
199 // this is shown in detail in the assembly function.
200 f_system.add_matrix ("stiffness");
201 f_system.add_matrix ("damping");
202 f_system.add_matrix ("mass");
203 f_system.add_vector ("rhs");
204
205 // Communicate the frequencies to the system. Note that the
206 // frequency system stores the frequencies as parameters in the
207 // EquationSystems object, so that our assemble and solve functions
208 // may directly access them. Must be called before the
209 // EquationSystems object is initialized. Will solve for 1/3,
210 // 2/3, and 1 times the given frequency.
211 f_system.set_frequencies_by_steps (frequency_in/static_cast<Number>(n_frequencies),
212 frequency_in,
213 n_frequencies);
214
215 // Set the wave velocity and fluid density parameter values,
216 // otherwise default values will be used.
217 equation_systems.parameters.set<Real> ("wave speed") = 1.;
218 equation_systems.parameters.set<Real> ("rho") = 1.;
219
220 // Initialize the EquationSystems object.
221 equation_systems.init ();
222
223 // Set values in the "rhs" vector based on the entries stored in the
224 // UNVIO object from the dataset we read in. These values only need
225 // to be set once, as they are the same for every frequency. We can
226 // only do this once equation_systems.init() has been called...
227 {
228 NumericVector<Number> & freq_indep_rhs = f_system.get_vector("rhs");
229
230 for (const auto & node : mesh.node_ptr_range())
231 {
232 // Get the data read in from the dataset for the current Node, if any.
233 const std::vector<Number> * nodal_data = unvio.get_data(node);
234
235 // Set the rhs value based on values read in from the dataset.
236 if (nodal_data)
237 {
238 unsigned int dn = node->dof_number(/*system=*/0,
239 /*variable=*/0,
240 /*component=*/0);
241 freq_indep_rhs.set(dn, (*nodal_data)[0]);
242 }
243 }
244 }
245
246 // Print information about the system to the screen.
247 equation_systems.print_info ();
248
249 for (unsigned int n=0; n < n_frequencies; n++)
250 {
251 // Solve the "Helmholtz" system for the n-th frequency.
252 // Since we attached an assemble() function to the system,
253 // the mass, damping, and stiffness contributions will only
254 // be assembled once. Then, the system is solved for the
255 // given frequencies. Note that solve() may also solve
256 // the system only for specific frequencies.
257 f_system.solve (n, n);
258
259 // After solving the system, write the solution to an ExodusII
260 // file for every frequency.
261#ifdef LIBMESH_HAVE_EXODUS_API
262 std::ostringstream file_name;
263
264 file_name << "out_"
265 << std::setw(4)
266 << std::setfill('0')
267 << std::right
268 << n
269 << ".e";
270
271 ExodusII_IO(mesh).write_equation_systems (file_name.str(),
272 equation_systems);
273#endif
274 }
275
276 // Alternatively, the whole EquationSystems object can be
277 // written to disk. By default, the additional vectors are also
278 // saved.
279 equation_systems.write ("eqn_sys.dat", WRITE);
280
281 // All done.
282 return 0;
283
284#endif
285}
286
287
288#ifdef LIBMESH_USE_COMPLEX_NUMBERS
289// Here we define the matrix assembly routine for
290// the Helmholtz system. This function will be
291// called to form the stiffness matrix and right-hand side.
293 const std::string & system_name)
294{
295 LOG_SCOPE("assemble_helmholtz", "misc_ex2");
296
297 // It is a good idea to make sure we are assembling
298 // the proper system.
299 libmesh_assert_equal_to (system_name, "Helmholtz");
300
301 // Get a constant reference to the mesh object.
302 const MeshBase & mesh = es.get_mesh();
303
304 // The maximum dimension of the elements stored in the mesh.
305 const unsigned int dim = mesh.mesh_dimension();
306
307 // Get a reference to our system, as before
308 FrequencySystem & f_system =
309 es.get_system<FrequencySystem> (system_name);
310
311 // A const reference to the DofMap object for this system. The DofMap
312 // object handles the index translation from node and element numbers
313 // to degree of freedom numbers.
314 const DofMap & dof_map = f_system.get_dof_map();
315
316 // Get a constant reference to the finite element type
317 // for the first (and only) variable in the system.
318 const FEType & fe_type = dof_map.variable_type(0);
319
320 // The fluid density is used by the admittance boundary condition.
321 const Real rho = es.parameters.get<Real>("rho");
322
323 // In this example, we assemble the element matrices into the
324 // additional matrices "stiffness_mass", "damping", and the element
325 // vectors into "rhs". We get writable references to these objects
326 // now.
327 SparseMatrix<Number> & stiffness = f_system.get_matrix("stiffness");
328 SparseMatrix<Number> & damping = f_system.get_matrix("damping");
329 SparseMatrix<Number> & mass = f_system.get_matrix("mass");
330
331 // Build a finite element object of the specified type. Since the
332 // FEBase::build() member dynamically creates memory we will
333 // store the object as a std::unique_ptr<FEBase>. This can be thought
334 // of as a pointer that will clean up after itself.
335 std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
336
337 // A 5th-order Gauss quadrature rule for numerical integration.
338 QGauss qrule (dim, FIFTH);
339
340 // Tell the finite element object to use our quadrature rule.
341 fe->attach_quadrature_rule (&qrule);
342
343 // The element Jacobian times the quadrature weight at each integration point.
344 const std::vector<Real> & JxW = fe->get_JxW();
345
346 // The element shape functions evaluated at the quadrature points.
347 const std::vector<std::vector<Real>> & phi = fe->get_phi();
348
349 // The element shape function gradients evaluated at the quadrature
350 // points.
351 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
352
353 // Here we do not assemble directly in the System matrix, but to the
354 // additional matrices "stiffness_mass" and "damping". The same
355 // approach is followed for the right-hand-side vector Fe, which we
356 // will later on store in the additional vector "rhs".
357 // The zero_matrix is used to explicitly induce the same sparsity
358 // structure in the overall matrix. The mass and stiffness matrices
359 // are real-valued. Therefore, it would be possible to store them
360 // as a single complex-valued matrix to save on memory, but we do
361 // not follow this approach here.
362 DenseMatrix<Number> Ke, Ce, Me, zero_matrix;
364
365 // This vector will hold the degree of freedom indices for
366 // the element. These define where in the global system
367 // the element degrees of freedom get mapped.
368 std::vector<dof_id_type> dof_indices;
369
370 // The global system matrix
371 SparseMatrix<Number> & matrix = f_system.get_system_matrix();
372
373 // Now we will loop over all the elements in the mesh, and compute
374 // the element matrix and right-hand-side contributions.
375 for (const auto & elem : mesh.active_local_element_ptr_range())
376 {
377 // Get the degree of freedom indices for the
378 // current element. These define where in the global
379 // matrix and right-hand-side this element will
380 // contribute to.
381 dof_map.dof_indices (elem, dof_indices);
382
383 // Compute the element-specific data for the current
384 // element. This involves computing the location of the
385 // quadrature points (q_point) and the shape functions
386 // (phi, dphi) for the current element.
387 fe->reinit (elem);
388
389 // Zero & resize the element matrix and right-hand side before
390 // summing them, with different element types in the mesh this
391 // is quite necessary.
392 const unsigned int n_dof_indices = dof_indices.size();
393
394 Ke.resize (n_dof_indices, n_dof_indices);
395 Ce.resize (n_dof_indices, n_dof_indices);
396 Me.resize (n_dof_indices, n_dof_indices);
397 zero_matrix.resize (n_dof_indices, n_dof_indices);
398 Fe.resize (n_dof_indices);
399
400 // Now loop over the quadrature points. This handles
401 // the numeric integration.
402 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
403 {
404 // Now we will build the element matrix. This involves
405 // a double loop to integrate the test functions (i) against
406 // the trial functions (j).
407 for (std::size_t i=0; i<phi.size(); i++)
408 for (std::size_t j=0; j<phi.size(); j++)
409 {
410 Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);
411 Me(i,j) += JxW[qp]*(phi[i][qp]*phi[j][qp]);
412 }
413 }
414
415 // Now compute the contribution to the element matrix
416 // (due to mixed boundary conditions) if the current
417 // element lies on the boundary.
418 //
419 // The following loops over the sides of the element.
420 // If the element has no neighbor on a side then that
421 // side MUST live on a boundary of the domain.
422 for (auto side : elem->side_index_range())
423 if (elem->neighbor_ptr(side) == nullptr)
424 {
425 // Declare a special finite element object for
426 // boundary integration.
427 std::unique_ptr<FEBase> fe_face (FEBase::build(dim, fe_type));
428
429 // Boundary integration requires one quadrature rule,
430 // with dimensionality one less than the dimensionality
431 // of the element.
432 QGauss qface(dim-1, SECOND);
433
434 // Tell the finite element object to use our
435 // quadrature rule.
436 fe_face->attach_quadrature_rule (&qface);
437
438 // The value of the shape functions at the quadrature
439 // points.
440 const std::vector<std::vector<Real>> & phi_face =
441 fe_face->get_phi();
442
443 // The Jacobian times the quadrature weight at the quadrature
444 // points on the face.
445 const std::vector<Real> & JxW_face = fe_face->get_JxW();
446
447 // Compute the shape function values on the element
448 // face.
449 fe_face->reinit(elem, side);
450
451 // For the Robin BCs, consider a normal admittance an=1
452 // at some parts of the boundary
453 const Real an_value = 1.;
454
455 // Loop over the face quadrature points for integration.
456 for (unsigned int qp=0; qp<qface.n_points(); qp++)
457 {
458 // Element matrix contribution due to prescribed
459 // admittance boundary conditions.
460 for (std::size_t i=0; i<phi_face.size(); i++)
461 for (std::size_t j=0; j<phi_face.size(); j++)
462 Ce(i,j) += rho * an_value * JxW_face[qp] * phi_face[i][qp] * phi_face[j][qp];
463 }
464 }
465
466 // If this assembly program were to be used on an adaptive mesh,
467 // we would have to apply any hanging node constraint equations
468 // by uncommenting the following lines:
469 // std::vector<unsigned int> dof_indicesC = dof_indices;
470 // std::vector<unsigned int> dof_indicesM = dof_indices;
471 // dof_map.constrain_element_matrix (Ke, dof_indices);
472 // dof_map.constrain_element_matrix (Ce, dof_indicesC);
473 // dof_map.constrain_element_matrix (Me, dof_indicesM);
474
475 // Finally, simply add the contributions to the additional
476 // matrices and vector.
477 stiffness.add_matrix (Ke, dof_indices);
478 damping.add_matrix (Ce, dof_indices);
479 mass.add_matrix (Me, dof_indices);
480
481 // For the overall matrix, explicitly zero the entries where
482 // we added values in the other ones, so that we have
483 // identical sparsity footprints.
484 matrix.add_matrix(zero_matrix, dof_indices);
485 } // end loop over elements
486}
487
488
489// We now define the function which will combine the previously-assembled
490// mass, stiffness, and damping matrices into a single system matrix.
492 const std::string & system_name)
493{
494 LOG_SCOPE("add_M_C_K_helmholtz()", "misc_ex2");
495
496 // Verify that we are assembling the system we think we are.
497 libmesh_assert_equal_to (system_name, "Helmholtz");
498
499 // Get a reference to the FrequencySystem.
500 FrequencySystem & f_system =
501 es.get_system<FrequencySystem> (system_name);
502
503 // Get the frequency, fluid density, and sound speed of the current solve.
504 const Number frequency = es.parameters.get<Number> ("current frequency");
505 const Real rho = es.parameters.get<Real> ("rho");
506 const Real speed = es.parameters.get<Real> ("wave speed");
507
508 // Compute angular frequency omega and wave number k
509 const Number omega = 2.0*libMesh::pi*frequency;
510 const Number k = omega / speed;
511
512 // Get writable references to the system matrix and vector, where the
513 // frequency-dependent system is to be collected.
514 SparseMatrix<Number> & matrix = *f_system.matrix;
515 NumericVector<Number> & rhs = *f_system.rhs;
516
517 // Get writable references to the frequency-independent matrices
518 // and rhs, though we only need to extract values. This write access
519 // is necessary, since solver packages have to close the data structure
520 // before they can extract values for computation.
521 SparseMatrix<Number> & stiffness = f_system.get_matrix("stiffness");
522 SparseMatrix<Number> & damping = f_system.get_matrix("damping");
523 SparseMatrix<Number> & mass = f_system.get_matrix("mass");
524 NumericVector<Number> & freq_indep_rhs = f_system.get_vector("rhs");
525
526 Number unit_i (0,1);
527
528 // Compute the scale values for the different operators.
529 const Number scale_stiffness (1., 0.);
530 const Number scale_damping=unit_i*omega; // I is imaginary unit (from complex.h)
531 const Number scale_mass=-k*k;
532 const Number scale_rhs=-unit_i*rho*omega;
533
534 // Now simply add the matrices together, store the result
535 // in matrix and rhs. Clear them first.
536 matrix.close ();
537 matrix.zero ();
538 rhs.close ();
539 rhs.zero ();
540
541 // The matrices from which values are added to another matrix
542 // have to be closed. The add() method does take care of
543 // that, but let us do it explicitly.
544 stiffness.close ();
545 damping.close ();
546 mass.close ();
547
548 // Add the stiffness and mass with the proper frequency to the
549 // overall system. For this to work properly, the matrix has
550 // to be not only initialized, but filled with the identical
551 // sparsity structure as the matrix added to it, otherwise
552 // solver packages like PETSc crash.
553 //
554 // Note that we have to add the mass and stiffness contributions one
555 // at a time, otherwise the real part of matrix would be fine, but
556 // the imaginary part would be cluttered with unwanted products.
557 matrix.add (scale_stiffness, stiffness);
558 matrix.add (scale_mass, mass);
559 matrix.add (scale_damping, damping);
560 rhs.add (scale_rhs, freq_indep_rhs);
561
562 // The linear system involving "matrix" and "rhs" is now ready to be solved.
563}
564
565#endif // LIBMESH_USE_COMPLEX_NUMBERS
unsigned int dim
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().
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.
Definition dof_map.h:181
This is the EquationSystems class.
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...
Definition exodusII_io.h:53
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
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
FrequencySystem provides a specific system class for frequency-dependent (linear) systems.
virtual void solve() override
Solves the system for all frequencies.
void set_frequencies_by_steps(const Number base_freq, const Number freq_step=0., const unsigned int n_freq=1, const bool allocate_solution_duplicates=true)
Set the frequency range for which the system should be solved.
void attach_solve_function(void fptr(EquationSystems &es, const std::string &name))
Register a required user function to use in assembling/solving the system.
const SparseMatrix< Number > & get_system_matrix() const
SparseMatrix< Number > * matrix
The system matrix.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition libmesh.h:92
This is the MeshBase class.
Definition mesh_base.h:81
unsigned int mesh_dimension() const
Definition mesh_base.C:430
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
Definition mesh_base.C:824
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition mesh_base.C:1755
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
virtual void zero()=0
Set all entries to zero.
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 &)
Definition parameters.h:494
const T & get(std::string_view) const
Definition parameters.h:451
unsigned int n_points() const
Definition quadrature.h:131
This class implements specific orders of Gauss quadrature.
Generic sparse matrix.
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.
virtual void zero()=0
Set all entries to 0.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
Adds the additional matrix mat_name to this system.
Definition system.C:998
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
Definition system.C:1111
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Register a user function to use in assembling the system matrix and RHS.
Definition system.C:1959
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition system.C:1344
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition system.C:756
const DofMap & get_dof_map() const
Definition system.h:2417
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition system.C:931
The UNVIO class implements the Ideas UNV universal file format.
Definition unv_io.h:54
void read_dataset(std::string file_name)
Read a UNV data file containing a dataset of type "2414".
Definition unv_io.C:1161
const std::vector< Number > * get_data(Node *node) const
Definition unv_io.C:1317
virtual void read(const std::string &) override
This method implements reading a mesh from a specified file.
Definition unv_io.C:96
MeshBase & mesh
void assemble_helmholtz(EquationSystems &es, const std::string &system_name)
void add_M_C_K_helmholtz(EquationSystems &es, const std::string &system_name)
The libMesh namespace provides an interface to certain functionality in the library.
OStreamProxy err
OStreamProxy out
const Real pi
.
Definition libmesh.h:292
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
int main()