CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
CppNoddy::Example::Neutral_residual Class Reference
Inheritance diagram for CppNoddy::Example::Neutral_residual:
CppNoddy::Residual< double >

Public Member Functions

 Neutral_residual (const unsigned &initial_N)
 
 ~Neutral_residual ()
 
void residual_fn (const DenseVector< double > &z, DenseVector< double > &f) const
 A blank virtual residual function method. More...
 
- Public Member Functions inherited from CppNoddy::Residual< double >
 Residual (const unsigned &order)
 Constructor for a 'square' residual object that is, N residuals for N unknowns. More...
 
 Residual (const unsigned &order, const unsigned &nvars)
 Constructor for a 'non-square' residual object that is, there are less residual constraints than unknowns. More...
 
virtual ~Residual ()
 An empty destructor, virtual since we have virtual methods. More...
 
void update (const DenseVector< double > &state)
 Update the Residual object for the current set of state variables. More...
 
const DenseVector< double > & residual () const
 Return a handle to the residuals corresponding to the last update state. More...
 
const DenseMatrix< double > & jacobian () const
 Retrun a handle to the Jacobian of the residual corresponding to the last update state. More...
 
double & delta ()
 
const double & delta () const
 
unsigned get_order () const
 Get the order of the residual vector. More...
 
unsigned get_number_of_vars () const
 Get the number of variables that this residual condition is defined for. More...
 
virtual void residual_fn (const DenseVector< double > &state, DenseVector< double > &f) const
 A blank virtual residual function method. More...
 

Public Attributes

ODE_BVP< D_complex > * ode_local
 
OS_bvp_equationbvp
 
OS_bvp_left_BCBC_left
 
OS_bvp_right_BCBC_right
 

Additional Inherited Members

- Protected Member Functions inherited from CppNoddy::Residual< double >
virtual void jacobian (const DenseVector< double > &state, DenseMatrix< double > &jac) const
 Because the residual evaluation at the current state is assumed to have already been done by the 'update' method, this routine is protected. More...
 
- Protected Attributes inherited from CppNoddy::Residual< double >
DenseMatrix< double > JAC_AT_LAST_STATE
 Jacobian for the last state vector. More...
 
DenseVector< double > FN_AT_LAST_STATE
 Residual for the last state vector. More...
 
DenseVector< double > LAST_STATE
 The last state vector. More...
 
double DELTA
 A default step for FD computation of the Jacobian. More...
 
unsigned ORDER_OF_SYSTEM
 The order of the system of equations. More...
 
unsigned NUMBER_OF_VARS
 The number of elements in the state vector. More...
 

Detailed Description

Definition at line 155 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

Constructor & Destructor Documentation

◆ Neutral_residual()

CppNoddy::Example::Neutral_residual::Neutral_residual ( const unsigned &  initial_N)
inline

Definition at line 160 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

160 : Residual<double>( 1 )
161 {
162 // instantiate the object by doing a rough QZ pass of the eigenvalues
163 OS_evp_equation evp;
164 // instantiate the BCs
165 OS_evp_both_BC BC_both;
166 // domain is -1 to 1
167 double left = -1.0;
168 double right = 1.0;
169 // number of nodal points
170 int N = initial_N;
171 // mesh
172 DenseVector<double> nodes( Utility::uniform_node_vector( left, right, N ) );
173 // pass it to the ode
174 ODE_EVP<D_complex> ode_global( &evp, nodes, &BC_both, &BC_both );
175 try
176 {
177 // solve the global eigenvalue problem for growth rate
178 ode_global.eigensolve();
179 }
180 catch (const std::runtime_error &error )
181 {
182 std::cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
183 assert(false);
184 }
185 // get the eigenvalues near the origin
186 ode_global.p_eigensystem() -> tag_eigenvalues_disc( + 1, 0.6 );
187 // make a mesh of each tagged eigenmode in the ODE_EVP class
188 ode_global.add_tagged_to_mesh();
189 DenseVector<D_complex> lambdas = ode_global.p_eigensystem() -> get_tagged_eigenvalues();
190
191 // instantiate the nonlinear BVP formulation
192 bvp = new OS_bvp_equation;
193 BC_left = new OS_bvp_left_BC;
194 BC_right = new OS_bvp_right_BC;
195 // pass it to the ode BVP solver
197 ode_local -> set_monitor_det( false );
198 // use our not-great initial guess from QZ code to start the solver off
199 // here we just use the first (0) tagged eigenvalue
200 ode_local -> solution() = ode_global.get_mesh( 0 );
201 // interpolate onto a finer mesh
202 ode_local -> solution().remesh1( Utility::uniform_node_vector( left, right, 201 ) );
203 ode_local -> set_monitor_det( false );
204 ode_local -> solve2();
205 // adaptively refine the mesh
206 for ( int i = 0; i < MAX_REFINE; ++i )
207 {
208 ode_local -> adapt( 1.e-2 );
209 ode_local -> solve2();
210 std::cout << "Adapted to " << ode_local -> solution().get_nnodes() << " nodes \n";
211 }
212 }
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A templated object for real/complex vector system of first-order ordinary differential equations.
Definition: ODE_BVP.h:37
A templated object for real/complex vector system of first-order ordinary differential equations.
Definition: ODE_EVP.h:35
A base class to be inherited by objects that define residuals.
Definition: Residual.h:15
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...
Definition: Utility.cpp:113

References CppNoddy::ODE_EVP< _Type >::add_tagged_to_mesh(), BC_left, BC_right, bvp, CppNoddy::ODE_EVP< _Type >::eigensolve(), CppNoddy::ODE_EVP< _Type >::get_mesh(), CppNoddy::Example::MAX_REFINE(), ode_local, CppNoddy::ODE_EVP< _Type >::p_eigensystem(), and CppNoddy::Utility::uniform_node_vector().

◆ ~Neutral_residual()

CppNoddy::Example::Neutral_residual::~Neutral_residual ( )
inline

Definition at line 214 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

215 {
216 delete bvp;
217 delete BC_left;
218 delete BC_right;
219 delete ode_local;
220 }

References BC_left, BC_right, bvp, and ode_local.

Member Function Documentation

◆ residual_fn()

void CppNoddy::Example::Neutral_residual::residual_fn ( const DenseVector< double > &  state,
DenseVector< double > &  f 
) const
inlinevirtual

A blank virtual residual function method.

Parameters
stateThe unknown variable.
fThe residual function f(x).

Reimplemented from CppNoddy::Residual< double >.

Definition at line 222 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

223 {
224 Example::Re = z[ 0 ];
225 // solve the nonlinear BVP
226 ode_local -> solve2();
227 // return the residual
228 f[ 0 ] = ode_local -> solution()( 0, eval ).imag();
229 wave_speed = ode_local -> solution()( 0, eval ).real();
230 }
@ f
Definition: BVPBerman.cpp:15
double Re
Globally define the Reynolds number and wavenumber.
double wave_speed
The phase speed of the instability.
DenseVector< double > real(const DenseVector< D_complex > &X)
Return a double DENSE vector containing the real part of a complex DENSE vector.
Definition: Utility.cpp:177
DenseVector< double > imag(const DenseVector< D_complex > &X)
Return a double DENSE vector containing the imaginary part of a complex DENSE vector.
Definition: Utility.cpp:185

References eval, f, ode_local, CppNoddy::Example::Re, CppNoddy::Example::wave_speed, and CppNoddy::Example::z().

Member Data Documentation

◆ BC_left

OS_bvp_left_BC* CppNoddy::Example::Neutral_residual::BC_left

Definition at line 234 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

Referenced by Neutral_residual(), and ~Neutral_residual().

◆ BC_right

OS_bvp_right_BC* CppNoddy::Example::Neutral_residual::BC_right

Definition at line 235 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

Referenced by Neutral_residual(), and ~Neutral_residual().

◆ bvp

OS_bvp_equation* CppNoddy::Example::Neutral_residual::bvp

Definition at line 233 of file EVPOrrSommerfeldNeutralCurve_lapack.cpp.

Referenced by Neutral_residual(), and ~Neutral_residual().

◆ ode_local

ODE_BVP<D_complex>* CppNoddy::Example::Neutral_residual::ode_local

The documentation for this class was generated from the following file:

© 2012

R.E. Hewitt