37 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanTotalNormalStress.hpp> 51 #ifdef HAVE_LIFEV_DEBUG 52 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::MultiscaleCouplingMeanTotalNormalStress() \n";
65 #ifdef HAVE_LIFEV_DEBUG 66 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::setupCouplingVariablesNumber() \n";
69 M_couplingVariablesNumber = modelsNumber() + 1;
76 #ifdef HAVE_LIFEV_DEBUG 77 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::setupCoupling() \n";
80 if ( myModelsNumber() > 0 )
83 for ( UInt i ( 0 ); i < modelsNumber(); ++i )
86 M_localCouplingFunctions.push_back ( MultiscaleCouplingFunction (
this, i ) );
87 if (
static_cast<Int>(i) < M_flowRateInterfaces )
89 multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->imposeBoundaryFlowRate ( M_boundaryIDs[i], std::bind ( &MultiscaleCouplingFunction::function, M_localCouplingFunctions.back(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 ) );
93 multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->imposeBoundaryMeanNormalStress ( M_boundaryIDs[i], std::bind ( &MultiscaleCouplingFunction::function, M_localCouplingFunctions.back(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 ) );
103 #ifdef HAVE_LIFEV_DEBUG 104 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::initializeCouplingVariables() \n";
109 Real globalSum ( 0 );
111 for ( UInt i ( 0 ); i < modelsNumber(); ++i )
116 if (
static_cast<Int>(i) < M_flowRateInterfaces )
118 myValue = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryFlowRate ( M_boundaryIDs[i] );
122 myValue = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryMeanNormalStress ( M_boundaryIDs[i] );
125 if ( isModelLeaderProcess ( i ) )
132 M_comm->SumAll ( &localSum, &globalSum, 1 );
133 if ( myModelsNumber() > 0 )
135 localCouplingVariables ( 0 ) [i] = globalSum;
143 for ( UInt i ( 0 ); i < modelsNumber(); ++i )
146 Real myValue = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryMeanTotalNormalStress ( M_boundaryIDs[i] );
147 if ( isModelLeaderProcess ( i ) )
153 M_comm->SumAll ( &localSum, &globalSum, 1 );
154 if ( myModelsNumber() > 0 )
156 localCouplingVariables ( 0 ) [modelsNumber()] = globalSum / modelsNumber();
164 #ifdef HAVE_LIFEV_DEBUG 165 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::computeCouplingResiduals() \n";
169 *M_localCouplingResiduals = 0.;
171 if ( myModelsNumber() > 0 )
176 Real myValueTotalStress = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryMeanTotalNormalStress ( M_boundaryIDs[i] );
177 if ( isModelLeaderProcess ( i ) )
179 ( *M_localCouplingResiduals ) [0] += localCouplingVariables ( 0 ) [i];
180 ( *M_localCouplingResiduals ) [i + 1] = myValueTotalStress - localCouplingVariables ( 0 ) [modelsNumber()];
184 for ( UInt i ( M_flowRateInterfaces ); i < modelsNumber(); ++i )
187 Real myValueTotalStress = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryMeanTotalNormalStress ( M_boundaryIDs[i] );
188 Real myValueFlowRate = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryFlowRate ( M_boundaryIDs[i] );
189 if ( isModelLeaderProcess ( i ) )
191 ( *M_localCouplingResiduals ) [0] += myValueFlowRate;
192 ( *M_localCouplingResiduals ) [i + 1] = myValueTotalStress - localCouplingVariables ( 0 ) [modelsNumber()];
205 #ifdef HAVE_LIFEV_DEBUG 206 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::exportListOfPerturbedModels( localCouplingVariableID ) \n";
209 if ( localCouplingVariableID < modelsNumber() )
210 if ( myModel (localCouplingVariableID) )
212 perturbedModelsList.reserve ( 1 );
213 perturbedModelsList.push_back ( M_models[localCouplingVariableID] );
221 #ifdef HAVE_LIFEV_DEBUG 222 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::insertJacobianConstantCoefficients( jacobian ) \n";
227 if ( isModelLeaderProcess ( 0 ) )
228 for ( UInt i ( 0 ); i < modelsNumber(); ++i )
230 if (
static_cast<Int>(i) < M_flowRateInterfaces )
232 jacobian.addToCoefficient ( M_couplingVariablesOffset, M_couplingVariablesOffset + i, 1 );
234 jacobian.addToCoefficient ( M_couplingVariablesOffset + 1 + i, M_couplingVariablesOffset + modelsNumber(), -1 );
242 #ifdef HAVE_LIFEV_DEBUG 243 debugStream ( 8250 ) <<
"MultiscaleCouplingMeanTotalNormalStress::insertJacobianDeltaCoefficients( jacobian, column, ID, solveLinearSystem ) \n";
247 UInt modelLocalID = modelGlobalToLocalID ( ID );
248 if ( myModel ( modelLocalID ) )
251 Real coefficient ( 0 );
255 coefficient = multiscaleDynamicCast< MultiscaleInterface > ( M_models[modelLocalID] )->boundaryDeltaMeanTotalNormalStress ( M_boundaryIDs[modelLocalID], solveLinearSystem );
258 if ( isModelLeaderProcess ( modelLocalID ) )
260 jacobian.addToCoefficient ( row, column, coefficient );
262 #ifdef HAVE_LIFEV_DEBUG 263 debugStream ( 8250 ) <<
"J(" << row <<
"," << column <<
") = " << coefficient <<
"\n";
271 coefficient = multiscaleDynamicCast< MultiscaleInterface > ( M_models[modelLocalID] )->boundaryDeltaFlowRate ( M_boundaryIDs[modelLocalID], solveLinearSystem );
274 if ( isModelLeaderProcess ( modelLocalID ) )
276 jacobian.addToCoefficient ( row, column, coefficient );
278 #ifdef HAVE_LIFEV_DEBUG 279 debugStream ( 8250 ) <<
"J(" << row <<
"," << column <<
") = " << coefficient <<
"\n";
virtual void computeCouplingResiduals()
Compute the local coupling residuals vector.
virtual void exportListOfPerturbedModels(const UInt &localCouplingVariableID, multiscaleModelsContainer_Type &perturbedModelsList)
Build the list of models affected by the perturbation of a local coupling variable.
UInt M_couplingVariablesOffset
MultiscaleCoupling multiscaleCoupling_Type
int32_type Int
Generic integer data.
MultiscaleCoupling()
Constructor.
virtual void setupCouplingVariablesNumber()
Setup the coupling variables number.
void updateInverseJacobian(const UInt &iQuadPt)
MultiscaleCouplingMeanTotalNormalStress - Stress coupling condition.
virtual void setupCoupling()
Setup the coupling.
virtual void initializeCouplingVariables()
Initialize the values of the coupling variables.
virtual void insertJacobianDeltaCoefficients(multiscaleMatrix_Type &jacobian, const UInt &column, const UInt &ID, bool &solveLinearSystem)
Insert the Jacobian coefficient(s) depending on a perturbation of the model, due to a specific variab...
MatrixEpetra< Real > multiscaleMatrix_Type
std::vector< multiscaleModelPtr_Type > multiscaleModelsContainer_Type
MultiscaleCouplingMeanTotalNormalStress()
Constructor.
double Real
Generic real data.
virtual void insertJacobianConstantCoefficients(multiscaleMatrix_Type &jacobian)
Insert constant coefficients into the Jacobian matrix.
uint32_type UInt
generic unsigned integer (used mainly for addressing)