From d7983e5d5f42b2d79ee177161f17fc1a60fb2593 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 28 Jul 2022 22:01:57 +0100 Subject: [PATCH 01/21] Add macOS (darwin) binary directories to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d273fd25..b7f69be9 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ # OpenFOAM / WMake lnInclude/ Make/linux64GccDPInt32Opt/ +Make/darwin64ClangDPInt32Opt/ # Editors .cproject From 8bd4d57cde185389be4be9e6a54c93151e5fca1b Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 28 Jul 2022 22:04:07 +0100 Subject: [PATCH 02/21] Extend FSI to work with solids4foam for the solid --- Adapter.C | 14 ++++++++++++++ FSI/Displacement.C | 40 +++++++++++++++++++++++++++++++++++--- FSI/Force.C | 48 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 98 insertions(+), 4 deletions(-) diff --git a/Adapter.C b/Adapter.C index e4da2dca..73dee383 100644 --- a/Adapter.C +++ b/Adapter.C @@ -757,6 +757,20 @@ void preciceAdapter::Adapter::storeMeshPoints() void preciceAdapter::Adapter::reloadMeshPoints() { + // Allow the user to say the mesh should not be moved, e.g. this is required + // for solids in solids4foam + if + ( + !mesh_.lookupObject + ( + "preciceDict" + ).subDict("FSI").lookupOrDefault("moveMesh", true) + ) + { + DEBUG(adapterInfo("Not moving the mesh points!")); + return; + } + // In Foam::polyMesh::movePoints. // TODO: The function movePoints overwrites the pointer to the old mesh. // Therefore, if you revert the mesh, the oldpointer will be set to the points, which are the new values. diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 90a6e2de..0ec2d1df 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -41,9 +41,43 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv * the outer for the locations and the inner for the dimensions. * See the preCICE writeBlockVectorData() implementation. */ - FatalErrorInFunction - << "Writing displacements is not supported." - << exit(FatalError); + + // Copy the displacement field from OpenFOAM to the buffer + + if (this->locationType_ == LocationType::faceCenters) + { + // For every boundary patch of the interface + for (const label patchID : patchIDs_) + { + // Write the displacement to the preCICE buffer + // For every cell of the patch + forAll(cellDisplacement_->boundaryField()[patchID], i) + { + for (unsigned int d = 0; d < dim; ++d) + buffer[i * dim + d] = + cellDisplacement_->boundaryField()[patchID][i][d]; + } + } + } + else if (this->locationType_ == LocationType::faceNodes) + { + // For every boundary patch of the interface + for (const label patchID : patchIDs_) + { + // Write the displacement to the preCICE buffer + // For every cell of the patch + forAll(pointDisplacement_->boundaryField()[patchID], i) + { + const labelList& meshPoints = + mesh_.boundaryMesh()[patchID].meshPoints(); + + for (unsigned int d = 0; d < dim; ++d) + buffer[i * dim + d] = + //displacementField.boundaryField()[patchID][i][d]; + pointDisplacement_->internalField()[meshPoints[i]][d]; + } + } + } } diff --git a/FSI/Force.C b/FSI/Force.C index 46c298fb..f7d9b420 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -28,7 +28,53 @@ void preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, co void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) { - this->readFromBuffer(buffer); + // Copy the force field from the buffer to OpenFOAM + + // Here we assume that a force volVectorField exists, which is used by + // the OpenFOAM solver + + // Lookup the force field name + const word forceFieldName + ( + mesh_.lookupObject + ( + "preciceDict" + ).subDict("FSI").lookup("forceFieldName") + ); + + // Lookup the force field + volVectorField& forceField = + const_cast + ( + mesh_.lookupObject(forceFieldName) + ); + + // Set boundary forces + for (unsigned int j = 0; j < patchIDs_.size(); j++) + { + // Get the ID of the current patch + const unsigned int patchID = patchIDs_.at(j); + + if (this->locationType_ == LocationType::faceCenters) + { + // Make a force field + vectorField& force = forceField.boundaryFieldRef()[patchID]; + + // Copy the forces from the buffer into the force field + forAll(force, i) + { + for (unsigned int d = 0; d < dim; ++d) + force[i][d] = buffer[i * dim + d]; + } + } + else if (this->locationType_ == LocationType::faceNodes) + { + // Here we could easily interpolate the face values to point values + // and assign them to some field, but I guess there is no need + // unless it will be used + notImplemented("Read forces not implemented for faceNodes!"); + } + } } bool preciceAdapter::FSI::Force::isLocationTypeSupported(const bool meshConnectivity) const From 3916a16820e2e041c55744d123a1972799ee92c8 Mon Sep 17 00:00:00 2001 From: solids4foam <110133789+solids4foam@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:18:11 +0100 Subject: [PATCH 03/21] Update FSI/Displacement.C Co-authored-by: Gerasimos Chourdakis --- FSI/Displacement.C | 1 - 1 file changed, 1 deletion(-) diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 0ec2d1df..81031ddf 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -73,7 +73,6 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv for (unsigned int d = 0; d < dim; ++d) buffer[i * dim + d] = - //displacementField.boundaryField()[patchID][i][d]; pointDisplacement_->internalField()[meshPoints[i]][d]; } } From 88e6fa5ae921483628c3dff90c6519b32004aa13 Mon Sep 17 00:00:00 2001 From: solids4foam <110133789+solids4foam@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:30:37 +0100 Subject: [PATCH 04/21] Update Adapter.C Co-authored-by: Gerasimos Chourdakis --- Adapter.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adapter.C b/Adapter.C index 73dee383..8dc4f2de 100644 --- a/Adapter.C +++ b/Adapter.C @@ -767,7 +767,7 @@ void preciceAdapter::Adapter::reloadMeshPoints() ).subDict("FSI").lookupOrDefault("moveMesh", true) ) { - DEBUG(adapterInfo("Not moving the mesh points!")); + DEBUG(adapterInfo("Moving the mesh points is switched off in the adapter configuration file.")); return; } From 46aa5ee9d224b990df7b2f22ad4d22b9c1db06cb Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Fri, 29 Jul 2022 11:48:45 +0100 Subject: [PATCH 05/21] Added changelog-entries/236.md --- changelog-entries/236.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog-entries/236.md diff --git a/changelog-entries/236.md b/changelog-entries/236.md new file mode 100644 index 00000000..e80f533f --- /dev/null +++ b/changelog-entries/236.md @@ -0,0 +1 @@ +- Added functionality to allow use of solids4foam with the OpenFOAM adapter From 44c2f404f19e77120b5728022f359389eabc985b Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Fri, 29 Jul 2022 12:05:19 +0100 Subject: [PATCH 06/21] Apply clang-format to Adapter.C and FSI/Force.C --- Adapter.C | 20 +++++++++----------- FSI/Force.C | 18 +++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Adapter.C b/Adapter.C index 8dc4f2de..c52d7cb1 100644 --- a/Adapter.C +++ b/Adapter.C @@ -759,13 +759,11 @@ void preciceAdapter::Adapter::reloadMeshPoints() { // Allow the user to say the mesh should not be moved, e.g. this is required // for solids in solids4foam - if - ( - !mesh_.lookupObject - ( - "preciceDict" - ).subDict("FSI").lookupOrDefault("moveMesh", true) - ) + if ( + !mesh_.lookupObject( + "preciceDict") + .subDict("FSI") + .lookupOrDefault("moveMesh", true)) { DEBUG(adapterInfo("Moving the mesh points is switched off in the adapter configuration file.")); return; @@ -1315,8 +1313,8 @@ void preciceAdapter::Adapter::readMeshCheckpoint() { DEBUG(adapterInfo("Reading a mesh checkpoint...")); - //TODO only the meshPhi field is here, which is a surfaceScalarField. The other fields can be removed. - // Reload all the fields of type mesh surfaceScalarField + // TODO only the meshPhi field is here, which is a surfaceScalarField. The other fields can be removed. + // Reload all the fields of type mesh surfaceScalarField for (uint i = 0; i < meshSurfaceScalarFields_.size(); i++) { // Load the volume field @@ -1543,8 +1541,8 @@ void preciceAdapter::Adapter::teardown() } meshVolVectorFieldCopies_.clear(); - //TODO for the internal volume - // volScalarInternal + // TODO for the internal volume + // volScalarInternal for (uint i = 0; i < volScalarInternalFieldCopies_.size(); i++) { delete volScalarInternalFieldCopies_.at(i); diff --git a/FSI/Force.C b/FSI/Force.C index f7d9b420..551d0bb1 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -34,20 +34,16 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) // the OpenFOAM solver // Lookup the force field name - const word forceFieldName - ( - mesh_.lookupObject - ( - "preciceDict" - ).subDict("FSI").lookup("forceFieldName") - ); + const word forceFieldName( + mesh_.lookupObject( + "preciceDict") + .subDict("FSI") + .lookup("forceFieldName")); // Lookup the force field volVectorField& forceField = - const_cast - ( - mesh_.lookupObject(forceFieldName) - ); + const_cast( + mesh_.lookupObject(forceFieldName)); // Set boundary forces for (unsigned int j = 0; j < patchIDs_.size(); j++) From 4412d2ef482d9ffa17caa2077d94a079dc21f0f9 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Sun, 31 Jul 2022 23:10:08 +0100 Subject: [PATCH 07/21] Add solverType solid --- Adapter.C | 9 +++++---- FSI/FSI.C | 10 ++++++---- FSI/ForceBase.C | 25 +++++++++++++------------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Adapter.C b/Adapter.C index c52d7cb1..ca65bc60 100644 --- a/Adapter.C +++ b/Adapter.C @@ -760,10 +760,11 @@ void preciceAdapter::Adapter::reloadMeshPoints() // Allow the user to say the mesh should not be moved, e.g. this is required // for solids in solids4foam if ( - !mesh_.lookupObject( - "preciceDict") - .subDict("FSI") - .lookupOrDefault("moveMesh", true)) + mesh_.lookupObject( + "preciceDict") + .subDict("FSI") + .lookupOrDefault("solverType", "none") + == "solid") { DEBUG(adapterInfo("Moving the mesh points is switched off in the adapter configuration file.")); return; diff --git a/FSI/FSI.C b/FSI/FSI.C index a10e0326..b237faa6 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -27,7 +27,9 @@ bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionar // addWriters() and addReaders(). // Check the solver type and determine it if needed if ( - solverType_.compare("compressible") == 0 || solverType_.compare("incompressible") == 0) + solverType_.compare("compressible") == 0 + || solverType_.compare("incompressible") == 0 + || solverType_.compare("solid") == 0) { DEBUG(adapterInfo("Known solver type: " + solverType_)); } @@ -38,7 +40,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionar } else { - DEBUG(adapterInfo("Determining the solver type for the FSI module... (override by setting solverType to one of {compressible, incompressible})")); + DEBUG(adapterInfo("Determining the solver type for the FSI module... (override by setting solverType to one of {compressible, incompressible, solid})")); solverType_ = determineSolverType(); } @@ -54,8 +56,8 @@ bool preciceAdapter::FSI::FluidStructureInteraction::readConfig(const IOdictiona DEBUG(adapterInfo(" user-defined solver type : " + solverType_)); /* TODO: Read the names of any needed fields and parameters. - * Include the force here? - */ + * Include the force here? + */ // Read the name of the pointDisplacement field (if different) namePointDisplacement_ = FSIdict.lookupOrDefault("namePointDisplacement", "pointDisplacement"); diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 37e1c9e8..d4610e47 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -9,22 +9,24 @@ preciceAdapter::FSI::ForceBase::ForceBase( : mesh_(mesh), solverType_(solverType) { - //What about type "basic"? - if (solverType_.compare("incompressible") != 0 && solverType_.compare("compressible") != 0) + // What about type "basic"? + if (solverType_.compare("incompressible") != 0 + && solverType_.compare("compressible") != 0 + && solverType_.compare("solid") != 0) { FatalErrorInFunction << "Force based calculations only support " - << "compressible or incompressible solver types." + << "compressible, incompressible or solid solver types." << exit(FatalError); } dataType_ = vector; } -//Calculate viscous force +// Calculate viscous force Foam::tmp preciceAdapter::FSI::ForceBase::devRhoReff() const { - //For turbulent flows + // For turbulent flows typedef compressible::turbulenceModel cmpTurbModel; typedef incompressible::turbulenceModel icoTurbModel; @@ -52,7 +54,7 @@ Foam::tmp preciceAdapter::FSI::ForceBase::devRhoReff() } } -//lookup correct rho +// lookup correct rho Foam::tmp preciceAdapter::FSI::ForceBase::rho() const { // If volScalarField exists, read it from registry (for compressible cases) @@ -88,10 +90,9 @@ Foam::tmp preciceAdapter::FSI::ForceBase::rho() const } } -//lookup correct mu +// lookup correct mu Foam::tmp preciceAdapter::FSI::ForceBase::mu() const { - if (solverType_.compare("incompressible") == 0) { typedef immiscibleIncompressibleTwoPhaseMixture iitpMixture; @@ -191,10 +192,10 @@ void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, void preciceAdapter::FSI::ForceBase::readFromBuffer(double* buffer) const { /* TODO: Implement - * We need two nested for-loops for each patch, - * the outer for the locations and the inner for the dimensions. - * See the preCICE readBlockVectorData() implementation. - */ + * We need two nested for-loops for each patch, + * the outer for the locations and the inner for the dimensions. + * See the preCICE readBlockVectorData() implementation. + */ FatalErrorInFunction << "Reading forces is not supported." << exit(FatalError); From 75eca1b56efb51f7338ad2e342b516317c651146 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Tue, 2 Aug 2022 17:02:24 +0100 Subject: [PATCH 08/21] FSI: add nameSolidForce variable to FSI and Force classes --- FSI/FSI.C | 8 ++++++-- FSI/FSI.H | 3 +++ FSI/Force.C | 14 +++++--------- FSI/Force.H | 6 +++++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/FSI/FSI.C b/FSI/FSI.C index b237faa6..5050bb31 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -67,6 +67,10 @@ bool preciceAdapter::FSI::FluidStructureInteraction::readConfig(const IOdictiona nameCellDisplacement_ = FSIdict.lookupOrDefault("nameCellDisplacement", "cellDisplacement"); DEBUG(adapterInfo(" cellDisplacement field name : " + nameCellDisplacement_)); + // Read the name of the solidForce field (if different) + nameSolidForce_ = FSIdict.lookupOrDefault("nameSolidForce", "solidForce"); + DEBUG(adapterInfo(" solidForce field name : " + nameSolidForce_)); + return true; } @@ -119,7 +123,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data { interface->addCouplingDataWriter( dataName, - new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ + new Force(mesh_, solverType_, nameSolidForce_) /* TODO: Add any other arguments here */ ); DEBUG(adapterInfo("Added writer: Force.")); } @@ -167,7 +171,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data { interface->addCouplingDataReader( dataName, - new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ + new Force(mesh_, solverType_, nameSolidForce_) /* TODO: Add any other arguments here */ ); DEBUG(adapterInfo("Added reader: Force.")); } diff --git a/FSI/FSI.H b/FSI/FSI.H index 3e93d77e..008da0a6 100644 --- a/FSI/FSI.H +++ b/FSI/FSI.H @@ -34,6 +34,9 @@ protected: //- Name of the pointDisplacement field std::string nameCellDisplacement_ = "cellDisplacement"; + //- Name of the force field used by the solid + std::string nameSolidForce_ = "solidForce"; + /* TODO: Declare here any parameters that should be read from / the configuration file. See CHT/CHT.H for reference. / We want to support in-house solvers with different field names, diff --git a/FSI/Force.C b/FSI/Force.C index 551d0bb1..4f112ac2 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -4,7 +4,8 @@ using namespace Foam; preciceAdapter::FSI::Force::Force( const Foam::fvMesh& mesh, - const std::string solverType) + const std::string solverType, + const std::string nameSolidForce) : ForceBase(mesh, solverType) { Force_ = new volVectorField( @@ -19,6 +20,8 @@ preciceAdapter::FSI::Force::Force( "fdim", dimensionSet(1, 1, -2, 0, 0, 0, 0), Foam::vector::zero)); + + nameSolidForce_ = nameSolidForce; } void preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, const unsigned int dim) @@ -33,17 +36,10 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) // Here we assume that a force volVectorField exists, which is used by // the OpenFOAM solver - // Lookup the force field name - const word forceFieldName( - mesh_.lookupObject( - "preciceDict") - .subDict("FSI") - .lookup("forceFieldName")); - // Lookup the force field volVectorField& forceField = const_cast( - mesh_.lookupObject(forceFieldName)); + mesh_.lookupObject(nameSolidForce_)); // Set boundary forces for (unsigned int j = 0; j < patchIDs_.size(); j++) diff --git a/FSI/Force.H b/FSI/Force.H index 062e42c0..563721b9 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -15,11 +15,15 @@ private: //- Force field Foam::volVectorField* Force_; + //- Solid force field name + Foam::string nameSolidForce_; + public: //- Constructor Force( const Foam::fvMesh& mesh, - const std::string solverType); + const std::string solverType, + const std::string nameSolidForce); //- Write the forces values into the buffer void write(double* buffer, bool meshConnectivity, const unsigned int dim) override; From d4cc5ab402f73e7e6d1ed47b6ad5ce7a98f3979d Mon Sep 17 00:00:00 2001 From: solids4foam <110133789+solids4foam@users.noreply.github.com> Date: Tue, 2 Aug 2022 17:06:58 +0100 Subject: [PATCH 09/21] Update FSI/ForceBase.C Co-authored-by: Gerasimos Chourdakis --- FSI/ForceBase.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index d4610e47..b9aaafba 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -16,7 +16,7 @@ preciceAdapter::FSI::ForceBase::ForceBase( { FatalErrorInFunction << "Force based calculations only support " - << "compressible, incompressible or solid solver types." + << "compressible, incompressible, or solid solver types." << exit(FatalError); } From 4b49300d9cc17bb786481e78ea3930c6789e8c71 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Tue, 2 Aug 2022 17:33:44 +0100 Subject: [PATCH 10/21] FSI/Displacement.C: change required for solid solvers (like solidDisplacementFoam) which do not have a point field --- FSI/Displacement.C | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 81031ddf..181913a1 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -7,7 +7,9 @@ preciceAdapter::FSI::Displacement::Displacement( const std::string namePointDisplacement, const std::string nameCellDisplacement) : pointDisplacement_( - const_cast( + namePointDisplacement == "unused" + ? NULL + : const_cast( &mesh.lookupObject(namePointDisplacement))), cellDisplacement_( const_cast( From a0755dc3e3d82548c62dd533b09e4d931908099b Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 4 Aug 2022 10:36:47 +0100 Subject: [PATCH 11/21] FSI/Displacement.C: use nullptr instead of NULL --- FSI/Displacement.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 181913a1..a4e61890 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -8,7 +8,7 @@ preciceAdapter::FSI::Displacement::Displacement( const std::string nameCellDisplacement) : pointDisplacement_( namePointDisplacement == "unused" - ? NULL + ? nullptr : const_cast( &mesh.lookupObject(namePointDisplacement))), cellDisplacement_( From e18ea6e70356a7cc52470df2932db3bd4a59f09e Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 4 Aug 2022 10:48:48 +0100 Subject: [PATCH 12/21] FSI/Force: store pointer to solidForce field --- FSI/Force.C | 14 +++++++------- FSI/Force.H | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/FSI/Force.C b/FSI/Force.C index 4f112ac2..9b8181a2 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -21,7 +21,12 @@ preciceAdapter::FSI::Force::Force( dimensionSet(1, 1, -2, 0, 0, 0, 0), Foam::vector::zero)); - nameSolidForce_ = nameSolidForce; + if (mesh_.foundObject(nameSolidForce)) + { + solidForce_ = + &const_cast( + mesh_.lookupObject(nameSolidForce)); + } } void preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, const unsigned int dim) @@ -36,11 +41,6 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) // Here we assume that a force volVectorField exists, which is used by // the OpenFOAM solver - // Lookup the force field - volVectorField& forceField = - const_cast( - mesh_.lookupObject(nameSolidForce_)); - // Set boundary forces for (unsigned int j = 0; j < patchIDs_.size(); j++) { @@ -50,7 +50,7 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) if (this->locationType_ == LocationType::faceCenters) { // Make a force field - vectorField& force = forceField.boundaryFieldRef()[patchID]; + vectorField& force = solidForce_->boundaryFieldRef()[patchID]; // Copy the forces from the buffer into the force field forAll(force, i) diff --git a/FSI/Force.H b/FSI/Force.H index 563721b9..851863f3 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -15,8 +15,8 @@ private: //- Force field Foam::volVectorField* Force_; - //- Solid force field name - Foam::string nameSolidForce_; + //- Solid force field + Foam::volVectorField* solidForce_; public: //- Constructor From 3b17ab06f1bd03b29d505870b208edb8c249d651 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 4 Aug 2022 10:49:42 +0100 Subject: [PATCH 13/21] FSI/Force: store pointer to solidForce field (use nullptr if not found) --- FSI/Force.C | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FSI/Force.C b/FSI/Force.C index 9b8181a2..d2867f30 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -27,6 +27,10 @@ preciceAdapter::FSI::Force::Force( &const_cast( mesh_.lookupObject(nameSolidForce)); } + else + { + solidForce_ = nullptr; + } } void preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, const unsigned int dim) From abfe8c1660c23b0c85afd879c3bd930b9b313c0d Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 4 Aug 2022 10:58:35 +0100 Subject: [PATCH 14/21] Adapter/reloadMeshPoints: do nothing is the mesh is not moving --- Adapter.C | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Adapter.C b/Adapter.C index ca65bc60..faaab7b2 100644 --- a/Adapter.C +++ b/Adapter.C @@ -757,16 +757,9 @@ void preciceAdapter::Adapter::storeMeshPoints() void preciceAdapter::Adapter::reloadMeshPoints() { - // Allow the user to say the mesh should not be moved, e.g. this is required - // for solids in solids4foam - if ( - mesh_.lookupObject( - "preciceDict") - .subDict("FSI") - .lookupOrDefault("solverType", "none") - == "solid") - { - DEBUG(adapterInfo("Moving the mesh points is switched off in the adapter configuration file.")); + if (!mesh_.moving()) + { + DEBUG(adapterInfo("Mesh points not moved as the mesh is not moving")); return; } From b8621dfa91abd948e576a49a712b60889d083986 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 4 Aug 2022 12:10:08 +0100 Subject: [PATCH 15/21] FSI: apply clang-format --- FSI/Displacement.C | 14 +++++++------- FSI/DisplacementDelta.C | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/FSI/Displacement.C b/FSI/Displacement.C index a4e61890..ab404830 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -8,9 +8,9 @@ preciceAdapter::FSI::Displacement::Displacement( const std::string nameCellDisplacement) : pointDisplacement_( namePointDisplacement == "unused" - ? nullptr - : const_cast( - &mesh.lookupObject(namePointDisplacement))), + ? nullptr + : const_cast( + &mesh.lookupObject(namePointDisplacement))), cellDisplacement_( const_cast( &mesh.lookupObject(nameCellDisplacement))), @@ -39,10 +39,10 @@ void preciceAdapter::FSI::Displacement::initialize() void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectivity, const unsigned int dim) { /* TODO: Implement - * We need two nested for-loops for each patch, - * the outer for the locations and the inner for the dimensions. - * See the preCICE writeBlockVectorData() implementation. - */ + * We need two nested for-loops for each patch, + * the outer for the locations and the inner for the dimensions. + * See the preCICE writeBlockVectorData() implementation. + */ // Copy the displacement field from OpenFOAM to the buffer diff --git a/FSI/DisplacementDelta.C b/FSI/DisplacementDelta.C index ca4e4c2a..53b56240 100644 --- a/FSI/DisplacementDelta.C +++ b/FSI/DisplacementDelta.C @@ -37,10 +37,10 @@ void preciceAdapter::FSI::DisplacementDelta::initialize() void preciceAdapter::FSI::DisplacementDelta::write(double* buffer, bool meshConnectivity, const unsigned int dim) { /* TODO: Implement - * We need two nested for-loops for each patch, - * the outer for the locations and the inner for the dimensions. - * See the preCICE writeBlockVectorData() implementation. - */ + * We need two nested for-loops for each patch, + * the outer for the locations and the inner for the dimensions. + * See the preCICE writeBlockVectorData() implementation. + */ FatalErrorInFunction << "Writing displacementDeltas is not supported." << exit(FatalError); From 3c2a9ccd700a0c706949a70340173f6e77c1bef2 Mon Sep 17 00:00:00 2001 From: Philip Cardiff Date: Thu, 4 Aug 2022 13:43:11 +0100 Subject: [PATCH 16/21] FSI/Displacement: add warning about using faceNodes in parallel --- FSI/Displacement.C | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/FSI/Displacement.C b/FSI/Displacement.C index ab404830..deea5a65 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -63,6 +63,14 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv } else if (this->locationType_ == LocationType::faceNodes) { + WarningIn( + "void preciceAdapter::FSI::Displacement::write" + "(double* buffer, bool meshConnectivity, const unsigned int dim))") + << "Please be aware of issues with using 'locationType faceNodes' " + << "in parallel. " + << "See https://github.com/precice/openfoam-adapter/issues/153." + << endl; + // For every boundary patch of the interface for (const label patchID : patchIDs_) { From a591b5e868dd5c5fe7c0ad676bea2b0e81956bae Mon Sep 17 00:00:00 2001 From: solids4foam <110133789+solids4foam@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:12:32 +0100 Subject: [PATCH 17/21] Update FSI/Displacement.C Co-authored-by: Gerasimos Chourdakis --- FSI/Displacement.C | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/FSI/Displacement.C b/FSI/Displacement.C index deea5a65..398a65ed 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -63,13 +63,11 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv } else if (this->locationType_ == LocationType::faceNodes) { - WarningIn( - "void preciceAdapter::FSI::Displacement::write" - "(double* buffer, bool meshConnectivity, const unsigned int dim))") - << "Please be aware of issues with using 'locationType faceNodes' " - << "in parallel. " - << "See https://github.com/precice/openfoam-adapter/issues/153." - << endl; + DEBUG(adapterInfo( + "Please be aware of issues with using 'locationType faceNodes' " + "in parallel. \n" + "See https://github.com/precice/openfoam-adapter/issues/153.", + "warning")); // For every boundary patch of the interface for (const label patchID : patchIDs_) From a8a2e3b8368cb97016d60869d8f7b374ca8ce8e1 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 8 Aug 2022 19:20:36 +0200 Subject: [PATCH 18/21] Update config.md --- docs/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index 6371bac7..cdc9e27c 100644 --- a/docs/config.md +++ b/docs/config.md @@ -120,7 +120,7 @@ writeData ); ``` -For fluid-structure interaction, `writeData` can be `Force` or `Stress`, where `Stress` is essentially a force vector scaled by the cell face in spatial coordinates (with any postfix), thus, a conservative quantity as well.`readData` can be `Displacement` and `DisplacementDelta` (with any postfix). `DisplacementDelta` refers to the last coupling time step, which needs to considered in the case of subcycling. +For fluid-structure interaction, `writeData` can be `Force` or `Stress`, where `Stress` is essentially a force vector scaled by the cell face in spatial coordinates (with any postfix), thus, a conservative quantity as well. `readData` can be `Displacement` and `DisplacementDelta` (with any postfix). `DisplacementDelta` refers to the last coupling time step, which needs to considered in the case of subcycling. Structure solvers (such as solids4Foam) can also write `Displacement` and read `Force`. {% warning %} You will run into problems when you use `Displacement(Delta)` as write data set and execute RBF mappings in parallel. This would affect users who use OpenFOAM and the adapter as the Solid participant in order to compute solid mechanics with OpenFOAM (currently not officially supported at all). Have a look [at this issue on GitHub](https://github.com/precice/openfoam-adapter/issues/153) for details. From 58c296cf4bd552dc510dcd0ff8eb59a904fe212f Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 8 Aug 2022 19:21:24 +0200 Subject: [PATCH 19/21] Update README.md --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index ab1265f1..a1a437c5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,9 +18,9 @@ This adapter can read/write the following fields: - Heat flux (read + write) - Sink temperature (read + write) - Heat transfer coefficient (read + write) -- Force (write) +- Force (read + write) - Stress (write) -- Displacement (read) +- Displacement (read + write) - Displacement delta (read) - Pressure (read + write) - Pressure gradient (read + write) From a0aee14823d35579669646363f5b8b4162c1b682 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 8 Aug 2022 19:27:05 +0200 Subject: [PATCH 20/21] Update config.md --- docs/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index cdc9e27c..b40a8ab1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -312,7 +312,7 @@ and depends on the density (`rho [ 1 -3 0 0 0 0 0 ]`) and heat capacity (`Cp #### Fluid-structure interaction -The adapter's FSI functionality supports both compressible and incompressible solvers. +The adapter's FSI functionality supports both compressible and incompressible solvers, as well as solid (e.g., solids4Foam) solvers. For incompressible solvers, it tries to read uniform values for the density and kinematic viscosity (if it is not already available) from the `FSI` subdictionary of `preciceDict`: From 8b62dbda1f3cda1b15679a165e843cba012fdc00 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 8 Aug 2022 19:31:07 +0200 Subject: [PATCH 21/21] Update openfoam-support.md --- docs/openfoam-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 29beb897..0eba1fb8 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -40,7 +40,7 @@ Known not supported versions: OpenFOAM v1606+ or older, OpenFOAM 3 or older, foa ## Supported OpenFOAM solvers -We support mainstream OpenFOAM solvers such as pimpleFoam (for FSI) or buoyantPimpleFoam, buoyantSimpleFoam, laplacianFoam (for CHT). Our community has tried the adapter with multiple different solvers that support function objects. +We support mainstream OpenFOAM solvers such as pimpleFoam and solids4Foam for FSI, buoyantPimpleFoam, buoyantSimpleFoam, and laplacianFoam for CHT, or pimpleFoam and sonicLiquidFoam for FF. Our community has, additionally, tried the adapter with multiple different solvers that support function objects. ## Notes on OpenFOAM features