27 #ifndef OOMPH_MESH_SMOOTH_HEADER
28 #define OOMPH_MESH_SMOOTH_HEADER
33 #include "../linear_elasticity/elasticity_tensor.h"
34 #include "../constitutive/constitutive_laws.h"
35 #include "../solid/solid_traction_elements.h"
43 namespace Helper_namespace_for_mesh_smoothing
96 template<
class ELEMENT>
115 const unsigned& max_steps = 100000000)
122 controlled_boundary_id,
145 const unsigned& max_steps = 100000000)
151 unsigned nnode = orig_mesh_pt->
nnode();
152 unsigned nbound = orig_mesh_pt->
nboundary();
164 for (
unsigned j = 0; j < nnod; j++)
168 for (
unsigned i = 0;
i < dim;
i++)
187 unsigned n = controlled_boundary_id.size();
188 for (
unsigned i = 0;
i < n;
i++)
191 unsigned b = controlled_boundary_id[
i];
194 quadratic_surface_mesh_pt[b] =
new SolidMesh;
200 for (
unsigned e = 0;
e < n_element;
e++)
203 ELEMENT* bulk_elem_pt =
214 quadratic_surface_mesh_pt[b]->add_element_pt(el_pt);
221 quadratic_surface_geom_obj_pt[b] =
229 for (
unsigned i = 0;
i < n;
i++)
232 unsigned b = controlled_boundary_id[
i];
235 dummy_lagrange_multiplier_mesh_pt[
i] =
new SolidMesh;
241 for (
unsigned e = 0;
e < n_element;
e++)
245 ELEMENT* bulk_elem_pt =
254 bulk_elem_pt, face_index);
257 dummy_lagrange_multiplier_mesh_pt[
i]->add_element_pt(el_pt);
263 quadratic_surface_geom_obj_pt[b], b);
274 oomph_info <<
"Number of equations for nonlinear smoothing problem: "
281 for (
unsigned e = 0;
e < n_element;
e++)
287 el_pt->constitutive_law_pt() =
346 if (count == max_steps)
348 oomph_info <<
"Bailing out after " << count <<
" steps.\n";
354 oomph_info <<
"Done with Helper_namespace_for_mesh_smoothing::Scale="
358 for (
unsigned j = 0; j < nnode; j++)
365 for (
unsigned i = 0;
i < dim;
i++)
367 orig_node_pt->
x(
i) = new_node_pt->
x(
i);
376 n = controlled_boundary_id.size();
377 for (
unsigned i = 0;
i < n;
i++)
380 unsigned b = controlled_boundary_id[
i];
383 delete quadratic_surface_mesh_pt[b];
384 delete quadratic_surface_geom_obj_pt[b];
385 delete dummy_lagrange_multiplier_mesh_pt[
i];
397 oomph_info <<
"Solving nonlinear smoothing problem for scale "
400 for (
unsigned j = 0; j < nnod; j++)
403 unsigned dim = nod_pt->
ndim();
404 for (
unsigned i = 0;
i < dim;
i++)
420 for (
unsigned j = 0; j < nnod; j++)
423 unsigned dim = nod_pt->
ndim();
425 for (
unsigned i = 0;
i < dim;
i++)
438 for (
unsigned j = 0; j < nnod; j++)
441 unsigned dim = nod_pt->
ndim();
442 for (
unsigned i = 0;
i < dim;
i++)
455 std::ofstream some_file;
456 std::ostringstream filename;
462 filename << doc_info.
directory() <<
"/smoothing_soln" << doc_info.
number()
465 some_file.open(filename.str().c_str());
470 bool mesh_has_inverted_elements;
471 std::ofstream inverted_fluid_elements;
473 filename << doc_info.
directory() <<
"/inverted_elements_during_smoothing"
474 << doc_info.
number() <<
".dat";
475 some_file.open(filename.str().c_str());
480 if (!mesh_has_inverted_elements)
oomph_info <<
"not ";
522 template<
class LINEAR_ELASTICITY_ELEMENT>
533 unsigned nelem = orig_mesh_pt->
nelement();
534 unsigned nnode = orig_mesh_pt->
nnode();
537 std::map<Node*, Node*> new_node;
540 for (
unsigned e = 0;
e < nelem;
e++)
543 LINEAR_ELASTICITY_ELEMENT* el_pt =
new LINEAR_ELASTICITY_ELEMENT;
547 el_pt->elasticity_tensor_pt() =
553 unsigned nnod = orig_elem_pt->
nnode();
556 for (
unsigned j = 0; j < nnod; j++)
559 if (new_node[orig_elem_pt->
node_pt(j)] == 0)
563 new_node[orig_elem_pt->
node_pt(j)] = new_nod_pt;
565 unsigned dim = new_nod_pt->
ndim();
566 for (
unsigned i = 0;
i < dim;
i++)
578 new_node[orig_elem_pt->
node_pt(j)];
586 for (std::set<Node*>::iterator it = pinned_nodes.begin();
587 it != pinned_nodes.end();
590 unsigned dim = (*it)->
ndim();
591 for (
unsigned i = 0;
i < dim;
i++)
593 new_node[*it]->pin(
i);
594 new_node[*it]->set_value(
i,
601 oomph_info <<
"Number of equations for smoothing problem: "
609 for (
unsigned j = 0; j < nnode; j++)
613 Node* new_node_pt = new_node[orig_node_pt];
616 unsigned dim = new_node_pt->
ndim();
617 for (
unsigned i = 0;
i < dim;
i++)
619 orig_node_pt->
x(
i) = orig_node_pt->
xi(
i) + new_node_pt->
value(
i);
657 template<
class POISSON_ELEMENT>
668 unsigned nelem = orig_mesh_pt->
nelement();
669 unsigned nnode = orig_mesh_pt->
nnode();
672 std::map<Node*, Node*> new_node;
675 for (
unsigned e = 0;
e < nelem;
e++)
682 unsigned nnod = orig_elem_pt->
nnode();
685 for (
unsigned j = 0; j < nnod; j++)
688 if (new_node[orig_elem_pt->
node_pt(j)] == 0)
692 new_node[orig_elem_pt->
node_pt(j)] = new_nod_pt;
694 unsigned dim = new_nod_pt->
ndim();
695 for (
unsigned i = 0;
i < dim;
i++)
707 new_node[orig_elem_pt->
node_pt(j)];
714 for (std::set<Node*>::iterator it = pinned_nodes.begin();
715 it != pinned_nodes.end();
718 new_node[*it]->
pin(0);
721 oomph_info <<
"Number of equations for Poisson displacement smoothing: "
726 for (
unsigned i = 0;
i < dim;
i++)
729 for (
unsigned j = 0; j < nnode; j++)
733 Node* new_node_pt = new_node[orig_node_pt];
736 new_node_pt->
set_value(0, orig_node_pt->
x(
i) - orig_node_pt->
xi(
i));
743 for (
unsigned j = 0; j < nnode; j++)
747 Node* new_node_pt = new_node[orig_node_pt];
750 orig_node_pt->
x(
i) = orig_node_pt->
xi(
i) + new_node_pt->
value(0);
///////////////////////////////////////////////////////////////// ///////////////////////////////////...
void pin(const unsigned &i)
Pin the i-th stored variable.
void set_value(const unsigned &i, const double &value_)
Set the i-th stored data value to specified value. The only reason that we require an explicit set fu...
Information for documentation of results: Directory and file number to enable output in the form RESL...
bool is_doc_enabled() const
Are we documenting?
void disable_doc()
Disable documentation.
std::string directory() const
Output directory.
unsigned & number()
Number used (e.g.) for labeling output files.
void set_boundary_number_in_bulk_mesh(const unsigned &b)
Set function for the boundary number in bulk mesh.
virtual Node * construct_node(const unsigned &n)
Construct the local node n and return a pointer to the newly created node object.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
unsigned nnode() const
Return the number of nodes.
////////////////////////////////////////////////////////////////////// //////////////////////////////...
///////////////////////////////////////////////////////////////////////// ///////////////////////////...
void set_boundary_shape_geom_object_pt(GeomObject *boundary_shape_geom_object_pt, const unsigned &boundary_number_in_bulk_mesh)
Set GeomObject that specifies the prescribed boundary displacement; GeomObject is assumed to be param...
An isotropic elasticity tensor defined in terms of Young's modulus and Poisson's ratio....
/////////////////////////////////////////////////////////////// /////////////////////////////////////...
void operator()(SolidMesh *orig_mesh_pt, std::set< Node * > pinned_nodes)
Constructor: Specify SolidMesh whose nodal positions are to be adjusted, and set of nodes in that mes...
~LinearElasticitySmoothMesh()
Destructor (empty)
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
FiniteElement * finite_element_pt(const unsigned &e) const
Upcast (downcast?) to FiniteElement (needed to access FiniteElement member functions).
int face_index_at_boundary(const unsigned &b, const unsigned &e) const
For the e-th finite element on boundary b, return int to indicate the face_index of the face adjacent...
unsigned nboundary_element(const unsigned &b) const
Return number of finite elements that are adjacent to boundary b.
void check_inverted_elements(bool &mesh_has_inverted_elements, std::ofstream &inverted_element_file)
Check for inverted elements and report outcome in boolean variable. This visits all elements at their...
unsigned nboundary() const
Return number of boundaries.
FiniteElement * boundary_element_pt(const unsigned &b, const unsigned &e) const
Return pointer to e-th finite element on boundary b.
GeneralisedElement *& element_pt(const unsigned long &e)
Return pointer to element e.
unsigned long nnode() const
Return number of nodes in the mesh.
void output(std::ostream &outfile)
Output for all elements.
void add_element_pt(GeneralisedElement *const &element_pt)
Add a (pointer to) an element to the mesh.
void add_node_pt(Node *const &node_pt)
Add a (pointer to a) node to the mesh.
unsigned long nelement() const
Return number of elements in the mesh.
A class to handle errors in the Newton solver.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
double & x(const unsigned &i)
Return the i-th nodal coordinate.
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
double value(const unsigned &i) const
Return i-th value (dofs or pinned) at this node either directly or via hanging node representation....
/////////////////////////////////////////////////////////////// /////////////////////////////////////...
void backup()
Backup nodal positions in dummy mesh to allow for reset after non-convergence of Newton method.
void operator()(SolidMesh *orig_mesh_pt, SolidMesh *copy_of_mesh_pt, const Vector< unsigned > &controlled_boundary_id, const unsigned &max_steps=100000000)
Functor to update the nodal positions in SolidMesh pointed to by orig_mesh_pt in response to the disp...
Vector< Vector< double > > Orig_node_pos
Original nodal positions.
SolidMesh * Orig_mesh_pt
Bulk original mesh.
SolidMesh * Dummy_mesh_pt
Copy of mesh to work on.
void operator()(SolidMesh *orig_mesh_pt, SolidMesh *copy_of_mesh_pt, const Vector< unsigned > &controlled_boundary_id, DocInfo doc_info, const unsigned &max_steps=100000000)
Functor to update the nodal positions in SolidMesh pointed to by orig_mesh_pt in response to the disp...
void doc_solution(DocInfo &doc_info)
Doc the solution.
Vector< Vector< double > > Backup_node_pos
Backup nodal positions.
void actions_before_newton_solve()
Update nodal positions in main mesh – also moves the nodes of the FaceElements that impose the new po...
void reset()
Reset nodal positions in dummy mesh to allow for restart of Newton method with reduced increment in S...
~NonLinearElasticitySmoothMesh()
Destructor (empty)
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
void operator()(SolidMesh *orig_mesh_pt, std::set< Node * > pinned_nodes)
Functor: Specify SolidMesh whose nodal positions are to be adjusted, and set of nodes in that mesh wh...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
unsigned add_sub_mesh(Mesh *const &mesh_pt)
Add a submesh to the problem and return its number, i, by which it can be accessed via mesh_pt(i).
unsigned long assign_eqn_numbers(const bool &assign_local_eqn_numbers=true)
Assign all equation numbers for problem: Deals with global data (= data that isn't attached to any el...
void build_global_mesh()
Build the global mesh by combining the all the submeshes. Note: The nodes boundary information refers...
void newton_solve()
Use Newton method to solve the problem.
Mesh *& mesh_pt()
Return a pointer to the global mesh.
////////////////////////////////////////////////////////////////////// //////////////////////////////...
void set_lagrangian_nodal_coordinates()
Make the current configuration the undeformed one by setting the nodal Lagrangian coordinates to thei...
SolidNode * node_pt(const unsigned long &n)
Return a pointer to the n-th global SolidNode.
A Class for nodes that deform elastically (i.e. position is an unknown in the problem)....
double & xi(const unsigned &i)
Reference to i-th Lagrangian position.
A class for elements that allow the imposition of an applied traction in the principle of virtual dis...
ConstitutiveLaw * Constitutive_law_pt
Create constitutive law (for smoothing by nonlinear elasticity)
double Scale
Scale for displacement of quadratic boundary (0.0: simplex; 1.0: quadratic)
double Nu
Poisson's ratio (for smoothing by linear or nonlinear elasticity)
double E
Young's modulus (for smoothing by linear or nonlinear elasticity)
double Scale_increment
Increment for scale factor for displacement of quadratic boundary.
IsotropicElasticityTensor Isotropic_elasticity_tensor(Nu)
The elasticity tensor (for smoothing by linear elasticity)
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...