37 #include <lifev/multiscale/algorithms/MultiscaleAlgorithm.hpp> 60 #ifdef HAVE_LIFEV_DEBUG 61 debugStream ( 8010 ) <<
"MultiscaleAlgorithm::MultiscaleAlgorithm() \n";
73 #ifdef HAVE_LIFEV_DEBUG 74 debugStream ( 8010 ) <<
"MultiscaleAlgorithm::setMultiscaleProblem( multiscale ) \n";
78 std::vector<Int> myGlobalElements (0);
79 MapEpetra couplingMap ( -1,
static_cast<Int> ( myGlobalElements.size() ), &myGlobalElements[0], M_comm );
82 M_couplingVariables.reset (
new VectorEpetra ( couplingMap, Unique ) );
83 M_couplingResiduals.reset (
new VectorEpetra ( couplingMap, Unique ) );
90 #ifdef HAVE_LIFEV_DEBUG 91 debugStream ( 8010 ) <<
"MultiscaleAlgorithm::subIterate() \n";
95 if ( M_comm->MyPID() == 0 )
97 std::cout <<
" MS- " << enum2String ( M_type, multiscaleAlgorithmsMap ) <<
" Algorithm" << std::endl;
104 if ( M_comm->MyPID() == 0 )
106 std::cout <<
"Algorithm type = " << enum2String ( M_type, multiscaleAlgorithmsMap ) << std::endl
107 <<
"Algorithm name = " << M_name << std::endl
108 <<
"Max Sub-iterations = " << M_subiterationsMaximumNumber << std::endl
109 <<
"Tolerance = " << M_tolerance << std::endl << std::endl;
123 M_multiscale->exportCouplingResiduals ( *M_couplingResiduals );
126 return M_couplingResiduals->norm2();
135 M_name = parameterList.get<std::string> (
"Algorithm Name" );
141 M_subiterationsMaximumNumber = parameterList.get<UInt> (
"Subiterations Maximum Number" );
142 M_tolerance = parameterList.get<Real> (
"Tolerance" );
151 std::ofstream output;
152 output << std::scientific << std::setprecision ( 15 );
154 if ( M_comm->MyPID() == 0 )
156 std::string filename = multiscaleProblemFolder + multiscaleProblemPrefix +
"_Algorithm_" + number2string ( multiscaleProblemStep ) +
".mfile";
158 if ( M_multiscale->globalData()->dataTime()->isFirstTimeStep() )
160 output.open ( filename.c_str(), std::ios::trunc );
161 output <<
"% Algorithm Type: " << enum2String ( M_type, multiscaleAlgorithmsMap ) << std::endl;
162 output <<
"% Subiteration maximum number: " << M_subiterationsMaximumNumber << std::endl;
163 output <<
"% Tolerance: " << M_tolerance << std::endl << std::endl;
164 output <<
"% Time Subiterations Residual" << std::endl;
168 output.open ( filename.c_str(), std::ios::app );
171 output << M_multiscale->globalData()->dataTime()->time() <<
" " 172 << subiterationsNumber <<
" " << residual << std::endl;
185 if ( M_comm->MyPID() == 0 )
189 std::cout <<
" MS- Sub-iteration n.: " << subIT << std::endl;
191 std::cout <<
" MS- Residual: " << residual << std::endl;
196 save ( subIT, M_couplingResiduals->norm2() );
void save(const UInt &subiterationsNumber, const Real &residual) const
save on a Matlab file the information about the convergence of the algorithm.
void setAlgorithmName(const multiscaleParameterList_Type ¶meterList)
Set the algorithm name.
multiscaleVectorPtr_Type M_couplingVariables
virtual void showMe()
Display some information about the algorithm.
MultiscaleAlgorithm - The Multiscale Algorithm Interface.
MultiscaleAlgorithm()
Constructor.
multiscaleVectorPtr_Type M_couplingResiduals
virtual void setupAlgorithm()
Setup coupling variables and other quantities of the algorithm.
void updateInverseJacobian(const UInt &iQuadPt)
Epetra_Import const & importer()
Getter for the Epetra_Import.
virtual void setAlgorithmParameters(const multiscaleParameterList_Type ¶meterList)
Set the the main parameters of the algorithm (tolerance, maximum number of subiterations, etc.)
void createCouplingMap(MapEpetra &couplingMap)
Build the global map for the coupling vectors.
std::map< std::string, algorithms_Type > multiscaleAlgorithmsMap
LinearSolver::parameterList_Type multiscaleParameterList_Type
void computeCouplingResiduals()
Compute the values of the interface residuals.
double Real
Generic real data.
multiscaleModelMultiscalePtr_Type M_multiscale
bool checkResidual(const UInt &subIT=0) const
Update the residual and check if the tolerance has been satisfied.
Real computeResidual() const
virtual void subIterate()
Perform sub-iteration on the coupling variables.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
multiscaleCommPtr_Type M_comm
UInt M_subiterationsMaximumNumber