diff --git a/perpendicular-flap/README.md b/perpendicular-flap/README.md index 41da352e3..8133de614 100644 --- a/perpendicular-flap/README.md +++ b/perpendicular-flap/README.md @@ -37,6 +37,10 @@ Solid participant: * DUNE. For more information, have a look at the [experimental DUNE adapter](https://github.com/precice/dune-adapter) and send us your feedback. +* OpenFOAM (solidDisplacementFoam). For more information, have a look at the [OpenFOAM plateHole tutorial](https://www.openfoam.com/documentation/tutorial-guide/5-stress-analysis/5.1-stress-analysis-of-a-plate-with-a-hole). The solidDisplacementFoam solver only supports linear geometry. For general solid mechanics procedures in OpenFOAM, see solids4foam. + +* solids4foam. Like for CalculuX, the geometrically linear solver is used by default. For more information, see the [solids4foam documentation](https://bitbucket.org/philip_cardiff/solids4foam-release/src/master/documentation/overview.md) This case currently (August 2022) only works with the `nextRelease` branch of solids4foam, which is only compatible with up to OpenFOAM v2012 and OpenFOAM 9 (as well as foam-extend, with which the OpenFOAM-preCICE adapter is not compatible), as well as the `develop` branch of the OpenFOAM-preCICE adapter. Note that, since both solids4foam and preCICE rely on Eigen, and due to some [solids4foam-preCICE compatibility issue](https://github.com/precice/openfoam-adapter/issues/238), you need to build preCICE and solids4foam with the same Eigen version. + ## Running the Simulation All listed solvers can be used in order to run the simulation. OpenFOAM can be executed in parallel using `run.sh -parallel`. The default setting uses 4 MPI ranks. Open two separate terminals and start the desired fluid and solid participant by calling the respective run script `run.sh` located in the participant directory. For example: diff --git a/perpendicular-flap/solid-openfoam/0/D b/perpendicular-flap/solid-openfoam/0/D new file mode 100644 index 000000000..ee1780d12 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/0/D @@ -0,0 +1,33 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object D; +} + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + interface + { + type solidDisplacementFoamForce; + forceField solidForce; + value uniform (0 0 0); + } + bottom + { + type fixedValue; + value uniform (0 0 0); + } + frontAndBack + { + type empty; + } +} + + diff --git a/perpendicular-flap/solid-openfoam/0/solidForce b/perpendicular-flap/solid-openfoam/0/solidForce new file mode 100644 index 000000000..0cb4e7ce8 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/0/solidForce @@ -0,0 +1,32 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object solidForce; +} + +dimensions [1 2 2 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + interface + { + type calculated; + value uniform (0 0 0); + } + bottom + { + type calculated; + value uniform (0 0 0); + } + frontAndBack + { + type empty; + } +} + + diff --git a/perpendicular-flap/solid-openfoam/clean.sh b/perpendicular-flap/solid-openfoam/clean.sh new file mode 100755 index 000000000..c31d9fc76 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/clean.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e -u + +. ../../tools/cleaning-tools.sh + +clean_openfoam . diff --git a/perpendicular-flap/solid-openfoam/constant/mechanicalProperties b/perpendicular-flap/solid-openfoam/constant/mechanicalProperties new file mode 100644 index 000000000..62109031b --- /dev/null +++ b/perpendicular-flap/solid-openfoam/constant/mechanicalProperties @@ -0,0 +1,29 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object mechanicalProperties; +} + +rho +{ + type uniform; + value 3000; +} + +nu +{ + type uniform; + value 0.3; +} + +E +{ + type uniform; + value 4e+6; +} + +planeStress no; + diff --git a/perpendicular-flap/solid-openfoam/constant/thermalProperties b/perpendicular-flap/solid-openfoam/constant/thermalProperties new file mode 100644 index 000000000..bce2052e9 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/constant/thermalProperties @@ -0,0 +1,10 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermalProperties; +} + +thermalStress no; diff --git a/perpendicular-flap/solid-openfoam/run.sh b/perpendicular-flap/solid-openfoam/run.sh new file mode 100755 index 000000000..d56f9c8d6 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/run.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +blockMesh +touch solid-openfoam.foam + +# Compile boundary condition +(cd solidDisplacementFoamForce && wmake libso) + +../../tools/run-openfoam.sh "$@" +. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs diff --git a/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/Make/files b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/Make/files new file mode 100644 index 000000000..20cf11c08 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/Make/files @@ -0,0 +1,3 @@ +solidDisplacementFoamForceFvPatchVectorField.C + +LIB = $(FOAM_USER_LIBBIN)/libsolidDisplacementFoamForce diff --git a/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/Make/options b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/Make/options new file mode 100644 index 000000000..ac23a670e --- /dev/null +++ b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/Make/options @@ -0,0 +1,15 @@ +VERSION_SPECIFIC_INC = -DOPENFOAMESIORFOUNDATION +ifneq (,$(findstring v,$(WM_PROJECT_VERSION))) + VERSION_SPECIFIC_INC += -DOPENFOAMESI +else + VERSION_SPECIFIC_INC += -DOPENFOAMFOUNDATION +endif + +EXE_INC = \ + $(VERSION_SPECIFIC_INC) \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lmeshTools diff --git a/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/solidDisplacementFoamForceFvPatchVectorField.C b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/solidDisplacementFoamForceFvPatchVectorField.C new file mode 100644 index 000000000..25200fd9d --- /dev/null +++ b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/solidDisplacementFoamForceFvPatchVectorField.C @@ -0,0 +1,304 @@ +#include "solidDisplacementFoamForceFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +solidDisplacementFoamForceFvPatchVectorField:: +solidDisplacementFoamForceFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchVectorField(p, iF), + force_(p.size(), vector::zero), + forceFieldPtr_(), + curTimeIndex_(-1) +{ + fvPatchVectorField::operator=(patchInternalField()); + gradient() = vector::zero; +} + + +solidDisplacementFoamForceFvPatchVectorField:: +solidDisplacementFoamForceFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchVectorField(p, iF), + force_(p.size(), vector::zero), + forceFieldPtr_(), + curTimeIndex_(-1) +{ + Info<< "Creating " << type() << " boundary condition" << endl; + + if (dict.found("gradient")) + { + gradient() = vectorField("gradient", dict, p.size()); + } + else + { + gradient() = vector::zero; + } + + if (dict.found("value")) + { + Field::operator=(vectorField("value", dict, p.size())); + } + else + { + fvPatchVectorField::operator=(patchInternalField()); + } + + // Check how force is defined + if (dict.found("force") && dict.found("forceField")) + { + FatalErrorIn + ( + "solidDisplacementFoamForceFvPatchVectorField::solidDisplacementFoamForceFvPatchVectorField" + ) << "Only force or forceField can be " + << "specified, not both!" + << abort(FatalError); + } + else if (dict.found("forceField")) + { + Info<< " force is specified as a field" << endl; + forceFieldPtr_.reset + ( + new volVectorField + ( + IOobject + ( + word(dict.lookup("forceField")), + patch().boundaryMesh().mesh().time().timeName(), + patch().boundaryMesh().mesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + patch().boundaryMesh().mesh() + ) + ); + } + else + { + force_ = vectorField("force", dict, p.size()); + } +} + + +solidDisplacementFoamForceFvPatchVectorField:: +solidDisplacementFoamForceFvPatchVectorField +( + const solidDisplacementFoamForceFvPatchVectorField& stpvf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchVectorField(stpvf, p, iF, mapper), +#ifdef OPENFOAMFOUNDATION + force_(mapper(stpvf.force_)), +#else + force_(stpvf.force_, mapper), +#endif + forceFieldPtr_(), + curTimeIndex_(stpvf.curTimeIndex_) +{} + +#ifndef OPENFOAMFOUNDATION +solidDisplacementFoamForceFvPatchVectorField::solidDisplacementFoamForceFvPatchVectorField +( + const solidDisplacementFoamForceFvPatchVectorField& stpvf +) +: + fixedGradientFvPatchVectorField(stpvf), + force_(stpvf.force_), + forceFieldPtr_(), + curTimeIndex_(stpvf.curTimeIndex_) +{} +#endif + +solidDisplacementFoamForceFvPatchVectorField::solidDisplacementFoamForceFvPatchVectorField +( + const solidDisplacementFoamForceFvPatchVectorField& stpvf, + const DimensionedField& iF +) +: + fixedGradientFvPatchVectorField(stpvf, iF), + force_(stpvf.force_), + forceFieldPtr_(), + curTimeIndex_(stpvf.curTimeIndex_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void solidDisplacementFoamForceFvPatchVectorField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedGradientFvPatchVectorField::autoMap(m); + +#ifdef OPENFOAMFOUNDATION + m(force_, force_); +#else + force_.autoMap(m); +#endif +} + + +// Reverse-map the given fvPatchField onto this fvPatchField +void solidDisplacementFoamForceFvPatchVectorField::rmap +( + const fvPatchVectorField& ptf, + const labelList& addr +) +{ + fixedGradientFvPatchVectorField::rmap(ptf, addr); + + const solidDisplacementFoamForceFvPatchVectorField& dmptf = + refCast(ptf); + + force_.rmap(dmptf.force_, addr); +} + + +// Update the coefficients associated with the patch field +void solidDisplacementFoamForceFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + if (curTimeIndex_ != db().time().timeIndex()) + { + curTimeIndex_ = db().time().timeIndex(); + + // Called once per time-step + if (forceFieldPtr_.valid()) + { + // Force the traction field boundary conditions to update + const_cast + ( + forceFieldPtr_() + ).correctBoundaryConditions(); + } + } + + if (forceFieldPtr_.valid()) + { + force_ = forceFieldPtr_().boundaryField()[patch().index()]; + } + + // Convert the force field to a traction field + // Note: this assumes small strains / linear geometry + const vectorField traction(force_/patch().magSf()); + + // Apply traction + // The code below comes from tractionDisplacement:updateCoeffs() + + const dictionary& mechanicalProperties = + db().lookupObject("mechanicalProperties"); + + const dictionary& thermalProperties = + db().lookupObject("thermalProperties"); + + const fvPatchField& rho = + patch().lookupPatchField("rho"); + + const fvPatchField& rhoE = + patch().lookupPatchField("E"); + + const fvPatchField& nu = + patch().lookupPatchField("nu"); + + const scalarField E(rhoE/rho); + const scalarField mu(E/(2.0*(1.0 + nu))); + scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu))); + scalarField threeK(E/(1.0 - 2.0*nu)); + + if (mechanicalProperties.get("planeStress")) + { + lambda = nu*E/((1.0 + nu)*(1.0 - nu)); + threeK = E/(1.0 - nu); + } + + const scalarField twoMuLambda(2*mu + lambda); + + const vectorField n(patch().nf()); + + const fvPatchField& sigmaD = + patch().lookupPatchField("sigmaD"); + + gradient() = + ( + traction/rho + + twoMuLambda*fvPatchField::snGrad() - (n & sigmaD) + )/twoMuLambda; + + if (thermalProperties.get("thermalStress")) + { + const fvPatchField& threeKalpha= + patch().lookupPatchField("threeKalpha"); + + const fvPatchField& T = + patch().lookupPatchField("T"); + + gradient() += n*threeKalpha*T/twoMuLambda; + } + + fixedGradientFvPatchVectorField::updateCoeffs(); +} + +void solidDisplacementFoamForceFvPatchVectorField::write(Ostream& os) const +{ + // Bug-fix: courtesy of Michael@UW at https://www.cfd-online.com/Forums/ + // openfoam-cc-toolkits-fluid-structure-interaction/221892-solved-paraview + // -cant-read-solids-files-duplicate-entries-keyword-value.html#post762325 + //fixedGradientFvPatchVectorField::write(os); + fvPatchVectorField::write(os); + + if (forceFieldPtr_.valid()) + { + os.writeKeyword("forceField") + << forceFieldPtr_().name() << token::END_STATEMENT << nl; + } + else + { +#ifdef OPENFOAMFOUNDATION + writeEntry(os, "force", force_); +#else + force_.writeEntry("force", os); +#endif + } + +#ifdef OPENFOAMFOUNDATION + writeEntry(os, "value", *this); + writeEntry(os, "gradient", gradient()); +#else + writeEntry("value", os); + gradient().writeEntry("gradient", os); +#endif +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchVectorField, solidDisplacementFoamForceFvPatchVectorField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/solidDisplacementFoamForceFvPatchVectorField.H b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/solidDisplacementFoamForceFvPatchVectorField.H new file mode 100644 index 000000000..031b4bb0c --- /dev/null +++ b/perpendicular-flap/solid-openfoam/solidDisplacementFoamForce/solidDisplacementFoamForceFvPatchVectorField.H @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ +License + This code is based on previous work of foam extend and solids4foam. + + This code is distributed under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + +Class + solidDisplacementFoamForceFvPatchVectorField + +Description + Force boundary condition for solidDisplacementFoam solvers, ported from + the solidForce condition in solids4foam. + + This is similar to tractionDisplacement except the absolute force per face + is specified. + + Note: this applies the force per face, not to the entire patch. + + Obviously, for a uniform force field, the total force applied to the patch + as the mesh is refined as the force per face stays constant. + + The primary motivation for this condition is for FSI cases using + solidDisplacementFoam and the preCICE coupling library. + + The force field can be directly specified or specified via a "force" + volVectorField, as used with preCICE. + +Author + Philip Cardiff, UCD. + +SourceFiles + solidDisplacementFoamForceFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidDisplacementFoamForceFvPatchVectorField_H +#define solidDisplacementFoamForceFvPatchVectorField_H + +#include "fixedGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidDisplacementFoamForceFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class solidDisplacementFoamForceFvPatchVectorField +: + public fixedGradientFvPatchVectorField +{ + + // Private Data + + //- Force + vectorField force_; + + //- Force field given as a vol field + autoPtr forceFieldPtr_; + + //- Current time index + label curTimeIndex_; + +public: + + //- Runtime type information + TypeName("solidDisplacementFoamForce"); + + + // Constructors + + //- Construct from patch and internal field + solidDisplacementFoamForceFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + solidDisplacementFoamForceFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // solidDisplacementFoamForceFvPatchVectorField onto a new patch + solidDisplacementFoamForceFvPatchVectorField + ( + const solidDisplacementFoamForceFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + solidDisplacementFoamForceFvPatchVectorField + ( + const solidDisplacementFoamForceFvPatchVectorField& +#ifdef OPENFOAMFOUNDATION + ) = delete; +#else + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new solidDisplacementFoamForceFvPatchVectorField(*this) + ); + } +#endif + + //- Construct as copy setting internal field reference + solidDisplacementFoamForceFvPatchVectorField + ( + const solidDisplacementFoamForceFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new solidDisplacementFoamForceFvPatchVectorField(*this, iF) + ); + } + + + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchVectorField&, + const labelList& + ); + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/perpendicular-flap/solid-openfoam/system/blockMeshDict b/perpendicular-flap/solid-openfoam/system/blockMeshDict new file mode 100644 index 000000000..38b6334d0 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/system/blockMeshDict @@ -0,0 +1,55 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +convertToMeters 0.01; + +vertices +( + (-5 0 0) + (5 0 0) + (5 100 0) + (-5 100 0) + + (-5 0 100) + (5 0 100) + (5 100 100) + (-5 100 100) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (6 15 1) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + patch interface + ( + (4 7 3 0) + (7 6 2 3) + (1 2 6 5) + ) + patch bottom + ( + (0 1 5 4) + ) + empty frontAndBack + ( + (3 2 1 0) + (4 5 6 7) + ) +); + +mergePatchPairs +( +); + diff --git a/perpendicular-flap/solid-openfoam/system/controlDict b/perpendicular-flap/solid-openfoam/system/controlDict new file mode 100644 index 000000000..d3b75d002 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/system/controlDict @@ -0,0 +1,50 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} + +libs ("libsolidDisplacementFoamForce.so"); + +application solidDisplacementFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 10; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.1; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +functions +{ + preCICE_Adapter + { + type preciceAdapterFunctionObject; + libs ("libpreciceAdapterFunctionObject.so"); + } +} + + + diff --git a/perpendicular-flap/solid-openfoam/system/decomposeParDict b/perpendicular-flap/solid-openfoam/system/decomposeParDict new file mode 100644 index 000000000..ec722a896 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/system/decomposeParDict @@ -0,0 +1,10 @@ +numberOfSubdomains 4; + +method simple; + +simpleCoeffs +{ + n (1 4 1); + delta 0.001; +} + diff --git a/perpendicular-flap/solid-openfoam/system/fvSchemes b/perpendicular-flap/solid-openfoam/system/fvSchemes new file mode 100644 index 000000000..018f7cda9 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/system/fvSchemes @@ -0,0 +1,48 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} + +d2dt2Schemes +{ + default Euler; +} + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default leastSquares; + grad(D) leastSquares; + grad(T) leastSquares; +} + +divSchemes +{ + default none; + div(sigmaD) Gauss linear; +} + +laplacianSchemes +{ + default none; + laplacian(DD,D) Gauss linear corrected; + laplacian(DT,T) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default none; +} diff --git a/perpendicular-flap/solid-openfoam/system/fvSolution b/perpendicular-flap/solid-openfoam/system/fvSolution new file mode 100644 index 000000000..01600ef6e --- /dev/null +++ b/perpendicular-flap/solid-openfoam/system/fvSolution @@ -0,0 +1,30 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} + +solvers +{ + "(D|T)" + { + solver GAMG; + tolerance 1e-06; + relTol 0.9; + smoother GaussSeidel; + nCellsInCoarsestLevel 20; + } +} + +stressAnalysis +{ + compactNormalStress yes; + // Note: The accuracy of the solution can be significantly improved + // by increasing this number of iterations, but this will impact the runtime. + nCorrectors 30; + D 1e-06; +} + diff --git a/perpendicular-flap/solid-openfoam/system/preciceDict b/perpendicular-flap/solid-openfoam/system/preciceDict new file mode 100644 index 000000000..4ddf2e425 --- /dev/null +++ b/perpendicular-flap/solid-openfoam/system/preciceDict @@ -0,0 +1,50 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object preciceDict; +} + +preciceConfig "../precice-config.xml"; + +participant Solid; + +modules (FSI); + +interfaces +{ + Interface1 + { + mesh Solid-Mesh; + patches (interface); + locations faceCenters; + + readData + ( + Force + ); + + writeData + ( + Displacement + ); + }; +}; + +FSI +{ + solverType solid; + + // Name of cell displacement field + nameCellDisplacement D; + + // The solidDisplacementFoam does not have a point displacement field so we + // we use the special name "unused", which tells the adapter that it is not + // used + namePointDisplacement unused; + + // Name of the force field on the solid + forceFieldName solidForce; +} diff --git a/perpendicular-flap/solid-solids4foam/0/D b/perpendicular-flap/solid-solids4foam/0/D new file mode 100644 index 000000000..a05796b01 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/0/D @@ -0,0 +1,33 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object D; +} + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + interface + { + type solidForce; + forceField solidForce; + value uniform (0 0 0); + } + bottom + { + type fixedDisplacement; + value uniform (0 0 0); + } + frontAndBack + { + type empty; + } +} + + diff --git a/perpendicular-flap/solid-solids4foam/0/solidForce b/perpendicular-flap/solid-solids4foam/0/solidForce new file mode 100644 index 000000000..0cb4e7ce8 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/0/solidForce @@ -0,0 +1,32 @@ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object solidForce; +} + +dimensions [1 2 2 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + interface + { + type calculated; + value uniform (0 0 0); + } + bottom + { + type calculated; + value uniform (0 0 0); + } + frontAndBack + { + type empty; + } +} + + diff --git a/perpendicular-flap/solid-solids4foam/clean.sh b/perpendicular-flap/solid-solids4foam/clean.sh new file mode 100755 index 000000000..c31d9fc76 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/clean.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e -u + +. ../../tools/cleaning-tools.sh + +clean_openfoam . diff --git a/perpendicular-flap/solid-solids4foam/constant/dynamicMeshDict b/perpendicular-flap/solid-solids4foam/constant/dynamicMeshDict new file mode 100644 index 000000000..e88696b3d --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/constant/dynamicMeshDict @@ -0,0 +1,10 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object dynamicMeshDict; +} + +dynamicFvMesh staticFvMesh; + diff --git a/perpendicular-flap/solid-solids4foam/constant/g b/perpendicular-flap/solid-solids4foam/constant/g new file mode 100644 index 000000000..d5501f04c --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/constant/g @@ -0,0 +1,12 @@ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 0 ); + diff --git a/perpendicular-flap/solid-solids4foam/constant/mechanicalProperties b/perpendicular-flap/solid-solids4foam/constant/mechanicalProperties new file mode 100644 index 000000000..74b76dc44 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/constant/mechanicalProperties @@ -0,0 +1,21 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object mechanicalProperties; +} + +planeStress no; + +mechanical +( + rubber + { + type linearElastic; + rho rho [1 -3 0 0 0 0 0] 3000; + E E [1 -1 -2 0 0 0 0] 4e6; + nu nu [0 0 0 0 0 0 0] 0.3; + } +); + diff --git a/perpendicular-flap/solid-solids4foam/constant/physicsProperties b/perpendicular-flap/solid-solids4foam/constant/physicsProperties new file mode 100644 index 000000000..4d7820de1 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/constant/physicsProperties @@ -0,0 +1,12 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object physicsProperties; +} + +type solid; + + diff --git a/perpendicular-flap/solid-solids4foam/constant/solidProperties b/perpendicular-flap/solid-solids4foam/constant/solidProperties new file mode 100644 index 000000000..183eead5c --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/constant/solidProperties @@ -0,0 +1,25 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object solidProperties; +} + +solidModel linearGeometryTotalDisplacement; + +linearGeometryTotalDisplacementCoeffs +{ + // Maximum number of momentum correctors + nCorrectors 1000; + + // Solution tolerance for displacement + solutionTolerance 1e-08; + + // Alternative solution tolerance for displacement + alternativeTolerance 1e-08; + + // Write frequency for the residuals + infoFrequency 100; +} + diff --git a/perpendicular-flap/solid-solids4foam/run.sh b/perpendicular-flap/solid-solids4foam/run.sh new file mode 100755 index 000000000..90f973a25 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +blockMesh +touch solid-openfoam.foam + +../../tools/run-openfoam.sh "$@" +. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs diff --git a/perpendicular-flap/solid-solids4foam/system/blockMeshDict b/perpendicular-flap/solid-solids4foam/system/blockMeshDict new file mode 100644 index 000000000..38b6334d0 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/system/blockMeshDict @@ -0,0 +1,55 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +convertToMeters 0.01; + +vertices +( + (-5 0 0) + (5 0 0) + (5 100 0) + (-5 100 0) + + (-5 0 100) + (5 0 100) + (5 100 100) + (-5 100 100) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (6 15 1) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + patch interface + ( + (4 7 3 0) + (7 6 2 3) + (1 2 6 5) + ) + patch bottom + ( + (0 1 5 4) + ) + empty frontAndBack + ( + (3 2 1 0) + (4 5 6 7) + ) +); + +mergePatchPairs +( +); + diff --git a/perpendicular-flap/solid-solids4foam/system/controlDict b/perpendicular-flap/solid-solids4foam/system/controlDict new file mode 100644 index 000000000..ccc3474d5 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/system/controlDict @@ -0,0 +1,48 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} + +application solids4Foam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 10; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.1; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +functions +{ + preCICE_Adapter + { + type preciceAdapterFunctionObject; + libs ("libpreciceAdapterFunctionObject.so"); + } +} + + + diff --git a/perpendicular-flap/solid-solids4foam/system/decomposeParDict b/perpendicular-flap/solid-solids4foam/system/decomposeParDict new file mode 100644 index 000000000..ec722a896 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/system/decomposeParDict @@ -0,0 +1,10 @@ +numberOfSubdomains 4; + +method simple; + +simpleCoeffs +{ + n (1 4 1); + delta 0.001; +} + diff --git a/perpendicular-flap/solid-solids4foam/system/fvSchemes b/perpendicular-flap/solid-solids4foam/system/fvSchemes new file mode 100644 index 000000000..87d288970 --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/system/fvSchemes @@ -0,0 +1,51 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} + +d2dt2Schemes +{ + default backward; +} + +ddtSchemes +{ + default backward; +} + +gradSchemes +{ + default extendedLeastSquares 0; +} + +divSchemes +{ + default Gauss linear; +} + +laplacianSchemes +{ + default none; + laplacian(DD,D) Gauss linear corrected; + laplacian(DDD,DD) Gauss linear corrected; +} + +snGradSchemes +{ + default none; + snGrad(D) corrected; + snGrad(DD) corrected; +} + +interpolationSchemes +{ + default none; + interpolate(impK) linear; + interpolate(grad(D)) linear; + interpolate(grad(DD)) linear; + interpolate(sigma0) linear; +} + diff --git a/perpendicular-flap/solid-solids4foam/system/fvSolution b/perpendicular-flap/solid-solids4foam/system/fvSolution new file mode 100644 index 000000000..69fc05a9c --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/system/fvSolution @@ -0,0 +1,38 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} + +solvers +{ + "D|DD" + { + solver PCG; + preconditioner FDIC; + tolerance 1e-09; + relTol 0.1; + } +} + +relaxationFactors +{ + // Under-relaxating the D equation by 0.99-0.9999 can improve convergence in + // some cases, in particular when there are solidContact boundaries + equations + { + //D 0.999; + } + + // Under-relaxating the D field by 0.1-0.9 can improve convergence in some + // cases + fields + { + //D 0.9; + } +} + + diff --git a/perpendicular-flap/solid-solids4foam/system/preciceDict b/perpendicular-flap/solid-solids4foam/system/preciceDict new file mode 100644 index 000000000..e3b8174cc --- /dev/null +++ b/perpendicular-flap/solid-solids4foam/system/preciceDict @@ -0,0 +1,46 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object preciceDict; +} + +preciceConfig "../precice-config.xml"; + +participant Solid; + +modules (FSI); + +interfaces +{ + Interface1 + { + mesh Solid-Mesh; + patches (interface); + locations faceCenters; + + readData + ( + Force + ); + + writeData + ( + Displacement + ); + }; +}; + +FSI +{ + solverType solid; + + // Name of displacement fields + namePointDisplacement pointD; + nameCellDisplacement D; + + // Name of the force field on the solid + forceFieldName solidForce; +} diff --git a/tools/cleaning-tools.sh b/tools/cleaning-tools.sh index c143947c1..63c7af423 100755 --- a/tools/cleaning-tools.sh +++ b/tools/cleaning-tools.sh @@ -100,7 +100,7 @@ clean_openfoam() { # shellcheck disable=SC1090 # This is an OpenFOAM file which we don't need to check . "${WM_PROJECT_DIR}/bin/tools/CleanFunctions" cleanCase - rm -rfv 0/uniform/functionObjects/functionObjectProperties + rm -rfv 0/uniform/functionObjects/functionObjectProperties history fi rm -rfv ./preCICE-output/ clean_precice_logs . diff --git a/tools/openfoam-remove-empty-dirs.sh b/tools/openfoam-remove-empty-dirs.sh index 4d3acc36d..dca747e2b 100755 --- a/tools/openfoam-remove-empty-dirs.sh +++ b/tools/openfoam-remove-empty-dirs.sh @@ -6,7 +6,7 @@ openfoam_remove_empty_dirs() { echo "Looking for any time directories without results (e.g. stray functionObjectProperties files, see openfoam-adapter issue #26 on GitHub)..." for f in [0-9]* [0-9]*.[0-9]*; do - if ! [ -f "${f}/U" ] && ! [ -f "${f}/T" ] && ! [ -f "${f}/U.gz" ] && ! [ -f "${f}/T.gz" ]; then + if ! [ -f "${f}/U" ] && ! [ -f "${f}/T" ] && ! [ -f "${f}/U.gz" ] && ! [ -f "${f}/T.gz" ] && ! [ -f "${f}/D" ] && ! [ -f "${f}/pointD" ] && ! [ -f "${f}/DD" ] && ! [ -f "${f}/pointDD" ] && ! [ -f "${f}/D.gz" ] && ! [ -f "${f}/pointD.gz" ] && ! [ -f "${f}/DD.gz" ] && ! [ -f "${f}/pointDD.gz" ]; then rm -rfv "${f}" fi done @@ -14,7 +14,7 @@ openfoam_remove_empty_dirs() { for d in processor*; do cd "${d}" for f in [0-9]* [0-9]*.[0-9]*; do - if ! [ -f "${f}/U" ] && ! [ -f "${f}/T" ] && ! [ -f "${f}/U.gz" ] && ! [ -f "${f}/T.gz" ]; then + if ! [ -f "${f}/U" ] && ! [ -f "${f}/T" ] && ! [ -f "${f}/U.gz" ] && ! [ -f "${f}/T.gz" ] && ! [ -f "${f}/D" ] && ! [ -f "${f}/pointD" ] && ! [ -f "${f}/DD" ] && ! [ -f "${f}/pointDD" ] && ! [ -f "${f}/D.gz" ] && ! [ -f "${f}/pointD.gz" ] && ! [ -f "${f}/DD.gz" ] && ! [ -f "${f}/pointDD.gz" ]; then rm -rfv "${f}" fi done