void Problem::readLastVectorALETimeAdvance ( vectorPtr_Type fluidDisp, const std::string loadInitSol) { using namespace LifeV; typedef FSIOperator::mesh_Type mesh_Type; //We still need to load the last vector for ALE std::string iterationString = loadInitSol; fluidDisp.reset (new vector_Type (M_fsi->FSIOper()->mmFESpace().map(), LifeV::Unique) ); //Setting the exporterData to read: ALE problem LifeV::ExporterData<mesh_Type> initSolFluidDisp (LifeV::ExporterData<mesh_Type>::VectorField, "f-displacement." + iterationString, M_fsi->FSIOper()->mmFESpacePtr(), fluidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime ); //Initializing *fluidDisp *= 0.0; //Reading M_importerFluid->readVariable (initSolFluidDisp); //Fluid df //Output std::cout << "Norm of the df " << fluidDisp->norm2() << std::endl; //This is ugly but it's the only way I have figured out at the moment if ( M_data->method().compare ("monolithicGI") == 0 ) { //Don't be scared by the ten. The goal of 10 is just to make the first if fail M_fsi->FSIOper()->setALEVectorInStencil ( fluidDisp, 10, true ); } //Setting the vector in the stencil M_fsi->FSIOper()->ALETimeAdvance()->shiftRight ( *fluidDisp ); }
void Problem::initializeWithVectors ( void ) { using namespace LifeV; // vectors to store the solutions we want. vectorPtr_Type vel; vectorPtr_Type pressure; vectorPtr_Type solidDisp; vectorPtr_Type fluidDisp; vel.reset (new vector_Type (M_fsi->FSIOper()->uFESpace().map(), LifeV::Unique) ); pressure.reset (new vector_Type (M_fsi->FSIOper()->pFESpace().map(), LifeV::Unique) ); solidDisp.reset (new vector_Type (M_fsi->FSIOper()->dFESpace().map(), LifeV::Unique) ); fluidDisp.reset (new vector_Type (M_fsi->FSIOper()->mmFESpace().map(), LifeV::Unique) ); // In this case we want to initialize only the pressure M_fsi->FSIOper()->pFESpacePtr()->interpolate ( static_cast<FESpace<RegionMesh<LinearTetra>, MapEpetra> ::function_Type> ( pressureInitial ), *pressure, 0.0 ); *vel *= 0.0; *solidDisp *= 0.0; *fluidDisp *= 0.0; UInt iterInit; // Filling the stencils for (iterInit = 0; iterInit < M_fsi->FSIOper()->fluidTimeAdvance()->size(); iterInit++ ) { //We send the vectors to the FSIMonolithic class using the interface of FSIOper M_fsi->FSIOper()->setVectorInStencils (vel, pressure, solidDisp, iterInit ); } // This was in readLastVectorSolidStencil M_fsi->FSIOper()->setSolidVectorInStencil ( solidDisp, iterInit ); // Ale part for (iterInit = 0; iterInit < M_fsi->FSIOper()->ALETimeAdvance()->size(); iterInit++ ) { //Setting the vector in the stencil M_fsi->FSIOper()->setALEVectorInStencil ( fluidDisp, iterInit, false ); } //Initializing the vector for the RHS terms of the formulas M_fsi->FSIOper()->finalizeRestart(); // This was read the last vector from ALE //This is ugly but it's the only way I have figured out at the moment if ( M_data->method().compare ("monolithicGI") == 0 ) { //Don't be scared by the ten. The goal of 10 is just to make the first if fail M_fsi->FSIOper()->setALEVectorInStencil ( fluidDisp, 10, true ); } //Setting the vector in the stencil M_fsi->FSIOper()->ALETimeAdvance()->shiftRight ( *fluidDisp ); }
// =================================================== // Methods // =================================================== void FSISolver::setData( const dataPtr_Type& data ) { M_data = data; int rank, numtasks; MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &numtasks); bool fluid = false; bool solid = false; int fluidLeader(0); int solidLeader(0); if ( ( data->method().compare("monolithicGE") && data->method().compare("monolithicGI") ) ) { MPI_Group originGroup, newGroup; MPI_Comm_group(MPI_COMM_WORLD, &originGroup); if ( numtasks == 1 ) { std::cout << "Serial Fluid/Structure computation" << std::endl; fluid = true; solid = true; solidLeader = 0; fluidLeader = solidLeader; M_epetraWorldComm.reset( new Epetra_MpiComm(MPI_COMM_WORLD)); M_epetraComm = M_epetraWorldComm; } else { std::vector<int> members(numtasks); solidLeader = 0; fluidLeader = 1-solidLeader; if (rank == solidLeader) { members[0] = solidLeader; /* int ierr = */ MPI_Group_incl(originGroup, 1, &members[0], &newGroup); solid = true; } else { for (Int ii = 0; ii <= numtasks; ++ii) { if ( ii < solidLeader) members[ii] = ii; else if ( ii > solidLeader) members[ii - 1] = ii; } /* int ierr = */ MPI_Group_incl(originGroup, numtasks - 1, &members[0], &newGroup); fluid = true; } MPI_Comm* localComm = new MPI_Comm; MPI_Comm_create(MPI_COMM_WORLD, newGroup, localComm); M_localComm.reset(localComm); M_epetraComm.reset(new Epetra_MpiComm(*M_localComm.get())); M_epetraWorldComm.reset(new Epetra_MpiComm(MPI_COMM_WORLD)); } } else // Monolithic or FullMonolithic { fluid = true; solid = true; solidLeader = 0; fluidLeader = solidLeader; M_epetraWorldComm.reset( new Epetra_MpiComm(MPI_COMM_WORLD)); M_epetraComm = M_epetraWorldComm; } #ifdef DEBUG if ( fluid ) { debugStream(6220) << M_epetraComm->MyPID() << " ( " << rank << " ) " << " out of " << M_epetraComm->NumProc() << " ( " << numtasks << " ) " << " is fluid." << std::endl; } if ( solid ) { debugStream(6220) << M_epetraComm->MyPID() << " ( " << rank << " ) " << " out of " << M_epetraComm->NumProc() << " ( " << numtasks << " ) " << " is solid." << std::endl; } #endif M_epetraWorldComm->Barrier(); /* if (solid) { std::cout << "fluid: Building the intercommunicators ... " << std::flush; MPI_Comm* interComm = new MPI_Comm; Int ierr = MPI_Intercomm_create(*M_localComm, 0, MPI_COMM_WORLD, 1, 1, interComm); std::cout << ierr << std::endl; M_interComm.reset(interComm); } if (fluid) { std::cout << "solid: Building the intercommunicators ... " << std::flush; MPI_Comm* interComm = new MPI_Comm; Int ierr = MPI_Intercomm_create(*M_localComm, 0, MPI_COMM_WORLD, 0, 1, interComm); std::cout << ierr << std::endl; M_interComm.reset(interComm); } std::cout << M_interComm.get() << std::endl; //M_oper->setInterComm(M_interComm.get()); std::cout << "done." << std::endl; MPI_Barrier(MPI_COMM_WORLD); */ this->setFSI( ); M_oper->setFluid( fluid ); M_oper->setSolid( solid ); M_oper->setFluidLeader( fluidLeader ); M_oper->setSolidLeader( solidLeader ); M_oper->setComm( M_epetraComm, M_epetraWorldComm ); // opening files for output on the leader only if (M_epetraWorldComm->MyPID() == 0) { M_out_iter.open("iter"); M_out_res .open("res"); } M_epetraWorldComm->Barrier(); #ifdef DEBUG debugStream( 6220 ) << "FSISolver constructor ends\n"; #endif //@ M_lambda.resize(M_oper->displacement().size()); //@ M_lambdaDot.resize(M_oper->velocity().size()); // M_lambda = ZeroVector( M_lambda.size() ); // M_lambdaDot = ZeroVector( M_lambdaDot.size() ); // debugStream( 6220 ) << "FSISolver::M_lambda: " << M_lambda.size() << "\n"; // debugStream( 6220 ) << "FSISolver::M_lambdaDot: " << M_lambdaDot.size() << "\n"; M_oper->setData( data ); }