24#include "libmesh/elem.h"
25#include "libmesh/fe_interface.h"
26#include "libmesh/fe_type.h"
27#include "libmesh/getpot.h"
28#include "libmesh/int_range.h"
29#include "libmesh/libmesh.h"
30#include "libmesh/reference_elem.h"
31#include "libmesh/string_to_enum.h"
32#include "libmesh/point.h"
44 <<
" --elem type elem type (e.g. TET14)\n"
45 <<
" --childnum num child number\n"
46 <<
" --denominator num denominator to use\n"
47 <<
" --diff only output diffs from existing\n"
56 const std::string & argname,
57 const char * progname,
60 if (!cl.search(argname))
62 libMesh::err << (
"No " + argname +
" argument found!") << std::endl;
65 return cl.next(defaultarg);
69#ifdef LIBMESH_ENABLE_AMR
70int main(
int argc,
char ** argv)
74 GetPot cl(argc, argv);
76 const std::string elem_type_string =
82 const int denominator =
85 const bool diff = cl.search(
"--diff");
88 Utility::string_to_enum<ElemType>(elem_type_string);
92 std::unique_ptr<Elem> elem =
Elem::build(elem_type);
97 FEType fe_type(elem->default_order());
100 libmesh_error_msg_if(
n_nodes != elem->n_nodes(),
"Bad FEInterface value?");
102 std::vector<Node> nodes(
n_nodes);
112 nodes[v] = ref.
point(n);
113 elem->set_node(v, &nodes[v]);
115 else if (embed != 0.0)
116 libmesh_error_msg(
"Found fractional embedding on vertex!?");
127 for (
auto pbn : pbns)
128 nodes[n] += (ref.
point(pbn.first) + ref.
point(pbn.second))/2;
129 nodes[n] /= pbns.size();
130 elem->set_node(n, &nodes[n]);
133 const unsigned int denomdigits = std::ceil(std::log10(denominator));
134 const unsigned int spacing = denomdigits*2+3;
136 std::cout.precision(17);
138 std::cout <<
" // embedding matrix for child " << childnum <<
'\n';
143 const unsigned int indexdigits =
144 std::ceil(std::log10(i));
145 const int padding = spacing-indexdigits-2*(i==0);
146 for (
int k=0; k < padding; ++k)
157 const Point & pt = elem->point(i);
171 for (
unsigned int k=0; k != spacing; ++k)
178 int oldnumerator =
int(std::round(shape*denominator));
179 int newnumerator = oldnumerator;
180 int newdenominator = denominator;
184 int the_gcd = std::gcd(newnumerator, newdenominator);
185 newnumerator /= the_gcd;
186 newdenominator /= the_gcd;
189 const unsigned int newdenomdigits =
190 std::ceil(std::log10(newdenominator));
191 std::ostringstream ostr;
192 ostr << (shape*newdenominator);
194 (shape != 0.0 && newdenominator != 1) ?
195 int(spacing)-newdenomdigits-2-ostr.str().size() :
196 int(spacing)-ostr.str().size();
197 for (
int k=0; k < padding; ++k)
199 std::cout << ostr.str();
200 if (shape != 0.0 && newdenominator != 1)
202 if (1 << (
int)std::round(std::log2(newdenominator)) ==
204 std::cout <<
"/" << newdenominator <<
'.';
209 std::cout <<
"/r" << newdenominator;
221 std::cout <<
"// " << i <<
'\n';
223 std::cout <<
" },\n";
228int main (
int,
char **)
230 std::cout <<
"This libMesh was built with --disable-amr" << std::endl;
void ErrorVector unsigned int
This is the base class from which all geometric element types are derived.
virtual const std::vector< std::pair< unsigned char, unsigned char > > & parent_bracketing_nodes(unsigned int c, unsigned int n) const
const Point & point(const unsigned int i) const
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
virtual Real embedding_matrix(const unsigned int child_num, const unsigned int child_node_num, const unsigned int parent_node_num) const =0
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
A Point defines a location in LIBMESH_DIM dimensional Real space.
void usage_error(const char *progname)
T assert_argument(GetPot &cl, const std::string &argname, const char *progname, const T &defaultarg)
const Elem & get(const ElemType type_in)
The libMesh namespace provides an interface to certain functionality in the library.
ElemType
Defines an enum for geometric element types.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
const dof_id_type n_nodes