28 for (dal::bv_visitor i(im_convexes); !i.finished(); ++i) {
30 if (v_num_update < linked_mesh_->convex_version_number(i))
31 const_cast<mesh_im *>(
this)
32 ->set_integration_method(i, auto_add_elt_pim);
38 if (!im_convexes.is_in(i)
40 if (auto_add_elt_pim != 0)
45 v_num_update = v_num = act_counter();
50 GMM_ASSERT1(linked_mesh_ != 0,
"Uninitialized mesh_im");
53 {
if (im_convexes.is_in(cv))
54 { im_convexes.sup(cv); touch(); v_num = act_counter(); } }
55 else if (!im_convexes.is_in(cv) || ims[cv] != pim) {
57 (pim->type() == IM_NONE ||
60 "Incompatibility between integration method " 65 touch(); v_num = act_counter();
70 pintegration_method pim) {
71 for (dal::bv_visitor cv(cvs); !cv.finished(); ++cv)
82 GMM_ASSERT1(im_degree != dim_type(-1),
"im_degree==-1");
83 for (dal::bv_visitor cv(cvs); !cv.finished(); ++cv) {
84 pintegration_method pim =
91 GMM_ASSERT1(im_degree != dim_type(-1),
"im_degree==-1");
94 !cv.finished(); ++cv, ++i) {
95 pintegration_method pim =
102 if (pim != auto_add_elt_pim) auto_add_elt_pim = 0;
107 void mesh_im::clear(
void) {
108 ims.
clear(); im_convexes.clear();
109 touch(); v_num = act_counter();
113 void mesh_im::init_with_mesh(
const mesh &me) {
114 GMM_ASSERT1(linked_mesh_ == 0,
"Mesh im already initialized");
116 this->add_dependency(me);
117 auto_add_elt_pim = 0;
118 v_num_update = v_num = act_counter();
122 linked_mesh_ = 0; auto_add_elt_pim = 0;
123 is_lower_dim =
false;
124 v_num_update = v_num = act_counter();
127 void mesh_im::copy_from(
const mesh_im &mim) {
128 clear_dependencies();
130 init_with_mesh(*(mim.linked_mesh_));
131 is_lower_dim = mim.is_lower_dim;
132 im_convexes = mim.im_convexes;
133 v_num_update = mim.v_num_update;
136 auto_add_elt_pim = mim.auto_add_elt_pim;
140 linked_mesh_ = 0; copy_from(mim);
148 mesh_im::mesh_im(
const mesh &me)
149 { linked_mesh_ = 0; init_with_mesh(me); is_lower_dim =
false; }
151 mesh_im::~mesh_im() {}
155 GMM_ASSERT1(linked_mesh_ != 0,
"Uninitialized mesh_im");
156 gmm::stream_standard_locale sl(ist);
162 ist.seekg(0);ist.clear();
163 bgeot::read_until(ist,
"BEGIN MESH_IM");
168 if (bgeot::casecmp(tmp,
"END")==0) {
170 }
else if (bgeot::casecmp(tmp,
"CONVEX")==0) {
174 " does not exist, are you sure " 175 "that the mesh attached to this object is right one ?");
180 while (!isspace(c)) { tmp.push_back(c); ist.get(c); }
183 GMM_ASSERT1(pfi,
"could not create the integration method '" 187 }
else if (tmp.size()) {
188 GMM_ASSERT1(
false,
"Unexpected token '" << tmp <<
189 "' [pos=" << std::streamoff(ist.tellg()) <<
"]");
190 }
else if (ist.eof()) {
191 GMM_ASSERT1(
false,
"Unexpected end of stream " 192 <<
"(missing BEGIN MESH_IM/END MESH_IM ?)");
199 std::ifstream o(name.c_str());
200 GMM_ASSERT1(o,
"mesh_im file '" << name <<
"' does not exist");
207 gmm::stream_standard_locale sl(ost);
208 ost <<
'\n' <<
"BEGIN MESH_IM" <<
'\n' <<
'\n';
209 for (dal::bv_visitor cv(
convex_index()); !cv.finished(); ++cv) {
210 ost <<
" CONVEX " << cv;
215 ost <<
"END MESH_IM" <<
'\n';
220 std::ofstream o(name.c_str());
221 GMM_ASSERT1(o,
"impossible to open file '" << name <<
"'");
222 o <<
"% GETFEM MESH_IM FILE " <<
'\n';
223 o <<
"% GETFEM VERSION " << GETFEM_VERSION <<
'\n' <<
'\n' <<
'\n';
229 struct dummy_mesh_im_ {
231 dummy_mesh_im_() : mim() {}
void read_from_file(std::istream &ist)
Read the mesh_im from a stream.
virtual pintegration_method int_method_of_element(size_type cv) const
return the integration method associated with an element (in no integration is associated, the function will crash! use the convex_index() of the mesh_im to check that a fem is associated to a given convex)
void write_to_file(const std::string &name) const
Write the mesh to a file.
const mesh_im & dummy_mesh_im()
Dummy mesh_im for default parameter of functions.
void set_integration_method(size_type cv, pintegration_method pim)
Set the integration method of a convex.
void write_to_file(std::ostream &ost) const
Write the mesh_im to a stream.
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
Describe a mesh (collection of convexes (elements) and points).
pconvex_structure structure_of_convex(size_type ic) const
Return the pconvex_structure of the convex ic.
pintegration_method int_method_descriptor(std::string name, bool throw_if_not_found=true)
Get an integration method from its name .
Describe an integration method linked to a mesh.
static T & instance()
Instance from the current thread.
int get_token(std::istream &ist, std::string &st, bool ignore_cr, bool to_up, bool read_un_pm, int *linenb)
Very simple lexical analysis of general interest for reading small langages with a "MATLAB like" synt...
size_t size_type
used as the common size type in the library
void set_auto_add(pintegration_method pim)
Set the im for automatic addition of element option.
std::string name_of_int_method(pintegration_method p)
Get the string name of an integration method .
Deal with interdependencies of objects.
GEneric Tool for Finite Element Methods.
std::string name_of_geometric_trans(pgeometric_trans p)
Get the string name of a geometric transformation.
const dal::bit_vector & convex_index(void) const
Get the set of convexes where an integration method has been assigned.
void update_from_context(void) const
this function has to be defined and should update the object when the context is modified.
pintegration_method classical_approx_im(bgeot::pgeometric_trans pgt, dim_type degree)
try to find an approximate integration method for the geometric transformation pgt which is able to i...
pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
const mesh & linked_mesh() const
Give a reference to the linked mesh of type mesh.
bool context_check() const
return true if update_from_context was called
void clear(void)
Clear and desallocate all the elements.
gmm::uint64_type convex_version_number(size_type ic) const
return the version number of the convex ic.
const dal::bit_vector & convex_index() const
Return the list of valid convex IDs.