VortexWaveInteraction.cpp 84.6 KB
Newer Older
Spencer Sherwin's avatar
Spencer Sherwin committed
1
//////////////////////////////////////////////////////////////////////////////
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// File VortexWaveInteraction.cpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Vortex Wave Interaction class
//
///////////////////////////////////////////////////////////////////////////////
35

36
#include <VortexWaveInteraction/VortexWaveInteraction.h>
37
#include <MultiRegions/GlobalLinSysKey.h>
Pavel Burovskiy's avatar
Pavel Burovskiy committed
38
#include <MultiRegions/ExpList1D.h>
39
#include <SolverUtils/Driver.h>
40
#include <IncNavierStokesSolver/EquationSystems/IncNavierStokes.h>
41
42
43

namespace Nektar
{
44
45

    VortexWaveInteraction::VortexWaveInteraction(int argc, char * argv[]):
46
        m_nOuterIterations(0)
47
    {
48

49
        int storesize;// number of previous iterations to store
50

51
52
53
54
55
56
57
58
59
60
61
62
        m_sessionName = argv[argc-1];
        string meshfile = m_sessionName + ".xml";

        LibUtilities::SessionReaderSharedPtr session; 

        std::string VWICondFile(argv[argc-1]); 
        VWICondFile += "_VWI.xml"; 
        std::vector<std::string> VWIFilenames;
        VWIFilenames.push_back(meshfile);   
        VWIFilenames.push_back(VWICondFile);

        // Create Incompressible NavierStokesSolver session reader.
63
64
        m_sessionVWI = LibUtilities::SessionReader::CreateInstance(argc, argv, 
                                                                   VWIFilenames);
65
        
66
        m_sessionVWI->LoadParameter("AlphaStep",              m_alphaStep,0.05);
67
        m_sessionVWI->LoadParameter("OuterIterationStoreSize",storesize,10);
68
69

        //set a low tol for interfaceVWI
70
71
	m_sessionVWI->LoadParameter("EigenvalueRelativeTol",  m_eigRelTol,1e-3);
       
Spencer Sherwin's avatar
Spencer Sherwin committed
72
        
73
74
        m_sessionVWI->LoadParameter("NeutralPointTolerance",  m_neutralPointTol,1e-4);
        m_sessionVWI->LoadParameter("MaxOuterIterations",     m_maxOuterIterations,100);
75
        
76
77
        m_sessionVWI->LoadParameter("StartIteration",m_iterStart, 0);
        m_sessionVWI->LoadParameter("EndIteration",  m_iterEnd, 0);
78

79
        m_sessionVWI->LoadParameter("WaveForceMagStep",   m_waveForceMagStep,0.01);
80
        m_sessionVWI->LoadParameter("DAlphaDWaveForceMag", m_dAlphaDWaveForceMag,0.0);
81
        m_sessionVWI->LoadParameter("MaxWaveForceMagIter",m_maxWaveForceMagIter,1);
82
        m_sessionVWI->LoadParameter("RollForceScale",     m_rollForceScale,1.0);
83
        
84
85
86
        if(m_sessionVWI->DefinesSolverInfo("DeltaFcnApprox"))
        {
            m_deltaFcnApprox = true;
87
            m_sessionVWI->LoadParameter("DeltaFcnDecay", m_deltaFcnDecay,1.0/500);
88
89
90
91
92
93
94
        }
        else
        {
            m_deltaFcnApprox = false;
            m_deltaFcnDecay = 0.0;
        }

95
96
97
98
99
100
101
102
103
        if(m_sessionVWI->DefinesSolverInfo("LinfPressureNorm"))
        {
            m_useLinfPressureNorm  = true;
        }
        else
        {
            m_useLinfPressureNorm  = false;
        }

Andrea Isoni's avatar
Andrea Isoni committed
104
105
        if( m_sessionVWI->DefinesSolverInfo("INTERFACE")  )
        {
106
            m_iterinterface = true;
Andrea Isoni's avatar
Andrea Isoni committed
107
108
109
        }
        else
        {
110
            m_iterinterface = false;
Andrea Isoni's avatar
Andrea Isoni committed
111
112
        }

Spencer Sherwin's avatar
Spencer Sherwin committed
113
114
115
116
117
118
119
120
121
        if(m_sessionVWI->DefinesSolverInfo("MoveMeshToCriticalLayer"))
        {
            m_moveMeshToCriticalLayer = true;
        }
        else
        {
            m_moveMeshToCriticalLayer = false;
        }

122
        m_alpha = Array<OneD, NekDouble> (storesize);
123
124
        m_alpha[0]         = m_sessionVWI->GetParameter("Alpha");
        m_waveForceMag     = Array<OneD, NekDouble> (storesize);
125
126
        m_waveForceMag[0]  = m_sessionVWI->GetParameter("WaveForceMag");
        
127
128
        m_leading_real_evl = Array<OneD, NekDouble> (storesize);
        m_leading_imag_evl = Array<OneD, NekDouble> (storesize);
129
130
131
132
        
        if(m_sessionVWI->DefinesParameter("Relaxation"))
        {
            m_vwiRelaxation = m_sessionVWI->GetParameter("Relaxation");
133
134
135
136
            // fix minimum number of iterations to be number of
            // iterations required to make contribution of innitial
            // forcing to 0.1
            m_minInnerIterations = (int) (log(0.1)/log(m_vwiRelaxation)); 
137
138
139
140
        }
        else
        {
            m_vwiRelaxation = 0.0;
141
            m_minInnerIterations = 1;
142
        }
143
144
145
146
147
148
149
150
151
        
        // Initialise NS Roll solver 
        std::string IncCondFile(argv[argc-1]); 
        IncCondFile += "_IncNSCond.xml"; 
        std::vector<std::string> IncNSFilenames;
        IncNSFilenames.push_back(meshfile);   
        IncNSFilenames.push_back(IncCondFile);

        // Create Incompressible NavierStokesSolver session reader.
152
153
        m_sessionRoll = LibUtilities::SessionReader::CreateInstance(argc, argv, IncNSFilenames, 
                                                                    m_sessionVWI->GetComm());
154
155
        std::string vEquation = m_sessionRoll->GetSolverInfo("SolverType");
        m_solverRoll = GetEquationSystemFactory().CreateInstance(vEquation, m_sessionRoll);
156
        m_solverRoll->PrintSummary(cout);
157

158
159
160

        if(m_sessionRoll->DefinesSolverInfo("INTERFACE"))
	{
161
            m_sessionVWI->LoadParameter("EigenvalueRelativeTol",  m_eigRelTol,1e-2);
162
163
	}

164
165
166
167
168
169
170
171
172
        int ncoeffs = m_solverRoll->UpdateFields()[0]->GetNcoeffs();
        m_vwiForcing = Array<OneD, Array<OneD, NekDouble> > (4);
        m_vwiForcing[0] = Array<OneD, NekDouble> (4*ncoeffs);
        for(int i = 1; i < 4; ++i)
        {
            m_vwiForcing[i] = m_vwiForcing[i-1] + ncoeffs;
        }

        // Fill forcing into m_vwiForcing
173
174
175
        // Has forcing even been initialised yet?
//        Vmath::Vcopy(ncoeffs,m_solverRoll->UpdateForces()[0]->GetCoeffs(),1,m_vwiForcing[0],1);
//        Vmath::Vcopy(ncoeffs,m_solverRoll->UpdateForces()[1]->GetCoeffs(),1,m_vwiForcing[1],1);
176
        
177
178
179
180
181
182
183

        // Create AdvDiff Streak solver 
        std::string AdvDiffCondFile(argv[argc-1]); 
        AdvDiffCondFile += "_AdvDiffCond.xml"; 
        std::vector<std::string> AdvDiffFilenames;
        AdvDiffFilenames.push_back(meshfile);   
        AdvDiffFilenames.push_back(AdvDiffCondFile);
184
        
185
        // Create AdvDiffusion session reader.
186
        m_sessionStreak = LibUtilities::SessionReader::CreateInstance(argc, argv, AdvDiffFilenames, m_sessionVWI->GetComm());
187
188
189
190
191
192
193
194
195

        // Initialise LinNS solver 
        std::string LinNSCondFile(argv[argc-1]); 
        LinNSCondFile += "_LinNSCond.xml"; 
        std::vector<std::string> LinNSFilenames;
        LinNSFilenames.push_back(meshfile);   
        LinNSFilenames.push_back(LinNSCondFile);
        
        // Create Linearised NS stability session reader.
196
        m_sessionWave = LibUtilities::SessionReader::CreateInstance(argc, argv, LinNSFilenames, m_sessionVWI->GetComm());
197
198
199

        // Set the initial beta value in stability to be equal to VWI file
        std::string LZstr("LZ");
200
        NekDouble LZ = 2*M_PI/m_alpha[0];
201
        cout << "Setting LZ in Linearised solver to " << LZ << endl;
202
        m_sessionWave->SetParameter(LZstr,LZ);
203

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
        // Check for iteration type 
        if(m_sessionVWI->DefinesSolverInfo("VWIIterationType"))
        {
            std::string IterationTypeStr = m_sessionVWI->GetSolverInfo("VWIIterationType");
            for(int i = 0; i < (int) eVWIIterationTypeSize; ++i)
            {
                if(m_solverRoll->NoCaseStringCompare(VWIIterationTypeMap[i],IterationTypeStr) == 0 )
                {
                    m_VWIIterationType = (VWIIterationType)i; 
                    break;
                }
            }
        }
        else
        {
            m_VWIIterationType = eFixedAlphaWaveForcing;
        }
221

222
223


224
225
226
227
228
        // Check for restart
        bool restart;
        m_sessionVWI->MatchSolverInfo("RestartIteration","True",restart,false);
        if(restart)
        {
229
230
            switch(m_VWIIterationType)
            {
231
            case  eFixedAlpha:
232
233
234
235
236
                break;
            case  eFixedWaveForcing:
                {
                    FILE *fp;
                    // Check for OuterIter.his file to read
237
                    if((fp = fopen("OuterIter.his","r")))
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
                    {
                        char buf[BUFSIZ];
                        std::vector<NekDouble> Alpha, Growth, Phase;
                        NekDouble alpha,growth,phase;
                        while(fgets(buf,BUFSIZ,fp))
                        {
                            sscanf(buf,"%*d:%lf%lf%lf",&alpha,&growth,&phase);
                            Alpha.push_back(alpha);
                            Growth.push_back(growth);
                            Phase.push_back(phase);
                        }

                        m_nOuterIterations = Alpha.size();
                        
                        int nvals = std::min(m_nOuterIterations,(int)m_alpha.num_elements());
                        
                        for(int i = 0; i < nvals; ++i)
                        {
                            m_alpha[nvals-1-i]            = Alpha[m_nOuterIterations-nvals+i];
                            m_leading_real_evl[nvals-1-i] = Growth[m_nOuterIterations-nvals+i];
                            m_leading_imag_evl[nvals-1-i] = Phase [m_nOuterIterations-nvals+i];
                        }

                        UpdateAlpha(m_nOuterIterations++);
                    }
                    else
                    {
                        cout << " No File OuterIter.his to restart from" << endl;
                    }
                }
                break;
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
            case eFixedAlphaWaveForcing:
                {
                    string nstr =  boost::lexical_cast<std::string>(m_iterStart);
                    cout << "Restarting from iteration " << m_iterStart << endl;
                    std::string rstfile = "cp -f Save/" + m_sessionName + ".rst." + nstr + " " + m_sessionName + ".rst"; 
                    cout << "      " << rstfile << endl;
                    if(system(rstfile.c_str()))
                    {
                        ASSERTL0(false,rstfile.c_str());
                    }
                    std::string vwifile = "cp -f Save/" + m_sessionName + ".vwi." + nstr + " " + m_sessionName + ".vwi"; 
                    cout << "      " << vwifile << endl;
                    if(system(vwifile.c_str()))
                    {
                        ASSERTL0(false,vwifile.c_str());
                    }
                }
                break;
Chris Cantwell's avatar
Chris Cantwell committed
287
            default:
288
289
                ASSERTL0(false,"Unknown VWIITerationType in restart");
            }
290
        }
291
292
293
294

        // Check for ConveredSoln to update DAlphaDWaveForce
        {
            FILE *fp;
295
            if((fp = fopen("ConvergedSolns","r")))
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
            {
                char buf[BUFSIZ];
                std::vector<NekDouble> WaveForce, Alpha;
                NekDouble waveforce,alpha;
                while(fgets(buf,BUFSIZ,fp))
                {
                    sscanf(buf,"%*d:%lf%lf",&waveforce,&alpha);
                    WaveForce.push_back(waveforce);
                    Alpha.push_back(alpha);
                }

                if(Alpha.size() > 1)
                {
                    int min_i = 0;
                    NekDouble min_alph = fabs(m_alpha[0]-Alpha[min_i]);
                    // find nearest point 
                    for(int i = 1; i < Alpha.size(); ++i)
                    {
                        if(fabs(m_alpha[0]-Alpha[min_i]) < min_alph)
                        {
                            min_i = i;
                            min_alph = fabs(m_alpha[0]-Alpha[min_i]);
                        }
                    }

                    // find next nearest point 
                    int min_j = (min_i == 0)? 1:0;
                    min_alph = fabs(m_alpha[0]-Alpha[min_j]);
                    for(int i = 0; i < Alpha.size(); ++i)
                    {
                        if(i != min_i)
                        {
                            if(fabs(m_alpha[0]-Alpha[min_j]) < min_alph)
                            {
                                min_j = i;
                                min_alph = fabs(m_alpha[0]-Alpha[min_j]);
                            }
                        }
                    }
                    
                    if(fabs(Alpha[min_i] - Alpha[min_j]) > 1e-4)
                    {
                        m_dAlphaDWaveForceMag = (Alpha[min_i]-Alpha[min_j])/(WaveForce[min_i]-WaveForce[min_j]);
                    }
                }
            }
        }
343
344
345
346
347
    }


    VortexWaveInteraction::~VortexWaveInteraction()
    {
348
        m_sessionVWI->Finalise();
349
350
351
352
    }
    
    void VortexWaveInteraction::ExecuteRoll(void)
    {
353
        //set up the equation system to update the mesh
354
355
356
357
        if(m_sessionRoll->DefinesSolverInfo("INTERFACE"))
        {
            string vEquation = m_sessionRoll->GetSolverInfo("solvertype");
            EquationSystemSharedPtr solverRoll = GetEquationSystemFactory().CreateInstance(vEquation,m_sessionRoll);
Spencer Sherwin's avatar
Spencer Sherwin committed
358
359
            // The forcing terms are inserted as N bcs
            // Execute Roll 
360
361
362
363
364
365
366
367
368
369
370
371
            cout << "Executing Roll solver" << endl;
            solverRoll->DoInitialise();
            solverRoll->DoSolve();
            solverRoll->Output();
            m_rollField = solverRoll->UpdateFields();
            for(int g=0; g< solverRoll->GetNvariables(); ++g)
            {
                NekDouble vL2Error = solverRoll->L2Error(g,false);
                NekDouble vLinfError = solverRoll->LinfError(g);
                cout << "L 2 error (variable " << solverRoll->GetVariable(g) << ") : " << vL2Error << endl;
                cout << "L inf error (variable " << solverRoll->GetVariable(g) << ") : " << vLinfError << endl;
            }  
372
373
374
        }
        else
        {
Spencer Sherwin's avatar
Spencer Sherwin committed
375
            if(m_moveMeshToCriticalLayer)
376
            {
Spencer Sherwin's avatar
Spencer Sherwin committed
377
378
379
380
381
                string vEquation = m_sessionRoll->GetSolverInfo("solvertype");
                EquationSystemSharedPtr solverRoll = GetEquationSystemFactory().CreateInstance(vEquation,m_sessionRoll);
            }
            else
            {
382
383
384
                const int npoints = m_solverRoll->GetNpoints();
                const int ncoeffs = m_solverRoll->GetNcoeffs();

Spencer Sherwin's avatar
Spencer Sherwin committed
385
386
                static int init = 1;
                if(init)
387
                {
Spencer Sherwin's avatar
Spencer Sherwin committed
388
                    m_solverRoll->DoInitialise();
389
                    m_vwiForcingObj = boost::dynamic_pointer_cast<SolverUtils::ForcingProgrammatic>(GetForcingFactory().CreateInstance("Programmatic", m_sessionRoll, m_solverRoll->UpdateFields(), m_solverRoll->UpdateFields().num_elements() - 1, 0));
Spencer Sherwin's avatar
Spencer Sherwin committed
390

391
392
393
394
                    std::vector<std::string> vFieldNames = m_sessionRoll->GetVariables();
                    vFieldNames.erase(vFieldNames.end()-1);

                    m_solverRoll->EvaluateFunction(vFieldNames, m_vwiForcingObj->UpdateForces(), "BodyForce");
395
396
397
398
399
400

                    // Scale forcing
                    for(int i = 0; i < m_vwiForcingObj->UpdateForces().num_elements(); ++i)
                    {
                        m_solverRoll->UpdateFields()[0]->FwdTrans(m_vwiForcingObj->UpdateForces()[i], m_vwiForcing[2+i]);
                        Vmath::Smul(npoints,m_rollForceScale,m_vwiForcingObj->UpdateForces()[i],1,m_vwiForcingObj->UpdateForces()[i],1);
Spencer Sherwin's avatar
Spencer Sherwin committed
401
                    }
402

403
                    IncNavierStokesSharedPtr ins = m_solverRoll->as<IncNavierStokes>();
404
405
                    ins->AddForcing(m_vwiForcingObj);

406
                    init = 0;
Spencer Sherwin's avatar
Spencer Sherwin committed
407
408
409
                }
                else // use internal definition of forcing in m_vwiForcing
                {
410
                    // Scale forcing
411
                    for(int i = 0; i < m_vwiForcingObj->UpdateForces().num_elements(); ++i)
412
                    {
413
414
                        m_solverRoll->UpdateFields()[i]->BwdTrans(m_vwiForcing[i],m_vwiForcingObj->UpdateForces()[i]);
                        Vmath::Smul(npoints,m_rollForceScale,m_vwiForcingObj->UpdateForces()[i],1,m_vwiForcingObj->UpdateForces()[i],1);
415
                    }
Spencer Sherwin's avatar
Spencer Sherwin committed
416
417
418
419
                    
                    // Shift m_vwiForcing for new restart in case of relaxation 
                    Vmath::Vcopy(ncoeffs,m_vwiForcing[0],1,m_vwiForcing[2],1);
                    Vmath::Vcopy(ncoeffs,m_vwiForcing[1],1,m_vwiForcing[3],1);
420
                }
421
            }
422

Andrea Isoni's avatar
Andrea Isoni committed
423
424
425
426
            // Execute Roll 
            cout << "Executing Roll solver" << endl;
            m_solverRoll->DoSolve();
            m_solverRoll->Output();
427
            m_rollField = m_solverRoll->UpdateFields();
428
429
430
431
432
433
434
435
436
            for(int g=0; g< m_solverRoll->GetNvariables(); ++g)
            {
                NekDouble vL2Error = m_solverRoll->L2Error(g,false);
                NekDouble vLinfError = m_solverRoll->LinfError(g);
                cout << "L 2 error (variable " << m_solverRoll->GetVariable(g) << ") : " << vL2Error << endl;
                cout << "L inf error (variable " << m_solverRoll->GetVariable(g) << ") : " << vLinfError << endl;
            }  


Spencer Sherwin's avatar
.    
Spencer Sherwin committed
437
        }
438
439
        
        // Copy .fld file to .rst and base.fld
Andrea Isoni's avatar
Andrea Isoni committed
440
441
        cout << "Executing cp -f session.fld session.rst" << endl;
        CopyFile(".fld",".rst");
442
443
444
445
        
        // Write out data into base flow with variable Vx,Vy
        cout << "Writing data to session-Base.fld" << endl;
        
Dave Moxey's avatar
Dave Moxey committed
446
        std::vector<std::string> variables(2);
447
        variables[0] = "Vx";   variables[1] = "Vy";
Dave Moxey's avatar
Dave Moxey committed
448
        std::vector<Array<OneD, NekDouble> > outfield(2);
449
450
451
452
453
        outfield[0]  = m_solverRoll->UpdateFields()[0]->UpdateCoeffs(); 
        outfield[1]  = m_solverRoll->UpdateFields()[1]->UpdateCoeffs(); 
        std::string outname = m_sessionName  + "-Base.fld";
        m_solverRoll->WriteFld(outname, m_solverRoll->UpdateFields()[0], 
                               outfield, variables);
454
455
456
457
458
    }


    void VortexWaveInteraction::ExecuteStreak(void)
    {
459
        // Create driver
460
461
462
463
464
465
466
467
468
#if 1
        std::string vDriverModule;
        m_sessionStreak->LoadSolverInfo("Driver", vDriverModule, "Standard");
        
        DriverSharedPtr solverStreak = GetDriverFactory().CreateInstance(vDriverModule, m_sessionStreak); 
        solverStreak->Execute();

        m_streakField = solverStreak->GetEqu()[0]->UpdateFields();
#else        
469
470
471
472
473
474
475
476
        // Setup and execute Advection Diffusion solver 
        string vEquation = m_sessionStreak->GetSolverInfo("EqType");
        EquationSystemSharedPtr solverStreak = GetEquationSystemFactory().CreateInstance(vEquation,m_sessionStreak);

        cout << "Executing Streak Solver" << endl;
        solverStreak->DoInitialise();
        solverStreak->DoSolve();
        solverStreak->Output();
477
478

        m_streakField = solverStreak->UpdateFields();
479

480
        if(m_sessionVWI->DefinesSolverInfo("INTERFACE"))
Andrea Isoni's avatar
Andrea Isoni committed
481
482
483
        {
            for(int g=0; g< solverStreak->GetNvariables(); ++g)
            {
484
485
486
487
                NekDouble vL2Error = solverStreak->L2Error(g,false);
                NekDouble vLinfError = solverStreak->LinfError(g);
                cout << "L 2 error (variable " << solverStreak->GetVariable(g) << ") : " << vL2Error << endl;
                cout << "L inf error (variable " << solverStreak->GetVariable(g) << ") : " << vLinfError << endl;
Andrea Isoni's avatar
Andrea Isoni committed
488
489
            }
        }
490
491
492
493
#endif

        cout << "Executing cp -f session.fld session_streak.fld" << endl;
        CopyFile(".fld","_streak.fld");
494
495
    }

496
    void VortexWaveInteraction::ExecuteWave(void)
497
    {
498
499
500

        // Set the initial beta value in stability to be equal to VWI file
        std::string LZstr("LZ");
501
        NekDouble LZ = 2*M_PI/m_alpha[0];
502
        cout << "Setting LZ in Linearised solver to " << LZ << endl;
503
        m_sessionWave->SetParameter(LZstr,LZ);
504

505
506
507
508
509
510
511
512
513
514
        // Create driver
        std::string vDriverModule;
        m_sessionWave->LoadSolverInfo("Driver", vDriverModule, "ModifiedArnoldi");
        cout << "Setting up linearised NS sovler" << endl;
        DriverSharedPtr solverWave = GetDriverFactory().CreateInstance(vDriverModule, m_sessionWave);  

        /// Do linearised NavierStokes Session  with Modified Arnoldi
        cout << "Executing wave solution " << endl;
        solverWave->Execute();

515
516
517
518
        // Copy file to a rst location for next restart
        cout << "Executing cp -f session_eig_0 session_eig_0.rst" << endl;
        CopyFile("_eig_0","_eig_0.rst");

519
        // Store data relevant to other operations 
520
521
        m_leading_real_evl[0] = solverWave->GetRealEvl()[0];
        m_leading_imag_evl[0] = solverWave->GetImagEvl()[0];
522

Spencer Sherwin's avatar
Spencer Sherwin committed
523
        // note this will only be true for modified Arnoldi
524
        NekDouble realShift = 0.0;
Spencer Sherwin's avatar
Spencer Sherwin committed
525
        if(m_sessionWave->DefinesParameter("RealShift"))
Spencer Sherwin's avatar
Spencer Sherwin committed
526
        {
527
528
529
530
531
532
533
534
535
            bool defineshift;
            // only use shift in modifiedArnoldi solver since
            // implicitly handled in Arpack.
            m_sessionWave->MatchSolverInfo("Driver","ModifiedArnoldi",defineshift,true);
            if(defineshift)
            {
                realShift = m_sessionWave->GetParameter("RealShift");
            }

Spencer Sherwin's avatar
Spencer Sherwin committed
536
537
        }

538
539
540
541
        // Set up leading eigenvalue from inverse 
        NekDouble invmag = 1.0/(m_leading_real_evl[0]*m_leading_real_evl[0] + 
                                m_leading_imag_evl[0]*m_leading_imag_evl[0]);
        m_leading_real_evl[0] *= -invmag;
Spencer Sherwin's avatar
Spencer Sherwin committed
542
        m_leading_real_evl[0] += realShift;
543
544
545
        m_leading_imag_evl[0] *= invmag;


546
547
        m_waveVelocities = solverWave->GetEqu()[0]->UpdateFields();
        m_wavePressure   = solverWave->GetEqu()[0]->GetPressure();
Andrea Isoni's avatar
Andrea Isoni committed
548
549
550
551
552
553
554


        if( m_sessionVWI->DefinesSolverInfo("INTERFACE")  )
        {
            cout << "Growth =" <<m_leading_real_evl[0]<<endl; 
            cout << "Phase =" <<m_leading_imag_evl[0]<<endl; 
        }
555
        
556
557
    }

558
    void VortexWaveInteraction::CalcNonLinearWaveForce(void)
559
    {
Andrea Isoni's avatar
Andrea Isoni committed
560
        if(m_sessionRoll->DefinesSolverInfo("INTERFACE") )
561
        {
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
            static int cnt=0;
            string wavefile  = m_sessionName +".fld"; 
            string movedmesh = m_sessionName + "_advPost_moved.xml";
            string filestreak   = m_sessionName + "_streak.fld";
            char c[16]="";
            sprintf(c,"%d",cnt);               
            char c_alpha[16]="";
            sprintf(c_alpha,"%f",m_alpha[0]);    
            string syscall;
            if( m_sessionVWI->GetSolverInfo("INTERFACE")=="phase" )
            {
                string filePost = m_sessionName + "_advPost.xml";
                syscall = "../../utilities/PostProcessing/Extras/FldCalcBCs  "
                    + filePost +"     "+
                    "meshhalf_pos_Spen_stability_moved.fld  meshhalf_pos_Spen_advPost_moved.fld "
                    +c_alpha +"  > data_alpha0";
                cout<<syscall.c_str()<<endl;
                if(system(syscall.c_str()))
                {
                    ASSERTL0(false,syscall.c_str());
                }
Andrea Isoni's avatar
Andrea Isoni committed
583
             
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
                syscall = "cp -f meshhalf_pos_Spen_stability_moved_u_5.bc  "+m_sessionName+"_u_5.bc";  
                cout<<syscall.c_str()<<endl;
                if(system(syscall.c_str()))
                {
                    ASSERTL0(false,syscall.c_str());
                }
                syscall = "cp -f meshhalf_pos_Spen_stability_moved_v_5.bc  "+m_sessionName+"_v_5.bc";  
                cout<<syscall.c_str()<<endl;
                if(system(syscall.c_str()))
                {
                    ASSERTL0(false,syscall.c_str());
                }
            }
            else
            {
                syscall =  "../../utilities/PostProcessing/Extras/FldCalcBCs  "
                    + movedmesh + "  " + wavefile + "  " + filestreak + "   "+c_alpha +"  >  datasub_"+c;
                cout<<syscall.c_str()<<endl;
                if(system(syscall.c_str()))
                {
                    ASSERTL0(false,syscall.c_str());
                }
            }
Andrea Isoni's avatar
Andrea Isoni committed
607

Andrea Isoni's avatar
Andrea Isoni committed
608
609
             
             
610
611
612
613
614
615
616
617
618
619
620
621
            //relaxation for different alpha values? does it make sense?

            //save the wave
            string wave_subalp = m_sessionName + "_wave_subalp_"+c+".fld";
            syscall = "cp -f " + wavefile + "  " + wave_subalp;
            cout<<syscall.c_str()<<endl;
            if(system(syscall.c_str()))
            {
                ASSERTL0(false,syscall.c_str());
            }
            //FileRelaxation(3);
            cnt++;
Andrea Isoni's avatar
Andrea Isoni committed
622
     
Spencer Sherwin's avatar
Spencer Sherwin committed
623
        }
Andrea Isoni's avatar
Andrea Isoni committed
624
        else
Spencer Sherwin's avatar
Spencer Sherwin committed
625
        {
Andrea Isoni's avatar
Andrea Isoni committed
626
627
628
629
630
631
632
633
            int npts    = m_waveVelocities[0]->GetPlane(0)->GetNpoints();
            int ncoeffs = m_waveVelocities[0]->GetPlane(0)->GetNcoeffs();
            Array<OneD, NekDouble> val(npts), der1(2*npts);
            Array<OneD, NekDouble> der2 = der1 + npts; 
            Array<OneD, NekDouble> streak;
            static int projectfield = -1;

            if(m_deltaFcnApprox)
Spencer Sherwin's avatar
Spencer Sherwin committed
634
            {
Andrea Isoni's avatar
Andrea Isoni committed
635
636
                streak = Array<OneD, NekDouble> (npts);
                m_streakField[0]->BwdTrans(m_streakField[0]->GetCoeffs(), streak);
637
            }
Andrea Isoni's avatar
Andrea Isoni committed
638
639
640
641
 
            // Set project field to be first field that has a Neumann
            // boundary since this not impose any condition on the vertical boundaries
            // Othersise set to zero. 
Spencer Sherwin's avatar
Spencer Sherwin committed
642
643
            if(projectfield == -1)
            {
644
                Array<OneD, const SpatialDomains::BoundaryConditionShPtr > BndConds;
Spencer Sherwin's avatar
Spencer Sherwin committed
645
                 
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
                for(int i = 0; i < m_waveVelocities.num_elements(); ++i)
                {
                    BndConds = m_waveVelocities[i]->GetBndConditions();
                    for(int j = 0; j < BndConds.num_elements(); ++j)
                    {
                        if(BndConds[j]->GetBoundaryConditionType() == SpatialDomains::eNeumann)
                        {
                            projectfield = i;
                            break;
                        }
                    }
                    if(projectfield != -1)
                    {
                        break;
                    }
                }
                if(projectfield == -1)
                {
                    cout << "using first field to project non-linear forcing which imposes a Dirichlet condition" << endl;
                    projectfield = 0;
                }
Spencer Sherwin's avatar
Spencer Sherwin committed
667
            }
668
        
Andrea Isoni's avatar
Andrea Isoni committed
669
670
671
            // Shift m_vwiForcing in case of relaxation 
            Vmath::Vcopy(ncoeffs,m_vwiForcing[0],1,m_vwiForcing[2],1);
            Vmath::Vcopy(ncoeffs,m_vwiForcing[1],1,m_vwiForcing[3],1);
672
        
Andrea Isoni's avatar
Andrea Isoni committed
673
            // determine inverse of area normalised field. 
Spencer Sherwin's avatar
Spencer Sherwin committed
674
675
            m_wavePressure->GetPlane(0)->BwdTrans(m_wavePressure->GetPlane(0)->GetCoeffs(), m_wavePressure->GetPlane(0)->UpdatePhys());
            m_wavePressure->GetPlane(1)->BwdTrans(m_wavePressure->GetPlane(1)->GetCoeffs(), m_wavePressure->GetPlane(1)->UpdatePhys());
676
677
678
679
            NekDouble invnorm;

            if(m_useLinfPressureNorm)
            {
680
681
682
683
684
                Vmath::Vmul(npts,m_wavePressure->GetPlane(0)->UpdatePhys(),1,m_wavePressure->GetPlane(0)->UpdatePhys(),1,der1,1);
                Vmath::Vvtvp(npts,m_wavePressure->GetPlane(1)->UpdatePhys(),1,m_wavePressure->GetPlane(1)->UpdatePhys(),1,der1,1,der1,1);
                Vmath::Vsqrt(npts,der1,1,der1,1);
                
                NekDouble Linf = Vmath::Vmax(npts,der1,1);
685
686
687
688
689
690
691
                
                invnorm = 1.0/Linf;
            }
            else
            {
                // Determine normalisation of pressure so that |P|/A = 1
                NekDouble l2;
692
                l2    = m_wavePressure->GetPlane(0)->L2(m_wavePressure->GetPlane(0)->GetPhys());
693
                invnorm  = l2*l2;
694
                l2    = m_wavePressure->GetPlane(1)->L2(m_wavePressure->GetPlane(1)->GetPhys());
695
696
697
                invnorm += l2*l2;
                Vmath::Fill(2*npts,1.0,der1,1);
                NekDouble area = m_waveVelocities[0]->GetPlane(0)->PhysIntegral(der1);
698
                cout << "Area: " << area << endl;
699
700
                invnorm = sqrt(area/invnorm);
            }
Andrea Isoni's avatar
Andrea Isoni committed
701
702
703
704
        
            // Get hold of arrays. 
            m_waveVelocities[0]->GetPlane(0)->BwdTrans(m_waveVelocities[0]->GetPlane(0)->GetCoeffs(),m_waveVelocities[0]->GetPlane(0)->UpdatePhys());
            Array<OneD, NekDouble> u_real = m_waveVelocities[0]->GetPlane(0)->UpdatePhys();
705
            Vmath::Smul(npts,invnorm,u_real,1,u_real,1);
Andrea Isoni's avatar
Andrea Isoni committed
706
707
            m_waveVelocities[0]->GetPlane(1)->BwdTrans(m_waveVelocities[0]->GetPlane(1)->GetCoeffs(),m_waveVelocities[0]->GetPlane(1)->UpdatePhys());
            Array<OneD, NekDouble> u_imag = m_waveVelocities[0]->GetPlane(1)->UpdatePhys();
708
            Vmath::Smul(npts,invnorm,u_imag,1,u_imag,1);
Andrea Isoni's avatar
Andrea Isoni committed
709
710
            m_waveVelocities[1]->GetPlane(0)->BwdTrans(m_waveVelocities[1]->GetPlane(0)->GetCoeffs(),m_waveVelocities[1]->GetPlane(0)->UpdatePhys());
            Array<OneD, NekDouble> v_real = m_waveVelocities[1]->GetPlane(0)->UpdatePhys(); 
711
            Vmath::Smul(npts,invnorm,v_real,1,v_real,1);
Andrea Isoni's avatar
Andrea Isoni committed
712
713
            m_waveVelocities[1]->GetPlane(1)->BwdTrans(m_waveVelocities[1]->GetPlane(1)->GetCoeffs(),m_waveVelocities[1]->GetPlane(1)->UpdatePhys());
            Array<OneD, NekDouble> v_imag = m_waveVelocities[1]->GetPlane(1)->UpdatePhys();
714
            Vmath::Smul(npts,invnorm,v_imag,1,v_imag,1);
715
716
717
718
719
720
721
722

            // normalise wave for output
            Vmath::Smul(2*ncoeffs,invnorm,m_waveVelocities[0]->UpdateCoeffs(),1,m_waveVelocities[0]->UpdateCoeffs(),1);
            Vmath::Smul(2*ncoeffs,invnorm,m_waveVelocities[1]->UpdateCoeffs(),1,m_waveVelocities[1]->UpdateCoeffs(),1);
            Vmath::Smul(2*ncoeffs,invnorm,m_waveVelocities[2]->UpdateCoeffs(),1,m_waveVelocities[2]->UpdateCoeffs(),1);

            // dump field
            {
Dave Moxey's avatar
Dave Moxey committed
723
724
                std::vector<std::string> variables(3);
                std::vector<Array<OneD, NekDouble> > outfield(3);
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
                variables[0] = "u_w"; 
                variables[1] = "v_w"; 
                variables[2] = "w_w"; 
                outfield[0] = m_waveVelocities[0]->UpdateCoeffs();
                outfield[1] = m_waveVelocities[1]->UpdateCoeffs();
                outfield[2] = m_waveVelocities[2]->UpdateCoeffs();
                std::string outname = m_sessionName  + "_wave.fld";
                m_solverRoll->WriteFld(outname, m_waveVelocities[0], outfield, variables);
            }

#if 1
            int ncoeffs_p = m_wavePressure->GetPlane(0)->GetNcoeffs();
            Vmath::Smul(ncoeffs_p,invnorm,m_wavePressure->GetPlane(0)->UpdateCoeffs(),1,m_wavePressure->GetPlane(0)->UpdateCoeffs(),1);
            Vmath::Smul(ncoeffs_p,invnorm,m_wavePressure->GetPlane(1)->UpdateCoeffs(),1,m_wavePressure->GetPlane(1)->UpdateCoeffs(),1);
#else
            m_wavePressure->GetPlane(0)->BwdTrans(m_wavePressure->GetPlane(0)->GetCoeffs(),m_wavePressure->GetPlane(0)->UpdatePhys());
            Vmath::Smul(npts,invnorm,m_wavePressure->GetPlane(0)->UpdatePhys(),1,m_wavePressure->GetPlane(0)->UpdatePhys(),1);
            m_wavePressure->GetPlane(0)->FwdTrans(m_wavePressure->GetPlane(0)->UpdatePhys(),m_wavePressure->GetPlane(0)->UpdateCoeffs());
            
            m_wavePressure->GetPlane(1)->BwdTrans(m_wavePressure->GetPlane(1)->GetCoeffs(),m_wavePressure->GetPlane(1)->UpdatePhys());
            Vmath::Smul(npts,invnorm,m_wavePressure->GetPlane(1)->UpdatePhys(),1,m_wavePressure->GetPlane(1)->UpdatePhys(),1);
            m_wavePressure->GetPlane(1)->FwdTrans(m_wavePressure->GetPlane(1)->UpdatePhys(),m_wavePressure->GetPlane(1)->UpdateCoeffs());
#endif
       
Andrea Isoni's avatar
Andrea Isoni committed
749
750
751
752
753
754
755
756
757
758
759
760
            // Calculate non-linear terms for x and y directions
            // d/dx(u u* + u* u)
            Vmath::Vmul (npts,u_real,1,u_real,1,val,1);
            Vmath::Vvtvp(npts,u_imag,1,u_imag,1,val,1,val,1);
            Vmath::Smul (npts,2.0,val,1,val,1);
            m_waveVelocities[0]->GetPlane(0)->PhysDeriv(0,val,der1);
        
            // d/dy(v u* + v* u)
            Vmath::Vmul (npts,u_real,1,v_real,1,val,1);
            Vmath::Vvtvp(npts,u_imag,1,v_imag,1,val,1,val,1);
            Vmath::Smul (npts,2.0,val,1,val,1);
            m_waveVelocities[0]->GetPlane(0)->PhysDeriv(1,val,der2);
Spencer Sherwin's avatar
Spencer Sherwin committed
761
            
Andrea Isoni's avatar
Andrea Isoni committed
762
            Vmath::Vadd(npts,der1,1,der2,1,der1,1);
763
#if 1
Andrea Isoni's avatar
Andrea Isoni committed
764
            m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(der1,m_vwiForcing[0]);
765
#else
Andrea Isoni's avatar
Andrea Isoni committed
766
            m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der1,m_vwiForcing[0]);
767
#endif
Andrea Isoni's avatar
Andrea Isoni committed
768
            Vmath::Smul(ncoeffs,-m_waveForceMag[0],m_vwiForcing[0],1,m_vwiForcing[0],1);
769

Andrea Isoni's avatar
Andrea Isoni committed
770
771
            // d/dx(u v* + u* v)
            m_waveVelocities[0]->GetPlane(0)->PhysDeriv(0,val,der1);
772
        
Andrea Isoni's avatar
Andrea Isoni committed
773
774
775
776
777
            // d/dy(v v* + v* v)
            Vmath::Vmul(npts,v_real,1,v_real,1,val,1);
            Vmath::Vvtvp(npts,v_imag,1,v_imag,1,val,1,val,1);
            Vmath::Smul (npts,2.0,val,1,val,1);
            m_waveVelocities[0]->GetPlane(0)->PhysDeriv(1,val,der2);
778
        
Andrea Isoni's avatar
Andrea Isoni committed
779
            Vmath::Vadd(npts,der1,1,der2,1,der1,1);
780

781
#if 1
Andrea Isoni's avatar
Andrea Isoni committed
782
            m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(der1,m_vwiForcing[1]);
783
#else
Andrea Isoni's avatar
Andrea Isoni committed
784
            m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der1,m_vwiForcing[1]);
785
786
#endif

Andrea Isoni's avatar
Andrea Isoni committed
787
            Vmath::Smul(ncoeffs,-m_waveForceMag[0],m_vwiForcing[1],1,m_vwiForcing[1],1);
788
        
Andrea Isoni's avatar
Andrea Isoni committed
789
790
791
            //by default the symmetrization is on
            bool symm=true;
            m_sessionVWI->MatchSolverInfo("Symmetrization","True",symm,true);
792
#if 0
Andrea Isoni's avatar
Andrea Isoni committed
793
            if(symm== true )
Andrea Isoni's avatar
Andrea Isoni committed
794
            {
Spencer Sherwin's avatar
Spencer Sherwin committed
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
                
                // Symmetrise forcing
                //-> Get coordinates 
                Array<OneD, NekDouble> coord(2);
                Array<OneD, NekDouble> coord_x(npts);
                Array<OneD, NekDouble> coord_y(npts);
                
                //-> Impose symmetry (x -> -x + Lx/2, y-> -y) on coordinates
                m_waveVelocities[0]->GetPlane(0)->GetCoords(coord_x,coord_y);
                NekDouble xmax = Vmath::Vmax(npts,coord_x,1);
                Vmath::Neg(npts,coord_x,1);
                Vmath::Sadd(npts,xmax,coord_x,1,coord_x,1);
                Vmath::Neg(npts,coord_y,1);
                
                int i, physoffset;
                
                //-> Obtain list of expansion element ids for each point. 
                Array<OneD, int> Eid(npts);
                // This search may not be necessary every iteration
                for(i = 0; i < npts; ++i)
                {
                    coord[0] = coord_x[i];
                    coord[1] = coord_y[i];
                    
                    // Note this will not quite be symmetric. 
                    Eid[i] = m_waveVelocities[0]->GetPlane(0)->GetExpIndex(coord,1e-6);
                }
                
                // Interpolate field 0 
                m_waveVelocities[0]->GetPlane(0)->BwdTrans_IterPerExp(m_vwiForcing[0],der1);
                for(i = 0; i < npts; ++i)
                {
                    physoffset = m_waveVelocities[0]->GetPlane(0)->GetPhys_Offset(Eid[i]);
                    coord[0] = coord_x[i];
                    coord[1] = coord_y[i];
                    der2 [i] = m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord, der1 + physoffset);
                }
                //-> Average field 0 
                Vmath::Vsub(npts,der1,1,der2,1,der2,1);
                Vmath::Smul(npts,0.5,der2,1,der2,1);
#if 1
                m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(der2,m_vwiForcing[0]);
#else
                m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der2, m_vwiForcing[0]);
#endif
                
                //-> Interpoloate field 1
                m_waveVelocities[0]->GetPlane(0)->BwdTrans_IterPerExp(m_vwiForcing[1],der1);
                for(i = 0; i < npts; ++i)
                {
                    physoffset = m_waveVelocities[0]->GetPlane(0)->GetPhys_Offset(Eid[i]);
                    coord[0] = coord_x[i];
                    coord[1] = coord_y[i];
                    der2[i]  = m_waveVelocities[0]->GetPlane(0)->GetExp(Eid[i])->PhysEvaluate(coord,                                                                         der1 + physoffset);
                }
                
                //-> Average field 1
                Vmath::Vsub(npts,der1,1,der2,1,der2,1);
                Vmath::Smul(npts,0.5,der2,1,der2,1);
#if 1
                m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(der2,m_vwiForcing[1]);
#else
                m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(der2, m_vwiForceing[1]);
#endif
            }
#else
            int i;
            if(symm== true )
863
            {
Spencer Sherwin's avatar
Spencer Sherwin committed
864
865
866
867
868
869
870
871
872
873
874
                cout<<"symmetrization is active"<<endl;              
                static Array<OneD, int> index = GetReflectionIndex();
                
                m_waveVelocities[0]->GetPlane(0)->BwdTrans_IterPerExp(m_vwiForcing[0],der1);
                for(i = 0; i < npts; ++i)
                {
                    if(index[i] != -1)
                    {
                        val[i] = 0.5*(der1[i] - der1[index[i]]);
                    }
                }
875
876
877
#if 1 
                m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(val,m_vwiForcing[0]);
#else
878
                m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(val, m_vwiForcing[0]);
879
#endif
880

Spencer Sherwin's avatar
Spencer Sherwin committed
881
882
883
884
885
886
887
888
                m_waveVelocities[0]->GetPlane(0)->BwdTrans_IterPerExp(m_vwiForcing[1],der2);
                for(i = 0; i < npts; ++i)
                {
                    if(index[i] != -1)
                    {
                        val[i] = 0.5*(der2[i] - der2[index[i]]);
                    }
                }        
889
890
891
#if 1 
                m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(val,m_vwiForcing[1]);
#else
Spencer Sherwin's avatar
Spencer Sherwin committed
892
                m_waveVelocities[0]->GetPlane(0)->FwdTrans_BndConstrained(val, m_vwiForcing[1]);
893
#endif
Andrea Isoni's avatar
Andrea Isoni committed
894
            }
895
896
897
898
899
900
901


            Vmath::Vmul(npts,der1,1,der1,1,val,1);
            Vmath::Vvtvp(npts,der2,1,der2,1,val,1,val,1);
            Vmath::Vsqrt(npts,val,1,val,1);
            cout << "F_Linf: " <<  Vmath::Vmax(npts,val,1) << endl;

902
903
#endif

Andrea Isoni's avatar
Andrea Isoni committed
904
905
906
            if(m_vwiRelaxation)
            {
                 Vmath::Smul(ncoeffs,1.0-m_vwiRelaxation,
907
                        m_vwiForcing[0],1,m_vwiForcing[0],1);
Andrea Isoni's avatar
Andrea Isoni committed
908
                 Vmath::Svtvp(ncoeffs,m_vwiRelaxation,m_vwiForcing[2],1,
909
910
                         m_vwiForcing[0],1,m_vwiForcing[0],1);
            
Andrea Isoni's avatar
Andrea Isoni committed
911
                 Vmath::Smul(ncoeffs,1.0-m_vwiRelaxation,
912
                        m_vwiForcing[1],1,m_vwiForcing[1],1);
Andrea Isoni's avatar
Andrea Isoni committed
913
                 Vmath::Svtvp(ncoeffs,m_vwiRelaxation,m_vwiForcing[3],1,
914
                         m_vwiForcing[1],1,m_vwiForcing[1],1);
Andrea Isoni's avatar
Andrea Isoni committed
915
            }
916

Andrea Isoni's avatar
Andrea Isoni committed
917
            if(m_deltaFcnApprox)
918
            {
Andrea Isoni's avatar
Andrea Isoni committed
919
920
                 for(int j = 0; j < 2; ++j)
                 {
921
                
Andrea Isoni's avatar
Andrea Isoni committed
922
923
924
925
926
927
928
                      m_waveVelocities[projectfield]->GetPlane(0)->BwdTrans(m_vwiForcing[j],der1);
                      for(int i = 0; i < npts; ++i)
                      {
                           der1[i] *= exp(-streak[i]*streak[i]/m_deltaFcnDecay);
                      }
                      m_waveVelocities[projectfield]->GetPlane(0)->FwdTrans(der1,m_vwiForcing[j]);
                 }
929
            }
930
931
932
            
            
            // dump output
Dave Moxey's avatar
Dave Moxey committed
933
934
            std::vector<std::string> variables(4);
            std::vector<Array<OneD, NekDouble> > outfield(4);
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
            variables[0] = "u";  variables[1] = "v"; 
            variables[2] = "pr"; variables[3] = "pi";
            outfield[0]  = m_vwiForcing[0];
            outfield[1]  = m_vwiForcing[1];
            Array<OneD,NekDouble> soln(npts,0.0);
            m_wavePressure->GetPlane(0)->BwdTrans(m_wavePressure->GetPlane(0)->GetCoeffs(),m_wavePressure->GetPlane(0)->UpdatePhys());
            outfield[2] = Array<OneD,NekDouble>(ncoeffs);
            m_waveVelocities[0]->GetPlane(0)->FwdTrans_IterPerExp(m_wavePressure->GetPlane(0)->GetPhys(),outfield[2]);
            m_wavePressure->GetPlane(1)->BwdTrans(m_wavePressure->GetPlane(1)->GetCoeffs(),m_wavePressure->GetPlane(1)->UpdatePhys());
            
            Vmath::Vmul(npts,m_wavePressure->GetPlane(0)->UpdatePhys(),1,
                        m_wavePressure->GetPlane(0)->UpdatePhys(),1,val,1);
            Vmath::Vvtvp(npts,m_wavePressure->GetPlane(1)->UpdatePhys(),1,
                         m_wavePressure->GetPlane(1)->UpdatePhys(),1,val,1,val,1);
            cout << "int P^2: " << m_wavePressure->GetPlane(0)->PhysIntegral(val) << endl;
            Vmath::Vsqrt(npts,val,1,val,1);
            cout << "PLinf: " <<  Vmath::Vmax(npts,val,1) << endl;

            outfield[3] = Array<OneD,NekDouble>(ncoeffs);
            m_waveVelocities[1]->GetPlane(0)->FwdTrans_IterPerExp(m_wavePressure->GetPlane(1)->GetPhys(),outfield[3]);
            
            std::string outname = m_sessionName  + ".vwi";
            
            m_solverRoll->WriteFld(outname, m_waveVelocities[0]->GetPlane(0), outfield, variables);
959

960
        }
961
962
    }
    
963
964
965
966
967
    void VortexWaveInteraction::CalcL2ToLinfPressure(void)
    {

        ExecuteWave();

968
969
970
971
972
973
        m_wavePressure->GetPlane(0)->BwdTrans(m_wavePressure->GetPlane(0)->GetCoeffs(),
                                              m_wavePressure->GetPlane(0)->UpdatePhys());
        m_wavePressure->GetPlane(1)->BwdTrans(m_wavePressure->GetPlane(1)->GetCoeffs(),
                                              m_wavePressure->GetPlane(1)->UpdatePhys());

        int npts    = m_waveVelocities[0]->GetPlane(0)->GetNpoints();
974
        NekDouble Linf;
975
976
        Array<OneD, NekDouble> val(2*npts,0.0);
        
977
978
        Vmath::Vmul(npts,m_wavePressure->GetPlane(0)->UpdatePhys(),1,m_wavePressure->GetPlane(0)->UpdatePhys(),1,val,1);
        Vmath::Vvtvp(npts,m_wavePressure->GetPlane(1)->UpdatePhys(),1,m_wavePressure->GetPlane(1)->UpdatePhys(),1,val,1,val,1);
979
        cout << "int P^2 " << m_wavePressure->GetPlane(0)->PhysIntegral(val) << endl;
980
981
982
983
        Vmath::Vsqrt(npts,val,1,val,1);
        
               
        Linf = Vmath::Vmax(npts,val,1);
984
985
986
        cout << "Linf: " << Linf << endl;

        NekDouble l2,norm;
987
        l2    = m_wavePressure->GetPlane(0)->L2(m_wavePressure->GetPlane(0)->GetPhys());
988
        norm  = l2*l2;
989
        l2    = m_wavePressure->GetPlane(1)->L2(m_wavePressure->GetPlane(1)->GetPhys());
990
991
        norm += l2*l2;

992
993
994

        Vmath::Fill(npts,1.0,val,1);
        NekDouble area = m_waveVelocities[0]->GetPlane(0)->PhysIntegral(val);
995
996
997
998
999
1000
1001
1002

        l2 = sqrt(norm/area);

        cout << "L2:   " << l2 << endl;
        
        cout << "Ratio Linf/L2: "<< Linf/l2 << endl;
    }

1003
    void VortexWaveInteraction::SaveFile(string file, string dir, int n)
1004
    {
Spencer Sherwin's avatar
.    
Spencer Sherwin committed
1005
        static map<string,int> opendir;
1006

Spencer Sherwin's avatar
.    
Spencer Sherwin committed
1007
1008
        if(opendir.find(dir) == opendir.end())
        {
1009
1010
1011
            // make directory and presume will fail if it already exists
            string mkdir = "mkdir " + dir;
            system(mkdir.c_str());
1012

Spencer Sherwin's avatar
.    
Spencer Sherwin committed
1013
            opendir[dir] = 1;
1014
1015
        }
        
1016
1017
        string savefile = dir + "/" + file + "." + boost::lexical_cast<std::string>(n);
        string syscall  = "cp -f "  + file + " " + savefile; 
1018

1019
1020
1021
1022
1023
        if(system(syscall.c_str()))
        {
            ASSERTL0(false,syscall.c_str());
        }

1024
     }
1025
1026


1027
    void VortexWaveInteraction::MoveFile(string file, string dir, int n)
Spencer Sherwin's avatar
.    
Spencer Sherwin committed
1028
    {
1029
        static map<string,int> opendir;
1030

1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
        if(opendir.find(dir) == opendir.end())
        {
            // make directory and presume will fail if it already exists
            string mkdir = "mkdir " + dir;
            system(mkdir.c_str());
            opendir[dir] = 1;
        }
        
        string savefile = dir + "/" + file + "." + boost::lexical_cast<std::string>(n);
        string syscall  = "mv -f "  + file + " " + savefile; 

1042
1043
1044
1045
        if(system(syscall.c_str()))
        {
            ASSERTL0(false,syscall.c_str());
        }
1046
1047
1048
1049
1050
1051
1052
1053
     }

     void VortexWaveInteraction::CopyFile(string file1end, string file2end)
     {
         string cpfile1   = m_sessionName + file1end;
         string cpfile2   = m_sessionName + file2end;
         string syscall  = "cp -f "  + cpfile1 + " " + cpfile2; 

1054
1055
1056
1057
         if(system(syscall.c_str()))
         {
             ASSERTL0(false,syscall.c_str());
         }
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
     }

     void VortexWaveInteraction::AppendEvlToFile(string file, int n)
     {
         FILE *fp;
         fp = fopen(file.c_str(),"a");
         fprintf(fp, "%d: %lf %16.12le  %16.12le\n",n, m_alpha[0], m_leading_real_evl[0],m_leading_imag_evl[0]);
         fclose(fp);
     }

1068
1069
1070
1071
1072
1073
1074
1075
     void VortexWaveInteraction::AppendEvlToFile(string file, NekDouble WaveForceMag)
     {
         FILE *fp;
         fp = fopen(file.c_str(),"a");
         fprintf(fp, "%lf %lf %16.12le  %16.12le\n",WaveForceMag, m_alpha[0], m_leading_real_evl[0],m_leading_imag_evl[0]);
         fclose(fp);
     }

1076
    void VortexWaveInteraction::SaveLoopDetails(std::string SaveDir, int i)
1077

1078
1079
    {
        // Save NS restart file
1080
        SaveFile(m_sessionName + ".rst",SaveDir,i+1);
1081
        // Save Streak Solution
1082
        SaveFile(m_sessionName + "_streak.fld",SaveDir,i);
1083
        // Save Wave solution output
1084
1085
        SaveFile(m_sessionName + ".evl",SaveDir,i);
        SaveFile(m_sessionName + "_eig_0",SaveDir,i);
Spencer Sherwin's avatar
Spencer Sherwin committed
1086
1087
        // Save new field file of eigenvalue
        SaveFile(m_sessionName + ".fld",SaveDir,i);
1088
1089
        if(!(m_sessionVWI->DefinesSolverInfo("INTERFACE")))
        {
1090
1091
            // Save new forcing file
            SaveFile(m_sessionName + ".vwi",SaveDir,i+1);
1092
        }
1093

1094
1095
    }

1096
    void VortexWaveInteraction::ExecuteLoop(bool CalcWaveForce)
1097
    {
Spencer Sherwin's avatar
.    
Spencer Sherwin committed
1098

1099

1100
1101
1102
1103
	//the global info has to be written in the 
	//roll session file to use the interface loop
        if(m_sessionRoll->DefinesSolverInfo("INTERFACE"))
	{
Andrea Isoni's avatar
Andrea Isoni committed
1104
             static int cnt=0;     
Andrea Isoni's avatar
Andrea Isoni committed
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
             bool skiprollstreak=false;
             if(cnt==0 && m_sessionVWI->GetParameter("rollstreakfromit")==1)
             {
                  skiprollstreak =true;
                  cout<<"skip roll-streak at the first iteration"<<endl;
             }
             
             
             if(skiprollstreak != true)
             {

1116
                 LibUtilities::NekManager<MultiRegions::GlobalLinSysKey,MultiRegions::GlobalLinSys>::EnableManagement("GlobalLinSys");
Andrea Isoni's avatar
Andrea Isoni committed
1117
                 ExecuteRoll();
1118
                 LibUtilities::NekManager<MultiRegions::GlobalLinSysKey,MultiRegions::GlobalLinSys>::DisableManagement("GlobalLinSys");
Andrea Isoni's avatar
Andrea Isoni committed
1119
1120
1121
1122
1123
1124
1125
1126
#ifndef _WIN32
   	         sleep(3);
#endif
                 ExecuteStreak();
#ifndef _WIN32
	         sleep(3);
#endif
             }
Andrea Isoni's avatar
Andrea Isoni committed
1127
              
1128
             string syscall;
Andrea Isoni's avatar
Andrea Isoni committed
1129
1130
1131
             char c[16]="";
             string movedmesh = m_sessionName + "_advPost_moved.xml";
             string movedinterpmesh = m_sessionName + "_interp_moved.xml";
1132
1133
1134
1135
1136
1137
1138
             //rewrite the Rollsessionfile (we start from the waleffe forcing)
             //string meshbndjumps = m_sessionName +"_bndjumps.xml";             
             //if(cnt==0)
             //{
                 //take the conditions tag from meshbndjumps and copy into 
                 // the rolls session file
             //}
Andrea Isoni's avatar
Andrea Isoni committed
1139
1140
1141


             sprintf(c,"%d",cnt);  
1142
1143
             //save old roll solution
             string oldroll = m_sessionName +"_roll_"+c +".fld";    
Andrea Isoni's avatar
Andrea Isoni committed
1144
             syscall = "cp -f " + m_sessionName+"-Base.fld" + "  " + oldroll;
1145
1146
1147
1148
1149
             cout<<syscall.c_str()<<endl;
             if(system(syscall.c_str()))
             {
                  ASSERTL0(false,syscall.c_str());
             } 
Andrea Isoni's avatar
Andrea Isoni committed
1150
             //define file names
1151
1152
             string filePost   = m_sessionName + "_advPost.xml";
             string filestreak   = m_sessionName + "_streak.fld";
Andrea Isoni's avatar
Andrea Isoni committed
1153
1154
             string filewave    = m_sessionName + "_wave.fld";
             string filewavepressure = m_sessionName + "_wave_p_split.fld";
1155
             string fileinterp = m_sessionName + "_interp.xml";
Andrea Isoni's avatar
Andrea Isoni committed
1156
1157
             string interpstreak = m_sessionName +"_interpstreak_"+ c +".fld";  
             string interwavepressure  = m_sessionName +"_wave_p_split_interp_"+ c +".fld";
Andrea Isoni's avatar
Andrea Isoni committed
1158
             char alpchar[16]="";
Andrea Isoni's avatar
Andrea Isoni committed
1159
cout<<"alpha = "<<m_alpha[0]<<endl;
Andrea Isoni's avatar
Andrea Isoni committed
1160
             sprintf(alpchar, "%f", m_alpha[0]);
Andrea Isoni's avatar
Andrea Isoni committed
1161
1162


Andrea Isoni's avatar
Andrea Isoni committed
1163
             if( m_sessionVWI->GetSolverInfo("INTERFACE")!="phase" )
Andrea Isoni's avatar
Andrea Isoni committed
1164
             {
Spencer Sherwin's avatar
Spencer Sherwin committed
1165
                 cout<<"zerophase"<<endl;
Andrea Isoni's avatar
Andrea Isoni committed
1166

Andrea Isoni's avatar
Andrea Isoni committed
1167
                 syscall  = "../../utilities/PostProcessing/Extras/MoveMesh  "
Andrea Isoni's avatar
Andrea Isoni committed
1168
                             + filePost +"  "+ filestreak +"  "+ fileinterp + "   "+ alpchar; 
Andrea Isoni's avatar
Andrea Isoni committed
1169

Andrea Isoni's avatar
Andrea Isoni committed
1170
1171
1172
1173
1174
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                      ASSERTL0(false,syscall.c_str());
                 }
1175

Andrea Isoni's avatar
Andrea Isoni committed
1176
                 //move the advPost mesh (remark update alpha!!!)
Andrea Isoni's avatar
Andrea Isoni committed
1177
                 syscall  =  "../../utilities/PostProcessing/Extras/MoveMesh  "
Andrea Isoni's avatar
Andrea Isoni committed
1178
1179
1180
1181
1182
1183
                       + filePost + "  " + filestreak + "  " + filePost + "    "+ alpchar;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                     ASSERTL0(false,syscall.c_str());
                 }
Andrea Isoni's avatar
Andrea Isoni committed
1184

Andrea Isoni's avatar
Andrea Isoni committed
1185

Andrea Isoni's avatar
Andrea Isoni committed
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200

                 //save oldstreak
                 string oldstreak = m_sessionName +"_streak_"+ c +".fld";            
        	 syscall = "cp -f " + filestreak + "  " + oldstreak;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                      ASSERTL0(false,syscall.c_str());
                 } 

    	         //interpolate the streak field into the new mesh
                 string movedmesh = m_sessionName + "_advPost_moved.xml";
                 string movedinterpmesh = m_sessionName + "_interp_moved.xml";

                 //create the interp streak             
Andrea Isoni's avatar
Andrea Isoni committed
1201
1202

                 syscall  =  "../../utilities/PostProcessing/Extras/FieldToField  "
1203
1204
                      + fileinterp + "  " + filestreak + "  " + movedinterpmesh + "  " 
	              + interpstreak;
Andrea Isoni's avatar
Andrea Isoni committed
1205

Andrea Isoni's avatar
Andrea Isoni committed
1206
1207
1208
1209
1210
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                      ASSERTL0(false,syscall.c_str());
                 } 
Andrea Isoni's avatar
Andrea Isoni committed
1211

Andrea Isoni's avatar
Andrea Isoni committed
1212

Andrea Isoni's avatar
Andrea Isoni committed
1213
1214
1215
1216
1217
1218
1219
1220
1221
                 //save the old mesh     
                 string meshfile = m_sessionName + ".xml";                  
                 string meshold = m_sessionName +"_"+ c +".xml";
     	         syscall = "cp -f " + meshfile + "  " + meshold;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                     ASSERTL0(false,syscall.c_str());
                 }  
1222

Andrea Isoni's avatar
Andrea Isoni committed
1223
1224
1225
1226
1227
1228
1229
                 //overwriting the meshfile with the new mesh
	         syscall = "cp -f " + movedmesh + "  " + meshfile;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                     ASSERTL0(false,syscall.c_str());
                 }
1230

Andrea Isoni's avatar
Andrea Isoni committed
1231
1232
1233
1234
1235
1236
1237
                 //overwriting the streak file!!          
                 syscall = "cp -f " + interpstreak + "  " + filestreak;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                     ASSERTL0(false,syscall.c_str());
                 } 
1238

Andrea Isoni's avatar
Andrea Isoni committed
1239
1240
                 //calculate the wave
                 ExecuteWave();
Andrea Isoni's avatar
Andrea Isoni committed
1241

Andrea Isoni's avatar
Andrea Isoni committed
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
                 //save the wave field:
                 string oldwave = m_sessionName +"_wave_"+c +".fld";    
	         syscall = "cp -f " + m_sessionName+".fld" + "  " + oldwave;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                      ASSERTL0(false,syscall.c_str());
                 } 

                 //save old jump conditions:
                 string ujump = m_sessionName+"_u_5.bc";
	         syscall = "cp -f " + ujump + "  " + m_sessionName+"_u_5.bc_"+c;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                      ASSERTL0(false,syscall.c_str());
                 }              
1259

Andrea Isoni's avatar
Andrea Isoni committed
1260
1261
1262
1263
1264
1265
1266
1267
                 string vjump = m_sessionName+"_v_5.bc";
     	         syscall = "cp -f " + vjump + "  " + m_sessionName+"_v_5.bc_"+c;
                 cout<<syscall.c_str()<<endl;
                 if(system(syscall.c_str()))
                 {
                     ASSERTL0(false,syscall.c_str());
                 }    
                 cnt++;
1268

1269
1270
1271



Andrea Isoni's avatar
Andrea Isoni committed
1272
1273
1274
1275
1276
                  //use relaxation
                  if(GetVWIIterationType()!=eFixedWaveForcingWithSubIterationOnAlpha 
                    )
                  {
                       // the critical layer should be the bnd region 3
Dave Moxey's avatar
Dave Moxey committed
1277
                       //int reg =3;
Andrea Isoni's avatar
Andrea Isoni committed
1278
1279
1280
1281
1282
1283
                       //FileRelaxation(reg);
                  }
                  char c1[16]="";
                  sprintf(c1,"%d",cnt);   
                  //calculate the jump conditions
                  string wavefile  = m_sessionName +".fld"; 
Andrea Isoni's avatar
Andrea Isoni committed
1284
                  syscall =  "../../utilities/PostProcessing/Extras/FldCalcBCs  "
Andrea Isoni's avatar
Andrea Isoni committed
1285
1286
1287
1288
1289
1290
                        + movedmesh + "  " + wavefile + "  " + interpstreak + ">  data"+c1;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  }
1291

Andrea Isoni's avatar
Andrea Isoni committed
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
                  //move the new name_interp_moved.xml into name_interp.xml
	          syscall = "cp -f " + movedinterpmesh + "  " + fileinterp;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  } 
                  //move the new name_advPost_moved.xml into name_advPost.xml
	          syscall = "cp -f " + movedmesh + "  " + filePost;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  } 
 
1307

Andrea Isoni's avatar
Andrea Isoni committed
1308
             }
Andrea Isoni's avatar
Andrea Isoni committed
1309
             else if(  m_sessionVWI->GetSolverInfo("INTERFACE")=="phase" )
Andrea Isoni's avatar
Andrea Isoni committed
1310
1311
             {    
cout<<"phase"<<endl;
Andrea Isoni's avatar
Andrea Isoni committed
1312
1313
1314
1315
                  //determine cr:
                  NekDouble cr;
                  string cr_str;
                  stringstream st;
Spencer Sherwin's avatar
Spencer Sherwin committed
1316

Andrea Isoni's avatar
Andrea Isoni committed
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
                  //calculate the wave
                  ExecuteWave();
   
                  //save oldstreak
                  string oldstreak = m_sessionName +"_streak_"+ c +".fld";            
	          syscall = "cp -f " + filestreak + "  " + oldstreak;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  } 

                  //save wave
	          syscall = "cp -f " + m_sessionName+".fld" + "  " + filewave;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  } 
                  //save the old mesh     
                  string meshfile = m_sessionName + ".xml";                  
                  string meshold = m_sessionName +"_"+ c +".xml";
	          syscall = "cp -f " + meshfile + "  " + meshold;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  }  
1345

Andrea Isoni's avatar
Andrea Isoni committed
1346
1347
1348
1349
1350
1351
1352
                  //save the oldwave field:
                  string oldwave = m_sessionName +"_wave_"+c +".fld";    
    	          syscall = "cp -f " + m_sessionName+".fld" + "  " + oldwave;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
Andrea Isoni's avatar
Andrea Isoni committed
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
                  }       

                  //save old jump conditions:
                  string ujump = m_sessionName+"_u_5.bc";
	          syscall = "cp -f " + ujump + "  " + m_sessionName+"_u_5.bc_"+c;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                      ASSERTL0(false,syscall.c_str());
                  }              

                  string vjump = m_sessionName+"_v_5.bc";
     	          syscall = "cp -f " + vjump + "  " + m_sessionName+"_v_5.bc_"+c;
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                     ASSERTL0(false,syscall.c_str());
                  }
Andrea Isoni's avatar
Andrea Isoni committed
1371
1372
1373
1374
1375
1376
                  cnt++;


                  cr = m_leading_imag_evl[0]/m_alpha[0];
                  st << cr; 
                  cr_str = st.str();
Andrea Isoni's avatar
Andrea Isoni committed
1377
cout<<"cr="<<cr_str<<endl;
Andrea Isoni's avatar
Andrea Isoni committed
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
                  //NB -g or NOT!!!
                  //move the mesh around the critical layer    
                  syscall  = "../../utilities/PostProcessing/Extras/MoveMesh  "
                               + filePost +"  "+ filestreak +"  "+ fileinterp + "   "+ alpchar
                               +"      "+cr_str; 
  
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                       ASSERTL0(false,syscall.c_str());
                  }
                  //NB -g or NOT!!!
                  //move the advPost mesh (remark update alpha!!!)
                  syscall  =  "../../utilities/PostProcessing/Extras/MoveMesh  "
                        + filePost + "  " + filestreak + "  " + filePost + "    "+ alpchar
                               +"      "+cr_str; 
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                      ASSERTL0(false,syscall.c_str());
                  }
1399

Andrea Isoni's avatar
Andrea Isoni committed
1400
                  //interp streak into the new mesh
Andrea Isoni's avatar
Andrea Isoni committed
1401
                  syscall  =  "../../utilities/PostProcessing/Extras/FieldToField  "
Andrea Isoni's avatar
Andrea Isoni committed
1402
1403
                        + fileinterp + "  " + filestreak + "  " + movedinterpmesh + "  " 
	                + interpstreak;
Andrea Isoni's avatar
Andrea Isoni committed
1404

Andrea Isoni's avatar
Andrea Isoni committed
1405
1406
1407
1408
1409
1410
1411
1412
1413
                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                      ASSERTL0(false,syscall.c_str());
                  }

                  //split wave sol
                  syscall  =  "../../utilities/PostProcessing/Extras/SplitFld  "
                        + filePost + "  " + filewave;
Andrea Isoni's avatar
Andrea Isoni committed
1414
1415
1416
1417

                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
Andrea Isoni's avatar
Andrea Isoni committed
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
                      ASSERTL0(false,syscall.c_str());
                  }                
                  //interp wave
                  syscall  =  "../../utilities/PostProcessing/Extras/FieldToField  "
                        + filePost + "  " + filewavepressure + "  " + movedmesh + "  " 
	                + interwavepressure;

                  cout<<syscall.c_str()<<endl;
                  if(system(syscall.c_str()))
                  {
                      ASSERTL0(false,syscall.c_str());