// Constructor - creates the Epetra objects (maps and vectors) ConvDiff_PDE::ConvDiff_PDE( Epetra_Comm& Comm_ , double peclet_ , double radiation_ , double kappa_ , double bcWeight_ , double xmin_ , double xmax_ , double Tleft_ , double Tright_ , int NumGlobalUnknowns_ , std::string name_ ) : GenericEpetraProblem(Comm_, NumGlobalUnknowns_, name_), xmin ( xmin_ ) , xmax ( xmax_ ) , Tleft ( Tleft_ ) , Tright ( Tright_ ) , peclet ( peclet_ ) , radiation ( radiation_ ) , kappa ( kappa_ ) , bcWeight ( bcWeight_ ) , expandJacobian ( true ) , depProbPtr ( NULL ) { // Create mesh and solution vectors // We first initialize the mesh and then the solution since the latter can depend on the mesh. xptr = Teuchos::rcp( new Epetra_Vector(*StandardMap) ); dx = (xmax - xmin) / ( (double) NumGlobalNodes - 1 ); for( int i = 0; i < NumMyNodes; ++i ) (*xptr)[i]=xmin + dx*((double) StandardMap->MinMyGID()+i); // Create extra vector needed for transient problem interface oldSolution = Teuchos::rcp( new Epetra_Vector(*StandardMap) ); // Create and initialize (using default provided) the solution vector initialSolution = Teuchos::rcp(new Epetra_Vector(*StandardMap)); initializeSolution(); // Allocate the memory for a matrix dynamically (i.e. the graph is dynamic). AA = Teuchos::rcp( new Epetra_CrsGraph(Copy, *StandardMap, 0) ); generateGraph(); #ifdef DEBUG AA->Print(cout); #endif // Create a matrix using the graph just created - this creates a // static graph so we can refill the new matirx after FillComplete() // is called. A = Teuchos::rcp(new Epetra_CrsMatrix (Copy, *AA)); A->FillComplete(); // Create the Importer needed for FD coloring ColumnToOverlapImporter = Teuchos::rcp( new Epetra_Import(A->ColMap(),*OverlapMap) ); }
// Constructor - creates the Epetra objects (maps and vectors) HMX_PDE::HMX_PDE(Epetra_Comm& comm, double diffCoef_, double Const_R_, double Steric_C_, double PreExp_A_, double ActEnergy_, map<string, double> SrcTermExponent_, map<string, double> SrcTermWeight_, int numGlobalNodes, std::string name_) : GenericEpetraProblem(comm, numGlobalNodes, name_), xmin(0.0), xmax(1.0), dt(2.0e-1), diffCoef(diffCoef_), Const_R(Const_R_), StericCoef(Steric_C_), PreExp_A(PreExp_A_), ActEnergy(ActEnergy_), SrcTermExponent(SrcTermExponent_), SrcTermWeight(SrcTermWeight_) { // Create mesh and solution vectors // We first initialize the mesh and then the solution since the latter // can depend on the mesh. xptr = Teuchos::rcp( new Epetra_Vector(*StandardMap) ); double Length= xmax - xmin; dx=Length/((double) NumGlobalNodes-1); for (int i=0; i < NumMyNodes; i++) { (*xptr)[i]=xmin + dx*((double) StandardMap->MinMyGID()+i); } // Create extra vector needed for this transient problem oldSolution = new Epetra_Vector(*StandardMap); // Next we create and initialize (using default provided) the solution vector initialSolution = Teuchos::rcp(new Epetra_Vector(*StandardMap)); initializeSolution(); // Allocate the memory for a matrix dynamically (i.e. the graph is dynamic). AA = Teuchos::rcp( new Epetra_CrsGraph(Copy, *StandardMap, 0) ); generateGraph(); #ifdef DEBUG AA->Print(cout); #endif // Create a matrix using the graph just created - this creates a // static graph so we can refill the new matirx after FillComplete() // is called. A = Teuchos::rcp(new Epetra_CrsMatrix (Copy, *AA)); A->FillComplete(); // Create the Importer needed for FD coloring ColumnToOverlapImporter = new Epetra_Import(A->ColMap(),*OverlapMap); }
void MultiscaleModelFSI1D::setupModel() { #ifdef HAVE_LIFEV_DEBUG debugStream ( 8130 ) << "MultiscaleModelFSI1D::setupModel() \n"; #endif //FEspace setupFESpace(); //Setup solution M_solver->setupSolution ( *M_solution ); M_solver->setupSolution ( *M_solution_tn ); //Set default BC (has to be called after setting other BC) M_bc->handler()->setDefaultBC(); M_bc->setPhysicalSolver ( M_solver ); M_bc->setSolution ( M_solution ); M_bc->setFluxSource ( M_flux, M_source ); //Post-processing #ifdef HAVE_HDF5 M_exporter->setMeshProcId ( M_exporterMesh, M_comm->MyPID() ); DOF tmpDof ( *M_exporterMesh, M_feSpace->refFE() ); std::vector<Int> myGlobalElements ( tmpDof.globalElements ( *M_exporterMesh ) ); MapEpetra map ( -1, myGlobalElements.size(), &myGlobalElements[0], M_comm ); M_solver->setupSolution ( *M_exporterSolution, map, true ); M_exporter->addVariable ( IOData_Type::ScalarField, "Area ratio (fluid)", M_feSpace, (*M_exporterSolution) ["AoverA0minus1"], static_cast <UInt> ( 0 ) ); M_exporter->addVariable ( IOData_Type::ScalarField, "Flow rate (fluid)", M_feSpace, (*M_exporterSolution) ["Q"], static_cast <UInt> ( 0 ) ); //M_exporter->addVariable( IOData_Type::ScalarField, "W1", M_feSpace, (*M_exporterSolution)["W1"], static_cast <UInt> ( 0 ), M_feSpace->dof().numTotalDof() ); //M_exporter->addVariable( IOData_Type::ScalarField, "W2", M_feSpace, (*M_exporterSolution)["W2"], static_cast <UInt> ( 0 ), M_feSpace->dof().numTotalDof() ); M_exporter->addVariable ( IOData_Type::ScalarField, "Pressure (fluid)", M_feSpace, (*M_exporterSolution) ["P"], static_cast <UInt> ( 0 ) ); #endif #ifdef HAVE_MATLAB_POSTPROCESSING M_solver->resetOutput ( *M_exporterSolution ); #endif //Setup solution initializeSolution(); #ifdef JACOBIAN_WITH_FINITEDIFFERENCE if ( M_couplings.size() > 0 ) { createLinearBC(); updateLinearBC ( *M_solution ); setupLinearModel(); // Initialize the linear solution copySolution ( *M_solution, *M_linearSolution ); } #endif }
// =================================================== // Methods // =================================================== void ZeroDimensionalData::setup( const GetPot& dataFile, bcPtr_Type bc, const std::string & section ) { if ( !M_time.get() ) M_time.reset( new time_Type( dataFile, section + "/time_discretization" ) ); std::string circuirDataFile = dataFile( ( section + "/CircuitDataFile" ).data(), "./inputFilexx.dat" ); GetPot dataFileCircuit( circuirDataFile ); std::string circuitFile = dataFileCircuit( "Files/InputFiles/CircuitFile", "./circuitFilexx.dat" ); std::string folder = dataFileCircuit( "Files/OutputFiles/Folder", "outputxx" );//TODO create folder output std::string voltageFile = folder + "/" + dataFileCircuit( "Files/OutputFiles/VoltageFile", "voltagexx.txt" ); std::string currentFile = folder + "/" + dataFileCircuit( "Files/OutputFiles/CurrentFile", "currentxx.txt" ); std::string balanceFile = folder + "/" + dataFileCircuit( "Files/OutputFiles/BalanceCurrentinNode", "balancexx.txt" ); M_voltageFileStream.open( voltageFile.c_str() ); M_currentFileStream.open( currentFile.c_str() ); M_balanceFileStream.open( balanceFile.c_str() ); //Build the Circuit M_circuitData->buildCircuit( circuitFile.c_str(), bc ); //assign varible index assignVaribleIndex(); M_solverData.method = dataFile( ( section + "/Solver/method" ).data(), "IRK" ); M_solverData.numberTimeStep = dataFile( ( section + "/Solver/numberTimeStep" ).data(), 1 ); M_solverData.maxError = dataFile( ( section + "/Solver/maxError" ).data(), 1.0 ); M_solverData.reltol = dataFile( ( section + "/Solver/reltol" ).data(), 0.1 ); M_solverData.abstol = dataFile( ( section + "/Solver/abstol" ).data(), 1.0 ); M_solverData.maxOrder = dataFile( ( section + "/Solver/maxOrder" ).data(), 1 ); M_solverData.verbose = dataFile( ( section + "/Solver/verbose" ).data(), false ); M_solverData.verboseLevel = dataFile( ( section + "/Solver/verboseLevel" ).data(), 0 ); M_solverData.useNOX = dataFile( ( section + "/Solver/useNOX" ).data(), false ); M_solverData.fixTimeStep = dataFile( ( section + "/Solver/fixTimeStep" ).data(), true ); M_solverData.extraLSParamsFile = dataFile( ( section + "/Solver/extraLinearSolverParamsFile" ).data(), "./Extra_AztecOO_Params.xml" ); M_solverData.linearSolverParamsFile = dataFile( ( section + "/Solver/linearSolverParamsUsedFile" ).data(), "./lowsf.aztecoo.used.xml" ); //Set zero initial condition // TODO: change to general initial condition initializeSolution(); //Wrire Header OutputFiles writeHeaders(); }