37 #include <lifev/multiscale/couplings/MultiscaleCouplingMeanNormalStress.hpp> 51 #ifdef HAVE_LIFEV_DEBUG 52 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::MultiscaleCouplingMeanNormalStress() \n";
65 #ifdef HAVE_LIFEV_DEBUG 66 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::setupCouplingVariablesNumber() \n";
76 #ifdef HAVE_LIFEV_DEBUG 77 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::setupCoupling() \n";
80 if ( myModelsNumber() > 0 )
86 M_localCouplingFunctions.push_back ( MultiscaleCouplingFunction (
this, i ) );
87 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 ) );
91 for ( UInt i ( M_flowRateInterfaces ); i < modelsNumber(); ++i )
94 M_localCouplingFunctions.push_back ( MultiscaleCouplingFunction (
this, M_flowRateInterfaces ) );
95 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 ) );
104 #ifdef HAVE_LIFEV_DEBUG 105 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::initializeCouplingVariables() \n";
110 Real globalSum ( 0 );
116 Real myValue = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryFlowRate ( M_boundaryIDs[i] );
117 if ( isModelLeaderProcess ( i ) )
124 M_comm->SumAll ( &localSum, &globalSum, 1 );
125 if ( myModelsNumber() > 0 )
127 localCouplingVariables ( 0 ) [i] = globalSum;
135 for ( UInt i ( 0 ); i < modelsNumber(); ++i )
138 Real myValue = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryMeanNormalStress ( M_boundaryIDs[i] );
139 if ( isModelLeaderProcess ( i ) )
145 M_comm->SumAll ( &localSum, &globalSum, 1 );
146 if ( myModelsNumber() > 0 )
148 localCouplingVariables ( 0 ) [M_flowRateInterfaces] = globalSum / modelsNumber();
156 #ifdef HAVE_LIFEV_DEBUG 157 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::computeCouplingResiduals() \n";
161 *M_localCouplingResiduals = 0.;
163 if ( myModelsNumber() > 0 )
168 Real myValueStress = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryMeanNormalStress ( M_boundaryIDs[i] );
169 if ( isModelLeaderProcess ( i ) )
171 ( *M_localCouplingResiduals ) [0] += localCouplingVariables ( 0 ) [i];
172 ( *M_localCouplingResiduals ) [i + 1] = myValueStress - localCouplingVariables ( 0 ) [M_flowRateInterfaces];
176 for ( UInt i ( M_flowRateInterfaces ); i < modelsNumber(); ++i )
179 Real myValueFlowRate = multiscaleDynamicCast< MultiscaleInterface > ( M_models[i] )->boundaryFlowRate ( M_boundaryIDs[i] );
180 if ( isModelLeaderProcess ( i ) )
182 ( *M_localCouplingResiduals ) [0] += myValueFlowRate;
195 #ifdef HAVE_LIFEV_DEBUG 196 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::exportListOfPerturbedModels( localCouplingVariableID ) \n";
201 if ( myModel (localCouplingVariableID) )
203 perturbedModelsList.reserve ( 1 );
204 perturbedModelsList.push_back ( M_models[localCouplingVariableID] );
209 perturbedModelsList.reserve ( modelsNumber() - M_flowRateInterfaces );
210 for ( UInt i ( M_flowRateInterfaces ); i < modelsNumber(); ++i )
213 perturbedModelsList.push_back ( M_models[i] );
222 #ifdef HAVE_LIFEV_DEBUG 223 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::insertJacobianConstantCoefficients( jacobian ) \n";
228 if ( isModelLeaderProcess ( 0 ) )
231 jacobian.addToCoefficient ( M_couplingVariablesOffset, M_couplingVariablesOffset + i, 1 );
232 jacobian.addToCoefficient ( M_couplingVariablesOffset + 1 + i, M_couplingVariablesOffset + M_flowRateInterfaces, -1 );
240 #ifdef HAVE_LIFEV_DEBUG 241 debugStream ( 8220 ) <<
"MultiscaleCouplingMeanNormalStress::insertJacobianDeltaCoefficients( jacobian, column, ID, solveLinearSystem ) \n";
245 UInt modelLocalID = modelGlobalToLocalID ( ID );
246 if ( myModel ( modelLocalID ) )
249 Real coefficient ( 0 );
254 coefficient = multiscaleDynamicCast< MultiscaleInterface > ( M_models[modelLocalID] )->boundaryDeltaFlowRate ( M_boundaryIDs[modelLocalID], solveLinearSystem );
259 coefficient = multiscaleDynamicCast< MultiscaleInterface > ( M_models[modelLocalID] )->boundaryDeltaMeanNormalStress ( M_boundaryIDs[modelLocalID], solveLinearSystem );
263 if ( isModelLeaderProcess ( modelLocalID ) )
265 jacobian.addToCoefficient ( row, column, coefficient );
267 #ifdef HAVE_LIFEV_DEBUG 268 debugStream ( 8220 ) <<
"J(" << row <<
"," << column <<
") = " << coefficient <<
"\n";
virtual void setupCouplingVariablesNumber()
Setup the coupling variables number.
MultiscaleCouplingMeanNormalStress()
Constructor.
UInt M_couplingVariablesOffset
MultiscaleCoupling multiscaleCoupling_Type
int32_type Int
Generic integer data.
MultiscaleCoupling()
Constructor.
void updateInverseJacobian(const UInt &iQuadPt)
virtual void setupCoupling()
Setup the coupling.
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...
UInt M_couplingVariablesNumber
MatrixEpetra< Real > multiscaleMatrix_Type
virtual void exportListOfPerturbedModels(const UInt &localCouplingVariableID, multiscaleModelsContainer_Type &perturbedModelsList)
Build the list of models affected by the perturbation of a local coupling variable.
std::vector< multiscaleModelPtr_Type > multiscaleModelsContainer_Type
double Real
Generic real data.
virtual void computeCouplingResiduals()
Compute the local coupling residuals vector.
MultiscaleCouplingMeanNormalStress - Stress coupling condition.
virtual void initializeCouplingVariables()
Initialize the values of the coupling variables.
virtual void insertJacobianConstantCoefficients(multiscaleMatrix_Type &jacobian)
Insert constant coefficients into the Jacobian matrix.
uint32_type UInt
generic unsigned integer (used mainly for addressing)