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];
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;
465 some_file.open(
filename.str().c_str());
470 bool mesh_has_inverted_elements;
471 std::ofstream inverted_fluid_elements;
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++)
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++)
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);
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Scalar * b
Definition: benchVecAdd.cpp:17
Definition: constitutive_laws.h:471
void pin(const unsigned &i)
Pin the i-th stored variable.
Definition: nodes.h:385
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271
Definition: oomph_utilities.h:499
bool is_doc_enabled() const
Are we documenting?
Definition: oomph_utilities.h:548
void disable_doc()
Disable documentation.
Definition: oomph_utilities.h:542
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
unsigned & number()
Number used (e.g.) for labeling output files.
Definition: oomph_utilities.h:554
void set_boundary_number_in_bulk_mesh(const unsigned &b)
Set function for the boundary number in bulk mesh.
Definition: elements.h:4482
virtual Node * construct_node(const unsigned &n)
Definition: elements.h:2509
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
Definition: constitutive_laws.h:699
Definition: solid_traction_elements.h:1107
void set_boundary_shape_geom_object_pt(GeomObject *boundary_shape_geom_object_pt, const unsigned &boundary_number_in_bulk_mesh)
Definition: solid_traction_elements.h:1209
Definition: linear_elasticity/elasticity_tensor.h:160
Definition: mesh_smooth.h:524
void operator()(SolidMesh *orig_mesh_pt, std::set< Node * > pinned_nodes)
Definition: mesh_smooth.h:529
~LinearElasticitySmoothMesh()
Destructor (empty)
Definition: mesh_smooth.h:631
Definition: mesh_as_geometric_object.h:93
FiniteElement * finite_element_pt(const unsigned &e) const
Definition: mesh.h:473
int face_index_at_boundary(const unsigned &b, const unsigned &e) const
Definition: mesh.h:896
unsigned nboundary_element(const unsigned &b) const
Return number of finite elements that are adjacent to boundary b.
Definition: mesh.h:878
void check_inverted_elements(bool &mesh_has_inverted_elements, std::ofstream &inverted_element_file)
Definition: mesh.cc:870
unsigned nboundary() const
Return number of boundaries.
Definition: mesh.h:827
FiniteElement * boundary_element_pt(const unsigned &b, const unsigned &e) const
Return pointer to e-th finite element on boundary b.
Definition: mesh.h:840
GeneralisedElement *& element_pt(const unsigned long &e)
Return pointer to element e.
Definition: mesh.h:448
unsigned long nnode() const
Return number of nodes in the mesh.
Definition: mesh.h:596
void output(std::ostream &outfile)
Output for all elements.
Definition: mesh.cc:2027
void add_element_pt(GeneralisedElement *const &element_pt)
Add a (pointer to) an element to the mesh.
Definition: mesh.h:617
void add_node_pt(Node *const &node_pt)
Add a (pointer to a) node to the mesh.
Definition: mesh.h:611
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
A class to handle errors in the Newton solver.
Definition: problem.h:2952
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
double value(const unsigned &i) const
Definition: nodes.cc:2408
Definition: mesh_smooth.h:98
void backup()
Definition: mesh_smooth.h:416
void operator()(SolidMesh *orig_mesh_pt, SolidMesh *copy_of_mesh_pt, const Vector< unsigned > &controlled_boundary_id, const unsigned &max_steps=100000000)
Definition: mesh_smooth.h:112
Vector< Vector< double > > Orig_node_pos
Original nodal positions.
Definition: mesh_smooth.h:486
SolidMesh * Orig_mesh_pt
Bulk original mesh.
Definition: mesh_smooth.h:492
SolidMesh * Dummy_mesh_pt
Copy of mesh to work on.
Definition: mesh_smooth.h:495
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)
Definition: mesh_smooth.h:141
void doc_solution(DocInfo &doc_info)
Doc the solution.
Definition: mesh_smooth.h:450
Vector< Vector< double > > Backup_node_pos
Backup nodal positions.
Definition: mesh_smooth.h:489
void actions_before_newton_solve()
Definition: mesh_smooth.h:395
void reset()
Definition: mesh_smooth.h:435
~NonLinearElasticitySmoothMesh()
Destructor (empty)
Definition: mesh_smooth.h:390
Definition: mesh_smooth.h:659
void operator()(SolidMesh *orig_mesh_pt, std::set< Node * > pinned_nodes)
Definition: mesh_smooth.h:664
Definition: problem.h:151
unsigned add_sub_mesh(Mesh *const &mesh_pt)
Definition: problem.h:1330
void build_global_mesh()
Definition: problem.cc:1493
Mesh *& mesh_pt()
Return a pointer to the global mesh.
Definition: problem.h:1280
void newton_solve()
Use Newton method to solve the problem.
Definition: problem.cc:8783
unsigned long assign_eqn_numbers(const bool &assign_local_eqn_numbers=true)
Definition: problem.cc:1989
Definition: elements.h:3561
SolidNode * node_pt(const unsigned long &n)
Return a pointer to the n-th global SolidNode.
Definition: mesh.h:2594
void set_lagrangian_nodal_coordinates()
Definition: mesh.cc:9564
double & xi(const unsigned &i)
Reference to i-th Lagrangian position.
Definition: nodes.h:1883
Definition: solid_traction_elements.h:78
string filename
Definition: MergeRestartFiles.py:39
ConstitutiveLaw * Constitutive_law_pt
Create constitutive law (for smoothing by nonlinear elasticity)
Definition: mesh_smooth.h:55
double Scale
Definition: mesh_smooth.h:59
double Nu
Poisson's ratio (for smoothing by linear or nonlinear elasticity)
Definition: mesh_smooth.h:46
double E
Young's modulus (for smoothing by linear or nonlinear elasticity)
Definition: mesh_smooth.h:49
double Scale_increment
Increment for scale factor for displacement of quadratic boundary.
Definition: mesh_smooth.h:62
IsotropicElasticityTensor Isotropic_elasticity_tensor(Nu)
The elasticity tensor (for smoothing by linear elasticity)
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2