Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume coupling module #183

Merged

Conversation

prasadadhav
Copy link

@prasadadhav prasadadhav commented Jun 17, 2021

In this PR I add a class for the Volume coupling module.
This will form the basis for further development on the Volume Coupling module, it's data fields and test cases.

TODO list:

  • I updated the documentation in docs/
  • I added a changelog entry in changelog-entries/ (create directory if missing)

Adapter.C Outdated
Comment on lines 69 to 71
if (module == "Volume_Coupling")
{
Volume_Couplingenabled_ = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style-wise, the adapter uses nearly exclusively CamelCase, VolumeCouplingEnabled_. I guess it would be good to stick to it.

@@ -186,6 +190,14 @@ bool preciceAdapter::Adapter::configFileRead()
}
}

// If the Volume_Coupling module is enabled, create it, read the
// Volume_Coupling-specific options and configure it.
if (Volume_Couplingenabled_)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask you to add this option in the if block below in order to bail out in case no module was enabled?



//- Name of the Porosity
std::string nameYour_Volume_Field_ = "Your_Volume_Field";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to read this name through the dictionary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a placeholder. I have added `Fluid_Velocity' and 'Temperature'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should take this from the configuration file of the adapter.

Comment on lines +6 to +8
#include "Volume_Coupling/Generic_volScalarField.H"
#include "Volume_Coupling/Generic_volVectorField.H"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These includes are still missing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will be pushing things soon.
I should have named the PR with Draft as I was still working on cleaning up few things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted the PR to draft, mark as "ready for review" when you are ready. :-)

@MakisH MakisH marked this pull request as draft June 23, 2021 16:01
@prasadadhav
Copy link
Author

Regarding clang-format. The issue was that I was using Ubuntu 18.04. And clamg-format 11 is not supported on any OS below Ubuntu 20.04. I updated my OS to 20.04, and installed the correct clang-format version.

But I am unable to use the format-code.sh script. I get the following error (this error is repeated multiple times)

find: ‘clang-format’: No such file or directory

I tried changing the permissions for .clang-format file but still the same error.

@MakisH
Copy link
Member

MakisH commented Jun 28, 2021

Regarding clang-format. The issue was that I was using Ubuntu 18.04. And clamg-format 11 is not supported on any OS below Ubuntu 20.04. I updated my OS to 20.04, and installed the correct clang-format version.

But I am unable to use the format-code.sh script. I get the following error (this error is repeated multiple times)

find: ‘clang-format’: No such file or directory

I tried changing the permissions for .clang-format file but still the same error.

Does just running clang-format work on your system? What does which clang-format return? If you start typing clang-format in your terminal and press Tab twice to auto-complete, do you see any version-specific alternatives?

@prasadadhav
Copy link
Author

Regarding clang-format. The issue was that I was using Ubuntu 18.04. And clamg-format 11 is not supported on any OS below Ubuntu 20.04. I updated my OS to 20.04, and installed the correct clang-format version.
But I am unable to use the format-code.sh script. I get the following error (this error is repeated multiple times)

find: ‘clang-format’: No such file or directory

I tried changing the permissions for .clang-format file but still the same error.

Does just running clang-format work on your system? What does which clang-format return? If you start typing clang-format in your terminal and press Tab twice to auto-complete, do you see any version-specific alternatives?

  • Running just clang-format on my system does nothing, I did this in the OF adapter directory.
  • whcih clang-format returns nothing in the terminal
  • The alternatives I get after double tab are following:
clang-format-10        clang-format-6.0       clang-format-diff-11   
clang-format-11        clang-format-diff-10   clang-format-diff-6.0  

@MakisH
Copy link
Member

MakisH commented Jun 28, 2021

Then just change the format-code.sh script to point to your clang-format-11. This is probably not the default because of the upgrade process, and probably you can fix it somehow.

Alternatively, you can set an alias clang-format="clang-format-11" in your ~/.bashrc.

@prasadadhav
Copy link
Author

prasadadhav commented Jun 28, 2021

Then just change the format-code.sh script to point to your clang-format-11. This is probably not the default because of the upgrade process, and probably you can fix it somehow.

Alternatively, you can set an alias clang-format="clang-format-11" in your ~/.bashrc.

Thank you Makis. This worked properly. Pushed the changes for clang-format.

Edit:
Now just the build is failing due the GenericVolumeVectorField. But this fails for OF v2012. Works with OF v7. Will try and fix asap.

@prasadadhav
Copy link
Author

@MakisH @davidscn I would like some hints/direction on this one.
Although I am able to compile (& use) the adapter for OF v7, we have compile errors for v2012.

I went through the OF API, OF source code for OF v7 and v2012 relating to motion solver, I couldn't find any difference between the two versions.

This is the error for quick reference.

Volume_Coupling/Generic_volVectorField.C: In member function ‘virtual void preciceAdapter::Volume_Coupling::Generic_volVectorField::read(double*, unsigned int)’:
Volume_Coupling/Generic_volVectorField.C:76:9: error: ‘fixedValuePointPatchVectorField’ was not declared in this scope
   76 |         fixedValuePointPatchVectorField& pointGeneric_volVectorPatch =
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Volume_Coupling/Generic_volVectorField.C:76:42: error: ‘pointGeneric_volVectorPatch’ was not declared in this scope
   76 |         fixedValuePointPatchVectorField& pointGeneric_volVectorPatch =
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Comment on lines +305 to +321
for (uint j = 0; j < patchIDs_.size(); j++)
{
// Get the face centers of the current patch
const vectorField faceCenters =
mesh.boundaryMesh()[patchIDs_.at(j)].faceCentres();

// Assign the (x,y,z) locations to the vertices
for (int i = 0; i < faceCenters.size(); i++)
{
vertices[verticesIndex++] = faceCenters[i].x();
vertices[verticesIndex++] = faceCenters[i].y();
if (dim_ == 3)
{
vertices[verticesIndex++] = faceCenters[i].z();
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the configuration for such a case look like? Do I need to specify all involved patches or are all patches automatically included. I just want to raise a warning that we might run into issues with empty patches in case we run 2D simulations.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unanswered question. Configuration actually ignores different type of mapping for volumes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@engenegr what do you mean by "ignores different type of mapping for volumes"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@engenegr what do you mean by "ignores different type of mapping for volumes"?

I guess it means that there is no configuration option to set particular boundaries empty.

@MakisH
Copy link
Member

MakisH commented May 13, 2022

Some news: we are picking up this together with a student, to integrate it in the main branch of the adapter, write documentation, and add some tutorials on the website. Expect updates over the next months / by the end of the year.

@yinjun5200
Copy link

Hi, I used your volume coupling adaptor. I slightly modified it, it works fine with compilation. But I have an error which states that "there were undefined symbols". This is because I added some additional variables "alpha (volume fraction)" and "AF(acoustic force)" to the adapter. I know I have to include the required libraries to Make/Options. But those variables are added in "CreateFields.H" file in my modified solver, which do not have a library. Any suggestions to add those symbols?

@prasadadhav
Copy link
Author

Hi, I used your volume coupling adaptor. I slightly modified it, it works fine with compilation. But I have an error which states that "there were undefined symbols". This is because I added some additional variables "alpha (volume fraction)" and "AF(acoustic force)" to the adapter. I know I have to include the required libraries to Make/Options. But those variables are added in "CreateFields.H" file in my modified solver, which do not have a library. Any suggestions to add those symbols?

@yinjun5200 To summarize, your adapter compiles fine. But when you try to run the coupled simulation, you get this error, correct?
Could be helpful if you share the error log. Could you also clarify where you add these fields? alpha & AF?
Also, the moderators can say if this deserves an issue on its own (GitHub or Discourse) or if it's ok to continue discussing here.

Hi, I used your volume coupling adaptor. I slightly modified it, it works fine with compilation.

Also could you please tell me if you solved the compilation errors for OF v2022?

@yinjun5200
Copy link

@alphaoo1 Thanks for you kind reply. Yes, it compiles fine. But at the end of the compilation, it print out "Everything looks fine in wmake.log === ERROR: Building completed with linking problems: there were undefined symbol. I attached my ldd.log and wmake.log files there.

I added these fields in modified interFoam solver in "createFeilds.H" file, as seen in the attached file. I think I have to provide the library to link those variables in Make/options to solve this problem? But I don't have any developed library for those variables. I need your guide !

I used volume coupling, I think it should be fine to discuss there? But I don't mind if we need to create a new issue. :)

NO, I used OpenFOAM6, not OF 2022.

createFields

ldd.log
ols ===" I also attahched the log file there.
wmake.log

int patchID = patchIDs_.at(j);

// Get the field on the patch
fixedValuePointPatchVectorField& pointGeneric_volVectorPatch =
Copy link
Contributor

@tirgendetwas tirgendetwas Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the compilation issues with OFv2012: did you mean to make this a fvPatchVectorField? Since you are making a refCast to fvPatchVectorField anyway. I can't find information on fixedValuePointPatchVectorField in the OF v7 documentation (however, I am finding fixedValuePointPatchField)

Comment on lines +73 to +76
// if ( module.empty )
// {
// return false;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alphaoo1 What was the intention here? Why is this commented out?

@@ -277,6 +293,12 @@ void preciceAdapter::Adapter::configure()
FF_->addWriters(dataName, interface);
}

// Add Momentum-related coupling data writers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "momentum-related"?

@@ -186,6 +194,14 @@ bool preciceAdapter::Adapter::configFileRead()
}
}

// If the Volume_Coupling module is enabled, create it, read the
// Volume_Coupling-specific options and configure it.
if (Volume_Couplingenabled_)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(long term / document)

With this approach, we have the choice between {CHT, FSI, FF, Volume Coupling}. In the long run, we want volume coupling to be possible for all (?) of {CHT, FSI, FF}.

@@ -32,15 +32,15 @@ void preciceAdapter::CHT::SinkTemperature::write(double* buffer, bool meshConnec
tmp<scalarField> patchInternalFieldTmp = TPatch.patchInternalField();
const scalarField& patchInternalField = patchInternalFieldTmp();

//If we use the mesh connectivity, we interpolate from the centres to the nodes
// If we use the mesh connectivity, we interpolate from the centres to the nodes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge develop to the volume_coupling branch first, then the volume_coupling branch to this branch, and then check the formatting again. Maybe some of these changes have already been introduced before.

Comment on lines +305 to +321
for (uint j = 0; j < patchIDs_.size(); j++)
{
// Get the face centers of the current patch
const vectorField faceCenters =
mesh.boundaryMesh()[patchIDs_.at(j)].faceCentres();

// Assign the (x,y,z) locations to the vertices
for (int i = 0; i < faceCenters.size(); i++)
{
vertices[verticesIndex++] = faceCenters[i].x();
vertices[verticesIndex++] = faceCenters[i].y();
if (dim_ == 3)
{
vertices[verticesIndex++] = faceCenters[i].z();
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@engenegr what do you mean by "ignores different type of mapping for volumes"?

Comment on lines +42 to +48
// Read the name of the field Fluid_Velocity (if different)
nameFluid_Velocity_ = Volume_Couplingdict.lookupOrDefault<word>("nameFluid_Velocity", "Fluid_Velocity");
DEBUG(adapterInfo(" Fluid_Velocity field name : " + nameFluid_Velocity_));

// Read the name of the field Volume_Porosity (if different)
nameT_ = Volume_Couplingdict.lookupOrDefault<word>("nameT", "T");
DEBUG(adapterInfo(" Temperature field name : " + nameT_));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Application-specfiic

Comment on lines +55 to +69
if (dataName.find("Fluid_Velocity") == 0)
{
interface->addCouplingDataWriter(
dataName,
new Generic_volVectorField(mesh_, nameFluid_Velocity_));
DEBUG(adapterInfo("Added writer: Fluid_Velocity."));
}

else if (dataName.find("T") == 0)
{
interface->addCouplingDataWriter(
dataName,
new Generic_volScalarField(mesh_, nameT_));
DEBUG(adapterInfo("Added writer: T."));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Application-specific, check

Comment on lines +81 to +95
if (dataName.find("Fluid_Velocity") == 0)
{
interface->addCouplingDataReader(
dataName,
new Generic_volVectorField(mesh_, nameFluid_Velocity_));
DEBUG(adapterInfo("Added reader: Fluid_Velocity."));
}

else if (dataName.find("T") == 0)
{
interface->addCouplingDataReader(
dataName,
new Generic_volScalarField(mesh_, nameT_));
DEBUG(adapterInfo("Added reader: T."));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Application-specific, check.



//- Name of the Porosity
std::string nameYour_Volume_Field_ = "Your_Volume_Field";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should take this from the configuration file of the adapter.

find . \( -iname "*.H" -o -iname "*.C" \) -exec clang-format-11 -i {} \;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use whatever develop is using (after merging develop here).

@tirgendetwas tirgendetwas merged commit d453b8c into precice:volume-coupling Sep 11, 2022
@tirgendetwas
Copy link
Contributor

We will continue our work on the volume-coupling branch of precice. Follow PR#255 for updates!

@MakisH MakisH mentioned this pull request Oct 25, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants