Go to the documentation of this file. 1 #include <libmesh/equation_systems.h>
2 #include <libmesh/implicit_system.h>
3 #include <libmesh/mesh.h>
4 #include <libmesh/mesh_communication.h>
5 #include <libmesh/mesh_generation.h>
6 #include <libmesh/numeric_vector.h>
7 #include <libmesh/replicated_mesh.h>
8 #include <libmesh/dyna_io.h>
9 #include <libmesh/exodusII_io.h>
10 #include <libmesh/dof_map.h>
24 const Real & x = p(0);
25 const Real & y = p(1);
36 #ifdef LIBMESH_HAVE_EXODUS_API
37 CPPUNIT_TEST( testExodusCopyElementSolution );
38 #ifndef LIBMESH_USE_COMPLEX_NUMBERS
40 CPPUNIT_TEST( testExodusWriteElementDataFromDiscontinuousNodalData );
43 CPPUNIT_TEST( testDynaReadElem );
44 CPPUNIT_TEST( testDynaReadPatch );
46 CPPUNIT_TEST( testMeshMoveConstructor );
47 #endif // LIBMESH_DIM > 1
49 CPPUNIT_TEST_SUITE_END();
60 #ifdef LIBMESH_HAVE_EXODUS_API
80 std::set<std::string> sys_list;
98 exii.
read(
"mesh_with_soln.e");
108 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
129 #ifndef LIBMESH_USE_COMPLEX_NUMBERS
141 (
mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1.,
HEX8);
147 std::vector<dof_id_type> dof_indices;
151 for (
unsigned int i=0; i<dof_indices.size(); ++i)
152 sys.
solution->set(dof_indices[i], i);
160 std::set<std::string> sys_list;
164 sys_list = {
"SimpleSystem"};
167 (es, &sys_list,
"_elem_corner_");
172 std::vector<std::string> file_var_names =
177 std::vector<Real> expected_values = {0., 1., 2., 3.};
190 exii.
read(
"elemental_from_nodal.e");
205 LIBMESH_ASSERT_FP_EQUAL
211 #endif // !LIBMESH_USE_COMPLEX_NUMBERS
212 #endif // LIBMESH_HAVE_EXODUS_API
225 dyna.
read(
"1_quad.dyn");
245 CPPUNIT_ASSERT_EQUAL(elem->type(),
QUAD9);
246 for (
unsigned int n=0; n != 9; ++n)
248 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
251 CPPUNIT_ASSERT_EQUAL(elem->point(0)(0),
Real(0.5));
252 CPPUNIT_ASSERT_EQUAL(elem->point(0)(1),
Real(0.5));
253 CPPUNIT_ASSERT_EQUAL(elem->point(1)(0),
Real(1.5));
254 CPPUNIT_ASSERT_EQUAL(elem->point(1)(1),
Real(0.5));
255 CPPUNIT_ASSERT_EQUAL(elem->point(2)(0),
Real(1.5));
256 CPPUNIT_ASSERT_EQUAL(elem->point(2)(1),
Real(1.5));
257 CPPUNIT_ASSERT_EQUAL(elem->point(3)(0),
Real(0.5));
258 CPPUNIT_ASSERT_EQUAL(elem->point(3)(1),
Real(1.5));
259 CPPUNIT_ASSERT(elem->has_affine_map());
261 for (
unsigned int v=0; v != 4; ++v)
262 CPPUNIT_ASSERT_EQUAL(elem->point(v)(2),
Real(0));
278 dyna.
read(
"25_quad.bxt");
299 for (
unsigned int n=0; n != 9; ++n)
301 (elem->node_ref(n).get_extra_datum<
Real>(weight_index),
304 unsigned int n_neighbors = 0, n_neighbors_expected = 2;
305 for (
unsigned int side=0; side != 4; ++side)
306 if (elem->neighbor_ptr(side))
308 Point c = elem->centroid();
310 if (c(0) > 0.2 && c(0) < 0.8)
311 n_neighbors_expected++;
312 if (c(1) > 0.2 && c(1) < 0.8)
313 n_neighbors_expected++;
315 CPPUNIT_ASSERT_EQUAL(n_neighbors, n_neighbors_expected);
318 #ifdef LIBMESH_ENABLE_CONSTRAINTS
328 #endif // LIBMESH_ENABLE_CONSTRAINTS
343 CPPUNIT_ASSERT_EQUAL(mesh2.
n_elem(),
344 static_cast<dof_id_type>(9));
Manages consistently variables, degrees of freedom, and coefficient vectors.
void copy_elemental_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental sol...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
virtual System & add_system(const std::string &system_type, const std::string &name)
Add the system of type system_type named name to the systems array.
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
Manages consistently variables, degrees of freedom, coefficient vectors, and matrices for implicit sy...
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.
dof_id_type n_constrained_dofs() const
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
virtual dof_id_type n_elem() const =0
const std::string & variable_name(const unsigned int i) const
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
The libMesh namespace provides an interface to certain functionality in the library.
void write_element_data(const EquationSystems &es)
Write out element solution.
static const Real TOLERANCE
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
void add_spline_constraints(DofMap &dof_map, unsigned int sys_num, unsigned int var_num)
Constrains finite element degrees of freedom in terms of spline degrees of freedom by adding user-def...
void write_element_data_from_discontinuous_nodal_data(const EquationSystems &es, const std::set< std::string > *system_names=nullptr, const std::string &var_suffix="_elem_node_")
Similar to the function above, but instead of only handling (CONSTANT, MONOMIAL) data,...
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
virtual SimpleRange< element_iterator > element_ptr_range()=0
void broadcast(MeshBase &) const
virtual dof_id_type n_elem() const override
processor_id_type processor_id() const
unsigned int add_variable(const std::string &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.
libMesh::Parallel::Communicator * TestCommWorld
virtual void init()
Initialize all the systems.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Reading and writing meshes in (a subset of) LS-DYNA format.
This is the EquationSystems class.
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 ...
virtual dof_id_type n_nodes() const =0
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
This class handles the numbering of degrees of freedom on a mesh.
void allow_remote_element_removal(bool allow)
If false is passed in then this mesh will no longer have remote elements deleted when being prepared ...
const DofMap & get_dof_map() const
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
virtual void read(const std::string &name) override
Reads in a mesh in the Dyna format from the ASCII file given by name.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly ecreated (or read) mesh for use.
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
This is the MeshCommunication class.
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Parameters parameters
Data structure holding arbitrary parameters.
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()