CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

set directory for subMesh

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree4Likes
  • 2 Post By ngj
  • 2 Post By Jacks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2013, 08:14
Default set directory for subMesh
  #1
New Member
 
Fabian Wein
Join Date: Jan 2013
Posts: 13
Rep Power: 13
Fabian_W is on a distinguished road
I am stucked and need help.

I create my subMesh as

fvMeshSubset sm(mesh);
sm.setCellSubset(sub);

with the submesh I create volScalarField k_e and h_e

What I actually need is the laplacian matrix

fvMatrix<scalar> m = fvm::laplacian(k_e, h_2)

But sm.subMesh().schemesDict() is empty and has no laplacianSchemes.

I did not find how to add the schemes file:

keyword laplacian(k,h) is undefined in dictionary ".../system/region0SubSet/fvSchemes::laplacianSchemes"

And I was also not able to set i programatically as sm.subMesh().schemesDict() ist const.

How can I set my laplacian schemes for my subMesh?
Fabian_W is offline   Reply With Quote

Old   February 22, 2013, 08:18
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Fabian

Merely make a folder called system/region0SubSet and create an fvSolution and fvScheme file in this directory. OpenFoam will automatically find these files and use them in a way identical to the basic fvSolution and fvScheme files.

Kind regards,

Niels
ngj is offline   Reply With Quote

Old   February 22, 2013, 08:22
Default
  #3
New Member
 
Fabian Wein
Join Date: Jan 2013
Posts: 13
Rep Power: 13
Fabian_W is on a distinguished road
Thanks four your reply Niels.

It does not work. When I do sm.setLargeCellSubset(sub, -1, false) instead of sm.setCellSubset(sub); the name is not changed (also commented in fvMeshSubset.C) but the directory is also empty.

Do I miss something? Do I need to activate reading from the directory?
Fabian_W is offline   Reply With Quote

Old   February 22, 2013, 09:05
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Fabian,

I went into my code to see my steps:

1. This is how I create the subMesh:
Code:
    // Creates a fvMeshSubset (Construction done differently in 1.6 and onwards)
    submesh_ = new fvMeshSubset(cGlobal_, mesh_);

    // Set the cell labels to be used in cMesh. (cellSet, label, bool)
    submesh_->setLargeCellSubset(suspendedCells, suspPatchID_, true);

    // Write cMesh - write all information!
    submesh_->subMesh().setInstance( mesh_.time().constant() );
    submesh_->subMesh().write();

    // Make sure that only the points are written to the disk
    submesh_->subMesh().setInstance( mesh_.time().timeName() );
    submesh_->subMesh().setTopoWriteOpt(IOobject::NO_WRITE);
2. I have the following method in my class:
Code:
inline const fvMesh & cMesh() const
{
    return submesh_->subMesh();
};
3. Volume fields are subsequently created in the following way, and when I perform fvc:: and fvm:: on these, it works as a charm:

Code:
volScalarField k
(
    IOobject
    (
        "k",
        mesh_.time().timeName(),
        cMesh(),
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    cMesh()
);
Good luck,

Niels
elvis and yuhan1991 like this.
ngj is offline   Reply With Quote

Old   February 22, 2013, 09:28
Default
  #5
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
P.S. This works in 1.6-ext.

/ Niels
ngj is offline   Reply With Quote

Old   February 22, 2013, 11:21
Default
  #6
New Member
 
Fabian Wein
Join Date: Jan 2013
Posts: 13
Rep Power: 13
Fabian_W is on a distinguished road
I have 2.1.1, this might be the problem. The files exist, but as my dictionary is empty it might be the case that it is not read

I found that the vectors are only properly read when their name in their header are ok. I tried to play a little bit with the location.

How can I activate debug output? I have problems debugging my code, one day it works (complete OpenFoam build in debug version) the other day it does not work with gdb (Linux)
Fabian_W is offline   Reply With Quote

Old   February 22, 2013, 16:12
Default
  #7
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Well, if the files do exist, then what happens if you define how to compute the Laplacian? As I understand it, you have not defined the discretisation in system/region0SubSet/fvSchemes?

I have no experience with GDB, thus I cannot help you in that regard.

Have a nice weekend,

Niels
ngj is offline   Reply With Quote

Old   February 25, 2013, 06:14
Default
  #8
New Member
 
Fabian Wein
Join Date: Jan 2013
Posts: 13
Rep Power: 13
Fabian_W is on a distinguished road
Quote:
Originally Posted by ngj View Post
Well, if the files do exist, then what happens if you define how to compute the Laplacian? As I understand it, you have not defined the discretisation in system/region0SubSet/fvSchemes?

I have no experience with GDB, thus I cannot help you in that regard.
The file exists, I copied fvSchemes and fvSolutions from system to system/region0SubSet

I tried also with adding region0SubSet to location or object in these files.

sm.subMesh().schemesDict().size() is always empty.

Any more hints? It might be something stupid, e.g. like setting the wrong entries in the location field in the files or some other file needs to be present in region0SubSet, ...?
Fabian_W is offline   Reply With Quote

Old   February 27, 2013, 04:47
Default
  #9
New Member
 
Fabian Wein
Join Date: Jan 2013
Posts: 13
Rep Power: 13
Fabian_W is on a distinguished road
The submesh definetly does not try to read the scheme. I checked with strace the system calls and see all file operations.

I also cannot call

dynamic_cast<fvSchemes&>(sm.subMesh()).read()

as the readOpt is set to READ_ONLY and I did not find, who it can be changed.

Meanwhile I'm sure this is a bug in OpenFOAM 2.1.1

This is the laplacian method in question:

laplacian
(
const GeometricField<GType, fvPatchField, volMesh>& gamma,
const GeometricField<Type, fvPatchField, volMesh>& vf,
const word& name
)
{
return fv::laplacianScheme<Type, GType>::New
(
vf.mesh(),
vf.mesh().laplacianScheme(name)
)().fvmLaplacian(gamma, vf);
}

I add a own implementation where I can provide the laplacianScheme of the system mesh

laplacian
(
const GeometricField<GType, fvPatchField, volMesh>& gamma,
const GeometricField<Type, fvPatchField, volMesh>& vf,
const word& name,
ITstream& scheme
)
{
return fv::laplacianScheme<Type, GType>::New
(
vf.mesh(),
scheme
)().fvmLaplacian(gamma, vf);
}
Fabian_W is offline   Reply With Quote

Old   February 27, 2013, 04:49
Default
  #10
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Fabian,

It is good that you found a work-around. Please report the issue in the OpenCFD's bug-tracker.

Kind regards

Niels
ngj is offline   Reply With Quote

Old   April 24, 2014, 10:28
Default Other solution
  #11
New Member
 
Jacques F.
Join Date: Jul 2013
Location: Toulouse
Posts: 6
Rep Power: 12
Jacks is on a distinguished road
As fvMesh Objects are indeed construct with the NO_READ IOObject option, it do not read fvSchemes nor fvSolution dict neither for subMesh constructed from setCellSubSet() method (and looking for a system/region0SubSet as instance dir.) nor for setLargeCellSubSet(), which keeps the parent mesh system directory.

A solution, which seems to work, is to set the subMesh read option on MUST_READ manually via:

Code:
 subMesh.fvSchemes::readOpt() = parentMesh.fvSchemes::readOpt();
 subMesh.fvSolution::readOpt() = parentMesh.fvSolution::readOpt();
And ask it for red these dictionnary:

Code:
 subMesh.fvSchemes::read();
 subMesh.fvSolution::read();
I keep testing this solution but it seems to work for me.

Best regards,
tom_flint2012 and rhalder like this.
Jacks is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM.org] unable to source openFOAM under $HOME directory lilinghan8 OpenFOAM Installation 15 October 15, 2019 03:53
[CGNS] CGNS converters available mbeaudoin OpenFOAM Meshing & Mesh Conversion 137 December 14, 2018 05:20
Problem installing on Ubuntu 9.10 -> 'Cannot open : No such file or directory' mfiandor OpenFOAM Installation 2 January 25, 2010 10:50
Compiling OpenFOAM13 on AMD64 with Redhat Enterprise mbeaudoin OpenFOAM Installation 20 June 17, 2008 07:43
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 05:27


All times are GMT -4. The time now is 15:36.