<commit_before>#include <cstdio>
#include <cstdlib>

#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList0D.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList1DHomogeneous2D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>

using namespace Nektar;

int main(int argc, char *argv[])
{
    int i,j;

    if(argc != 2)
    {
        fprintf(stderr,"Usage: Splitmodes fieldfile \n");
        exit(1);
    }

    //default meshgraph
    SpatialDomains::MeshGraph graph; 


    //----------------------------------------------
    // Import fieldfile2.
    string fieldfile(argv[argc-1]);
    vector<SpatialDomains::FieldDefinitionsSharedPtr> fielddef;
    vector<vector<NekDouble> > fielddata;
    graph.Import(fieldfile,fielddef,fielddata);
    //----------------------------------------------


    ASSERTL0(fielddef[0]->m_numModes[2] > 1,"Expected Fourier field to have at least 2 modes");
    
    ASSERTL0(fielddef[0]->m_numHomogeneousDir == 1,"Expected second fld to have one homogeneous direction");
    
    int nmodes = fielddef[0]->m_numModes[2];

    // take off modes from fielddef 
    vector<unsigned int> newNumModes;
    newNumModes.push_back(fielddef[0]->m_numModes[0]);
    newNumModes.push_back(fielddef[0]->m_numModes[1]);
    vector<LibUtilities::BasisType> newBasis;
    newBasis.push_back(fielddef[0]->m_basis[0]);
    newBasis.push_back(fielddef[0]->m_basis[1]);
    for(int i = 0; i < fielddata.size(); ++i)
    {
        fielddef[i]->m_numModes = newNumModes;
        fielddef[i]->m_basis    = newBasis;
        fielddef[i]->m_numHomogeneousDir = 0;
    }


    for(int m = 0; m < nmodes; ++m)
    {
        vector<vector<NekDouble> > writedata;
        
        // outfile 
        string outfile(argv[argc-1]);
        string out = outfile.substr(0, outfile.find_last_of("."));
        char num[16] ="";
        sprintf(num,"%d",(m/2));
        
        if(m%2 == 0)
        {
            out = out + "_mode_" + num + "_real.fld";
        }
        else
        {
            out = out +  "_mode_" + num  + "_imag.fld"; 
        }
        
        vector<NekDouble> newdata;
        
        for(int i = 0; i < fielddata.size(); ++i)
        {
            int j;
            int datalen = fielddata[i].size()/fielddef[i]->m_fields.size()/nmodes;

            // Determine the number of coefficients per element
            int ncoeffs;
            switch(fielddef[i]->m_shapeType)
            {
            case SpatialDomains::eTriangle:
                ncoeffs = StdRegions::StdTriData::getNumberOfCoefficients(fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
                break;
            case SpatialDomains::eQuadrilateral:
                ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
                break;
            default:
                ASSERTL0(false,"Shape not recognised");
                break;
            }
        
            std::vector<NekDouble>::iterator vec_iter; <commit_msg>Moved definition of newdata so that redefined for all fielddata iterations<commit_after>#include <cstdio>
#include <cstdlib>

#include <MultiRegions/ExpList.h>
#include <MultiRegions/ExpList0D.h>
#include <MultiRegions/ExpList1D.h>
#include <MultiRegions/ExpList2D.h>
#include <MultiRegions/ExpList3D.h>
#include <MultiRegions/ExpList2DHomogeneous1D.h>
#include <MultiRegions/ExpList3DHomogeneous1D.h>
#include <MultiRegions/ExpList1DHomogeneous2D.h>
#include <MultiRegions/ExpList3DHomogeneous2D.h>

using namespace Nektar;

int main(int argc, char *argv[])
{
    int i,j;

    if(argc != 2)
    {
        fprintf(stderr,"Usage: Splitmodes fieldfile \n");
        exit(1);
    }

    //default meshgraph
    SpatialDomains::MeshGraph graph; 


    //----------------------------------------------
    // Import fieldfile2.
    string fieldfile(argv[argc-1]);
    vector<SpatialDomains::FieldDefinitionsSharedPtr> fielddef;
    vector<vector<NekDouble> > fielddata;
    graph.Import(fieldfile,fielddef,fielddata);
    //----------------------------------------------


    ASSERTL0(fielddef[0]->m_numModes[2] > 1,"Expected Fourier field to have at least 2 modes");
    
    ASSERTL0(fielddef[0]->m_numHomogeneousDir == 1,"Expected second fld to have one homogeneous direction");
    
    int nmodes = fielddef[0]->m_numModes[2];

    // take off modes from fielddef 
    vector<unsigned int> newNumModes;
    newNumModes.push_back(fielddef[0]->m_numModes[0]);
    newNumModes.push_back(fielddef[0]->m_numModes[1]);
    vector<LibUtilities::BasisType> newBasis;
    newBasis.push_back(fielddef[0]->m_basis[0]);
    newBasis.push_back(fielddef[0]->m_basis[1]);
    for(int i = 0; i < fielddata.size(); ++i)
    {
        fielddef[i]->m_numModes = newNumModes;
        fielddef[i]->m_basis    = newBasis;
        fielddef[i]->m_numHomogeneousDir = 0;
    }


    for(int m = 0; m < nmodes; ++m)
    {
        vector<vector<NekDouble> > writedata;
        
        // outfile 
        string outfile(argv[argc-1]);
        string out = outfile.substr(0, outfile.find_last_of("."));
        char num[16] ="";
        sprintf(num,"%d",(m/2));
        
        if(m%2 == 0)
        {
            out = out + "_mode_" + num + "_real.fld";
        }
        else
        {
            out = out +  "_mode_" + num  + "_imag.fld"; 
        }
        
        for(int i = 0; i < fielddata.size(); ++i)
        {
            int j;
            int datalen = fielddata[i].size()/fielddef[i]->m_fields.size()/nmodes;

            vector<NekDouble> newdata;
        
            // Determine the number of coefficients per element
            int ncoeffs;
            switch(fielddef[i]->m_shapeType)
            {
            case SpatialDomains::eTriangle:
                ncoeffs = StdRegions::StdTriData::getNumberOfCoefficients(fielddef[i]->m_numModes[0], fielddef[i]->m_numModes[1]);
                break;
            case SpatialDomains::eQuadrilateral:
                ncoeffs = fielddef[i]->m_numModes[0]*fielddef[i]->m_numModes[1];
                break;
            default:
                ASSERTL0(false,"Shape not recognised");
                break;
            }
        
            std::vector<NekDouble>::iterator vec_iter; 
{'fraction_non_alphanumeric': 0.15740885620403694, 'fraction_numerical': 0.015647003598810827, 'mean_word_length': 2.2299140980293077, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4255855', 'n_tokens_mistral': 2199, 'n_tokens_neox': 2111, 'n_words': 354}