void g (void) { fsi(f); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ x.fsi(f); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ fsi(cf); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than complex due to prototype" } */ x.fsi(cf); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than complex due to prototype" } */ fcf(f); /* { dg-warning "passing argument 1 of 'fcf' as complex rather than floating due to prototype" } */ x.fcf(f); /* { dg-warning "passing argument 1 of 'x.fcf' as complex rather than floating due to prototype" } */ fcf(si); /* { dg-warning "passing argument 1 of 'fcf' as complex rather than integer due to prototype" } */ x.fcf(si); /* { dg-warning "passing argument 1 of 'x.fcf' as complex rather than integer due to prototype" } */ ff(sc); /* { dg-warning "passing argument 1 of 'ff' as floating rather than integer due to prototype" } */ x.ff(sc); /* { dg-warning "passing argument 1 of 'x.ff' as floating rather than integer due to prototype" } */ ff(cf); /* { dg-warning "passing argument 1 of 'ff' as floating rather than complex due to prototype" } */ x.ff(cf); /* { dg-warning "passing argument 1 of 'x.ff' as floating rather than complex due to prototype" } */ ff(1.0); /* { dg-warning "passing argument 1 of 'ff' as 'float' rather than 'double' due to prototype" } */ x.ff(1.0); /* { dg-warning "passing argument 1 of 'x.ff' as 'float' rather than 'double' due to prototype" } */ fsll(sc); /* { dg-warning "passing argument 1 of 'fsll' with different width due to prototype" } */ x.fsll(sc); /* { dg-warning "passing argument 1 of 'x.fsll' with different width due to prototype" } */ fsc(sll); /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" } */ x.fsc(sll); /* { dg-warning "passing argument 1 of 'x.fsc' with different width due to prototype" } */ fsi(ui); /* { dg-warning "passing argument 1 of 'fsi' as signed due to prototype" } */ x.fsi(ui); /* { dg-warning "passing argument 1 of 'x.fsi' as signed due to prototype" } */ full(sll); /* { dg-warning "passing argument 1 of 'full' as unsigned due to prototype" } */ x.full(sll); /* { dg-warning "passing argument 1 of 'x.full' as unsigned due to prototype" } */ }
void m(char16_t c0, char32_t c1) { f_c (c0); /* { dg-warning "conversion from .char16_t. to .char. may change value" } */ fsc (c0); /* { dg-warning "change value" } */ fuc (c0); /* { dg-warning "change value" } */ f_s (c0); /* { dg-warning "change the sign" } */ fss (c0); /* { dg-warning "change the sign" } */ fus (c0); f_i (c0); fsi (c0); fui (c0); f_l (c0); fsl (c0); ful (c0); f_ll (c0); fsll (c0); full (c0); f_c (c1); /* { dg-warning "change value" } */ fsc (c1); /* { dg-warning "change value" } */ fuc (c1); /* { dg-warning "change value" } */ f_s (c1); /* { dg-warning "change value" } */ fss (c1); /* { dg-warning "change value" } */ fus (c1); /* { dg-warning "change value" } */ f_i (c1); /* { dg-warning "change the sign" } */ fsi (c1); /* { dg-warning "change the sign" } */ fui (c1); f_l (c1); /* { dg-warning "change the sign" "" { target { llp64 || ilp32 } } } */ fsl (c1); /* { dg-warning "change the sign" "" { target { llp64 || ilp32 } } } */ ful (c1); f_ll (c1); fsll (c1); full (c1); }
void m (char16_t c0, char32_t c1) { f_c (c0); /* { dg-warning "alter its value" } */ fsc (c0); /* { dg-warning "alter its value" } */ fuc (c0); /* { dg-warning "alter its value" } */ f_s (c0); /* { dg-warning "change the sign" } */ fss (c0); /* { dg-warning "change the sign" } */ fus (c0); f_i (c0); fsi (c0); fui (c0); f_l (c0); fsl (c0); ful (c0); f_ll (c0); fsll (c0); full (c0); f_c (c1); /* { dg-warning "alter its value" } */ fsc (c1); /* { dg-warning "alter its value" } */ fuc (c1); /* { dg-warning "alter its value" } */ f_s (c1); /* { dg-warning "alter its value" } */ fss (c1); /* { dg-warning "alter its value" } */ fus (c1); /* { dg-warning "alter its value" } */ f_i (c1); /* { dg-warning "change the sign" "" { target { ! int16 } } } */ fsi (c1); /* { dg-warning "change the sign" "" { target { ! int16 } } } */ fui (c1); f_l (c1); /* { dg-warning "change the sign" "" { target { llp64 || ilp32 } } } */ fsl (c1); /* { dg-warning "change the sign" "" { target { llp64 || ilp32 } } } */ ful (c1); f_ll (c1); fsll (c1); full (c1); }
void h2i (int x) { /* For some reason, we only give certain warnings for implicit conversions among values of the same precision with -Wconversion, while we don't give others at all. */ fsi ((unsigned)INT_MAX + 1); si = (unsigned)INT_MAX + 1; si = x ? (unsigned)INT_MAX + 1 : 1; fsi ((unsigned)INT_MAX + 2); si = (unsigned)INT_MAX + 2; si = x ? (unsigned)INT_MAX + 2 : 1; fsi (UINT_MAX); si = UINT_MAX; fui (-1); ui = -1; ui = x ? -1 : 1U; fui (INT_MIN); ui = INT_MIN; ui = x ? INT_MIN : 1U; }
void g (void) { fsi(d32); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ x.fsi(d32); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ fsi(d64); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ x.fsi(d64); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ fsi(d128); /* { dg-warning "passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */ x.fsi(d128); /* { dg-warning "passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */ fd32(si); /* { dg-warning "passing argument 1 of 'fd32' as floating rather than integer due to prototype" } */ x.fd32(si); /* { dg-warning "passing argument 1 of 'x.fd32' as floating rather than integer due to prototype" } */ fd64(ui); /* { dg-warning "passing argument 1 of 'fd64' as floating rather than integer due to prototype" } */ x.fd64(ui); /* { dg-warning "passing argument 1 of 'x.fd64' as floating rather than integer due to prototype" } */ fd128(si); /* { dg-warning "passing argument 1 of 'fd128' as floating rather than integer due to prototype" } */ x.fd128(ui); /* { dg-warning "passing argument 1 of 'x.fd128' as floating rather than integer due to prototype" } */ fd32(1.0); /* { dg-warning "passing argument 1 of 'fd32' as '_Decimal32' rather than 'double' due to prototype" } */ x.fd32(1.0); /* { dg-warning "passing argument 1 of 'x.fd32' as '_Decimal32' rather than 'double' due to prototype" } */ fd64(1.0); /* { dg-warning "passing argument 1 of 'fd64' as '_Decimal64' rather than 'double' due to prototype" } */ x.fd64(1.0); /* { dg-warning "passing argument 1 of 'x.fd64' as '_Decimal64' rather than 'double' due to prototype" } */ fd128(1.0); /* { dg-warning "passing argument 1 of 'fd128' as '_Decimal128' rather than 'double' due to prototype" } */ x.fd128(1.0); /* { dg-warning "passing argument 1 of 'x.fd128' as '_Decimal128' rather than 'double' due to prototype" } */ }
void h2i (int x) { /* For some reason, we only give certain warnings for implicit conversions among values of the same precision with -Wconversion, while we don't give others at all. */ fsi ((unsigned)INT_MAX + 1); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ si = (unsigned)INT_MAX + 1; si = x ? (unsigned)INT_MAX + 1 : 1; fsi ((unsigned)INT_MAX + 2); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ si = (unsigned)INT_MAX + 2; si = x ? (unsigned)INT_MAX + 2 : 1; fsi (UINT_MAX); /* { dg-warning "warning: passing argument 1 of 'fsi' as signed due to prototype" } */ si = UINT_MAX; fui (-1); /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ /* { dg-warning "warning: passing argument 1 of 'fui' as unsigned due to prototype" "-Wconversion" { target *-*-* } 124 } */ ui = -1; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ ui = x ? -1 : 1U; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ fui (INT_MIN); /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ /* { dg-warning "warning: passing argument 1 of 'fui' as unsigned due to prototype" "-Wconversion" { target *-*-* } 128 } */ ui = INT_MIN; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ ui = x ? INT_MIN : 1U; /* { dg-warning "warning: negative integer implicitly converted to unsigned type" } */ }
int main(int argc, char **argv) { char buffer[MAX_BUFFER_SIZE]; for (int i=1; i< argc; ++i) { std::string filename(argv[i]); std::ifstream fs(filename.c_str(), std::ios::in); if (!fs.good()) { std::cerr << "Unable to open file " << filename << std::endl; return 1; } size_t last_slash = filename.rfind('/'); if (last_slash == std::string::npos) { last_slash = filename.rfind('\\'); if (last_slash == std::string::npos) last_slash = 0; else ++last_slash; } else ++last_slash; std::string outName = filename.substr(last_slash,filename.size()-last_slash); std::stringstream ssi; std::stringstream sso; std::ifstream fsi(outName.c_str(),std::ios::in); if (fsi.good()) { while (!fsi.eof()) { fsi.getline(buffer,MAX_BUFFER_SIZE); if (!fsi.eof()) ssi << buffer << std::endl ; } fsi.close(); } // fist line fs.getline(buffer,MAX_BUFFER_SIZE); char *sub=buffer; while ((*sub=='/') || (*sub==' ')) ++sub; sso << "std::string "<<sub<< " ="; // text of shader unsigned int nbbl=0; while (!fs.eof()) { fs.getline(buffer,MAX_BUFFER_SIZE); //std::cout << buffer << std::endl; if (*buffer!=0) { for (unsigned int i=0; i<nbbl;++i) sso << std::endl <<"\"\\n\""; nbbl=0; sso << std::endl << "\"" << buffer <<"\\n\""; } else nbbl++; }; sso << ";"<< std::endl<< std::endl; std::string ssostr = sso.str(); if (ssostr != ssi.str()) { std::ofstream fso(outName.c_str(),std::ios::out); fso << ssostr; std::cout << "Shader_to_h: "<< outName << " copy"<< std::endl; fso.close(); } else std::cout << "Shader_to_h: "<< outName << " ok"<< std::endl; fs.close(); } return 0; }
// Function to load the runInfo structure with all runID's on local disk void US_XpnRunAuc::load_runs( void ) { impdir = US_Settings::importDir(); // Imports directory impdir.replace( "\\", "/" ); // Possible Windows issue if ( impdir.right( 1 ) != "/" ) impdir = impdir + "/"; // Insure trailing slash // Set up to load either from a raw DB file or from openAUC files QStringList efilt( "*.auc" ); QStringList runids; QStringList rdirs = QDir( impdir ).entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name ); qDebug() << "LdDk: rdirs count" << rdirs.count() << "impdir" << impdir << "efilt" << efilt; // Get the list of all Run IDs with data in their work directories for ( int ii = 0; ii < rdirs.count(); ii++ ) { QString runID = rdirs[ ii ]; QString wdir = impdir + runID + "/"; QStringList efiles = QDir( wdir ).entryList( efilt, QDir::Files, QDir::Name ); int nfiles = efiles.count(); qDebug() << "LdDk: ii" << ii << "run" << rdirs[ii] << "count" << nfiles; if ( nfiles < 1 ) // Definitely not Optima continue; QString rfn = wdir + efiles[ 0 ]; QString date = US_Util::toUTCDatetimeText( QFileInfo( rfn ).lastModified().toUTC() .toString( Qt::ISODate ), true ) .section( " ", 0, 0 ).simplified(); // Look for TMST definition file and test import origin QString dfname = runID + ".time_state.xml"; QString dpath = wdir + dfname; QFile dfile( dpath ); if ( ! dfile.exists() || ! dfile.open( QIODevice::ReadOnly ) ) continue; // Skip if TMST def file does not exist or can't be opened qDebug() << "LdDk: dfname -- exists/opened"; QTextStream fsi( &dfile ); QString pmatch( "import_type=\"Optima\"" ); QString pmatch2( "import_type=\"XPN\"" ); QString xmli = fsi.readAll(); dfile.close(); qDebug() << "LdDk: pmatch" << pmatch; if ( ! xmli.contains( pmatch ) && ! xmli.contains( pmatch2 ) ) continue; // Skip if TMST def has no import_type="Optima" // Add an eligible run directory to the list //qDebug() << "LdDk: ii" << ii << " rfn" << rfn; RunInfo rr; rr.runID = runID; rr.date = date; rr.ntriple = nfiles; //qDebug() << "LdDk: ii" << ii << " runID date count" // << rr.runID << rr.date << rr.nfiles; runInfo << rr; } if ( runInfo.size() < 1 ) { QMessageBox::information( this, tr( "Error" ), tr( "There are no US3 runs on the local Disk to load.\n" ) ); } return; }
void h (int x) { unsigned int ui = 3; int si = 3; unsigned char uc = 3; signed char sc = 3; uc = ui; uc = si; sc = ui; sc = si; fuc (ui); fuc (si); fsc (ui); fsc (si); fsi (si); fui (ui); fsi (uc); si = uc; fui (uc); ui = uc; fui ('A'); ui = 'A'; fsi ('A'); si = 'A'; fuc ('A'); uc = 'A'; uc = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */ uc = x ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */ uc = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-1." } */ uc = x ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned char. changes the value of .-\[0-9\]+." } */ ui = x ? 1U : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-1. to .\[0-9\]+." } */ ui = x ? INT_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value from .-\[0-9\]+. to .\[0-9\]+." } */ ui = ui ? SCHAR_MIN : 1U; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ ui = 1U * -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ ui = ui + INT_MIN; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes value " } */ ui = x ? 1 : -1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of .-1." } */ ui = ui ? SCHAR_MIN : 1; /* { dg-warning "unsigned conversion from .int. to .unsigned int. changes the value of " } */ fuc (-1); /* { dg-warning "unsigned conversion" } */ uc = -1; /* { dg-warning "unsigned conversion" } */ fui (-1); /* { dg-warning "unsigned conversion" } */ ui = -1; /* { dg-warning "unsigned conversion" } */ fuc ('\xa0'); /* { dg-warning "unsigned conversion" } */ uc = '\xa0'; /* { dg-warning "unsigned conversion" } */ fui ('\xa0');/* { dg-warning "unsigned conversion" } */ ui = '\xa0'; /* { dg-warning "unsigned conversion" } */ fsi (0x80000000); /* { dg-warning "signed conversion" } */ si = 0x80000000; /* { dg-warning "signed conversion" } */ fsi (UINT_MAX - 1); /* { dg-warning "conversion" } */ si = UINT_MAX - 1; /* { dg-warning "conversion" } */ fsi (UINT_MAX - 1U); /* { dg-warning "conversion" } */ si = UINT_MAX - 1U; /* { dg-warning "conversion" } */ fsi (UINT_MAX/3U); si = UINT_MAX/3U; fsi (UINT_MAX/3); si = UINT_MAX/3; fui (UINT_MAX - 1); ui = UINT_MAX - 1; uc = (unsigned char) -1; ui = -1 * (1 * -1); ui = (unsigned) -1; fsc (uc); /* { dg-warning "conversion" } */ sc = uc; /* { dg-warning "conversion" } */ fuc (sc); /* { dg-warning "conversion" } */ uc = sc; /* { dg-warning "conversion" } */ fsi (ui); /* { dg-warning "conversion" } */ si = ui; /* { dg-warning "conversion" } */ fui (si); /* { dg-warning "conversion" } */ ui = si; /* { dg-warning "conversion" } */ fui (sc); /* { dg-warning "conversion" } */ ui = sc; /* { dg-warning "conversion" } */ }
void h (int x) { unsigned int ui = 3; int si = 3; unsigned char uc = 3; signed char sc = 3; uc = ui; /* { dg-warning "conversion" } */ uc = si; /* { dg-warning "conversion" } */ sc = ui; /* { dg-warning "conversion" } */ sc = si; /* { dg-warning "conversion" } */ fuc (ui); /* { dg-warning "conversion" } */ fuc (si); /* { dg-warning "conversion" } */ fsc (ui); /* { dg-warning "conversion" } */ fsc (si); /* { dg-warning "conversion" } */ fsi (si); fui (ui); fsi (uc); si = uc; fui (uc); ui = uc; fui ('A'); ui = 'A'; fsi ('A'); si = 'A'; fuc ('A'); uc = 'A'; uc = x ? 1U : -1; /* { dg-warning "conversion" } */ uc = x ? SCHAR_MIN : 1U; /* { dg-warning "conversion" } */ uc = x ? 1 : -1; /* Warned by -Wsign-conversion. */ uc = x ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion. */ ui = x ? 1U : -1; /* Warned by -Wsign-conversion. */ ui = x ? INT_MIN : 1U; /* Warned by -Wsign-conversion. */ ui = ui ? SCHAR_MIN : 1U; /* Warned by -Wsign-conversion. */ ui = 1U * -1; /* Warned by -Wsign-conversion. */ ui = ui + INT_MIN; /* Warned by -Wsign-conversion. */ ui = x ? 1 : -1; /* Warned by -Wsign-conversion. */ ui = ui ? SCHAR_MIN : 1; /* Warned by -Wsign-conversion. */ fuc (-1); /* Warned by -Wsign-conversion. */ uc = -1; /* Warned by -Wsign-conversion. */ fui (-1); /* Warned by -Wsign-conversion. */ ui = -1; /* Warned by -Wsign-conversion. */ fuc ('\xa0'); /* Warned by -Wsign-conversion. */ uc = '\xa0'; /* Warned by -Wsign-conversion. */ fui ('\xa0'); /* Warned by -Wsign-conversion. */ ui = '\xa0'; /* Warned by -Wsign-conversion. */ fsi (0x80000000); /* Warned by -Wsign-conversion. */ si = 0x80000000; /* Warned by -Wsign-conversion. */ fsi (UINT_MAX - 1); /* Warned by -Wsign-conversion. */ si = UINT_MAX - 1; /* Warned by -Wsign-conversion. */ fsi (UINT_MAX - 1U); /* Warned by -Wsign-conversion. */ si = UINT_MAX - 1U; /* Warned by -Wsign-conversion. */ fsi (UINT_MAX/3U); si = UINT_MAX/3U; fsi (UINT_MAX/3); si = UINT_MAX/3; fui (UINT_MAX - 1); ui = UINT_MAX - 1; uc = (unsigned char) -1; ui = -1 * (1 * -1); ui = (unsigned) -1; fsc (uc); /* Warned by -Wsign-conversion. */ sc = uc; /* Warned by -Wsign-conversion. */ fuc (sc); /* Warned by -Wsign-conversion. */ uc = sc; /* Warned by -Wsign-conversion. */ fsi (ui); /* Warned by -Wsign-conversion. */ si = ui; /* Warned by -Wsign-conversion. */ fui (si); /* Warned by -Wsign-conversion. */ ui = si; /* Warned by -Wsign-conversion. */ fui (sc); /* Warned by -Wsign-conversion. */ ui = sc; /* Warned by -Wsign-conversion. */ }
TEST( SDIRKFsiSolidTest, linearized ) { scalar r0 = 3.0e-3; scalar h = 3.0e-4; scalar L = 0.126; scalar rho_s = 1000; scalar E0 = 4.0e5; scalar G = 4.0e5; scalar nu = 0.5; scalar a0 = M_PI * r0 * r0; scalar u0 = 0.26; scalar p0 = 0; int N = 5; scalar T = 1; scalar rho_f = 1060; scalar E = 490; scalar cmk = std::sqrt( E * h / (2 * rho_f * r0) ); bool parallel = false; int extrapolation = 0; scalar tol = 1.0e-8; int maxIter = 50; scalar initialRelaxation = 1.0e-3; int maxUsedIterations = 50; int nbReuse = 0; scalar singularityLimit = 1.0e-13; int reuseInformationStartingFromTimeIndex = 0; bool scaling = false; scalar beta = 0.01; bool updateJacobian = false; int minIter = 5; int nbComputations = 3; std::deque<std::shared_ptr<tubeflow::SDCTubeFlowFluidSolver> > fluidSolvers; std::deque<std::shared_ptr<tubeflow::SDCTubeFlowLinearizedSolidSolver> > solidSolvers; std::deque<int> nbTimeStepsList; for ( int iComputation = 0; iComputation < nbComputations; iComputation++ ) { int nbTimeSteps = 120 * std::pow( 2, iComputation ); std::cout << "nbTimeSteps = " << nbTimeSteps << std::endl; scalar dt = T / nbTimeSteps; std::shared_ptr<tubeflow::SDCTubeFlowFluidSolver> fluid( new tubeflow::SDCTubeFlowFluidSolver( a0, u0, p0, dt, cmk, N, L, T, rho_f ) ); std::shared_ptr<tubeflow::SDCTubeFlowLinearizedSolidSolver> solid( new tubeflow::SDCTubeFlowLinearizedSolidSolver( N, nu, rho_s, h, L, dt, G, E0, r0, T ) ); shared_ptr<RBFFunctionInterface> rbfFunction; shared_ptr<RBFInterpolation> rbfInterpolator; shared_ptr<RBFCoarsening> rbfInterpToCouplingMesh; shared_ptr<RBFCoarsening> rbfInterpToMesh; rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> fluidSolver( new MultiLevelSolver( fluid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 0, 0 ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> solidSolver( new MultiLevelSolver( solid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 1, 0 ) ); std::shared_ptr< std::list<std::shared_ptr<ConvergenceMeasure> > > convergenceMeasures; convergenceMeasures = std::shared_ptr<std::list<std::shared_ptr<ConvergenceMeasure> > >( new std::list<std::shared_ptr<ConvergenceMeasure> >() ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new RelativeConvergenceMeasure( 0, true, tol ) ) ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new MinIterationConvergenceMeasure( 0, false, minIter ) ) ); shared_ptr<MultiLevelFsiSolver> fsi( new MultiLevelFsiSolver( fluidSolver, solidSolver, convergenceMeasures, parallel, extrapolation ) ); shared_ptr<PostProcessing> postProcessing( new AndersonPostProcessing( fsi, maxIter, initialRelaxation, maxUsedIterations, nbReuse, singularityLimit, reuseInformationStartingFromTimeIndex, scaling, beta, updateJacobian ) ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcFluidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( fluid ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcSolidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( solid ); assert( sdcFluidSolver ); assert( sdcSolidSolver ); std::shared_ptr<fsi::SDCFsiSolver> fsiSolver( new fsi::SDCFsiSolver( sdcFluidSolver, sdcSolidSolver, postProcessing, extrapolation ) ); std::shared_ptr<sdc::AdaptiveTimeStepper> adaptiveTimeStepper( new sdc::AdaptiveTimeStepper( false ) ); std::string method = "ESDIRK53PR"; std::shared_ptr<sdc::ESDIRK> esdirk( new sdc::ESDIRK( fsiSolver, method, adaptiveTimeStepper ) ); esdirk->run(); fluidSolvers.push_back( fluid ); solidSolvers.push_back( solid ); nbTimeStepsList.push_back( nbTimeSteps ); } std::cout << "solid" << std::endl; for ( int i = 0; i < 2; i++ ) { fsi::vector ref; if ( i == 0 ) ref = solidSolvers.back()->r; else ref = solidSolvers.back()->u; std::deque<scalar> errors; for ( int iComputation = 0; iComputation < nbComputations - 1; iComputation++ ) { fsi::vector data; if ( i == 0 ) data = solidSolvers.at( iComputation )->r; else data = solidSolvers.at( iComputation )->u; scalar error = (ref - data).norm() / ref.norm(); errors.push_back( error ); } for ( int iComputation = 0; iComputation < nbComputations - 2; iComputation++ ) { scalar order = ( std::log10( errors.at( iComputation ) ) - std::log10( errors.at( iComputation + 1 ) ) ) / ( std::log10( nbTimeStepsList.at( iComputation + 1 ) ) - std::log10( nbTimeStepsList.at( iComputation ) ) ); std::cout << "order = " << order << std::endl; if ( i == 0 ) ASSERT_NEAR( order, 3, 0.1 ); } } std::cout << "fluid" << std::endl; for ( int i = 0; i < 3; i++ ) { fsi::vector ref; if ( i == 0 ) ref = fluidSolvers.back()->u; if ( i == 1 ) ref = fluidSolvers.back()->a; if ( i == 2 ) ref = fluidSolvers.back()->p; std::deque<scalar> errors; for ( int iComputation = 0; iComputation < nbComputations - 1; iComputation++ ) { fsi::vector data; if ( i == 0 ) data = fluidSolvers.at( iComputation )->u; if ( i == 1 ) data = fluidSolvers.at( iComputation )->a; if ( i == 2 ) data = fluidSolvers.at( iComputation )->p; scalar error = (ref - data).norm() / ref.norm(); errors.push_back( error ); } for ( int iComputation = 0; iComputation < nbComputations - 2; iComputation++ ) { scalar order = ( std::log10( errors.at( iComputation ) ) - std::log10( errors.at( iComputation + 1 ) ) ) / ( std::log10( nbTimeStepsList.at( iComputation + 1 ) ) - std::log10( nbTimeStepsList.at( iComputation ) ) ); std::cout << "order = " << order << std::endl; if ( i == 1 || i == 2 ) ASSERT_NEAR( order, 3, 0.1 ); } } }
virtual void SetUp() { scalar r0 = 3.0e-3; scalar h = 3.0e-4; scalar L = 0.126; scalar rho_s = 1000; scalar E0 = 4.0e5; scalar G = 4.0e5; scalar nu = 0.5; scalar a0 = M_PI * r0 * r0; scalar u0 = 0.26; scalar p0 = 0; scalar dt = 1; int N = 5; scalar T = 1; scalar rho_f = 1060; scalar E = 490; scalar cmk = std::sqrt( E * h / (2 * rho_f * r0) ); bool parallel = false; int extrapolation = 0; scalar tol = 1.0e-3; int maxIter = 20; scalar initialRelaxation = 1.0e-3; int maxUsedIterations = 50; int nbReuse = 0; scalar singularityLimit = 1.0e-13; int reuseInformationStartingFromTimeIndex = 0; bool scaling = false; bool updateJacobian = false; scalar beta = 0.5; int minIter = 5; std::shared_ptr<tubeflow::SDCTubeFlowFluidSolver> fluid( new tubeflow::SDCTubeFlowFluidSolver( a0, u0, p0, dt, cmk, N, L, T, rho_f ) ); std::shared_ptr<fsi::BaseMultiLevelSolver> solid; solid = std::shared_ptr<fsi::BaseMultiLevelSolver>( new tubeflow::SDCTubeFlowLinearizedSolidSolver( N, nu, rho_s, h, L, dt, G, E0, r0, T ) ); assert( solid ); shared_ptr<RBFFunctionInterface> rbfFunction; shared_ptr<RBFInterpolation> rbfInterpolator; shared_ptr<RBFCoarsening> rbfInterpToCouplingMesh; shared_ptr<RBFCoarsening> rbfInterpToMesh; rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> fluidSolver( new MultiLevelSolver( fluid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 0, 0 ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> solidSolver( new MultiLevelSolver( solid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 1, 0 ) ); std::shared_ptr< std::list<std::shared_ptr<ConvergenceMeasure> > > convergenceMeasures; convergenceMeasures = std::shared_ptr<std::list<std::shared_ptr<ConvergenceMeasure> > >( new std::list<std::shared_ptr<ConvergenceMeasure> >() ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new RelativeConvergenceMeasure( 0, true, tol ) ) ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new MinIterationConvergenceMeasure( 0, false, minIter ) ) ); shared_ptr<MultiLevelFsiSolver> fsi( new MultiLevelFsiSolver( fluidSolver, solidSolver, convergenceMeasures, parallel, extrapolation ) ); shared_ptr<PostProcessing> postProcessing( new AndersonPostProcessing( fsi, maxIter, initialRelaxation, maxUsedIterations, nbReuse, singularityLimit, reuseInformationStartingFromTimeIndex, scaling, beta, updateJacobian ) ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcFluidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( fluid ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcSolidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( solid ); assert( sdcFluidSolver ); assert( sdcSolidSolver ); std::shared_ptr<fsi::SDCFsiSolver> fsiSolver( new fsi::SDCFsiSolver( sdcFluidSolver, sdcSolidSolver, postProcessing, extrapolation ) ); std::shared_ptr<sdc::AdaptiveTimeStepper> adaptiveTimeStepper( new sdc::AdaptiveTimeStepper( false ) ); std::string method = "ESDIRK53PR"; esdirk = std::shared_ptr<sdc::ESDIRK> ( new sdc::ESDIRK( fsiSolver, method, adaptiveTimeStepper ) ); }
TEST( SDCFsiTest, reuse ) { std::vector<int> nbIter; for ( int nbReuse = 0; nbReuse < 3; nbReuse++ ) { scalar r0 = 0.2; scalar a0 = M_PI * r0 * r0; scalar u0 = 0.1; scalar p0 = 0; scalar dt = 0.01; int N = 20; scalar L = 1; scalar T = 1; scalar dx = L / N; scalar rho = 1.225; scalar E = 490; scalar h = 1.0e-3; scalar cmk = std::sqrt( E * h / (2 * rho * r0) ); scalar c0 = std::sqrt( cmk * cmk - p0 / (2 * rho) ); scalar kappa = c0 / u0; bool parallel = false; int extrapolation = 0; scalar tol = 1.0e-5; int maxIter = 50; scalar initialRelaxation = 1.0e-3; int maxUsedIterations = 50; scalar singularityLimit = 1.0e-13; int reuseInformationStartingFromTimeIndex = 0; bool scaling = false; bool updateJacobian = false; scalar beta = 0.1; int minIter = 5; ASSERT_NEAR( kappa, 10, 1.0e-13 ); ASSERT_TRUE( dx > 0 ); std::shared_ptr<tubeflow::SDCTubeFlowFluidSolver> fluid( new tubeflow::SDCTubeFlowFluidSolver( a0, u0, p0, dt, cmk, N, L, T, rho ) ); std::shared_ptr<tubeflow::SDCTubeFlowSolidSolver> solid( new tubeflow::SDCTubeFlowSolidSolver( a0, cmk, p0, rho, L, N ) ); shared_ptr<RBFFunctionInterface> rbfFunction; shared_ptr<RBFInterpolation> rbfInterpolator; shared_ptr<RBFCoarsening> rbfInterpToCouplingMesh; shared_ptr<RBFCoarsening> rbfInterpToMesh; rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> fluidSolver( new MultiLevelSolver( fluid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 0, 0 ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> solidSolver( new MultiLevelSolver( solid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 1, 0 ) ); std::shared_ptr< std::list<std::shared_ptr<ConvergenceMeasure> > > convergenceMeasures; convergenceMeasures = std::shared_ptr<std::list<std::shared_ptr<ConvergenceMeasure> > >( new std::list<std::shared_ptr<ConvergenceMeasure> > ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new RelativeConvergenceMeasure( 0, false, tol ) ) ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new MinIterationConvergenceMeasure( 0, false, minIter ) ) ); shared_ptr<MultiLevelFsiSolver> fsi( new MultiLevelFsiSolver( fluidSolver, solidSolver, convergenceMeasures, parallel, extrapolation ) ); shared_ptr<PostProcessing> postProcessing( new AndersonPostProcessing( fsi, maxIter, initialRelaxation, maxUsedIterations, nbReuse, singularityLimit, reuseInformationStartingFromTimeIndex, scaling, beta, updateJacobian ) ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcFluidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( fluid ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcSolidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( solid ); assert( sdcFluidSolver ); assert( sdcSolidSolver ); std::shared_ptr<fsi::SDCFsiSolver> fsiSolver( new fsi::SDCFsiSolver( sdcFluidSolver, sdcSolidSolver, postProcessing, extrapolation ) ); int nbNodes = 3; std::shared_ptr<fsi::quadrature::IQuadrature<scalar> > quadrature; quadrature = std::shared_ptr<fsi::quadrature::IQuadrature<scalar> >( new fsi::quadrature::Uniform<scalar>( nbNodes ) ); std::shared_ptr<sdc::SDC> sdc( new sdc::SDC( fsiSolver, quadrature, 1.0e-10, nbNodes, nbNodes ) ); sdc->run(); nbIter.push_back( fsi->nbIter ); } int iprev; int index = 0; for ( int i : nbIter ) { std::cout << "nbIter = " << i << std::endl; if ( index > 0 ) ASSERT_LE( i, iprev ); iprev = i; index++; } }
TEST( SDCFsiTest, order ) { int N = 5; scalar r0 = 0.2; scalar a0 = M_PI * r0 * r0; scalar u0 = 0.1; scalar p0 = 0; scalar L = 1; scalar T = 1; scalar dx = L / N; scalar rho = 1.225; scalar E = 490; scalar h = 1.0e-3; scalar cmk = std::sqrt( E * h / (2 * rho * r0) ); scalar c0 = std::sqrt( cmk * cmk - p0 / (2 * rho) ); scalar kappa = c0 / u0; bool parallel = false; int extrapolation = 0; scalar tol = 1.0e-5; int maxIter = 20; scalar initialRelaxation = 1.0e-3; int maxUsedIterations = 50; int nbReuse = 0; scalar singularityLimit = 1.0e-13; int reuseInformationStartingFromTimeIndex = 0; bool scaling = false; scalar beta = 0.01; bool updateJacobian = false; int minIter = 5; ASSERT_NEAR( kappa, 10, 1.0e-13 ); ASSERT_TRUE( dx > 0 ); int nbComputations = 5; std::deque<std::shared_ptr<tubeflow::SDCTubeFlowFluidSolver> > fluidSolvers; std::deque<int> nbTimeStepsList; for ( int iComputation = 0; iComputation < nbComputations; iComputation++ ) { int nbTimeSteps = 4 * std::pow( 2, iComputation ); std::cout << "nbTimeSteps = " << nbTimeSteps << std::endl; scalar dt = T / nbTimeSteps; std::shared_ptr<tubeflow::SDCTubeFlowFluidSolver> fluid( new tubeflow::SDCTubeFlowFluidSolver( a0, u0, p0, dt, cmk, N, L, T, rho ) ); std::shared_ptr<tubeflow::SDCTubeFlowSolidSolver> solid( new tubeflow::SDCTubeFlowSolidSolver( a0, cmk, p0, rho, L, N ) ); shared_ptr<RBFFunctionInterface> rbfFunction; shared_ptr<RBFInterpolation> rbfInterpolator; shared_ptr<RBFCoarsening> rbfInterpToCouplingMesh; shared_ptr<RBFCoarsening> rbfInterpToMesh; rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> fluidSolver( new MultiLevelSolver( fluid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 0, 0 ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToCouplingMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); rbfFunction = shared_ptr<RBFFunctionInterface>( new TPSFunction() ); rbfInterpolator = shared_ptr<RBFInterpolation>( new RBFInterpolation( rbfFunction ) ); rbfInterpToMesh = shared_ptr<RBFCoarsening> ( new RBFCoarsening( rbfInterpolator ) ); shared_ptr<MultiLevelSolver> solidSolver( new MultiLevelSolver( solid, fluid, rbfInterpToCouplingMesh, rbfInterpToMesh, 1, 0 ) ); std::shared_ptr< std::list<std::shared_ptr<ConvergenceMeasure> > > convergenceMeasures; convergenceMeasures = std::shared_ptr<std::list<std::shared_ptr<ConvergenceMeasure> > >( new std::list<std::shared_ptr<ConvergenceMeasure> > ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new ResidualRelativeConvergenceMeasure( 0, false, tol ) ) ); convergenceMeasures->push_back( std::shared_ptr<ConvergenceMeasure>( new MinIterationConvergenceMeasure( 0, false, minIter ) ) ); shared_ptr<MultiLevelFsiSolver> fsi( new MultiLevelFsiSolver( fluidSolver, solidSolver, convergenceMeasures, parallel, extrapolation ) ); shared_ptr<PostProcessing> postProcessing( new AndersonPostProcessing( fsi, maxIter, initialRelaxation, maxUsedIterations, nbReuse, singularityLimit, reuseInformationStartingFromTimeIndex, scaling, beta, updateJacobian ) ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcFluidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( fluid ); std::shared_ptr<sdc::SDCFsiSolverInterface> sdcSolidSolver = std::dynamic_pointer_cast<sdc::SDCFsiSolverInterface>( solid ); assert( sdcFluidSolver ); assert( sdcSolidSolver ); std::shared_ptr<fsi::SDCFsiSolver> fsiSolver( new fsi::SDCFsiSolver( sdcFluidSolver, sdcSolidSolver, postProcessing, extrapolation ) ); int nbNodes = 3; std::shared_ptr<fsi::quadrature::IQuadrature<scalar> > quadrature; quadrature = std::shared_ptr<fsi::quadrature::IQuadrature<scalar> >( new fsi::quadrature::GaussLobatto<scalar>( nbNodes ) ); std::shared_ptr<sdc::SDC> sdc( new sdc::SDC( fsiSolver, quadrature, 1.0e-13, 10, 200 ) ); sdc->run(); ASSERT_TRUE( sdc->isConverged() ); fluidSolvers.push_back( fluid ); nbTimeStepsList.push_back( nbTimeSteps ); } for ( int i = 0; i < 2; i++ ) { fsi::vector ref; if ( i == 0 ) ref = fluidSolvers.back()->u; else ref = fluidSolvers.back()->a; std::deque<scalar> errors; for ( int iComputation = 0; iComputation < nbComputations - 1; iComputation++ ) { fsi::vector data; if ( i == 0 ) data = fluidSolvers.at( iComputation )->u; else data = fluidSolvers.at( iComputation )->a; scalar error = (ref - data).norm() / data.norm(); std::cout << "error = " << error << std::endl; errors.push_back( error ); } for ( int iComputation = 0; iComputation < nbComputations - 2; iComputation++ ) { scalar order = ( std::log10( errors.at( iComputation ) ) - std::log10( errors.at( iComputation + 1 ) ) ) / ( std::log10( nbTimeStepsList.at( iComputation + 1 ) ) - std::log10( nbTimeStepsList.at( iComputation ) ) ); std::cout << "order = " << order << std::endl; ASSERT_GE( order, 3.8 ); } } }