mpi/distribution/bifurcation_tracking/pitchfork.cc File Reference
#include <iostream>
#include <fstream>
#include <cmath>
#include <typeinfo>
#include <algorithm>
#include <cstdio>
#include "generic.h"

Classes

class  Mesh1D< ELEMENT >
 
class  SSPorousChannelEquations
 
class  SSPorousChannelElement
 
class  UniformTranspiration< ELEMENT >
 

Namespaces

 Global_Physical_Variables
 Global variables.
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
618 {
619 #ifdef OOMPH_HAS_MPI
620  MPI_Helpers::init(argc,argv);
621 #endif
622 
623  //Load the namespace
624  using namespace Global_Physical_Variables;
625 
626  //Set the number of elements in each section of the mesh.
627  unsigned Nx1=50, Nx2=50;
628  //Set up the problem
630 
631  //Open output file
632  std::ostringstream trace_filename;
633  trace_filename << "trace" << problem.communicator_pt()->my_rank()
634  << ".dat";
635  ofstream trace(trace_filename.str().c_str());
636 
637  //Track the node in the middle
638  //The element Nx1 contains this node
639  SSPorousChannelElement *Test_pt =
640  dynamic_cast<SSPorousChannelElement *>(problem.mesh_pt()->element_pt(Nx1));
641  //Set the position of the node within the element
642  Vector<double> s(1); s[0] = 1.0;
643 
644 #ifdef OOMPH_HAS_MPI
645  //Set up a dummy partition
646  unsigned n_element = problem.mesh_pt()->nelement();
647  Vector<unsigned> element_partition(n_element);
648  for(unsigned e=0;e<n_element/2;e++) {element_partition[e]=0;}
649  for(unsigned e=n_element/2;e<n_element;e++) {element_partition[e]=1;}
650 
651  //DocInfo mesh_doc_info;
652  //bool report_stats=true;
653  //mesh_doc_info.set_directory("RESLT_MESH");
654  problem.distribute(element_partition);//,mesh_doc_info,report_stats);
655  //problem.check_halo_schemes(mesh_doc_info);
656  //problem.distribute();
657 #endif
658 
659  //Step up in Reynolds number
660  for(unsigned i=0;i<6;i++)
661  {
662  //Increase the Reynolds number by 0.5 each time
663  Re = i*0.5;
664  problem.steady_newton_solve();
665  //Output to the trace file
666  trace << Re << " "
667  << Test_pt->interpolated_f(s,1) << " "
668  << Test_pt->interpolated_f(s,0) << std::endl;
669  }
670 
671 
672  //Temp to get the distribution
673 /* DoubleVector res;
674  problem.get_residuals(res);
675 
676  Vector<unsigned> desired_global_eqns;
677  for(unsigned i=0;i<400;i++)
678  {
679  desired_global_eqns.push_back(i);
680  }
681 
682  DoubleVectorHaloScheme test(res.distribution_pt(),desired_global_eqns);
683 
684  DoubleVectorWithHaloEntries junk(res);
685 
686  junk.build_halo_scheme(&test);
687 
688  //Now let's check the synchronisation
689  const unsigned n_row_local = junk.nrow_local();
690  for(unsigned n=0;n<n_row_local;n++)
691  {
692  junk[n] = 100.0;
693  }
694  junk.global_value(200) = 100.0;
695  junk.gather();
696 
697  for(unsigned n=0;n<problem.ndof();n++)
698  {
699  oomph_info << n << " " << junk.global_value(n) << "\n";
700  }
701 
702 #ifdef OOMPH_HAS_MPI
703  MPI_Helpers::finalize();
704 #endif
705 exit(1);*/
706 
707 
708 
709  //Specify the symmetry the hard way
710  //Need to consider the possibility of distribution, so
711  //only work with local dofs
712  unsigned n_dof_local = problem.dof_distribution_pt()->nrow_local();
713  Vector<double> backup(n_dof_local);
714  for(unsigned n=0;n<n_dof_local;n++)
715  {
716  backup[n] = problem.dof(n);
717  }
718 
719  //Now sort out the problem
720  unsigned n_node=problem.mesh_pt()->nnode();
721  for(unsigned n=0;n<n_node;n++)
722  {
723  Node* nod_pt = problem.mesh_pt()->node_pt(n);
724  double x = nod_pt->x(0);
725  if(!nod_pt->is_pinned(1))
726  {
727  nod_pt->set_value(1,x*x);
728  }
729  if(!nod_pt->is_pinned(0))
730  {
731  nod_pt->set_value(0,0.0);
732  }
733  }
734 
735  //The symmetry vector needs to have the DOF distribution
736 
737  //LinearAlgebraDistribution dist(problem.communicator_pt(),n_dof,false);
738  DoubleVector symm(problem.dof_distribution_pt());
739  for(unsigned n=0;n<n_dof_local;n++)
740  {
741  symm[n] = problem.dof(n);
742  problem.dof(n) = backup[n];
743  }
744 
745 
746  //Let's try to find the pitchfork it
747  problem.activate_pitchfork_tracking(&Re,symm,false);
748 
749  problem.steady_newton_solve();
750 
751  std::cout << "Pitchfork detected at " << Re << std::endl;
752  if(problem.communicator_pt()->my_rank()==0)
753  {
754  std::cout << "The slack parameter is "
755  << problem.dof(2*n_dof_local+1) << std::endl;
756  }
757 
758  //Output to the trace file
759  trace << Re << " "
760  << Test_pt->interpolated_f(s,1) << " "
761  << Test_pt->interpolated_f(s,0) << std::endl;
762 
763 
764  // problem.deactivate_bifurcation_tracking();
765  // Re += 0.01;
766  // problem.steady_newton_solve();
767 
768 #ifdef OOMPH_HAS_MPI
769  MPI_Helpers::finalize();
770 #endif
771  }
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.)
Definition: bifurcation_tracking/pitchfork.cc:467
double interpolated_f(const Vector< double > &s, const unsigned &i)
FE interpolated values of the arguments.
Definition: bifurcation_tracking/pitchfork.cc:433
Definition: bifurcation_tracking/pitchfork.cc:560
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271
bool is_pinned(const unsigned &i) const
Test whether the i-th variable is pinned (1: true; 0: false).
Definition: nodes.h:417
Definition: double_vector.h:58
Definition: nodes.h:906
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
RealScalar s
Definition: level1_cplx_impl.h:130
Global variables.
Definition: TwenteMeshGluing.cpp:60
double Re
Reynolds number.
Definition: fibre.cc:55
list x
Definition: plotDoE.py:28
void symm(int size=Size, int othersize=OtherSize)
Definition: product_symm.cpp:13
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References e(), i, SSPorousChannelEquations::interpolated_f(), oomph::Data::is_pinned(), n, problem, GlobalPhysicalVariables::Re, s, oomph::Data::set_value(), symm(), plotDoE::x, and oomph::Node::x().