25 #include <queso/Defines.h>
27 #ifdef QUESO_HAVE_LIBMESH
30 #include <queso/LibMeshFunction.h>
31 #include <queso/FunctionOperatorBuilder.h>
32 #include <libmesh/libmesh.h>
33 #include <libmesh/mesh.h>
34 #include <libmesh/mesh_generation.h>
35 #include <libmesh/equation_systems.h>
36 #include <libmesh/explicit_system.h>
37 #include <libmesh/system_norm.h>
38 #include <libmesh/exodusII_io.h>
41 #include <libmesh/fe.h>
44 #include <libmesh/quadrature_gauss.h>
48 #include <libmesh/sparse_matrix.h>
49 #include <libmesh/numeric_vector.h>
50 #include <libmesh/dense_matrix.h>
51 #include <libmesh/dense_vector.h>
52 #include <libmesh/elem.h>
56 #include <libmesh/dof_map.h>
57 #include <libmesh/utility.h>
58 #include <libmesh/string_to_enum.h>
59 #include <libmesh/enum_order.h>
60 #include <libmesh/enum_fe_family.h>
64 LibMeshFunction::LibMeshFunction(
65 const FunctionOperatorBuilder & builder, libMesh::MeshBase & m)
68 equation_systems(new libMesh::EquationSystems(m))
70 this->equation_systems->add_system<libMesh::ExplicitSystem>(
"Function");
71 this->equation_systems->get_system(
"Function").add_variable(
"u",
72 libMesh::Utility::string_to_enum<libMeshEnums::Order>(this->builder.order),
73 libMesh::Utility::string_to_enum<libMeshEnums::FEFamily>(this->builder.family));
74 this->equation_systems->init();
77 LibMeshFunction::~LibMeshFunction()
81 void LibMeshFunction::print_info()
const
84 this->equation_systems->get_mesh().print_info(std::cerr);
87 void LibMeshFunction::save_function(
const std::string & filename,
double time)
const
92 libMesh::ExodusII_IO(this->equation_systems->get_mesh()).write_timestep(
93 filename, *this->equation_systems, 1, time);
96 void LibMeshFunction::add(
double scale,
const FunctionBase & rhs) {
98 const LibMeshFunction & rhs_derived =
dynamic_cast<
99 const LibMeshFunction &
>(rhs);
101 this->equation_systems->get_system<libMesh::ExplicitSystem>(
"Function").solution->add(
102 scale, *(rhs_derived.equation_systems->get_system<libMesh::ExplicitSystem>(
103 "Function").solution));
106 void LibMeshFunction::pointwise_mult(
const FunctionBase & f1,
107 const FunctionBase & f2)
109 const LibMeshFunction & f1_derived =
static_cast<
110 const LibMeshFunction &
>(f1);
111 const LibMeshFunction & f2_derived =
static_cast<
112 const LibMeshFunction &
>(f2);
114 this->equation_systems->get_system<libMesh::ExplicitSystem>(
"Function").solution->pointwise_mult(
115 *(f1_derived.equation_systems->get_system<libMesh::ExplicitSystem>(
"Function").solution),
116 *(f2_derived.equation_systems->get_system<libMesh::ExplicitSystem>(
"Function").solution));
120 this->equation_systems->get_system<libMesh::ExplicitSystem>(
121 "Function").solution->scale(scale);
124 void LibMeshFunction::zero() {
125 this->equation_systems->get_system<libMesh::ExplicitSystem>(
126 "Function").solution->zero();
129 double LibMeshFunction::L2_norm()
const {
130 libMesh::ExplicitSystem &
system =
131 this->equation_systems->get_system<libMesh::ExplicitSystem>(
"Function");
133 double norm = system.calculate_norm(*system.solution,
134 libMesh::SystemNorm(libMeshEnums::L2));
138 boost::shared_ptr<FunctionBase> LibMeshFunction::zero_clone()
const
140 LibMeshFunction * clone =
new LibMeshFunction(this->builder,
141 this->equation_systems->get_mesh());
142 clone->equation_systems->get_system<libMesh::ExplicitSystem>(
143 "Function").solution->zero();
145 boost::shared_ptr<FunctionBase> ptr(clone);
149 boost::shared_ptr<libMesh::EquationSystems>
150 LibMeshFunction::get_equation_systems()
const {
151 return this->equation_systems;
156 #endif // QUESO_HAVE_LIBMESH
this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system