ElmerFoamFSI  2.0
ElmerFoamFSI is fluid-solid interaction simulation application built up from OpenFOAM CFD and Elmer CSM coupled through the IMPACT multiphysics software integration infrastructure.
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Groups Pages
fsiFOAMPar.H
Go to the documentation of this file.
1 
2 // includes for IMPACT
3 #include "com.h"
4 #include "com_devel.hpp"
5 #include "SolverAgent.H"
6 #include "InterfaceLayer.H"
7 
8 #include "fvCFD.H"
9 #include "dynamicFvMesh.H"
10 
11 #include "constitutiveModel.H"
12 #include "solidTractionFvPatchVectorField.H"
13 #include "volPointInterpolation.H"
14 #include "pointPatchInterpolation.H"
15 
16 #include "patchToPatchInterpolation.H"
17 #include "movingWallVelocityFvPatchVectorField.H"
18 
19 #include "tetFemMatrices.H"
20 #include "tetPointFields.H"
21 #include "faceTetPolyPatch.H"
22 #include "tetPolyPatchInterpolation.H"
23 #include "fixedValueTetPolyPatchFields.H"
24 #include "fixedValuePointPatchFields.H"
25 
26 #include "OFstream.H"
27 #include "EulerDdtScheme.H"
28 #include "backwardDdtScheme.H"
29 
30 #include "pointFields.H"
31 #include "fixedGradientFvPatchFields.H"
32 #include "primitivePatchInterpolation.H"
33 #include "twoDPointCorrector.H"
34 #include "scalarIOField.H"
35 #include "leastSquaresVolPointInterpolation.H"
36 #include "symmetryPolyPatch.H"
37 
38 class fsifoam_module : public COM_Object , public SolverUtils::FEM::SolverAgent
39 {
40 private:
41  std::string my_window_name;
42  MPI_Comm my_window_comm;
43 
44 protected:
45  // Communicator data
46  int rank;
47  int nproc;
48 
49  // ====== Data to register with IMPACT =======
50  // Surface Mesh
51  int numPointsSurface;
53  std::vector<double> surfaceCoordinates;
54  std::vector<unsigned int> surfaceConnectivity;
55  std::map<int, int> surfaceNodeMap;
56  std::map<int, int> interfaceToFoamNodeMap;
57  std::map<int, int> foamGlobalToPatchNodeMap;
58  std::vector<double> surfacePressure;
59  std::vector<double> surfaceTraction;
60  std::vector<double> surfaceDisplacement;
61  std::vector<double> solidDisplacement;
62  std::vector<double> time;
63  std::vector<double> deltaTime;
64  int verbosity;
65 
66  // function status variables
67  std::vector<int> initStatus;
68  std::vector<int> runStatus;
69 
70  // timing variables
71  std::vector<double> endTime;
72 
73  // ====== OpenFOAM stuff ========
74  //
75  // General, init stuff
76  Foam::argList *argsPtr;
77  Foam::Time *runTimePtr;
78  //
79  // Fluid data
80  autoPtr<dynamicFvMesh> meshPtr;
81  IOdictionary *transportPropertiesPtr;
82  dimensionedScalar *nuPtr;
83  dimensionedScalar *rhoFluidPtr;
84  volScalarField *pPtr;
85  volVectorField *UPtr;
86  surfaceScalarField *phiPtr;
87  label pRefCell;
88  scalar pRefValue;
89  //
90  // Structures data
91  fvMesh *stressMeshPtr;
92  volVectorField *DUPtr;
93  volTensorField *gradDUPtr;
94  volVectorField *UsolidPtr;
95  volVectorField *DVPtr;
96  volVectorField *VsPtr;
97  volSymmTensorField *sigmaPtr;
98  volSymmTensorField *DSigmaPtr;
99  constitutiveModel *rheologyPtr;
100  volScalarField *rhoPtr;
101  volScalarField *muPtr;
102  volScalarField *lambdaPtr;
103  volTensorField *FPtr;
104  volTensorField *DFPtr;
105  volScalarField *JPtr;
106  word *solidDdtSchemePtr;
107  pointMesh *pStressMeshPtr;
108  pointVectorField *pointDUPtr;
109  // label pRefCell;
110  // scalar pRefValue;
111 
112  //
113  // Coupling data
114  IOdictionary *couplingPropertiesPtr;
115  word solidPatchName;
116  label solidPatchID;
117  word solidZoneName;
118  label solidZoneID;
119  word fluidPatchName;
120  label fluidPatchID;
121  word fluidZoneName;
122  label fluidZoneID;
123  bool feMotionSolver;
124  bool fvMotionSolver;
127  // solidTractionFvPatchVectorField *tForcePtr;
128  zoneToZoneInterpolation *interpolatorFluidSolidPtr;
129  zoneToZoneInterpolation *interpolatorSolidFluidPtr;
130  pointPatchInterpolation *patchPointInterpolatorPtr;
131 
132 
133 
134  //
135  // Stepper junk
136  scalar sumLocalContErr;
137  scalar globalContErr;
138  scalar cumulativeContErr;
139  labelList globalFaceZones;
140  labelListList globalToLocalFaceZonePointMap;
141 
142  //
143  // Junk?
144  int nCorr;
145  int nNonOrthCorr;
146  bool momentumPredictor;
147  bool transonic;
148  int nOuterCorr;
149  // label outerCorr;
150  scalar CoNum;
151  scalar meanCoNum;
152  scalar velMag;
153  word couplingScheme;
155  IOdictionary *dynamicMeshDictPtr;
156  scalar fsiRelaxationFactor;
157  scalar fsiRelaxationFactorMin;
158  scalar outerCorrTolerance;
159  Switch fsi;
160 
161 public:
162 
164  nuPtr(NULL), rhoFluidPtr(NULL), pPtr(NULL), UPtr(NULL), phiPtr(NULL),
165  stressMeshPtr(NULL), DUPtr(NULL), gradDUPtr(NULL), UsolidPtr(NULL), DVPtr(NULL),
166  VsPtr(NULL), sigmaPtr(NULL), DSigmaPtr(NULL), rheologyPtr(NULL),
167  rhoPtr(NULL), muPtr(NULL), lambdaPtr(NULL), FPtr(NULL), DFPtr(NULL),
168  JPtr(NULL), solidDdtSchemePtr(NULL), pStressMeshPtr(NULL),pointDUPtr(NULL),
169  couplingPropertiesPtr(NULL),
175  {};
176 
177  fsifoam_module(int argc,char *argv[]) : argsPtr(NULL), runTimePtr(NULL),
179  nuPtr(NULL), rhoFluidPtr(NULL), pPtr(NULL),
180  UPtr(NULL), phiPtr(NULL), stressMeshPtr(NULL),
181  DUPtr(NULL), gradDUPtr(NULL), UsolidPtr(NULL),
182  DVPtr(NULL), VsPtr(NULL), sigmaPtr(NULL),
183  DSigmaPtr(NULL), rheologyPtr(NULL), rhoPtr(NULL),
184  muPtr(NULL), lambdaPtr(NULL), FPtr(NULL), DFPtr(NULL),
185  JPtr(NULL), solidDdtSchemePtr(NULL),
186  pStressMeshPtr(NULL),pointDUPtr(NULL),
187  couplingPropertiesPtr(NULL),
194  {Initialize(argc,argv);};
195 
196  int Initialize(int argc,char *argv[]);
197  int InitFluidMesh();
199  int CreateFluidFields();
200  int InitStructuresMesh();
204  int FindGlobalFaceZones();
205  int ReadPISOControls();
206  int ReadFSIControls();
207  int Step();
208  int StepFluidAlone();
209  int StepFluidNonItr();
210  int StepFluidItr();
211  int Dump();
212  int Rank(){ return(rank);} ;
213  int Size(){ return(nproc);} ;
214 
215 
217  void InitFoam(int *pargc, void **pargv, int *verbIn);
218  void RunFoam();
219  void StepFoam();
220  void StepFluid();
221  //void ModifyEndTime(const double &endTime);
222  static void Load(const std::string &name);
223  static void Unload(const std::string &name);
224 
225 
226  Foam::Time &RunTime(){return(*runTimePtr);};
227  Foam::argList &ArgList(){return(*argsPtr);};
228  //dynamicFvMesh &Mesh(){return(meshPtr());};
229  dynamicFvMesh &FluidMesh(){return(meshPtr());};
230  IOdictionary &TransportProperties(){return(*transportPropertiesPtr);};
231  dimensionedScalar &nu(){return(*nuPtr);};
232  dimensionedScalar &rhoFluid(){return(*rhoFluidPtr);};
233  volScalarField &p(){return(*pPtr);};
234  volVectorField &U(){return(*UPtr);};
235  surfaceScalarField &phi(){return(*phiPtr);};
236  fvMesh &StructuresMesh(){return(*stressMeshPtr);};
237  volVectorField &DU(){return(*DUPtr);};
238  volTensorField &gradDU(){return(*gradDUPtr);};
239  volVectorField &Usolid(){return(*UsolidPtr);};
240  volVectorField &DV(){return(*DVPtr);};
241  volVectorField &Vs(){return(*VsPtr);};
242  volSymmTensorField &sigma(){return(*sigmaPtr);};
243  volSymmTensorField &DSigma(){return(*DSigmaPtr);};
244  constitutiveModel &Rheology(){return(*rheologyPtr);};
245  volScalarField &rhoSolid(){return(*rhoPtr);};
246  volScalarField &mu(){return(*muPtr);};
247  volScalarField &lambda(){return(*lambdaPtr);};
248  volTensorField &F(){return(*FPtr);};
249  volTensorField &DF(){return(*DFPtr);};
250  volScalarField &J(){return(*JPtr);};
251  word &SolidDdtScheme(){return(*solidDdtSchemePtr);};
252  pointMesh &pStressMesh(){return(*pStressMeshPtr);};
253  pointVectorField &PointDU(){return(*pointDUPtr);};
254  IOdictionary &CouplingProperties(){return(*couplingPropertiesPtr);};
255  label SolidPatchID(){return(solidPatchID);};
256  word SolidPatchName(){return(solidPatchName);};
257  label FluidPatchID(){return(fluidPatchID);};
258  word FluidPatchName(){return(fluidPatchName);};
259  word FluidZoneName(){return(fluidZoneName);};
260  word SolidZoneName(){return(solidZoneName);};
261  label FluidZoneID(){return(fluidZoneID);};
262  label SolidZoneID(){return(solidZoneID);};
263  bool FEMotion(){return(feMotionSolver);};
264  bool FVMotion(){return(fvMotionSolver);};
267  zoneToZoneInterpolation &interpFluidSolid(){return(*interpolatorFluidSolidPtr);};
268  zoneToZoneInterpolation &interpSolidFluid(){return(*interpolatorSolidFluidPtr);};
269  solidTractionFvPatchVectorField &tForce(){
270  return(refCast<solidTractionFvPatchVectorField>(DUPtr->boundaryField()[solidPatchID]));};
271 
272  scalar &LocalContErr(){return(sumLocalContErr);};
273  scalar &GlobalContErr(){return(globalContErr);};
275  labelList &GlobalFaceZones(){return(globalFaceZones);};
277  word CouplingScheme(){return(couplingScheme);};
278  // label &OuterCorr(){return(outerCorr);};
281  Switch FSIEnabled(){return(fsi);};
282  int &NCorrPISO(){return(nCorr);};
283  int &NNonOrthCorr(){return(nNonOrthCorr);};
286  int &NOuterCorr(){return(nOuterCorr);};
287 
288  protected:
289  // ===== Functions specific to IMPACT FSI =====
298  void CreateFSISurfaceMesh();
299 
307  void UpdateFSISurfaceMesh();
308 
317  int UpdateFSISurface(Foam::vectorField &solidPatchPointsDispl);
318 
326  void UpdateFSISurfaceData();
327 
336  void UpdateTime();
337 };
label solidPatchID
Definition: fsiFOAM.H:110
volTensorField & F()
Definition: fsiFOAMPar.H:248
volScalarField * JPtr
Definition: fsiFOAM.H:99
dimensionedScalar * rhoFluidPtr
Definition: fsiFOAM.H:77
MPI_Comm my_window_comm
Tracks this window name.
Definition: fsiFOAMPar.H:42
label FluidZoneID()
Definition: fsiFOAMPar.H:261
void UpdateFSISurfaceData()
Update the data registered on the FSI surface.
Definition: fsiFOAM.C:3514
void StepFoam()
the OpenFOAM stepping
Definition: fsiFOAM.C:3297
volVectorField * VsPtr
Definition: fsiFOAM.H:90
std::vector< double > endTime
Definition: fsiFOAM.H:65
scalar & GlobalContErr()
Definition: fsiFOAMPar.H:273
int StepFluidItr()
Definition: fsiFOAM.C:2674
std::vector< double > surfaceDisplacement
Definition: fsiFOAM.H:54
volScalarField * muPtr
Definition: fsiFOAM.H:95
label solidZoneID
Definition: fsiFOAM.H:112
autoPtr< dynamicFvMesh > meshPtr
Definition: fsiFOAM.H:74
scalar & LocalContErr()
Definition: fsiFOAMPar.H:272
volTensorField * gradDUPtr
Definition: fsiFOAM.H:87
volVectorField * UPtr
Definition: fsiFOAM.H:79
std::vector< double > surfaceCoordinates
Definition: fsiFOAM.H:47
void InitFoam(int *pargc, void **pargv, int *verbIn)
function to register through IMPACT
Definition: fsiFOAM.C:3184
solidTractionFvPatchVectorField & tForce()
Definition: fsiFOAMPar.H:269
Foam::argList * argsPtr
Definition: fsiFOAM.H:70
zoneToZoneInterpolation * interpolatorSolidFluidPtr
Definition: fsiFOAM.H:123
word * solidDdtSchemePtr
Definition: fsiFOAM.H:100
int & NNonOrthCorr()
Definition: fsiFOAMPar.H:283
zoneToZoneInterpolation & interpFluidSolid()
Definition: fsiFOAMPar.H:267
Foam::argList & ArgList()
Definition: fsiFOAMPar.H:227
int InitFluidMesh()
Definition: fsiFOAM.C:52
int UpdateFSISurface(Foam::vectorField &solidPatchPointsDispl)
Update the nodal coordinates of the IMAPCT and OpenFoam FSI surfaces from the IMPACT displacement dat...
Definition: fsiFOAM.C:3489
volTensorField * DFPtr
Definition: fsiFOAM.H:98
scalar sumLocalContErr
Definition: fsiFOAM.H:130
word FluidZoneName()
Definition: fsiFOAMPar.H:259
IOdictionary & TransportProperties()
Definition: fsiFOAMPar.H:230
label fluidZoneID
Definition: fsiFOAM.H:116
void UpdateTime()
Update the time control data registered with OpenFOAM i.e.
Definition: fsiFOAM.C:3483
word solidZoneName
Definition: fsiFOAM.H:111
bool transonic
Definition: fsiFOAM.H:141
scalar outerCorrTolerance
Definition: fsiFOAM.H:152
word & SolidDdtScheme()
Definition: fsiFOAMPar.H:251
IOdictionary * couplingPropertiesPtr
Definition: fsiFOAM.H:108
scalar cumulativeContErr
Definition: fsiFOAM.H:132
std::map< int, int > interfaceToFoamNodeMap
Definition: fsiFOAM.H:50
static void Load(const std::string &name)
&quot;Loads&quot; IcoFoamModule
Definition: fsiFOAM.C:3137
int & NCorrPISO()
Definition: fsiFOAMPar.H:282
labelListList globalToLocalFaceZonePointMap
Definition: fsiFOAM.H:134
static void Unload(const std::string &name)
Unloads the IcoFoamModule.
Definition: fsiFOAM.C:3257
label SolidZoneID()
Definition: fsiFOAMPar.H:262
int ReadPISOControls()
Definition: fsiFOAM.C:629
zoneToZoneInterpolation & interpSolidFluid()
Definition: fsiFOAMPar.H:268
volSymmTensorField * sigmaPtr
Definition: fsiFOAM.H:91
vectorField & AccumulatedFluidInterfaceDisplacements()
Definition: fsiFOAMPar.H:265
volTensorField * FPtr
Definition: fsiFOAM.H:97
IOobject * accumulatedFluidInterfaceDisplacementHeaderPtr
Definition: fsiFOAM.H:119
void RunFoam()
the OpenFOAM main
Definition: fsiFOAM.C:3271
word SolidZoneName()
Definition: fsiFOAMPar.H:260
volScalarField & rhoSolid()
Definition: fsiFOAMPar.H:245
IOdictionary * dynamicMeshDictPtr
Definition: fsiFOAM.H:149
int numPointsSurface
Tracks this window name.
Definition: fsiFOAM.H:45
std::vector< unsigned int > surfaceConnectivity
Definition: fsiFOAM.H:48
Switch fsi
Definition: fsiFOAM.H:153
volVectorField & U()
Definition: fsiFOAMPar.H:234
volScalarField * rhoPtr
Definition: fsiFOAM.H:94
word fluidPatchName
Definition: fsiFOAM.H:113
volSymmTensorField * DSigmaPtr
Definition: fsiFOAM.H:92
scalar velMag
Definition: fsiFOAM.H:146
word FluidPatchName()
Definition: fsiFOAMPar.H:258
Switch FSIEnabled()
Definition: fsiFOAMPar.H:281
scalar meanCoNum
Definition: fsiFOAM.H:145
labelListList & GlobalToLocalFaceZonePointMap()
Definition: fsiFOAMPar.H:276
std::vector< int > initStatus
Definition: fsiFOAM.H:61
int numElementsSurface
Definition: fsiFOAM.H:46
IOdictionary * transportPropertiesPtr
Definition: fsiFOAM.H:75
constitutiveModel * rheologyPtr
Definition: fsiFOAM.H:93
int verbosity
Definition: fsiFOAM.H:58
scalar CoNum
Definition: fsiFOAM.H:144
scalar & FSIRelaxationFactorMin()
Definition: fsiFOAMPar.H:280
scalar & CumulativeContErr()
Definition: fsiFOAMPar.H:274
std::vector< double > surfacePressure
Definition: fsiFOAM.H:52
word SolidPatchName()
Definition: fsiFOAMPar.H:256
scalar & FSIRelaxationFactor()
Definition: fsiFOAMPar.H:279
label SolidPatchID()
Definition: fsiFOAMPar.H:255
int Initialize(int argc, char *argv[])
Definition: fsiFOAM.C:5
int rank
Tracks window&#39;s communicator.
Definition: fsiFOAMPar.H:46
volTensorField & DF()
Definition: fsiFOAMPar.H:249
volVectorField * DUPtr
Definition: fsiFOAM.H:86
std::string my_window_name
Definition: fsiFOAM.H:41
std::vector< double > solidDisplacement
Definition: fsiFOAM.H:55
volScalarField * lambdaPtr
Definition: fsiFOAM.H:96
volTensorField & gradDU()
Definition: fsiFOAMPar.H:238
volVectorField & Vs()
Definition: fsiFOAMPar.H:241
surfaceScalarField & phi()
Definition: fsiFOAMPar.H:235
bool fvMotionSolver
Definition: fsiFOAM.H:118
fsifoam_module(int argc, char *argv[])
Definition: fsiFOAMPar.H:177
volSymmTensorField & DSigma()
Definition: fsiFOAMPar.H:243
volScalarField & J()
Definition: fsiFOAMPar.H:250
std::vector< double > time
Definition: fsiFOAM.H:56
int ReadFSIControls()
Definition: fsiFOAM.C:642
pointPatchInterpolation * patchPointInterpolatorPtr
Definition: fsiFOAM.H:124
std::map< int, int > surfaceNodeMap
Definition: fsiFOAM.H:49
int nNonOrthCorr
Definition: fsiFOAM.H:139
bool FVMotion()
Definition: fsiFOAMPar.H:264
dynamicFvMesh & FluidMesh()
Definition: fsiFOAMPar.H:229
scalar & InterfaceDeformationLimit()
Definition: fsiFOAMPar.H:284
zoneToZoneInterpolation * interpolatorFluidSolidPtr
Definition: fsiFOAM.H:122
pointVectorField * pointDUPtr
Definition: fsiFOAM.H:102
word CouplingScheme()
Definition: fsiFOAMPar.H:277
pointMesh * pStressMeshPtr
Definition: fsiFOAM.H:101
void StepFluid()
the OpenFOAM stepping fluid alone
Definition: fsiFOAM.C:3344
void UpdateFSISurfaceMesh()
Update of the surface mesh data coordinates.
Definition: fsiFOAM.C:3470
int CreateInterZoneInterpolators()
Definition: fsiFOAM.C:350
label FluidPatchID()
Definition: fsiFOAMPar.H:257
std::vector< int > runStatus
Definition: fsiFOAM.H:62
word fluidZoneName
Definition: fsiFOAM.H:115
volVectorField * DVPtr
Definition: fsiFOAM.H:89
word solidPatchName
Definition: fsiFOAM.H:109
volVectorField & DU()
Definition: fsiFOAMPar.H:237
int StepFluidNonItr()
Definition: fsiFOAM.C:2310
bool FEMotion()
Definition: fsiFOAMPar.H:263
void CreateFSISurfaceMesh()
Initialization of the surface mesh data structures from the OpenFOAM mesh data structures.
Definition: fsiFOAM.C:3417
int InitTransportProperties()
Definition: fsiFOAM.C:68
volVectorField & DV()
Definition: fsiFOAMPar.H:240
labelList globalFaceZones
Definition: fsiFOAM.H:133
volVectorField * UsolidPtr
Definition: fsiFOAM.H:88
bool momentumPredictor
Definition: fsiFOAM.H:140
scalar globalContErr
Definition: fsiFOAM.H:131
volScalarField * pPtr
Definition: fsiFOAM.H:78
int ReadCouplingProperties()
Definition: fsiFOAM.C:204
int Step()
Definition: fsiFOAM.C:703
volVectorField & Usolid()
Definition: fsiFOAMPar.H:239
pointMesh & pStressMesh()
Definition: fsiFOAMPar.H:252
volScalarField & lambda()
Definition: fsiFOAMPar.H:247
int nOuterCorr
Definition: fsiFOAM.H:142
constitutiveModel & Rheology()
Definition: fsiFOAMPar.H:244
volScalarField & p()
Definition: fsiFOAMPar.H:233
Foam::Time & RunTime()
Definition: fsiFOAMPar.H:226
word couplingScheme
Definition: fsiFOAM.H:147
labelList & GlobalFaceZones()
Definition: fsiFOAMPar.H:275
Foam::Time * runTimePtr
Definition: fsiFOAM.H:71
int InitStructuresMesh()
Definition: fsiFOAM.C:127
bool feMotionSolver
Definition: fsiFOAM.H:117
scalar interfaceDeformationLimit
Definition: fsiFOAM.H:148
surfaceScalarField * phiPtr
Definition: fsiFOAM.H:80
volScalarField & mu()
Definition: fsiFOAMPar.H:246
dimensionedScalar & nu()
Definition: fsiFOAMPar.H:231
std::vector< double > deltaTime
Definition: fsiFOAM.H:57
int CreateFluidFields()
Definition: fsiFOAM.C:80
dimensionedScalar & rhoFluid()
Definition: fsiFOAMPar.H:232
vectorField * accumulatedFluidInterfaceDisplacementPtr
Definition: fsiFOAM.H:120
scalar pRefValue
Definition: fsiFOAM.H:82
int CreateStructuresFields()
Definition: fsiFOAM.C:133
std::map< int, int > foamGlobalToPatchNodeMap
Definition: fsiFOAM.H:51
dimensionedScalar * nuPtr
Definition: fsiFOAM.H:76
int & NOuterCorr()
Definition: fsiFOAMPar.H:286
label pRefCell
Definition: fsiFOAM.H:81
label fluidPatchID
Definition: fsiFOAM.H:114
int FindGlobalFaceZones()
Definition: fsiFOAM.C:514
pointVectorField & PointDU()
Definition: fsiFOAMPar.H:253
fvMesh * stressMeshPtr
Definition: fsiFOAM.H:85
scalar & OuterCorrTolerance()
Definition: fsiFOAMPar.H:285
fvMesh & StructuresMesh()
Definition: fsiFOAMPar.H:236
std::vector< double > surfaceTraction
Definition: fsiFOAM.H:53
volSymmTensorField & sigma()
Definition: fsiFOAMPar.H:242
scalar fsiRelaxationFactor
Definition: fsiFOAM.H:150
int StepFluidAlone()
Definition: fsiFOAM.C:1854
scalar fsiRelaxationFactorMin
Definition: fsiFOAM.H:151
IOdictionary & CouplingProperties()
Definition: fsiFOAMPar.H:254