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
fsiFOAM.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 protected:
43  // ====== Data to register with IMPACT =======
44  // Surface Mesh
47  std::vector<double> surfaceCoordinates;
48  std::vector<unsigned int> surfaceConnectivity;
49  std::map<int, int> surfaceNodeMap;
50  std::map<int, int> interfaceToFoamNodeMap;
51  std::map<int, int> foamGlobalToPatchNodeMap;
52  std::vector<double> surfacePressure;
53  std::vector<double> surfaceTraction;
54  std::vector<double> surfaceDisplacement;
55  std::vector<double> solidDisplacement;
56  std::vector<double> time;
57  std::vector<double> deltaTime;
58  int verbosity;
59 
60  // function status variables
61  std::vector<int> initStatus;
62  std::vector<int> runStatus;
63 
64  // timing variables
65  std::vector<double> endTime;
66 
67  // ====== OpenFOAM stuff ========
68  //
69  // General, init stuff
70  Foam::argList *argsPtr;
71  Foam::Time *runTimePtr;
72  //
73  // Fluid data
74  autoPtr<dynamicFvMesh> meshPtr;
75  IOdictionary *transportPropertiesPtr;
76  dimensionedScalar *nuPtr;
77  dimensionedScalar *rhoFluidPtr;
78  volScalarField *pPtr;
79  volVectorField *UPtr;
80  surfaceScalarField *phiPtr;
81  label pRefCell;
82  scalar pRefValue;
83  //
84  // Structures data
85  fvMesh *stressMeshPtr;
86  volVectorField *DUPtr;
87  volTensorField *gradDUPtr;
88  volVectorField *UsolidPtr;
89  volVectorField *DVPtr;
90  volVectorField *VsPtr;
91  volSymmTensorField *sigmaPtr;
92  volSymmTensorField *DSigmaPtr;
93  constitutiveModel *rheologyPtr;
94  volScalarField *rhoPtr;
95  volScalarField *muPtr;
96  volScalarField *lambdaPtr;
97  volTensorField *FPtr;
98  volTensorField *DFPtr;
99  volScalarField *JPtr;
101  pointMesh *pStressMeshPtr;
102  pointVectorField *pointDUPtr;
103  // label pRefCell;
104  // scalar pRefValue;
105 
106  //
107  // Coupling data
108  IOdictionary *couplingPropertiesPtr;
112  label solidZoneID;
116  label fluidZoneID;
121  // solidTractionFvPatchVectorField *tForcePtr;
122  zoneToZoneInterpolation *interpolatorFluidSolidPtr;
123  zoneToZoneInterpolation *interpolatorSolidFluidPtr;
124  pointPatchInterpolation *patchPointInterpolatorPtr;
125 
126 
127 
128  //
129  // Stepper junk
133  labelList globalFaceZones;
135 
136  //
137  // Junk?
138  int nCorr;
141  bool transonic;
143  // label outerCorr;
144  scalar CoNum;
145  scalar meanCoNum;
146  scalar velMag;
149  IOdictionary *dynamicMeshDictPtr;
153  Switch fsi;
154 
155 public:
156 
158  nuPtr(NULL), rhoFluidPtr(NULL), pPtr(NULL), UPtr(NULL), phiPtr(NULL),
159  stressMeshPtr(NULL), DUPtr(NULL), gradDUPtr(NULL), UsolidPtr(NULL), DVPtr(NULL),
160  VsPtr(NULL), sigmaPtr(NULL), DSigmaPtr(NULL), rheologyPtr(NULL),
161  rhoPtr(NULL), muPtr(NULL), lambdaPtr(NULL), FPtr(NULL), DFPtr(NULL),
162  JPtr(NULL), solidDdtSchemePtr(NULL), pStressMeshPtr(NULL),pointDUPtr(NULL),
163  couplingPropertiesPtr(NULL),
168  dynamicMeshDictPtr(NULL)//,
169  {};
170 
171  fsifoam_module(int argc,char *argv[]) : argsPtr(NULL), runTimePtr(NULL),
173  nuPtr(NULL), rhoFluidPtr(NULL), pPtr(NULL),
174  UPtr(NULL), phiPtr(NULL), stressMeshPtr(NULL),
175  DUPtr(NULL), gradDUPtr(NULL), UsolidPtr(NULL),
176  DVPtr(NULL), VsPtr(NULL), sigmaPtr(NULL),
177  DSigmaPtr(NULL), rheologyPtr(NULL), rhoPtr(NULL),
178  muPtr(NULL), lambdaPtr(NULL), FPtr(NULL), DFPtr(NULL),
179  JPtr(NULL), solidDdtSchemePtr(NULL),
180  pStressMeshPtr(NULL),pointDUPtr(NULL),
181  couplingPropertiesPtr(NULL),
186  dynamicMeshDictPtr(NULL)//,
187  {Initialize(argc,argv);};
188 
189  int Initialize(int argc,char *argv[]);
190  int InitFluidMesh();
192  int CreateFluidFields();
193  int InitStructuresMesh();
197  int FindGlobalFaceZones();
198  int ReadPISOControls();
199  int ReadFSIControls();
200  int Step();
201  int StepFluidAlone();
202  int StepFluidNonItr();
203  int StepFluidItr();
204  int Dump();
205 
206 
208  void InitFoam(int *pargc, void **pargv, int *verbIn);
209  void RunFoam();
210  void StepFoam();
211  void StepFluid();
212  //void ModifyEndTime(const double &endTime);
213  static void Load(const std::string &name);
214  static void Unload(const std::string &name);
215 
216 
217  Foam::Time &RunTime(){return(*runTimePtr);};
218  Foam::argList &ArgList(){return(*argsPtr);};
219  //dynamicFvMesh &Mesh(){return(meshPtr());};
220  dynamicFvMesh &FluidMesh(){return(meshPtr());};
221  IOdictionary &TransportProperties(){return(*transportPropertiesPtr);};
222  dimensionedScalar &nu(){return(*nuPtr);};
223  dimensionedScalar &rhoFluid(){return(*rhoFluidPtr);};
224  volScalarField &p(){return(*pPtr);};
225  volVectorField &U(){return(*UPtr);};
226  surfaceScalarField &phi(){return(*phiPtr);};
227  fvMesh &StructuresMesh(){return(*stressMeshPtr);};
228  volVectorField &DU(){return(*DUPtr);};
229  volTensorField &gradDU(){return(*gradDUPtr);};
230  volVectorField &Usolid(){return(*UsolidPtr);};
231  volVectorField &DV(){return(*DVPtr);};
232  volVectorField &Vs(){return(*VsPtr);};
233  volSymmTensorField &sigma(){return(*sigmaPtr);};
234  volSymmTensorField &DSigma(){return(*DSigmaPtr);};
235  constitutiveModel &Rheology(){return(*rheologyPtr);};
236  volScalarField &rhoSolid(){return(*rhoPtr);};
237  volScalarField &mu(){return(*muPtr);};
238  volScalarField &lambda(){return(*lambdaPtr);};
239  volTensorField &F(){return(*FPtr);};
240  volTensorField &DF(){return(*DFPtr);};
241  volScalarField &J(){return(*JPtr);};
242  word &SolidDdtScheme(){return(*solidDdtSchemePtr);};
243  pointMesh &pStressMesh(){return(*pStressMeshPtr);};
244  pointVectorField &PointDU(){return(*pointDUPtr);};
245  IOdictionary &CouplingProperties(){return(*couplingPropertiesPtr);};
246  label SolidPatchID(){return(solidPatchID);};
247  word SolidPatchName(){return(solidPatchName);};
248  label FluidPatchID(){return(fluidPatchID);};
249  word FluidPatchName(){return(fluidPatchName);};
250  word FluidZoneName(){return(fluidZoneName);};
251  word SolidZoneName(){return(solidZoneName);};
252  label FluidZoneID(){return(fluidZoneID);};
253  label SolidZoneID(){return(solidZoneID);};
254  bool FEMotion(){return(feMotionSolver);};
255  bool FVMotion(){return(fvMotionSolver);};
258  zoneToZoneInterpolation &interpFluidSolid(){return(*interpolatorFluidSolidPtr);};
259  zoneToZoneInterpolation &interpSolidFluid(){return(*interpolatorSolidFluidPtr);};
260  solidTractionFvPatchVectorField &tForce(){
261  return(refCast<solidTractionFvPatchVectorField>(DUPtr->boundaryField()[solidPatchID]));};
262 
263  scalar &LocalContErr(){return(sumLocalContErr);};
264  scalar &GlobalContErr(){return(globalContErr);};
266  labelList &GlobalFaceZones(){return(globalFaceZones);};
268  word CouplingScheme(){return(couplingScheme);};
269  // label &OuterCorr(){return(outerCorr);};
272  Switch FSIEnabled(){return(fsi);};
273  int &NCorrPISO(){return(nCorr);};
274  int &NNonOrthCorr(){return(nNonOrthCorr);};
277  int &NOuterCorr(){return(nOuterCorr);};
278 
279  protected:
280  // ===== Functions specific to IMPACT FSI =====
289  void CreateFSISurfaceMesh();
290 
298  void UpdateFSISurfaceMesh();
299 
308  int UpdateFSISurface(Foam::vectorField &solidPatchPointsDispl);
309 
317  void UpdateFSISurfaceData();
318 
327  void UpdateTime();
328 };
label solidPatchID
Definition: fsiFOAM.H:110
volTensorField & F()
Definition: fsiFOAM.H:239
volScalarField * JPtr
Definition: fsiFOAM.H:99
dimensionedScalar * rhoFluidPtr
Definition: fsiFOAM.H:77
label FluidZoneID()
Definition: fsiFOAM.H:252
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: fsiFOAM.H:264
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: fsiFOAM.H:263
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: fsiFOAM.H:260
Foam::argList * argsPtr
Definition: fsiFOAM.H:70
zoneToZoneInterpolation * interpolatorSolidFluidPtr
Definition: fsiFOAM.H:123
word * solidDdtSchemePtr
Definition: fsiFOAM.H:100
int & NNonOrthCorr()
Definition: fsiFOAM.H:274
zoneToZoneInterpolation & interpFluidSolid()
Definition: fsiFOAM.H:258
Foam::argList & ArgList()
Definition: fsiFOAM.H:218
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: fsiFOAM.H:250
IOdictionary & TransportProperties()
Definition: fsiFOAM.H:221
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: fsiFOAM.H:242
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: fsiFOAM.H:273
labelListList globalToLocalFaceZonePointMap
Definition: fsiFOAM.H:134
static void Unload(const std::string &name)
Unloads the IcoFoamModule.
Definition: fsiFOAM.C:3257
label SolidZoneID()
Definition: fsiFOAM.H:253
int ReadPISOControls()
Definition: fsiFOAM.C:629
zoneToZoneInterpolation & interpSolidFluid()
Definition: fsiFOAM.H:259
volSymmTensorField * sigmaPtr
Definition: fsiFOAM.H:91
vectorField & AccumulatedFluidInterfaceDisplacements()
Definition: fsiFOAM.H:256
volTensorField * FPtr
Definition: fsiFOAM.H:97
IOobject * accumulatedFluidInterfaceDisplacementHeaderPtr
Definition: fsiFOAM.H:119
void RunFoam()
the OpenFOAM main
Definition: fsiFOAM.C:3271
word SolidZoneName()
Definition: fsiFOAM.H:251
volScalarField & rhoSolid()
Definition: fsiFOAM.H:236
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: fsiFOAM.H:225
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: fsiFOAM.H:249
Switch FSIEnabled()
Definition: fsiFOAM.H:272
scalar meanCoNum
Definition: fsiFOAM.H:145
labelListList & GlobalToLocalFaceZonePointMap()
Definition: fsiFOAM.H:267
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: fsiFOAM.H:271
scalar & CumulativeContErr()
Definition: fsiFOAM.H:265
std::vector< double > surfacePressure
Definition: fsiFOAM.H:52
word SolidPatchName()
Definition: fsiFOAM.H:247
scalar & FSIRelaxationFactor()
Definition: fsiFOAM.H:270
label SolidPatchID()
Definition: fsiFOAM.H:246
int Initialize(int argc, char *argv[])
Definition: fsiFOAM.C:5
volTensorField & DF()
Definition: fsiFOAM.H:240
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: fsiFOAM.H:229
volVectorField & Vs()
Definition: fsiFOAM.H:232
surfaceScalarField & phi()
Definition: fsiFOAM.H:226
bool fvMotionSolver
Definition: fsiFOAM.H:118
fsifoam_module(int argc, char *argv[])
Definition: fsiFOAM.H:171
volSymmTensorField & DSigma()
Definition: fsiFOAM.H:234
volScalarField & J()
Definition: fsiFOAM.H:241
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: fsiFOAM.H:255
dynamicFvMesh & FluidMesh()
Definition: fsiFOAM.H:220
scalar & InterfaceDeformationLimit()
Definition: fsiFOAM.H:275
zoneToZoneInterpolation * interpolatorFluidSolidPtr
Definition: fsiFOAM.H:122
pointVectorField * pointDUPtr
Definition: fsiFOAM.H:102
word CouplingScheme()
Definition: fsiFOAM.H:268
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: fsiFOAM.H:248
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: fsiFOAM.H:228
int StepFluidNonItr()
Definition: fsiFOAM.C:2310
bool FEMotion()
Definition: fsiFOAM.H:254
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: fsiFOAM.H:231
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: fsiFOAM.H:230
pointMesh & pStressMesh()
Definition: fsiFOAM.H:243
volScalarField & lambda()
Definition: fsiFOAM.H:238
int nOuterCorr
Definition: fsiFOAM.H:142
constitutiveModel & Rheology()
Definition: fsiFOAM.H:235
volScalarField & p()
Definition: fsiFOAM.H:224
Foam::Time & RunTime()
Definition: fsiFOAM.H:217
word couplingScheme
Definition: fsiFOAM.H:147
labelList & GlobalFaceZones()
Definition: fsiFOAM.H:266
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: fsiFOAM.H:237
dimensionedScalar & nu()
Definition: fsiFOAM.H:222
std::vector< double > deltaTime
Definition: fsiFOAM.H:57
int CreateFluidFields()
Definition: fsiFOAM.C:80
dimensionedScalar & rhoFluid()
Definition: fsiFOAM.H:223
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: fsiFOAM.H:277
label pRefCell
Definition: fsiFOAM.H:81
label fluidPatchID
Definition: fsiFOAM.H:114
int FindGlobalFaceZones()
Definition: fsiFOAM.C:514
pointVectorField & PointDU()
Definition: fsiFOAM.H:244
fvMesh * stressMeshPtr
Definition: fsiFOAM.H:85
scalar & OuterCorrTolerance()
Definition: fsiFOAM.H:276
fvMesh & StructuresMesh()
Definition: fsiFOAM.H:227
std::vector< double > surfaceTraction
Definition: fsiFOAM.H:53
volSymmTensorField & sigma()
Definition: fsiFOAM.H:233
scalar fsiRelaxationFactor
Definition: fsiFOAM.H:150
int StepFluidAlone()
Definition: fsiFOAM.C:1854
scalar fsiRelaxationFactorMin
Definition: fsiFOAM.H:151
IOdictionary & CouplingProperties()
Definition: fsiFOAM.H:245